From 69890fb10359f68d3b78a201bfe228dda6792516 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 24 Feb 2025 23:28:01 +0000 Subject: [PATCH] CodeGen from PR 32527 in Azure/azure-rest-api-specs Merge 8f64ced8adb830e25603307f05f7e0f61535e97c into 2f9b4fb3e3f8bf822476acac1faefc3ef7389d8a --- sdk/storage/azure-storage-blob/CHANGELOG.md | 924 +- sdk/storage/azure-storage-blob/README.md | 619 +- sdk/storage/azure-storage-blob/assets.json | 7 +- .../checkstyle-suppressions.xml | 48 - .../migrationGuides/V10_V12.md | 377 - .../migrationGuides/V8_V12.md | 315 - .../azure-storage-blob/perf-resources.bicep | 21 - sdk/storage/azure-storage-blob/perf-tests.yml | 61 - sdk/storage/azure-storage-blob/perf.yml | 40 - sdk/storage/azure-storage-blob/pom.xml | 173 +- .../azure-storage-blob/spotbugs-exclude.xml | 199 - .../storage/blob/AppendBlobAsyncClient.java | 877 ++ .../azure/storage/blob/AppendBlobClient.java | 866 ++ .../azure/storage/blob/BlobAsyncClient.java | 1075 -- .../com/azure/storage/blob/BlobClient.java | 573 - .../azure/storage/blob/BlobClientBuilder.java | 643 - .../blob/BlobContainerAsyncClient.java | 1700 --- .../storage/blob/BlobContainerClient.java | 1511 --- .../blob/BlobContainerClientBuilder.java | 599 - .../storage/blob/BlobServiceAsyncClient.java | 1269 -- .../azure/storage/blob/BlobServiceClient.java | 1129 -- .../blob/BlobServiceClientBuilder.java | 580 - .../storage/blob/BlobServiceVersion.java | 140 +- .../com/azure/storage/blob/BlobUrlParts.java | 471 - .../storage/blob/BlockBlobAsyncClient.java | 1656 +++ .../azure/storage/blob/BlockBlobClient.java | 1638 +++ .../storage/blob/ContainerAsyncClient.java | 2097 +++ .../blob/ContainerBlobAsyncClient.java | 3117 +++++ .../storage/blob/ContainerBlobClient.java | 3069 +++++ .../azure/storage/blob/ContainerClient.java | 2058 +++ .../azure/storage/blob/HttpGetterInfo.java | 101 - .../storage/blob/PageBlobAsyncClient.java | 1781 +++ .../azure/storage/blob/PageBlobClient.java | 1755 +++ .../azure/storage/blob/ProgressReceiver.java | 35 - .../azure/storage/blob/ProgressReporter.java | 184 - .../blob/ServiceClientAsyncClient.java | 920 ++ .../storage/blob/ServiceClientClient.java | 907 ++ .../blob/ServiceClientClientBuilder.java | 508 + .../blob/implementation/AppendBlobsImpl.java | 3933 +----- .../implementation/AzureBlobStorageImpl.java | 201 - .../AzureBlobStorageImplBuilder.java | 279 - .../blob/implementation/BlobsImpl.java | 11046 ---------------- .../blob/implementation/BlockBlobsImpl.java | 6787 ++-------- .../implementation/ContainerBlobsImpl.java | 3030 +++++ .../blob/implementation/ContainersImpl.java | 8580 +++--------- .../blob/implementation/PageBlobsImpl.java | 7492 ++--------- .../ServiceClientClientImpl.java | 1356 ++ .../blob/implementation/ServicesImpl.java | 3211 ----- ...DownloadAsyncResponseConstructorProxy.java | 71 - .../BlobDownloadHeadersConstructorProxy.java | 60 - .../BlobItemConstructorProxy.java | 59 - .../BlobItemPropertiesConstructorProxy.java | 78 - .../BlobPropertiesConstructorProxy.java | 60 - .../BlobQueryHeadersConstructorProxy.java | 59 - .../accesshelpers/package-info.java | 7 - .../AppendBlobsAppendBlockFromUrlHeaders.java | 389 - .../models/AppendBlobsAppendBlockHeaders.java | 443 - .../models/AppendBlobsCreateHeaders.java | 352 - .../models/AppendBlobsSealHeaders.java | 235 - .../models/ArrowConfiguration.java | 125 - .../implementation/models/ArrowField.java | 188 - .../models/BlobContainersSegment.java | 266 - .../models/BlobCopySourceTags.java | 42 - .../models/BlobFlatListSegment.java | 110 - .../models/BlobHierarchyListSegment.java | 144 - .../models/BlobItemInternal.java | 410 - .../models/BlobItemPropertiesInternal.java | 1293 -- .../blob/implementation/models/BlobName.java | 121 - .../models/BlobPrefixInternal.java | 104 - .../models/BlobPropertiesInternal.java | 266 - ...opertiesInternalConstructorProperties.java | 516 - .../BlobPropertiesInternalDownload.java | 259 - .../BlobPropertiesInternalGetProperties.java | 259 - .../models/BlobSignedIdentifierWrapper.java | 103 - .../models/BlobStorageError.java | 185 - .../models/BlobStorageExceptionInternal.java | 38 - .../blob/implementation/models/BlobTag.java | 132 - .../blob/implementation/models/BlobTags.java | 125 - .../models/BlobsAbortCopyFromURLHeaders.java | 142 - .../models/BlobsAcquireLeaseHeaders.java | 232 - .../models/BlobsBreakLeaseHeaders.java | 235 - .../models/BlobsChangeLeaseHeaders.java | 232 - .../models/BlobsCopyFromURLHeaders.java | 378 - .../models/BlobsCreateSnapshotHeaders.java | 292 - .../models/BlobsDeleteHeaders.java | 142 - .../BlobsDeleteImmutabilityPolicyHeaders.java | 142 - .../models/BlobsDownloadHeaders.java | 1425 -- .../models/BlobsGetAccessControlHeaders.java | 252 - .../models/BlobsGetAccountInfoHeaders.java | 237 - .../models/BlobsGetPropertiesHeaders.java | 1535 --- .../models/BlobsGetTagsHeaders.java | 142 - .../models/BlobsQueryHeaders.java | 1010 -- .../models/BlobsReleaseLeaseHeaders.java | 204 - .../models/BlobsRenameHeaders.java | 202 - .../models/BlobsRenewLeaseHeaders.java | 232 - .../models/BlobsSetAccessControlHeaders.java | 152 - .../models/BlobsSetExpiryHeaders.java | 204 - .../models/BlobsSetHttpHeadersHeaders.java | 236 - .../BlobsSetImmutabilityPolicyHeaders.java | 216 - .../models/BlobsSetLegalHoldHeaders.java | 173 - .../models/BlobsSetMetadataHeaders.java | 321 - .../models/BlobsSetTagsHeaders.java | 142 - .../models/BlobsSetTierHeaders.java | 104 - .../models/BlobsStartCopyFromURLHeaders.java | 292 - .../models/BlobsUndeleteHeaders.java | 142 - .../BlockBlobsCommitBlockListHeaders.java | 383 - .../models/BlockBlobsGetBlockListHeaders.java | 262 - .../BlockBlobsPutBlobFromUrlHeaders.java | 352 - .../BlockBlobsStageBlockFromURLHeaders.java | 293 - .../models/BlockBlobsStageBlockHeaders.java | 321 - .../models/BlockBlobsUploadHeaders.java | 380 - .../models/ContainersAcquireLeaseHeaders.java | 232 - .../models/ContainersBreakLeaseHeaders.java | 235 - .../models/ContainersChangeLeaseHeaders.java | 232 - .../models/ContainersCreateHeaders.java | 204 - .../models/ContainersDeleteHeaders.java | 142 - .../models/ContainersFilterBlobsHeaders.java | 142 - .../ContainersGetAccessPolicyHeaders.java | 236 - .../ContainersGetAccountInfoHeaders.java | 237 - .../ContainersGetPropertiesHeaders.java | 531 - .../ContainersListBlobFlatSegmentHeaders.java | 168 - ...ainersListBlobHierarchySegmentHeaders.java | 168 - .../models/ContainersReleaseLeaseHeaders.java | 204 - .../models/ContainersRenameHeaders.java | 142 - .../models/ContainersRenewLeaseHeaders.java | 232 - .../models/ContainersRestoreHeaders.java | 142 - .../ContainersSetAccessPolicyHeaders.java | 204 - .../models/ContainersSetMetadataHeaders.java | 204 - .../models/ContainersSubmitBatchHeaders.java | 104 - .../models/DirectoriesCreateHeaders.java | 202 - .../models/DirectoriesDeleteHeaders.java | 145 - .../DirectoriesGetAccessControlHeaders.java | 252 - .../models/DirectoriesRenameHeaders.java | 227 - .../DirectoriesSetAccessControlHeaders.java | 152 - .../models/DirectoryHttpHeaders.java | 136 - .../models/EncryptionScope.java | 50 - .../implementation/models/FilterBlobItem.java | 216 - .../models/FilterBlobSegment.java | 208 - .../models/FilterBlobsIncludeItem.java | 56 - .../models/GetUserDelegationKeyRequest.java | 105 + .../models/InternalBlobLegalHoldResult.java | 29 - .../models/JsonTextConfiguration.java | 105 - .../models/ListBlobsFlatSegmentResponse.java | 272 - .../ListBlobsHierarchySegmentResponse.java | 303 - .../models/PageBlobsClearPagesHeaders.java | 359 - .../PageBlobsCopyIncrementalHeaders.java | 264 - .../models/PageBlobsCreateHeaders.java | 352 - .../PageBlobsGetPageRangesDiffHeaders.java | 236 - ...PageBlobsGetPageRangesDiffNextHeaders.java | 202 - .../models/PageBlobsGetPageRangesHeaders.java | 236 - .../PageBlobsGetPageRangesNextHeaders.java | 202 - .../models/PageBlobsResizeHeaders.java | 236 - .../PageBlobsUpdateSequenceNumberHeaders.java | 236 - .../PageBlobsUploadPagesFromURLHeaders.java | 361 - .../models/PageBlobsUploadPagesHeaders.java | 415 - .../models/PageListCollection.java | 137 - .../implementation/models/PageListHelper.java | 28 - .../models/PageListSegment.java | 171 - .../implementation/models/QueryFormat.java | 224 - .../models/QueryFormatType.java | 66 - .../implementation/models/QueryRequest.java | 188 - .../models/QuerySerialization.java | 104 - .../models/ServicesFilterBlobsHeaders.java | 142 - .../models/ServicesGetAccountInfoHeaders.java | 237 - .../models/ServicesGetPropertiesHeaders.java | 104 - .../models/ServicesGetStatisticsHeaders.java | 142 - .../ServicesGetUserDelegationKeyHeaders.java | 142 - ...vicesListBlobContainersSegmentHeaders.java | 104 - ...sListBlobContainersSegmentNextHeaders.java | 104 - .../models/ServicesSetPropertiesHeaders.java | 104 - .../models/ServicesSubmitBatchHeaders.java | 104 - .../models/SetPropertiesRequest.java | 285 + .../implementation/models/StorageError.java | 104 - .../models/StorageErrorException.java | 42 - .../implementation/models/package-info.java | 5 +- .../blob/implementation/package-info.java | 5 +- .../implementation/util/BlobConstants.java | 73 - .../util/BlobHeadersAndQueryParameters.java | 62 - .../implementation/util/BlobQueryReader.java | 366 - .../util/BlobRequestConditionProperty.java | 41 - .../implementation/util/BlobSasImplUtil.java | 459 - .../util/BlobUserAgentModificationPolicy.java | 67 - .../implementation/util/BuilderHelper.java | 228 - .../ByteBufferBackedOutputStreamUtil.java | 37 - .../util/ChunkedDownloadUtils.java | 165 - .../blob/implementation/util/ModelHelper.java | 665 - .../util/StorageBlockingSink.java | 104 - .../implementation/util/package-info.java | 7 - .../storage/blob/models/AccessPolicy.java | 134 + .../azure/storage/blob/models/AccessTier.java | 56 +- .../storage/blob/models/AccountKind.java | 71 - .../storage/blob/models/AppendBlobItem.java | 170 - .../models/AppendBlobRequestConditions.java | 146 - .../storage/blob/models/ArchiveStatus.java | 17 +- .../blob/models/ArrowConfiguration.java | 84 + .../azure/storage/blob/models/ArrowField.java | 184 + .../storage/blob/models/BlobAccessPolicy.java | 166 - .../blob/models/BlobAnalyticsLogging.java | 220 - .../storage/blob/models/BlobAudience.java | 67 - .../BlobBeginCopySourceRequestConditions.java | 94 - .../models/BlobContainerAccessPolicies.java | 46 - .../models/BlobContainerEncryptionScope.java | 76 - .../blob/models/BlobContainerItem.java | 231 - .../models/BlobContainerItemProperties.java | 476 - .../blob/models/BlobContainerListDetails.java | 100 - .../blob/models/BlobContainerProperties.java | 218 - .../storage/blob/models/BlobCopyInfo.java | 167 - .../blob/models/BlobCopySourceTagsMode.java | 51 - .../storage/blob/models/BlobCorsRule.java | 235 - .../models/BlobDeleteType.java | 13 +- .../models/BlobDownloadAsyncResponse.java | 117 - .../BlobDownloadContentAsyncResponse.java | 28 - .../models/BlobDownloadContentResponse.java | 22 - .../blob/models/BlobDownloadHeaders.java | 1047 -- .../blob/models/BlobDownloadResponse.java | 21 - .../storage/blob/models/BlobErrorCode.java | 649 - .../models/BlobExpiryOptions.java | 22 +- .../blob/models/BlobFlatListSegment.java | 84 + .../blob/models/BlobHierarchyListSegment.java | 107 + .../storage/blob/models/BlobHttpHeaders.java | 188 - .../blob/models/BlobImmutabilityPolicy.java | 60 - .../models/BlobImmutabilityPolicyMode.java | 66 +- .../azure/storage/blob/models/BlobItem.java | 297 - .../storage/blob/models/BlobItemInternal.java | 277 + .../blob/models/BlobItemProperties.java | 847 -- .../models/BlobLeaseRequestConditions.java | 94 - .../blob/models/BlobLegalHoldResult.java | 16 - .../storage/blob/models/BlobListDetails.java | 277 - .../storage/blob/models/BlobMetadata.java | 109 + .../storage/blob/models/BlobMetrics.java | 192 - .../azure/storage/blob/models/BlobName.java | 105 + .../azure/storage/blob/models/BlobPrefix.java | 122 +- .../storage/blob/models/BlobProperties.java | 864 -- .../blob/models/BlobPropertiesInternal.java | 948 ++ .../blob/models/BlobQueryArrowField.java | 97 - .../blob/models/BlobQueryArrowFieldType.java | 70 - .../models/BlobQueryArrowSerialization.java | 40 - .../blob/models/BlobQueryAsyncResponse.java | 30 - .../BlobQueryDelimitedSerialization.java | 112 - .../storage/blob/models/BlobQueryError.java | 74 - .../storage/blob/models/BlobQueryHeaders.java | 880 -- .../models/BlobQueryJsonSerialization.java | 36 - .../models/BlobQueryParquetSerialization.java | 15 - .../blob/models/BlobQueryProgress.java | 41 - .../blob/models/BlobQueryResponse.java | 21 - .../blob/models/BlobQuerySerialization.java | 16 - .../azure/storage/blob/models/BlobRange.java | 101 - .../blob/models/BlobRequestConditions.java | 107 - .../blob/models/BlobRetentionPolicy.java | 136 - .../BlobSeekableByteChannelReadResult.java | 43 - .../blob/models/BlobServiceProperties.java | 306 - .../blob/models/BlobServiceStatistics.java | 105 - .../blob/models/BlobSignedIdentifier.java | 132 - .../blob/models/BlobStorageException.java | 63 - .../azure/storage/blob/models/BlobTag.java | 105 + .../azure/storage/blob/models/BlobTags.java | 84 + .../azure/storage/blob/models/BlobType.java | 66 +- .../com/azure/storage/blob/models/Block.java | 171 +- .../storage/blob/models/BlockBlobItem.java | 162 - .../azure/storage/blob/models/BlockList.java | 164 +- .../storage/blob/models/BlockListType.java | 66 +- .../storage/blob/models/BlockLookupList.java | 140 +- .../azure/storage/blob/models/ClearRange.java | 137 +- .../blob/models/ConsistentReadControl.java | 40 - .../storage/blob/models/ContainerItem.java | 171 + .../blob/models/ContainerProperties.java | 357 + .../azure/storage/blob/models/CopyStatus.java | 69 + .../storage/blob/models/CopyStatusType.java | 66 - .../azure/storage/blob/models/CorsRule.java | 175 + .../azure/storage/blob/models/CpkInfo.java | 105 - .../blob/models/CustomerProvidedKey.java | 103 - .../models/DeleteSnapshotsOptionType.java | 61 +- .../models/DelimitedTextConfiguration.java | 131 +- .../blob/models/DownloadRetryOptions.java | 61 - .../blob/models/EncryptionAlgorithmType.java | 57 +- .../storage/blob/models/FilterBlobItem.java | 170 + .../blob/models/FilterBlobSegment.java | 151 + .../blob/models/FilterBlobsIncludeItem.java | 57 + .../storage/blob/models/GeoReplication.java | 143 +- .../blob/models/GeoReplicationStatus.java | 56 - .../blob/models/GeoReplicationStatusType.java | 63 + .../blob/models/JsonTextConfiguration.java | 92 + .../azure/storage/blob/models/KeyInfo.java | 132 - .../storage/blob/models/LeaseDuration.java | 57 + .../blob/models/LeaseDurationType.java | 56 - .../azure/storage/blob/models/LeaseState.java | 75 + .../storage/blob/models/LeaseStateType.java | 71 - .../storage/blob/models/LeaseStatus.java | 57 + .../storage/blob/models/LeaseStatusType.java | 56 - .../models/ListBlobContainersIncludeType.java | 61 - .../models/ListBlobContainersOptions.java | 95 - .../models/ListBlobsFlatSegmentResponse.java | 214 + .../ListBlobsHierarchySegmentResponse.java | 236 + .../blob/models/ListBlobsIncludeItem.java | 101 +- .../storage/blob/models/ListBlobsOptions.java | 96 - .../models/ListContainersIncludeType.java | 63 + .../models/ListContainersSegmentResponse.java | 194 + .../azure/storage/blob/models/Logging.java | 171 + .../azure/storage/blob/models/Metrics.java | 184 + .../models/ObjectReplicationMetadata.java | 88 + .../blob/models/ObjectReplicationPolicy.java | 48 - .../blob/models/ObjectReplicationRule.java | 40 - .../blob/models/ObjectReplicationStatus.java | 51 - ...eBlobCopyIncrementalRequestConditions.java | 94 - .../storage/blob/models/PageBlobItem.java | 154 - .../models/PageBlobRequestConditions.java | 162 - .../azure/storage/blob/models/PageList.java | 189 +- .../azure/storage/blob/models/PageRange.java | 137 +- .../storage/blob/models/PageRangeItem.java | 46 - .../blob/models/ParallelTransferOptions.java | 253 - .../blob/models/ParquetConfiguration.java | 107 + .../storage/blob/models/PathRenameMode.java | 42 - .../models/PremiumPageBlobAccessTier.java | 43 +- .../storage/blob/models/PublicAccessType.java | 18 +- .../storage/blob/models/QueryFormat.java | 217 + .../storage/blob/models/QueryRequest.java | 173 + .../storage/blob/models/QueryRequestType.java | 51 + .../blob/models/QuerySerialization.java | 83 + .../azure/storage/blob/models/QueryType.java | 69 + .../blob/models/RehydratePriority.java | 12 +- .../storage/blob/models/RetentionPolicy.java | 151 + .../blob/models/SequenceNumberActionType.java | 66 +- .../blob/models/SetPropertiesOptions.java | 252 + .../storage/blob/models/SignedIdentifier.java | 105 + .../azure/storage/blob/models/SkuName.java | 71 - .../storage/blob/models/StaticWebsite.java | 146 +- .../blob/models/StorageAccountInfo.java | 67 - .../blob/models/StorageServiceProperties.java | 196 + .../blob/models/StorageServiceStats.java | 80 + .../blob/models/SyncCopyStatusType.java | 45 - .../storage/blob/models/TaggedBlobItem.java | 74 - .../blob/models/UserDelegationKey.java | 297 +- .../storage/blob/models/package-info.java | 5 +- .../AppendBlobAppendBlockFromUrlOptions.java | 145 - .../blob/options/AppendBlobCreateOptions.java | 156 - .../blob/options/AppendBlobSealOptions.java | 42 - .../blob/options/BlobAcquireLeaseOptions.java | 55 - .../blob/options/BlobBeginCopyOptions.java | 265 - .../blob/options/BlobBreakLeaseOptions.java | 71 - .../blob/options/BlobChangeLeaseOptions.java | 57 - .../options/BlobContainerCreateOptions.java | 64 - .../options/BlobContainerRenameOptions.java | 59 - .../blob/options/BlobCopyFromUrlOptions.java | 240 - .../options/BlobDownloadToFileOptions.java | 168 - .../blob/options/BlobGetTagsOptions.java | 42 - .../blob/options/BlobInputStreamOptions.java | 114 - .../options/BlobParallelUploadOptions.java | 369 - .../blob/options/BlobQueryOptions.java | 172 - .../blob/options/BlobReleaseLeaseOptions.java | 41 - .../blob/options/BlobRenewLeaseOptions.java | 41 - .../BlobSeekableByteChannelReadOptions.java | 111 - .../options/BlobSetAccessTierOptions.java | 100 - .../blob/options/BlobSetTagsOptions.java | 61 - .../options/BlobUploadFromFileOptions.java | 167 - .../options/BlobUploadFromUrlOptions.java | 238 - .../BlockBlobCommitBlockListOptions.java | 193 - .../options/BlockBlobListBlocksOptions.java | 77 - .../options/BlockBlobOutputStreamOptions.java | 149 - ...ckBlobSeekableByteChannelWriteOptions.java | 202 - .../options/BlockBlobSimpleUploadOptions.java | 296 - .../BlockBlobStageBlockFromUrlOptions.java | 155 - .../options/BlockBlobStageBlockOptions.java | 100 - .../blob/options/FindBlobsOptions.java | 69 - .../options/ListPageRangesDiffOptions.java | 92 - .../blob/options/ListPageRangesOptions.java | 79 - .../PageBlobCopyIncrementalOptions.java | 72 - .../blob/options/PageBlobCreateOptions.java | 194 - .../PageBlobUploadPagesFromUrlOptions.java | 156 - .../options/UndeleteBlobContainerOptions.java | 81 - .../storage/blob/options/package-info.java | 7 - .../com/azure/storage/blob/package-info.java | 4 +- .../blob/sas/BlobContainerSasPermission.java | 409 - .../storage/blob/sas/BlobSasPermission.java | 410 - .../blob/sas/BlobSasServiceVersion.java | 71 - .../sas/BlobServiceSasQueryParameters.java | 312 - .../sas/BlobServiceSasSignatureValues.java | 766 -- .../azure/storage/blob/sas/package-info.java | 7 - .../specialized/AppendBlobAsyncClient.java | 711 - .../blob/specialized/AppendBlobClient.java | 710 - .../blob/specialized/BlobAsyncClientBase.java | 2846 ---- .../blob/specialized/BlobClientBase.java | 2802 ---- .../blob/specialized/BlobInputStream.java | 114 - .../specialized/BlobLeaseAsyncClient.java | 639 - .../blob/specialized/BlobLeaseClient.java | 649 - .../specialized/BlobLeaseClientBuilder.java | 205 - .../blob/specialized/BlobOutputStream.java | 378 - .../specialized/BlockBlobAsyncClient.java | 1170 -- .../blob/specialized/BlockBlobClient.java | 1196 -- .../blob/specialized/PageBlobAsyncClient.java | 1674 --- .../blob/specialized/PageBlobClient.java | 1575 --- .../blob/specialized/ReliableDownload.java | 153 - .../SpecializedBlobClientBuilder.java | 773 -- ...geSeekableByteChannelBlobReadBehavior.java | 116 - ...ableByteChannelBlockBlobWriteBehavior.java | 150 - .../blob/specialized/package-info.java | 7 - .../src/main/java/module-info.java | 20 +- ...azure-storage-blob_apiview_properties.json | 362 + .../azure-storage-blob/proxy-config.json | 20 - .../azure-storage-blob/reflect-config.json | 1862 --- .../azure-storage-blob/resource-config.json | 10 - .../azure-storage-blob/src/samples/README.md | 64 - .../blob/AsyncBufferedUploadExample.java | 95 - .../storage/blob/AzureIdentityExample.java | 42 - .../com/azure/storage/blob/BasicExample.java | 128 - .../BlobAsyncClientJavaDocCodeSnippets.java | 623 - .../storage/blob/BlobAudienceExample.java | 90 - .../BlobClientBuilderJavaDocCodeSnippets.java | 78 - .../blob/BlobClientJavaDocCodeSnippets.java | 487 - ...ntainerAsyncClientJavaDocCodeSnippets.java | 516 - ...ainerClientBuilderJavaDocCodeSnippets.java | 78 - ...lobContainerClientJavaDocCodeSnippets.java | 537 - ...ServiceAsyncClientJavaDocCodeSnippets.java | 416 - .../BlobServiceClientJavaDocCodeSnippets.java | 426 - .../BufferedUploadWithKnownLengthExample.java | 105 - .../blob/ConnectionLevelTimeoutExample.java | 79 - .../storage/blob/FileTransferExample.java | 176 - .../blob/JavaDocCodeSnippetsHelpers.java | 36 - .../storage/blob/ListContainersExample.java | 58 - .../storage/blob/LocationModeExample.java | 107 - .../blob/OperationalLevelTimeoutExample.java | 125 - .../com/azure/storage/blob/ReadmeSamples.java | 382 +- .../blob/RequestLevelTimeoutExample.java | 161 - .../com/azure/storage/blob/SampleHelper.java | 19 - .../blob/ServiceLevelTimeoutExample.java | 109 - .../storage/blob/ServiceVersionExample.java | 35 - .../SetMetadataAndHTTPHeadersExample.java | 102 - .../blob/StorageErrorHandlingExample.java | 66 - .../storage/blob/StorageEventExample.java | 150 - ...endBlobAsyncClientJavaDocCodeSnippets.java | 218 - .../AppendBlobClientJavaDocCodeSnippets.java | 242 - ...lobAsyncClientBaseJavaDocCodeSnippets.java | 824 -- .../BlobClientBaseJavaDocCodeSnippets.java | 807 -- ...ockBlobAsyncClientJavaDocCodeSnippets.java | 416 - .../BlockBlobClientJavaDocCodeSnippets.java | 429 - .../LeaseAsyncClientJavaDocCodeSnippets.java | 218 - ...LeaseClientBuilderJavaDocCodeSnippets.java | 117 - .../LeaseClientJavaDocCodeSnippets.java | 230 - ...ageBlobAsyncClientJavaDocCodeSnippets.java | 558 - .../PageBlobClientJavaDocCodeSnippets.java | 604 - .../storage/blob/AccessPolicyAsyncTests.java | 158 - .../azure/storage/blob/AccessPolicyTests.java | 151 - .../com/azure/storage/blob/AzuriteTests.java | 275 - .../com/azure/storage/blob/BlobApiTests.java | 3075 ----- .../azure/storage/blob/BlobAsyncApiTests.java | 2849 ---- .../blob/BlobErrorDeserializationTests.java | 43 - .../storage/blob/BlobOutputStreamTests.java | 260 - .../blob/BlobServiceClientBuilderTests.java | 31 - .../blob/BlobServiceSasModelsTests.java | 216 - .../storage/blob/BlobServiceVersionTests.java | 37 - .../com/azure/storage/blob/BlobTestBase.java | 848 -- .../blob/BlobUserAgentPropertiesTests.java | 110 - .../blob/BlockBlobInputOutputStreamTests.java | 456 - .../storage/blob/BuilderHelperTests.java | 658 - .../com/azure/storage/blob/CPKAsyncTests.java | 292 - .../azure/storage/blob/CPKNAsyncTests.java | 398 - .../com/azure/storage/blob/CPKNTests.java | 381 - .../java/com/azure/storage/blob/CPKTests.java | 289 - .../azure/storage/blob/ContainerApiTests.java | 2092 --- .../storage/blob/ContainerAsyncApiTests.java | 2101 --- .../storage/blob/FakeCredentialInTests.java | 14 - ...utableStorageWithVersioningAsyncTests.java | 821 -- .../ImmutableStorageWithVersioningTests.java | 864 -- .../azure/storage/blob/LargeBlobTests.java | 238 - .../storage/blob/OAuthCopySourceTests.java | 158 - .../storage/blob/ProgressReporterTests.java | 162 - .../storage/blob/RequestRetryTestFactory.java | 612 - .../com/azure/storage/blob/RetryTests.java | 277 - .../storage/blob/SasAsyncClientTests.java | 1292 -- .../azure/storage/blob/SasClientTests.java | 1222 -- .../azure/storage/blob/ServiceApiTests.java | 1346 -- .../storage/blob/ServiceAsyncApiTests.java | 1172 -- .../storage/blob/SoftDeleteAsyncTests.java | 69 - .../azure/storage/blob/SoftDeleteTests.java | 89 - .../storage/blob/VersioningAsyncTests.java | 493 - .../azure/storage/blob/VersioningTests.java | 390 - .../ServiceClientClientTestBase.java | 138 + .../util/StorageBlockingSinkTests.java | 195 - .../blob/specialized/AppendBlobApiTests.java | 887 -- .../specialized/AppendBlobAsyncApiTests.java | 931 -- .../blob/specialized/BlobBaseApiTests.java | 851 -- .../specialized/BlobBaseAsyncApiTests.java | 606 - .../blob/specialized/BlobBaseTestHelper.java | 10 - .../BlobSeekableByteChannelTests.java | 334 - .../blob/specialized/BlockBlobApiTests.java | 1732 --- .../specialized/BlockBlobAsyncApiTests.java | 2694 ---- .../specialized/DownloadResponseMockFlux.java | 214 - .../specialized/DownloadResponseTests.java | 166 - .../storage/blob/specialized/HelperTests.java | 207 - .../specialized/HttpFaultInjectingTests.java | 315 - .../blob/specialized/LeaseApiTests.java | 799 -- .../blob/specialized/LeaseAsyncApiTests.java | 878 -- .../blob/specialized/PageBlobApiTests.java | 1719 --- .../specialized/PageBlobAsyncApiTests.java | 1804 --- ...kableByteChannelBlobReadBehaviorTests.java | 276 - ...yteChannelBlockBlobWriteBehaviorTests.java | 222 - .../org.mockito.plugins.MockMaker | 1 - .../src/test/resources/parquet.parquet | Bin 80087 -> 0 bytes .../azure-storage-blob/swagger/README.md | 682 - .../swagger/Update-Codegeneration.ps1 | 1 - .../azure-storage-blob/swagger/package.json | 1 - .../azure-storage-blob/swagger/pom.xml | 17 - .../main/java/BlobStorageCustomization.java | 264 - .../azure-storage-blob/tsp-location.yaml | 4 + 503 files changed, 39702 insertions(+), 167335 deletions(-) delete mode 100644 sdk/storage/azure-storage-blob/checkstyle-suppressions.xml delete mode 100644 sdk/storage/azure-storage-blob/migrationGuides/V10_V12.md delete mode 100644 sdk/storage/azure-storage-blob/migrationGuides/V8_V12.md delete mode 100644 sdk/storage/azure-storage-blob/perf-resources.bicep delete mode 100644 sdk/storage/azure-storage-blob/perf-tests.yml delete mode 100644 sdk/storage/azure-storage-blob/perf.yml delete mode 100644 sdk/storage/azure-storage-blob/spotbugs-exclude.xml create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/AppendBlobAsyncClient.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/AppendBlobClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobUrlParts.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlockBlobAsyncClient.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlockBlobClient.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerAsyncClient.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerBlobAsyncClient.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerBlobClient.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/HttpGetterInfo.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/PageBlobAsyncClient.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/PageBlobClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ProgressReceiver.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ProgressReporter.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientAsyncClient.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientClient.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientClientBuilder.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImpl.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImplBuilder.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlobsImpl.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ContainerBlobsImpl.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ServiceClientClientImpl.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ServicesImpl.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobDownloadAsyncResponseConstructorProxy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobDownloadHeadersConstructorProxy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobItemConstructorProxy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobItemPropertiesConstructorProxy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobPropertiesConstructorProxy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobQueryHeadersConstructorProxy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/package-info.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsAppendBlockFromUrlHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsAppendBlockHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsCreateHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsSealHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowConfiguration.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowField.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobContainersSegment.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobCopySourceTags.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobFlatListSegment.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobHierarchyListSegment.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemInternal.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobName.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPrefixInternal.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternal.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalConstructorProperties.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalDownload.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalGetProperties.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobSignedIdentifierWrapper.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobStorageError.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobStorageExceptionInternal.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobTag.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobTags.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsAbortCopyFromURLHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsAcquireLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsBreakLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsChangeLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsCopyFromURLHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsCreateSnapshotHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDeleteHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDeleteImmutabilityPolicyHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDownloadHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetAccessControlHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetAccountInfoHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetPropertiesHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetTagsHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsQueryHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsReleaseLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsRenameHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsRenewLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetAccessControlHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetExpiryHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetHttpHeadersHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetImmutabilityPolicyHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetLegalHoldHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetMetadataHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetTagsHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetTierHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsStartCopyFromURLHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsUndeleteHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsCommitBlockListHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsGetBlockListHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsPutBlobFromUrlHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsStageBlockFromURLHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsStageBlockHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsUploadHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersAcquireLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersBreakLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersChangeLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersCreateHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersDeleteHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersFilterBlobsHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetAccessPolicyHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetAccountInfoHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetPropertiesHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersListBlobFlatSegmentHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersListBlobHierarchySegmentHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersReleaseLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRenameHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRenewLeaseHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRestoreHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSetAccessPolicyHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSetMetadataHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSubmitBatchHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesCreateHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesDeleteHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesGetAccessControlHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesRenameHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesSetAccessControlHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoryHttpHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/EncryptionScope.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobItem.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobSegment.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobsIncludeItem.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/GetUserDelegationKeyRequest.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/InternalBlobLegalHoldResult.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/JsonTextConfiguration.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ListBlobsFlatSegmentResponse.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ListBlobsHierarchySegmentResponse.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsClearPagesHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsCopyIncrementalHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsCreateHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesDiffHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesDiffNextHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesNextHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsResizeHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUpdateSequenceNumberHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUploadPagesFromURLHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUploadPagesHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListCollection.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListHelper.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListSegment.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormat.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormatType.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryRequest.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QuerySerialization.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesFilterBlobsHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetAccountInfoHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetPropertiesHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetStatisticsHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetUserDelegationKeyHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesListBlobContainersSegmentHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesListBlobContainersSegmentNextHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesSetPropertiesHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesSubmitBatchHeaders.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/SetPropertiesRequest.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/StorageError.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/StorageErrorException.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobConstants.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobHeadersAndQueryParameters.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobQueryReader.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobRequestConditionProperty.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobUserAgentModificationPolicy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ByteBufferBackedOutputStreamUtil.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ChunkedDownloadUtils.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/StorageBlockingSink.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/package-info.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccessPolicy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccountKind.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AppendBlobItem.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AppendBlobRequestConditions.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArrowConfiguration.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArrowField.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAccessPolicy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAnalyticsLogging.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAudience.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobBeginCopySourceRequestConditions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerAccessPolicies.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerEncryptionScope.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItem.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItemProperties.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerListDetails.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerProperties.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCopyInfo.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCopySourceTagsMode.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCorsRule.java rename sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/{implementation => }/models/BlobDeleteType.java (80%) delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadAsyncResponse.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadContentAsyncResponse.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadContentResponse.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadResponse.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobErrorCode.java rename sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/{implementation => }/models/BlobExpiryOptions.java (79%) create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobFlatListSegment.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobHierarchyListSegment.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobHttpHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItem.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemInternal.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLeaseRequestConditions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLegalHoldResult.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobListDetails.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobMetadata.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobMetrics.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobName.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobPropertiesInternal.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowField.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowFieldType.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowSerialization.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryAsyncResponse.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryDelimitedSerialization.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryError.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryHeaders.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryJsonSerialization.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryParquetSerialization.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryProgress.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryResponse.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQuerySerialization.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRange.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRequestConditions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRetentionPolicy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobSeekableByteChannelReadResult.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobServiceProperties.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobServiceStatistics.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobSignedIdentifier.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobStorageException.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobTag.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobTags.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockBlobItem.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ConsistentReadControl.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ContainerItem.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ContainerProperties.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CopyStatus.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CopyStatusType.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CorsRule.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CpkInfo.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CustomerProvidedKey.java rename sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/{implementation => }/models/DelimitedTextConfiguration.java (53%) delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DownloadRetryOptions.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobItem.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobSegment.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobsIncludeItem.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplicationStatus.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplicationStatusType.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/JsonTextConfiguration.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/KeyInfo.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseDuration.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseDurationType.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseState.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStateType.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStatus.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStatusType.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobContainersIncludeType.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobContainersOptions.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsFlatSegmentResponse.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsHierarchySegmentResponse.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsOptions.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListContainersIncludeType.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListContainersSegmentResponse.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Logging.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Metrics.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationMetadata.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationPolicy.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationRule.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationStatus.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobCopyIncrementalRequestConditions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobItem.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobRequestConditions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageRangeItem.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParallelTransferOptions.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParquetConfiguration.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PathRenameMode.java rename sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/{implementation => }/models/PremiumPageBlobAccessTier.java (69%) create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryFormat.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryRequest.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryRequestType.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QuerySerialization.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryType.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/RetentionPolicy.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SetPropertiesOptions.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SignedIdentifier.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SkuName.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageAccountInfo.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageServiceProperties.java create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageServiceStats.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SyncCopyStatusType.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/TaggedBlobItem.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobAppendBlockFromUrlOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobCreateOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobSealOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobAcquireLeaseOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBeginCopyOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBreakLeaseOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobChangeLeaseOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobContainerCreateOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobContainerRenameOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobCopyFromUrlOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobDownloadToFileOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobGetTagsOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobInputStreamOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobParallelUploadOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobQueryOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobReleaseLeaseOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobRenewLeaseOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSeekableByteChannelReadOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSetAccessTierOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSetTagsOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobUploadFromFileOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobUploadFromUrlOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobCommitBlockListOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobListBlocksOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobOutputStreamOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSeekableByteChannelWriteOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSimpleUploadOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobStageBlockFromUrlOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobStageBlockOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/FindBlobsOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/ListPageRangesDiffOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/ListPageRangesOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCopyIncrementalOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCreateOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobUploadPagesFromUrlOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/UndeleteBlobContainerOptions.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/package-info.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobContainerSasPermission.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasPermission.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasServiceVersion.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasSignatureValues.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/package-info.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseAsyncClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseClientBuilder.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobOutputStream.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobAsyncClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobAsyncClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobClient.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/ReliableDownload.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/SpecializedBlobClientBuilder.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlobReadBehavior.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlockBlobWriteBehavior.java delete mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/package-info.java create mode 100644 sdk/storage/azure-storage-blob/src/main/resources/META-INF/azure-storage-blob_apiview_properties.json delete mode 100644 sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/proxy-config.json delete mode 100644 sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/reflect-config.json delete mode 100644 sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/resource-config.json delete mode 100644 sdk/storage/azure-storage-blob/src/samples/README.md delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/AsyncBufferedUploadExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/AzureIdentityExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BasicExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAudienceExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientBuilderJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientBuilderJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceAsyncClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BufferedUploadWithKnownLengthExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ConnectionLevelTimeoutExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/FileTransferExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ListContainersExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/LocationModeExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/OperationalLevelTimeoutExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/RequestLevelTimeoutExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/SampleHelper.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ServiceLevelTimeoutExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ServiceVersionExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/SetMetadataAndHTTPHeadersExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageErrorHandlingExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageEventExample.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/AppendBlobAsyncClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/AppendBlobClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlockBlobAsyncClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlockBlobClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseAsyncClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseClientBuilderJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/PageBlobAsyncClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/PageBlobClientJavaDocCodeSnippets.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AccessPolicyAsyncTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AccessPolicyTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AzuriteTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAsyncApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobErrorDeserializationTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobOutputStreamTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceClientBuilderTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceSasModelsTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceVersionTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobTestBase.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlockBlobInputOutputStreamTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BuilderHelperTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKAsyncTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNAsyncTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAsyncApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/FakeCredentialInTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningAsyncTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/LargeBlobTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/OAuthCopySourceTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ProgressReporterTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/RequestRetryTestFactory.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/RetryTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasAsyncClientTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAsyncApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SoftDeleteAsyncTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SoftDeleteTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/VersioningAsyncTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/VersioningTests.java create mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/generated/ServiceClientClientTestBase.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/implementation/util/StorageBlockingSinkTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobAsyncApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseAsyncApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseTestHelper.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobSeekableByteChannelTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAsyncApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseMockFlux.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HttpFaultInjectingTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/LeaseApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/LeaseAsyncApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobAsyncApiTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlobReadBehaviorTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlockBlobWriteBehaviorTests.java delete mode 100644 sdk/storage/azure-storage-blob/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker delete mode 100644 sdk/storage/azure-storage-blob/src/test/resources/parquet.parquet delete mode 100644 sdk/storage/azure-storage-blob/swagger/README.md delete mode 100644 sdk/storage/azure-storage-blob/swagger/Update-Codegeneration.ps1 delete mode 100644 sdk/storage/azure-storage-blob/swagger/package.json delete mode 100644 sdk/storage/azure-storage-blob/swagger/pom.xml delete mode 100644 sdk/storage/azure-storage-blob/swagger/src/main/java/BlobStorageCustomization.java create mode 100644 sdk/storage/azure-storage-blob/tsp-location.yaml diff --git a/sdk/storage/azure-storage-blob/CHANGELOG.md b/sdk/storage/azure-storage-blob/CHANGELOG.md index 957b07d1589b..34bdffb5d912 100644 --- a/sdk/storage/azure-storage-blob/CHANGELOG.md +++ b/sdk/storage/azure-storage-blob/CHANGELOG.md @@ -1,933 +1,13 @@ # Release History -## 12.30.0-beta.2 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - -## 12.30.0-beta.1 (2025-02-11) - -### Features Added -- Added support for service version 2025-05-05. - -## 12.29.0 (2024-11-13) - -### Features Added -- Added BlobErrorCode BlobAccessTierNotSupportedForAccountType value. -- Added support for service version 2025-01-05. - -### Bugs Fixed -- Fixed an issue where BlobClient.upload(InputStream data) would overwrite an existing blob by default. -- Fixed an issue where you couldn't set an immutability policy on a blob version or blob snapshot. -- Fixed an issue where you couldn't set a legal hold on a blob version. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` from `1.52.0` to version `1.54.0`. -- Upgraded `azure-core-http-netty` from `1.15.4` to version `1.15.6`. -- Upgraded `azure-storage-common` from `12.27.0` to version `12.28.0`. -- Upgraded `azure-storage-internal-avro` from `12.13.0` to version `12.14.0`. - -## 12.29.0-beta.1 (2024-10-17) - -### Features Added -- Added BlobErrorCode BlobAccessTierNotSupportedForAccountType value. -- Added support for service version 2025-01-05. - -### Bugs Fixed -- Fixed an issue where you couldn't set an immutability policy on a blob version or blob snapshot. -- Fixed an issue where you couldn't set a legal hold on a blob version. - -## 12.28.1 (2024-10-08) - -### Bugs Fixed -- Fixed a bug where downloadToFile and openInputStream was throwing an InvalidRange exception if the target file size was a multiple of the - authenticated region length. - -#### Dependency Updates -- Upgraded `azure-storage-common` from `12.27.0` to version `12.27.1`. - -## 12.28.0 (2024-09-17) - -### Features Added -- Added ability to retrieve SAS string to sign for debugging purposes. -- Added support for service version 2024-11-04. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` from `1.50.0` to version `1.52.0`. -- Upgraded `azure-core-http-netty` from `1.15.2` to version `1.15.4`. -- Upgraded `azure-storage-common` from `12.26.0` to version `12.27.0`. -- Upgraded `azure-storage-internal-avro` from `12.12.0` to version `12.13.0`. - -## 12.28.0-beta.1 (2024-08-06) - -### Features Added -- Added ability to retrieve SAS string to sign for debugging purposes. -- Added support for service version 2024-11-04. - -## 12.27.0 (2024-07-18) - -### Features Added -- Added support for getting account info on blob container clients and the blob base client. -- Added support for bearer token challenges. -- Added support for service version 2024-08-04. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` from `1.49.1` to version `1.50.0`. -- Upgraded `azure-core-http-netty` from `1.15.1` to version `1.15.2`. -- Upgraded `azure-storage-common` from `12.25.1` to version `12.26.0`. -- Upgraded `azure-storage-internal-avro` from `12.11.1` to version `12.12.0`. - -## 12.27.0-beta.1 (2024-06-11) - -### Features Added -- Added support for getting account info on blob container clients and the blob base client. -- Added support for bearer token challenges. -- Added support for service version 2024-08-04. - -## 12.26.1 (2024-06-06) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` from `1.49.0` to version `1.49.1`. -- Upgraded `azure-core-http-netty` from `1.15.0` to version `1.15.1`. -- Upgraded `azure-storage-common` from `12.25.0` to version `12.25.1`. -- Upgraded `azure-storage-internal-avro` from `12.11.0` to version `12.11.1`. - -## 12.26.0 (2024-05-15) - -### Features Added -- Added support for service versions 2024-02-04 and 2024-05-04. - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core-http-netty` from `1.14.2` to version `1.15.0`. -- Upgraded `azure-storage-common` from `12.25.0-beta.2` to version `12.25.0`. -- Upgraded `azure-core` from `1.48.0` to version `1.49.0`. -- Upgraded `azure-storage-internal-avro` from `12.11.0-beta.2` to version `12.11.0`. +## 1.0.0-beta.1 (Unreleased) - -## 12.25.4 (2024-04-23) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core-http-netty` from `1.14.1` to version `1.14.2`. -- Upgraded `azure-storage-common` from `12.24.3` to version `12.25.0-beta.2`. -- Upgraded `azure-core` from `1.47.0` to version `1.48.0`. -- Upgraded `azure-storage-internal-avro` from `12.10.3` to version `12.11.0-beta.2`. - - -## 12.26.0-beta.1 (2024-04-15) +- Azure Blob client library for Java. This package contains Microsoft Azure Blob client library. ### Features Added -- Added support for service versions 2024-02-04 and 2024-05-04. ### Breaking Changes -- When creating a `BlobClient` via `BlobContainerClient.getBlobClient(String blobName)` or -`BlobServiceClient.getBlobClient(String blobName)`, the blob name will be stored exactly as passed in and will not be -URL-encoded. For example, if blob name is "test%25test" and is created by calling -`BlobContainerClient.getBlobClient("test%25test")` or `BlobClient.getBlobName("test%25test")`, -`BlobClient.getBlobName()` will return "test%25test" and the blob's url will result in -“https://account.blob.core.windows.net/container/test%25%25test”. - -## 12.25.3 (2024-03-20) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core-http-netty` from `1.14.0` to version `1.14.1`. -- Upgraded `azure-core` from `1.46.0` to version `1.47.0`. -- Upgraded `azure-storage-common` from `12.24.2` to version `12.24.3`. -- Upgraded `azure-storage-internal-avro` from `12.10.2` to version `12.10.3`. - - -## 12.25.2 (2024-02-22) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.45.1` to version `1.46.0`. -- Upgraded `azure-core-http-netty` from `1.13.11` to version `1.14.0`. -- Upgraded `azure-storage-common` from `12.24.1` to version `12.24.2`. -- Upgraded `azure-storage-internal-avro` from `12.10.1` to version `12.10.2`. - - -## 12.25.1 (2023-12-04) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.45.0` to version `1.45.1`. -- Upgraded `azure-storage-internal-avro` from `12.10.0` to version `12.10.1`. -- Upgraded `azure-storage-common` from `12.24.0` to version `12.24.1`. -- Upgraded `azure-core-http-netty` from `1.13.10` to version `1.13.11`. - -## 12.25.0 (2023-11-08) - -### Features Added -- Added BlobProperties.getRequestId() to access the x-ms-request-id header property. -- Added support for service versions 2023-11-03. -- Added support for BlobAudience. - -## 12.24.1 (2023-10-24) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.43.0` to version `1.44.1`. -- Upgraded `azure-storage-internal-avro` from `12.9.0` to version `12.9.1`. -- Upgraded `azure-storage-common` from `12.23.0` to version `12.23.1`. -- Upgraded `azure-core-http-netty` from `1.13.7` to version `1.13.9`. - -## 12.25.0-beta.1 (2023-10-19) - -### Features Added -- Added support for service versions 2023-11-03. -- Added support for BlobAudience. - -## 12.24.0 (2023-09-12) - -### Features Added -- Added support for service versions 2023-05-03 and 2023-08-03. -- Added RehydratePendingToCold value to ArchiveStatus enum. - -## 12.23.1 (2023-08-18) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-storage-common` from `12.22.0` to version `12.22.1`. -- Upgraded `azure-core-http-netty` from `1.13.5` to version `1.13.6`. -- Upgraded `azure-core` from `1.41.0` to version `1.42.0`. -- Upgraded `azure-storage-internal-avro` from `12.8.0` to version `12.8.1`. - -## 12.24.0-beta.1 (2023-08-08) - -### Features Added -- Added support for service versions 2023-05-03 and 2023-08-03. -- Added RehydratePendingToCold value to ArchiveStatus enum. - -## 12.23.0 (2023-07-11) - -### Features Added -- Added support for the `2023-01-03` service version. -- Content length limit for `AppendBlobClient.appendBlock()` raised from 4 MiB to 100 MiB. - -## 12.22.3 (2023-06-14) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.39.0` to version `1.40.0`. -- Upgraded `azure-core-http-netty` from `1.13.3` to version `1.13.4`. -- Upgraded `azure-storage-common` from `12.21.1` to version `12.21.2`. -- Upgraded `azure-storage-internal-avro` from `12.7.1` to version `12.8.0-beta.2`. - -## 12.23.0-beta.1 (2023-05-30) - -### Features Added -- Added support for 2023-01-03 service version. -- Content length limit for `AppendBlobClient.appendBlock()` raised from 4 MiB to 100 MiB. - -## 12.22.2 (2023-05-23) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-storage-common` from `12.21.0` to version `12.21.1`. -- Upgraded `azure-storage-internal-avro` from `12.7.0` to version `12.7.1`. -- Upgraded `azure-core` from `1.38.0` to version `1.39.0`. -- Upgraded `azure-core-http-netty` from `1.13.2` to version `1.13.3`. - -## 12.22.1 (2023-05-15) ### Bugs Fixed -Fixed bug in `BlobBaseClient.downloadToFile()` and `BlobBaseClient.downloadToFileWithResponse()` where incorrect data could be written to the file in some circumstances if the SDK experienced a network error when using `azure-core-http-netty`'s `HttpClient` implementation. - -## 12.22.0 (2023-04-13) - -### Features Added -- Added new method `StorageAccountInfo.isHierarchicalNamespaceEnabled()` to determine whether storage account has hierarchical namespace enabled. -- Added support for 2022-11-02 service version. -- Added support for reading and writing a block blob via SeekableByteChannel. - -### Bugs Fixed -- Fixed bug for when `FindBlobsOptions.setMaxResultsPerPage(Integer)` was set and `.byPage()` was called on `BlobServiceAsyncClient.findBlobsByTags(FindBlobsOptions)`, number of results being returned was greater than the specified max results. - -## 12.22.0-beta.1 (2023-03-28) - -### Features Added -- Added support for 2022-11-02 service version. -- Added support for reading and writing a block blob via SeekableByteChannel. - -### Bugs Fixed -- Fixed bug for when `FindBlobsOptions.setMaxResultsPerPage(Integer)` was set and `.byPage()` was called on `BlobServiceAsyncClient.findBlobsByTags(FindBlobsOptions)`, number of results being returned was greater than the specified max results. - -## 12.21.1 (2023-03-16) ### Other Changes - -#### Dependency Updates - -- Upgraded `azure-storage-common` from `12.20.0` to version `12.20.1`. -- Upgraded `azure-core-http-netty` from `1.13.0` to version `1.13.1`. -- Upgraded `azure-core` from `1.36.0` to version `1.37.0`. -- Upgraded `azure-storage-internal-avro` from `12.6.0` to version `12.6.1`. - -## 12.21.0 (2023-02-21) - -### Features Added -- Added `BlobDownloadHeaders.getCreationTime()` and `BlobDownloadHeaders.setCreationTime(OffsetDateTime)` to access the x-ms-creation-time property. -- Added support for 2021-12-02 service version. -- Added support for Blob Cold Tier `AccessTier.COLD`. -- Added new overload `AppendBlobClient.getBlobOutputStream(boolean)` that takes in a boolean for overwrite and appends to existing data if overwrite is specified `false`, or deletes and recreates a blob if overwrite is specified `true`. - -### Bugs Fixed -- Fixed bug where `BlobErrorCode.IncrementalCopyOfEarlierVersionSnapshotNotAllowed` was spelled incorrectly. - -## 12.21.0-beta.1 (2023-02-07) - -### Features Added -- Added support for 2021-12-02 service version. -- Added support for Blob Cold Tier `AccessTier.COLD`. -- Fixed bug where `BlobErrorCode.IncrementalCopyOfEarlierVersionSnapshotNotAllowed` was spelled incorrectly. -- Added new overload `AppendBlobClient.getBlobOutputStream(boolean)` that takes in a boolean for overwrite and appends to existing data if overwrite is specified `false`, or deletes and recreates a blob if overwrite is specified `true`. - -## 12.20.2 (2023-01-10) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.34.0` to version `1.35.0`. -- Upgraded `azure-core-http-netty` from `1.12.7` to version `1.12.8`. -- Upgraded `azure-storage-common` from `12.19.1` to version `12.19.2`. -- Upgraded `azure-storage-internal-avro` from `12.5.1` to version `12.5.2`. - -## 12.20.1 (2022-11-15) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` from `1.33.0` to version `1.34.0`. -- Upgraded `azure-core-http-netty` from `1.12.6` to version `1.12.7`. -- Upgraded `azure-storage-common` from `12.19.0` to version `12.19.1`. -- Upgraded `azure-storage-internal-avro` from `12.5.0` to version `12.5.1`. - -## 12.20.0 (2022-10-11) - -### Features Added -- Added support for 2021-10-04 service version. -- Added ability to rename existing containers with `BlobContainerClient.rename()`. -- Added new overload for `BlobClient.upload()` that takes in `InputStream` without specifying length. - -### Breaking Changes -- `BlobItem.isPrefix()` now returns false if it is not a virtual directory instead of null. - -#### Dependency Updates -- Upgraded `azure-core` from `1.32.0` to version `1.33.0`. -- Upgraded `azure-core-http-netty` from `1.12.5` to version `1.12.6`. -- Upgraded `azure-storage-common` from `12.18.1` to version `12.19.0`. -- Upgraded `azure-storage-internal-avro` from `12.4.2` to version `12.5.0`. - -## 12.19.1 (2022-09-12) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` from `1.31.0` to version `1.32.0`. -- Upgraded `azure-core-http-netty` from `1.12.4` to version `1.12.5`. -- Upgraded `azure-storage-common` from `12.18.0` to version `12.18.1`. -- Upgraded `azure-storage-internal-avro` from `12.4.1` to version `12.4.2`. - -## 12.20.0-beta.1 (2022-09-06) - -### Features Added -- Added support for 2021-10-04 service version. -- Added new overload for `BlobClient.upload()` that takes in `InputStream` without specifying length. - -### Breaking Changes -- `BlobItem.isPrefix()` now returns false if it is not a virtual directory instead of null. - -## 12.19.0 (2022-08-12) - -### Features Added -- Added `ParallelTransferOptions.getProgressListener` and `ParallelTransferOptions.setProgressListener` - that replaces deprecated `ParallelTransferOptions.getProgressReceiver` and `ParallelTransferOptions.setProgressReceiver` -- `com.azure.storage.blob.ProgressReceiver` extends `com.azure.core.util.ProgressListener` for backwards compatibility. -- Added `BlobDownloadAsyncResponse.writeValueToAsync` and `BlobDownloadAsyncResponse.close`. -- Added `BlockBlobSimpleUploadOptions(BinaryData)` constructor, `BlockBlobStageBlockOptions`, - `BlockBlobAsyncClient.stageBlock(String, BinaryData)`, `BlockBlobAsyncClient.stageBlockWithResponse(BlockBlobStageBlockOptions)`, - `BlockBlobAsyncClient.upload(BinaryData)`, `BlockBlobAsyncClient.upload(BinaryData, boolean)`, - `BlockBlobClient.stageBlock(String, BinaryData)`, `BlockBlobClient.stageBlockWithResponse(BlockBlobStageBlockOptions, Duration, Context)`, - `BlockBlobClient.upload(BinaryData)`, `BlockBlobClient.upload(BinaryData, boolean)` - -### Other Changes -- `com.azure.storage.blob.ProgressReceiver` and `com.azure.storage.blob.ProgressReporter` are deprecated - and replaced by `com.azure.core.util.ProgressListener` and `com.azure.core.util.ProgressReporter`. - -## 12.18.0 (2022-07-07) - -### Features Added -- BlobOutputStream.close() will now attempt to close the stream at first attempt. Subsequent calls to close have no effect. -- GA release for 2021-08-06 service version. - -## 12.18.0-beta.1 (2022-06-15) - -### Features Added -- Added support for 2021-08-06 service version. - -## 12.17.1 (2022-06-08) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.28.0` to version `1.29.1`. -- Upgraded `azure-core-http-netty` from `1.12.0` to version `1.12.2`. -- Upgraded `azure-storage-common` from `12.16.0` to version `12.16.1`. -- Upgraded `azure-storage-internal-avro` from `12.3.0` to version `12.4.0-beta.1`. - -## 12.17.0 (2022-05-25) - -### Other Changes -- GA release for STG 82 - -### Other Changes -- Deprecated BlobClientBase.download and BlobClientBase.downloadWithResponse that downloads entire blob into an output - stream. Use BlobClientBase.downloadStream and BlobClientBase.downloadStreamWithResponse instead. - -## 12.16.1 (2022-05-12) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.27.0` to version `1.28.0`. -- Upgraded `azure-core-http-netty` from `1.11.9` to version `1.12.0`. -- Upgraded `azure-storage-common` from `12.15.1` to version `12.15.2`. -- Upgraded `azure-storage-internal-avro` from `12.2.1` to version `12.2.2`. - -## 12.17.0-beta.1 (2022-05-06) - -### Features Added -- Added support for 2021-06-08 service version. -- Added the ability to list PageRanges and PageRangesDiff by page. - -## 12.16.0 (2022-04-07) - -### Bugs Fixed -- Fixed a bug where `uploadFromFile(String, boolean)` used a different size to determine whether blob existence should - be checked before using chunked upload than the size used to triggered chunked upload. -### Other Changes -#### Dependency Updates -- Upgraded `azure-core` from `1.26.0` to version `1.27.0`. -- Upgraded `azure-core-http-netty` from `1.11.8` to version `1.11.9`. -- Upgraded `azure-storage-common` from `12.15.0` to version `12.15.1`. -- Upgraded `azure-storage-internal-avro` from `12.2.0` to version `12.2.1`. - -## 12.15.0 (2022-03-09) - -### Bugs Fixed -- Fixed a bug where a timeout parameter was being ignored on an uploadFromFileWithResponse. - -### Other Changes -- GA release for STG 79, 80, 81 - -## 12.14.4 (2022-02-11) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.24.1` to version `1.25.0`. -- Upgraded `azure-core-http-netty` from `1.11.6` to version `1.11.7`. -- Upgraded `azure-storage-common` from `12.14.2` to version `12.14.3`. -- Upgraded `azure-storage-internal-avro` from `12.1.3` to version `12.1.4`. - -## 12.15.0-beta.3 (2022-02-09) - -### Features Added -- Added support for 2021-04-10 service version. -- Added support for filterBlobs api on container clients. - -### Bugs Fixed -- Fixed a bug in builders that would cause container or blobName to be erased if specified before the connection string. - -## 12.14.3 (2022-01-14) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.22.0` to version `1.24.1`. -- Upgraded `azure-core-http-netty` from `1.11.2` to version `1.11.6`. -- Upgraded `azure-storage-common` from `12.14.1` to version `12.14.2`. -- Upgraded `azure-storage-internal-avro` from `12.1.2` to version `12.1.3`. - -## 12.15.0-beta.2 (2021-12-07) - -### Features Added -- Added support for 2021-02-12 service version. -- Added support for listing system containers. -- Added support for listing blobs which contain invalid xml characters. - -- When opening a BlobInputStream, removed the initial getProperties call in favor of a download for better performance. - -### Bugs Fixed -- Fixed a bug that would cause authenticating with a sas token to fail if the timestamps in the token were formatted differently. - -### Other Changes -- Deprecated BlobClient.uploadWithResponse that does not return a response. - -## 12.14.2 (2021-11-10) - -### Other Changes -#### Dependency Updates -- Updated to version `1.22.0` of `azure-core` -- Updated to version `12.14.1` of `azure-storage-common` - -## 12.15.0-beta.1 (2021-11-05) - -### Features Added -- Added support for permanent delete permissions in blob and account level SAS. - -- Added support for the 2020-12-06 service version. -- Added support for setting an encryption scope on a BlobServiceSas and an AccountSas. -- Added support for setting encryption scopes on the destination of a sync copy. - -## 12.14.1 (2021-10-12) - -### Bugs Fixed - -- Fixed a bug when Blob Endpoint is provided as an IP address (e.g., `https://x.x.x.x:10000`) with - empty component path, the parsing fails with StringIndexOutOfBoundsException - -### Other Changes -#### Dependency Updates -- Updated to version `1.21.0` of `azure-core` -- Updated to version `12.14.0` of `azure-storage-common` - -## 12.14.0 (2021-09-15) -- GA release - -## 12.14.0-beta.1 (2021-07-28) -- Fixed a bug where BlobClient.exists would not function correctly on blobs encrypted with CPK. -- Added support for the 2020-10-02 service version. -- Added support to list blobs deleted with versioning enabled. -- Added support to specify Parquet Input Serialization when querying a blob. -- Updated DownloadRetryOptions.maxRetryRequests to default downloads to retry 5 times. - -## 12.13.0 (2021-07-22) -- Added support to get a blob client that uses an encryption scope and customer provided key. - -## 12.12.0 (2021-06-09) -- GA release - -## 12.12.0-beta.1 (2021-05-13) -- Added support for the 2020-08-04 service version. -- Deprecated support to undelete a blob container to a new name. - -## 12.11.1 (2021-05-13) -### Dependency Updates -- Updated `azure-core` to version `1.16.0` - -## 12.11.0 (2021-04-29) -- Fixed a bug where large files would not respond when the upload method was called. - -## 12.11.0-beta.3 (2021-04-16) -- Fixed a bug where BlobOutputStream would lock up if the inner uploadWithResponse call is cancelled for any reason. -- Fixed a bug where BlobOutputStream could not respond when writing in a tight loop because the inner FluxSink would buffer in an unbounded manner. This would cause memory issues especially if the heap size was set to less than the size of the data being uploaded. -- Fixed a bug where a null check was placed on the wrong parameter of the InputStream constructor for BlobParallelUploadOptions - -## 12.11.0-beta.2 (2021-03-29) -- Fixed a bug where downloading would throw a NPE on large downloads due to a lack of eTag. -- Fixed a bug where more data would be buffered in buffered upload than expected due to Reactor's concatMap operator. -- Added upload and download methods on BlobClient and BlobAsyncClient that work with BinaryData. -- Fixed a bug that ignored the page size when calling PagedIterable.byPage(pageSize) - -## 12.10.2 (2021-03-26) -- Fixed a bug where BlobInputStream would not use request conditions when doing the initial getProperties call in openInputStream. - -## 12.10.1 (2021-03-19) -- Removed a deep copy in the general upload path to reduce memory consumption and increase perf -- Added a deep copy immediately after calling BlobOutputStream.write to prevent overwriting data in the case of reusing a single buffer to write to an output stream - -## 12.11.0-beta.1 (2021-02-10) -- Added support for the 2020-06-12 service version. -- Added support to lock on version id by specifying a consistent read control when opening a BlobInputStream. -- Removed a deep copy in the general upload path to reduce memory consumption and increase perf -- Added a deep copy immediately after calling BlobOutputStream.write to prevent overwriting data in the case of reusing a single buffer to write to an output stream - -## 12.10.0 (2021-01-14) -- GA release - -## 12.10.0-beta.1 (2020-12-07) -- Exposed ClientOptions on all client builders, allowing users to set a custom application id and custom headers. -- Added ability to get container client from blob clients and service client from container clients -- Added a MetadataValidationPolicy to check for leading and trailing whitespace in metadata that would cause Auth failures. -- Fixed a bug where the error message would not be displayed the exception message of a HEAD request. -- Added support for the 2020-04-08 service version. -- Added support to upload block blob from URL. -- Added lease ID parameter to Get and Set Blob Tags. -- Added blob tags to BlobServiceClient.findBlobsByTags() result. - -## 12.9.0 (2020-11-11) -- Fixed a bug where interspersed element types returned by page listing would deserialize incorrectly. -- Fixed a bug where BlobInputStream would not eTag lock on the blob, resulting in undesirable behavior if the blob was modified in the middle of reading. -- Renamed BlobDownloadToFileOptions.rangeGetContentMd5 to BlobDownloadToFileOptions.retrieveContentRangeMd5. -- Added support for move and execute permissions on blob SAS and container SAS, and list permissions on blob SAS. -- Added support to specify a preauthorized user id and correlation id for user delegation SAS. - -## 12.9.0-beta.2 (2020-10-08) -- Added support to specify whether or not a pipeline policy should be added per call or per retry. - -## 12.9.0-beta.1 (2020-10-01) -- Added support for the 2020-02-10 service version. -- Added support to specify Arrow Output Serialization when querying a blob. -- Added support to undelete a container. -- Added support to set BlobParallelUploadOptions.computeMd5 so the service can perform an md5 verification. -- Added support to specify block size when using BlobInputStream. -- Fixed a bug where users could not download more than 5000MB of data in one shot in the downloadToFile API. -- Fixed a bug where the TokenCredential scope would be incorrect for custom URLs. -- Fixed a bug where Default Azure Credential would not work with Azurite. -- Fixed a bug where a custom application id in HttpLogOptions would not be added to the User Agent String. -- Fixed a bug where BlockBlobOutputStream would not handle certain errors. -- Added BlobImmutableDueToPolicy to the BlobErrorCode enum. - -## 12.8.0 (2020-08-13) -- Fixed a bug that, when the data length parameter did not match the actual length of the data in BlobClient.upload, caused a zero length blob to be uploaded rather than throwing an exception. -- Fixed a bug that ignored the customer's specified block size when determining buffer sizes in BlobClient.upload -- Added support for Object Replication Service on listBlobs and getProperties. -- Added support for blob tags. Added tagsConditions to BlobRequestConditions that allow a user to specify a SQL statement for the blob's tags to satisfy. -- Added support for setting tags and filterTags operations on SAS by adding to AccountSASPermissions, BlobSASPermissions, and BlobContainerSASPermissions. -- Added support for setting and getting the StaticWebsite.DefaultIndexDocumentPath property on the service client. -- Added RehydratePriority to BlobProperties and BlobItemProperties. -- Fixed bug where Query Input Stream would throw when a ByteBuffer of length 0 was encountered. -- Added support to seal an append blob. Added AppendBlob.seal. Added ability to specify destinationSealed on BlobClient.beginCopy. isSealed property returned on getProperties/getBlob/listBlob. -- Added support to set tier on a snapshot or version. -- Fixed a bug that would cause buffered upload to always put an empty blob before uploading actual data. - -## 12.8.0-beta.1 (2020-07-07) -- Added support for the 2019-12-12 service version. -- Added support for blob tags. Added get/setTags method to Blob(Async)ClientBase. Added filterTags api to BlobServiceClient. Added ability to specify tags on all methods that create a blob. Tag count returned on getProperties/getBlob. Option to include returning tags on listing. -- Added support to query a blob. Added query and openQueryInputStream methods to Blob(Async)ClientBase. -- Added support to version a blob. Added `getVersionClient` to clients that returns a new client associated to the version. -- Added support to increase the maximum size of data that can be sent via a stage block. - -## 12.7.0 (2020-06-12) -- Moved BlobParallelUploadOptions into options package. -- Added data source and data length to BlobParallelUploadOptions and removed them from the relevant method parameter lists - -## 12.7.0-beta.1 (2020-06-08) -- Fixed a bug that would cause empty data to be sent if a call to stage block, block blob upload, append block, or upload pages was automatically retried by the SDK. -- Added a maxConcurrency option on ParallelTransferOptions that allows the customer to limit how many concurrent network requests will be outstanding per api request at once. -- Added an overload to BlobClient.upload which returns a BlockBlobItem containing the properties returned by the service upon blob creation. -- Fixed a bug that caused auth failures when constructing a client to a secondary endpoint using token auth. -- Modified client constructors to throw on invalid urls early to prevent SAS tokens from being logged in Exceptions. - -## 12.6.1 (2020-05-06) -- Updated `azure-core` version to `1.5.0` to pickup fixes for percent encoding `UTF-8` and invalid leading bytes in a body string. - -## 12.6.0 (2020-04-06) -- Fixed a bug that would prevent client initialization against Azurite in some containerized environments. -- Fixed a bug that would prevent progress from being reported when uploading small files. -- Modified BlobOutputStream to wait on a condition variable until transfer is complete instead of polling. -- Fixed a bug where the Date header wouldn't be updated with a new value on request retry. -- Fixed a bug that ignored the timeout and context parameters on BlobClient.uploadWithResponse. -- Added an overload to BlobOutputStream which accepts a context. - -## 12.5.0 (2020-03-11) -- Fixed a bug that was adding an invalid 'include' query-parameter for list blob item requests if no dataset-include options were specified. -- Fixed a bug in ReliableDownload that would cause multiple subscriber errors. -- Added logic to ReliableDownload to retry on TimeoutException -- Added default timeout to download stream to timeout if a certain amount of time passes without seeing any data. -- Fixed a bug that would cause IOExceptions to be swallowed in BlobClient.upload(InputStream, long) - -## 12.4.0 (2020-02-12) -- Added ability to access BlobProperties from BlobInputStream. -- Modified downloadToFile to populate BlobProperties.blobSize to be the actual blob size instead of the content length of the first range. -- Added upload methods on BlobClient to upload from an InputStream. - -- Added support for the 2019-07-07 service version. -- Added support for encryption scopes service, container and blob builders now accept an encryption scope parameter and service and container builders accept a BlobContainerEncryptionScope parameter. -- Added support for managed disk page range diff for managed disk accounts. - -## 12.3.1 (2020-02-10) -- Updated `azure-core-http-netty` to version 1.3.0 -- Update `azure-storage-common` to version 12.3.1 - -## 12.3.0 (2020-01-16) -This package's -[documentation](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.3.0/sdk/storage/azure-storage-blob/README.md) -and -[samples](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.3.0/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob) - -- Added ability to create service clients anonymously and should only be used to create anonymous container and blob clients. Anonymous service clients will throw on attempting to create network requests. -- Added an overload to listBlobs to include a continuation token. -- Added a check in BlobServiceClient.setAccountProperties to block invalid requests. -- Fixed a bug that could result in data corruption on download when using the downloadToFile method. - -## 12.2.0 (2020-01-08) -This package's -[documentation](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.2.0/sdk/storage/azure-storage-blob/README.md) -and -[samples](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.2.0/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob) - -- Added a field to ParallelTransferOptions that allows customers to configure the maximum size to upload in a single PUT. Data sizes larger than this value will be chunked and parallelized. -- Added overloads to downloadToFile to add the option to overwrite existing files. Default behavior is to not overwrite. -- Improved performance of BlockBlobOutputStream. -- Added overloads to BlockBlobClient.getBlobOutputStream to allow users to provide parallel transfer options, http headers, metadata, access tier, and request conditions. - -## 11.1.1 (2019.04.30) -- Upgraded to version 2.1.1 of the autorest-clientime which upgrades to a more secure version of jackson and fixes a NPE on unknown host errors. - -## 11.0.0 (2019.03.22) -- Upgraded to version 2.1.0 of the autorest-clientruntime which includes several important fixes to mitigate a commonly-seen "Connection reset by peer" error and other similar bugs. -- Support for 2018-11-09 REST version. Please see our REST API documentation and blogs for information about the related added features. -- Added appendBlockFromURL method. A block may be created with another blob as its source. -- Added uploadPagesFromURL method. Pages may be written to with another blob as their source. -- Fixed a bug that would set an invalid range header when downloading an empty blob. -- Modified the LoggingFactory to redact SAS signatures on outgoing requests. -- HTTPGetterInfo was made an internal type as it is an internal implementation detail. -- Removed DEFAULT and NONE static variables. Empty constructors should be used instead. DEFAULT static values were error prone and unsafe to use because although the field was final, the objects were mutable, so it was possible the value could be changed accidentally and alter the behavior of the program. -- Optimized the TransferManager download to file method to skip the initial HEAD request. -- Added an option to configure that maximum size data that will be uploaded in a single shot via the TransferManager. -- Added request Http Method, URL, and headers to logging messages. -- Changed *ListingDetails to *ListDetails. These name changes are to mitigate conflicts with v8, allowing for side-by-side loading of different versions, which may help with upgrading. -- Removed the extra quotes around etags in some responses so they are consistently now consistently formatted. -- Moved the Generated*** types into the blob package to avoid conflicts with generated types from other services (i.e. queues and files) -- Changed the logger name to be the name of class that uses it, which is a more conventional practice -- Support added for SAS tokens to scope to blob snapshot. -- Added getUserDelegationKey to ServiceURL, the result of which can be used to generate a user-delegation SAS. -- Made the max results field on listing responses Integer instead of int as it is an optional field only returned when specified in the request. - -## 10.5.0 (2019.02.15) -- Added uploadFromNonReplayableFlowable to support uploading arbitrary data sources (like network streams) to a block blob. - -## 10.4.0 (2019.01.11) -- Fixed a bug that caused errors when java.io.tempdir has no trailing separator. -- Upgrade autorest-clientruntime dependency to include some bug fixes. - -## 12.2.0-beta.1 (2019-12-17) -- Added SAS generation methods on clients to improve discoverability and convenience of sas. Deprecated setContainerName, setBlobName, setSnapshotId, generateSasQueryParameters methods on BlobServiceSasSignatureValues to direct users to using the methods added on clients. -- Fixed a bug where Account SAS would not work when set on clients. - -## 12.1.0 (2019-12-04) -This package's -[documentation](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.1.0/sdk/storage/azure-storage-blob/README.md) -and -[samples](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.1.0/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob) - -- Optimized downloadToFile to avoid an unnecessary getProperties call and to lock on an etag once the operation has started. -- Fixed a race condition that would sometimes result in a RuntimeException with a message related to unexpected header value of client-request-id. -- Fixed a bug in the RetryPolicy that would apply the delay of a fixed retry policy to the first try. -- Fixed a bug that could cause the overwrite flag to not be honored in cases where data was uploaded by another source after a parallel operation has already started. -- Added overloads to accept an overwrite flag to commitBlockList and getBlobOutputStream. Note that this changes the default behavior of the min overload and these methods will now fail if they are attempting to overwrite data. -- Added a check in ClientBuilders to enforce HTTPS for bearer token authentication. -- Upgraded to version 1.1.0 of Azure Core. - -## 12.0.0 (2019-10-31) - -- Removed BaseBlobClientBuilder -- Removed BlobClientBuilder, BlobContainerClientBuilder, BlobServiceClientBuilder, and SpecializedBlobClientBuilder inheritance of BaseBlobClientBuilder -- Renamed ListBlobContainerOptions getMaxResults and setMaxResults to getMaxResultsPerPage and setMaxResultsPerPage -- Renamed ListBlobsOptions getMaxResults and setMaxResults to getMaxResultsPerPage and setMaxResultsPerPage -- Renamed BlobProperties to BlobItemProperties and BlobContainerProperties to BlobContainerItemProperties -- Removes StorageError and StorageErrorException from public API -- Renamed StorageErrorCode to BlobErrorCode, SignedIdentifier to BlobSignedIdentifier, StorageServiceProperties to BlobServiceProperties, StorageServiceStats to BlobServiceStatistics, CorRules to BlobCorRules, AccessPolicy to BlobAccessPolicy, Logging to BlobAnalyticsLogging, Metrics to BlobMetrics, and RetentionPolicy to BlobRetentionPolicy -- Renamed BlobHTTPHeaders to BlobHttpHeaders and removed Blob from getter names -- Renamed StorageException to BlobStorageException -- Added BlobServiceVersion and the ability to set it on client builders -- Replaced URL parameters with String on appendBlockFromUrl, beginCopy, copyFromUrl, stageBlockFromUrl, uploadPagesFromUrl, and copyIncremental -- Added support for emulator endpoints -- Added support for additional connection string configurations and support for use development connection -- Changed constructors for AppendBlobItem, BlockBlobItem, PageBlobItem, -- Renamed listBlobsFlat to listBlobs and listBlobHierarchy to listBlobsByHierarchy -- Replaced startCopyFromUrl with beginCopy and return poller -- Renamed BlobContainerSasPermission and BlobSasPermission getters to use has prefix -- Replaced BlobAccessConditions, AppendBlobAccessConditions, and PageBlobAccessConditions with BlobRequestConditions, AppendBlobRequestConditions, and PageBlobRequestConditions. -- Removed ModifiedAccessConditions and SourceModifiedAccessConditions in favor of RequestConditions, removed BlobContainerAccessConditions in favor of BlobRequestConditions. -- Removed AppendPositionAccessConditions, LeaseAccessConditions, and SequenceNumberAccessConditions -- Renamed LeaseClient, LeaseAsyncClient, and LeaseClientBuilder to BlobLeaseClient, BlobLeaseAsyncClient, and BlobLeaseClientBuilder -- Added upload overloads which allow passing a flag to indicate if an existing blob should be overwritten -- Added support for blob names with special characters -- Changed return type for BlobClient.downloadWithProperties from Response to BlobDownloadResponse and BlobAsyncClient.downloadWithProperties from Mono>> to Mono - -## 12.0.0-preview.4 (2019-10-08) -For details on the Azure SDK for Java (October 2019 Preview) release, you can refer to the [release announcement](https://aka.ms/azure-sdk-preview4-java). - -This package's -[documentation](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0-preview.4/sdk/storage/azure-storage-blob/README.md) -and -[samples](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0-preview.4/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob) - -- Moved the specialized `BlobClient`, `AppendBlobClient`, `BlockBlobClient`, and `PageBlobClient`, into the `specialized` package within Azure Storage Blobs. Additionally, moved any model classes that are tied to a specific specialized client. -- Added a `BlobClientBase` which is now the super class for `BlobClient`, `AppendBlobClient`, `BlockBlobClient`, and `PageBlobClient`. -- Getters and setters were updated to use Java Bean notation. -- Added `getBlobContainerName` on `BlobContainerClient` and `BlobContainerAsyncClient` and `getContainerName`, `getBlobName` on `BlobClientBase` and `BlobAsyncClientBase` for fetching the resource names. -- Updated to be fully compliant with the Java 9 Platform Module System. -- Changed `VoidResponse` to `Response` on sync API, and `Mono` to `Mono>` on async API. -- Fixed metadata does not allow capital letter issue. [`Bug 5295`](https://github.com/Azure/azure-sdk-for-java/issues/5295) -- Updated the return type of `downloadToFile` API to `BlobProperties` on sync API and `Mono` on async API. -- `getAccountUrl`, `getBlobContainerUrl`, `getBlobUrl` API now returns URL with scheme, host, resource name and snapshot if any. -- Added `LeaseClient` and `LeaseAsyncClient` to the specialized package and removed the leasing methods from `BlobClient`, `BlobAsyncClient`, `ContainerClient`, and `ContainerAsyncClient`. -- Added `blocksize` parameter to sync `blockBlobClient`. -- Use Primitives for `exist` API return type. -- Removed a `create` and `appendBlockFromUrl` overload API in `AppendBlob`. -- Fixed `create` method name in PageBlob. -- Renamed `setTier` to `setAccessTier` from `BlobAsyncClientBase` and `BlobClientBase` classes. -- Added `ParallelTransferOptions` to buffered upload, upload from file and download to file methods. -- Removed `Metadata` class and uses Map for `matadata` field of `BlobProperties` and `ContainerProperties`. -- Removed SAS token generation APIs from clients, use BlobServiceSasSignatureValues to generate SAS tokens. -- Removed `SASTokenCredential`, `SASTokenCredentialPolicy` and the corresponding `credential(SASTokenCredential)` method in client builder, and added sasToken(String) instead. - -## 12.0.0-preview.3 (2019-09-10) -For details on the Azure SDK for Java (September 2019 Preview) release, you can refer to the [release announcement](https://aka.ms/azure-sdk-preview3-java). - -- Added tracing telemetry on maximum overload API. -- Throw `UnexpectedLengthException` when the upload body doesn't match the expected input length. -- Added validation policy to check the equality of request client ID between request and response. -- Updated to use service version 2019-02-02. -- Added dependency to azure-storage-common. -- Replaced `ByteBuf` with `ByteBuffer` and removed dependency on `Netty`. -- Added convenience upload method to `BlockBlobClient` and `BlockBlobAsyncClient`. -- Added rehydrate priority support. -- Added capability to set tier on additional APIs. -- Added customer provided key support. - -**Breaking changes: New API design** -- Changed list responses to `PagedFlux` on async APIs and `PagedIterable` on sync APIs. -- Simplified API to return model types directly on non-maximal overloads. Maximal overloads return `Response` and suffixed with WithResponse. - -This package's -[documentation](https://github.com/Azure/azure-sdk-for-java/blob/085c8570b411defff26860ef56ea189af07d3d6a/sdk/storage/azure-storage-blob/README.md) -and -[samples](https://github.com/Azure/azure-sdk-for-java/blob/085c8570b411defff26860ef56ea189af07d3d6a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob) -demonstrate the new API. - -## 12.0.0-preview.2 (2019-08-08) -For details on the Azure SDK for Java (August 2019 Preview) release refer to the [release announcement](https://azure.github.io/azure-sdk/releases/2019-08-06/java.html). - -- Renamed `StorageClient`, `StorageAsyncClient`, and `StorageClientBuilder` to `BlobServiceClient`, `BlobServiceAsyncClient`, and `BlobServiceClientBuilder`. -- Combined `AppendBlobClientBuilder`, `BlockBlobClientBuilder`, and `PageBlobClientBuilder` into `BlobClientBuilder`. Methods to create each client type were added. -- Removed static builder method from clients. Builders are now instantiable. -- Changed return type of `createSnapshot` in `BlobClient` to return a client associated to the blob snapshot instead of the snapshot ID. Use `getSnapshotId` to get snapshot ID and `isSnapshot` to indicate if the client is associated to a blob snapshot. -- Added `getSnapshotClient` to clients that returns a new client associated to the snapshot. -- Added SAS token generation to clients. -- Added `deleteContainer` to `BlobServiceClient` and `BlobServiceAsyncClient`. -- Added `getAppendBlobClient` with snapshot overload to `ContainerClient`. -- Removed `AnonymousClientCredential` class. -- Changed parameter ordering of `BlobClient` and `BlobAsyncClient` `download` and `downloadToFile`. - -This package's -[documentation](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0-preview.2/sdk/storage/azure-storage-blob/README.md) -and -[samples](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0-preview.2/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob) -demonstrate the new API. - -## 12.0.0-preview.1 (2019-06-28) -Version 12.0.0-preview.1 is a preview of our efforts in creating a client library that is developer-friendly, idiomatic to the Java ecosystem, and as consistent across different languages and platforms as possible. The principles that guide our efforts can be found in the [Azure SDK Design Guidelines for Java](https://azure.github.io/azure-sdk/java_introduction.html). - -For details on the Azure SDK for Java (July 2019 Preview) release, you can refer to the [release announcement](https://aka.ms/azure-sdk-preview1-java). - -**Breaking changes: New API design** -- Operations are now scoped to a particular client: - - `BlobServiceClient`: StorageURL's functionality was migrated to BlobServiceClient. This client handles account-level operations. This includes managing service properties and listing the containers within an account. - - `ContainerClient`: ContainerURL's functionality was migrated to ContainerClient. The client handles operations for a particular container. This includes creating or deleting that container, as well as listing the blobs within that container. - - `BlobClient`: BlobURL's functionality was migrated to BlobClient, TransferManager download functionality was migrated to BlobClient and TransferManager upload functionality was migrated to BlockBlobClient. The client handles most operations, excluding upload, for an individual blob, including downloading data and working with blob properties. - There are subclients (BlockBlobClient, PageBlobClient, AppendBlobClient) available for their respective blob types on the service. - - These clients can be accessed by navigating down the client hierarchy, or instantiated directly using builder to the resource (account, container or blob). -- New module level operations for simple upload and download using a block or page blob client. -- Download operations can download data in multiple ways: - - `download_to_stream`: Download the entire content to an open stream handle (e.g. an open file). Supports multi-threaded download. -- New underlying REST pipeline implementation, based on the new `azure-core` library. -- Client and pipeline configuration is now available via keyword arguments at both the client level. -- Authentication using `azure-identity` credentials. - -## 10.3.0 (2018.11.19) -- Added support for SLF4J. -- Included default logging to log warnings and errors to the temp directory by default. -- Fixed a bug in hierarchical listings that would sometimes return incomplete results. -- Included the whole HTTP Request in log statements (except for sensitive authorization information, which is redacted). -- Fixed a bug that made the request property on the response object always null. - -## 10.2.0 (2018.10.29) -- Added overloads which only accept the required parameters. -- Added CopyFromURL, which will do a synchronous server-side copy, meaning the service will not return an HTTP response until it has completed the copy. -- Added support for IProgressReceiver in TransferManager operations. This parameter was previously ignored but is now supported. -- Removed internal dependency on javafx to be compatible with openjdk. -- Fixed a bug that would cause downloading large files with the TransferManager to fail. -- Fixed a bug in BlobURL.download() logic for setting up reliable download. This had the potential to download the wrong range when a download stream was retried. - -## 10.1.0 (2018.09.11) -- Interfaces for helper types updated to be more consistent throughout the library. All types, with the exception of the options for pipeline factories, use a fluent pattern. -- Removed RetryReader type as it's functionality was moved to be built into the DownloadResponse. RetryReaderOptions are now named DownloadRetryOptions. -- Restructured the access conditions to be more logically adhere to their respective functions. -- Added support for context parameter on each api to allow communication with the pipeline from the application level - -## 10.0.4-rc (2018.08.22) -- Support for the 2017-11-09 REST version. Please see our REST api documentation and blogs for information about the related added features. -- Support for 2018-03-28 REST version. Please see our REST api documentation and blogs for information about the related added features. -- Support for the getAccountInfo api on ServiceURL, ContainerURL, and BlobURL. -- Added support for setting service properties related to static websites. -- Changed BlobURL.startCopy sourceAccessConditions parameter to be HTTPAccessConditions as lease is not actually supported. -- Added methods to TransferManager for conveniently downloading a blob to a file. -- UploadFromFile now takes an AsynchronousFileChannel. -- UploadByteBuffersToBlockBlob, UploadByteBufferToBlockBlob, and DownloadToBuffer have been removed. -- IPRange fields are now strings. -- Fixed retry policy. -- Fixed logging policy. - -## 10.0.3-Preview (2018.08.08) -- Resolved dependency issues - -## 10.0.2-Preview (2018.08.07) -- Support for 2017-07-29 REST version. Please see our REST api documentation and blogs for information about the related added features. -- Support for setting a block blob's tier. -- Added support for soft delete feature. If a delete retention policy is enabled through the set service properties API, then blobs or snapshots can be deleted softly and retained for a specified number of days, before being permanently removed by garbage collection. -- Changed BlobListingDetails constructor to take a flag to include deleted blobs. -- Restructured the blob and container listing responses. -- BlockBlobURL.MAX_PUT_BLOCK_BYTES renamed to BlockBlobURL.MAX_STAGE_BLOCK_BYTES. -- Changed the accessConditions parameter to be HTTPAccessConditions instead of BlobAccessConditions, since only http access conditions are supported. - -## 10.0.1-Preview (2018.07.03) -- Added the RetryReader class to allow for more reliable streaming on large downloads. This is now the return type of blobURL.download -- Fixed a bug that caused generation of signatures to fail at high levels of parallelism. -- Created the StorageException type to give easy access to the ErrorCode, StatusCode, and Message as available for unsuccessful responses. -- Added the StorageErrorCode type for checking against error codes returned by the service. -- Changed the AppendBlobAccessConditions field types to be Long instead of Int. -- Upgraded Netty dependency to allow uploading memory mapped files with https. -- Upgraded the autorest runtime dependency to fix a dependency bug in their package. -- Changed RequestRetryOptions maxTries and tryTimeout fields to be Integer instead of int. 0 is no longer allowed. -- Changed CommonRestResponse.lastModifiedTime to be lastModified. -- Added statusCode property to CommonRestResponse. -- Change dateProperty to be date on all generated types. -- Fixed a bug that prevented proper reset of body stream upon retry. -- Updated the defaults for RequestRetryOptions. - -## 10.0.0-preview (2018.04.27) -- Initial Release. Please see the README and wiki for information on the new design. diff --git a/sdk/storage/azure-storage-blob/README.md b/sdk/storage/azure-storage-blob/README.md index a6830cf100d4..567af36e8736 100644 --- a/sdk/storage/azure-storage-blob/README.md +++ b/sdk/storage/azure-storage-blob/README.md @@ -1,631 +1,78 @@ -# Azure Storage Blob client library for Java +# Azure Blob client library for Java -Azure Blob Storage is Microsoft's object storage solution for the cloud. Blob -Storage is optimized for storing massive amounts of unstructured data. -Unstructured data is data that does not adhere to a particular data model or -definition, such as text or binary data. +Azure Blob client library for Java. -[Source code][source] | [API reference documentation][docs] | [REST API documentation][rest_docs] | [Product documentation][product_docs] | [Samples][samples] +This package contains Microsoft Azure Blob client library. + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] +- [Product documentation][product_documentation] ## Getting started ### Prerequisites - [Java Development Kit (JDK)][jdk] with version 8 or above - - Here are details about [Java 8 client compatibility with Azure Certificate Authority](https://learn.microsoft.com/azure/security/fundamentals/azure-ca-details?tabs=root-and-subordinate-cas-list#client-compatibility-for-public-pkis). - [Azure Subscription][azure_subscription] -- [Create Storage Account][storage_account] - -### Include the package - -#### Include the BOM file - -Please include the azure-sdk-bom to your project to take dependency on GA version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number. -To learn more about the BOM, see the [AZURE SDK BOM README](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/boms/azure-sdk-bom/README.md). - -```xml - - - - com.azure - azure-sdk-bom - {bom_version_to_target} - pom - import - - - -``` -and then include the direct dependency in the dependencies section without the version tag. - -```xml - - - com.azure - azure-storage-blob - - -``` -#### Include direct dependency -If you want to take dependency on a particular version of the library that is not present in the BOM, -add the direct dependency to your project as follows. +### Adding the package to your product [//]: # ({x-version-update-start;com.azure:azure-storage-blob;current}) ```xml com.azure azure-storage-blob - 12.30.0-beta.1 + 1.0.0-beta.1 ``` [//]: # ({x-version-update-end}) -### Create a Storage Account -To create a Storage Account you can use the [Azure Portal][storage_account_create_portal] or [Azure CLI][storage_account_create_cli]. - -```bash -az storage account create \ - --resource-group \ - --name \ - --location -``` - -Your storage account URL, subsequently identified as ``, would be formatted as follows: -`http(s)://.blob.core.windows.net` +### Authentication -### Authenticate the client - -In order to interact with the Storage Service (Blob, Queue, Message, MessageId, File), you'll need to create an instance of the Service Client class. -To make this possible you'll need the Account SAS (shared access signature) string of the Storage Account. Learn more at [SAS Token][sas_token]. - -#### Get credentials - -##### SAS Token - -a. Use the Azure CLI snippet below to get the SAS token from the Storage Account. - -```bash -az storage blob generate-sas \ - --account-name {Storage Account name} \ - --container-name {container name} \ - --name {blob name} \ - --permissions {permissions to grant} \ - --expiry {datetime to expire the SAS token} \ - --services {storage services the SAS allows} \ - --resource-types {resource types the SAS allows} -``` - -Example: - -```bash -CONNECTION_STRING= - -az storage blob generate-sas \ - --account-name MyStorageAccount \ - --container-name MyContainer \ - --name MyBlob \ - --permissions racdw \ - --expiry 2020-06-15 -``` - -b. Alternatively, get the Account SAS token from the Azure Portal. - -1. Go to your Storage Account -2. Select `Shared access signature` from the menu on the left -3. Click on `Generate SAS and connection string` (after setup) - -##### **Shared Key Credential** - -a. Use Account name and Account key. Account name is your Storage Account name. - -1. Go to your Storage Account -2. Select `Access keys` from the menu on the left -3. Under `key1`/`key2` copy the contents of the `Key` field - -or - -b. Use the connection string. - -1. Go to your Storage Account -2. Select `Access keys` from the menu on the left -3. Under `key1`/`key2` copy the contents of the `Connection string` field +[Azure Identity][azure_identity] package provides the default implementation for authenticating the client. ## Key concepts -Blob Storage is designed for: - -- Serving images or documents directly to a browser -- Storing files for distributed access -- Streaming video and audio -- Writing to log files -- Storing data for backup and restore, disaster recovery, and archiving -- Storing data for analysis by an on-premises or Azure-hosted service - -### URL format -Blobs are addressable using the following URL format: -The following URL addresses a blob: -``` -https://myaccount.blob.core.windows.net/mycontainer/myblob -``` - -#### Resource URI Syntax -For the storage account, the base URI for blob operations includes the name of the account only: - -``` -https://myaccount.blob.core.windows.net -``` - -For a container, the base URI includes the name of the account and the name of the container: - -``` -https://myaccount.blob.core.windows.net/mycontainer -``` - -For a blob, the base URI includes the name of the account, the name of the container and the name of the blob: - -``` -https://myaccount.blob.core.windows.net/mycontainer/myblob -``` - -Note that the above URIs may not hold for more advanced scenarios such as custom domain names. - ## Examples -The following sections provide several code snippets covering some of the most common Azure Storage Blob tasks, including: - -- [Create a `BlobServiceClient`](#create-a-blobserviceclient) -- [Create a `BlobContainerClient`](#create-a-blobcontainerclient) -- [Create a `BlobClient`](#create-a-blobclient) -- [Create a container](#create-a-container) -- [Upload data to a blob](#upload-data-to-a-blob) -- [Upload a blob from a stream](#upload-a-blob-from-a-stream) -- [Upload a blob from local path](#upload-a-blob-from-local-path) -- [Upload a blob if one does not already exist](#upload-a-blob-if-one-does-not-already-exist) -- [Upload a blob and overwrite if one already exists](#upload-a-blob-and-overwrite-if-one-already-exists) -- [Upload a blob via an `OutputStream`](#upload-a-blob-via-an-outputstream) -- [Download data from a blob](#download-data-from-a-blob) -- [Download a blob to a stream](#download-a-blob-to-a-stream) -- [Download a blob to local path](#download-a-blob-to-local-path) -- [Read a blob via an `InputStream`](#read-a-blob-via-an-inputstream) -- [Enumerate blobs](#enumerate-blobs) -- [Copy a blob](#copy-a-blob) -- [Generate a SAS token](#generate-a-sas-token) -- [Authenticate with Azure Identity](#authenticate-with-azure-identity) -- [Set a proxy when building a client](#set-a-proxy-when-building-a-client) - -### Create a `BlobServiceClient` - -Create a `BlobServiceClient` using the [`sasToken`](#get-credentials) generated above. - -```java readme-sample-getBlobServiceClient1 -BlobServiceClient blobServiceClient = new BlobServiceClientBuilder() - .endpoint("") - .sasToken("") - .buildClient(); -``` - -or - -```java readme-sample-getBlobServiceClient2 -// Only one "?" is needed here. If the SAS token starts with "?", please removing one "?". -BlobServiceClient blobServiceClient = new BlobServiceClientBuilder() - .endpoint("" + "?" + "") - .buildClient(); -``` - -### Create a `BlobContainerClient` - -Create a `BlobContainerClient` using a `BlobServiceClient`. - -```java readme-sample-getBlobContainerClient1 -BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient("mycontainer"); -``` - -Create a `BlobContainerClient` from the builder [`sasToken`](#get-credentials) generated above. - -```java readme-sample-getBlobContainerClient2 -BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() - .endpoint("") - .sasToken("") - .containerName("mycontainer") - .buildClient(); -``` - -or - -```java readme-sample-getBlobContainerClient3 -// Only one "?" is needed here. If the SAS token starts with "?", please removing one "?". -BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() - .endpoint("" + "/" + "mycontainer" + "?" + "") - .buildClient(); -``` - -### Create a `BlobClient` - -Create a `BlobClient` using a `BlobContainerClient`. - -```java readme-sample-getBlobClient1 -BlobClient blobClient = blobContainerClient.getBlobClient("myblob"); -``` - -or - -Create a `BlobClient` from the builder [`sasToken`](#get-credentials) generated above. - -```java readme-sample-getBlobClient2 -BlobClient blobClient = new BlobClientBuilder() - .endpoint("") - .sasToken("") - .containerName("mycontainer") - .blobName("myblob") - .buildClient(); -``` - -or - -```java readme-sample-getBlobClient3 -// Only one "?" is needed here. If the SAS token starts with "?", please removing one "?". -BlobClient blobClient = new BlobClientBuilder() - .endpoint("" + "/" + "mycontainer" + "/" + "myblob" + "?" + "") - .buildClient(); -``` - -### Create a container - -Create a container using a `BlobServiceClient`. - -```java readme-sample-createBlobContainerClient1 -blobServiceClient.createBlobContainer("mycontainer"); +```java com.azure.storage.blob.readme ``` -or +### Service API versions -Create a container using a `BlobContainerClient`. +The client library targets the latest service API version by default. +The service client builder accepts an optional service API version parameter to specify which API version to communicate. -```java readme-sample-createBlobContainerClient2 -blobContainerClient.create(); -``` - -### Upload data to a blob - -Upload `BinaryData` to a blob using a `BlobClient` generated from a `BlobContainerClient`. - -```java readme-sample-uploadBinaryDataToBlob -BlobClient blobClient = blobContainerClient.getBlobClient("myblockblob"); -String dataSample = "samples"; -blobClient.upload(BinaryData.fromString(dataSample)); -``` - -### Upload a blob from a stream - -Upload from an `InputStream` to a blob using a `BlockBlobClient` generated from a `BlobContainerClient`. - -```java readme-sample-uploadBlobFromStream -BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient("myblockblob").getBlockBlobClient(); -String dataSample = "samples"; -try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - blockBlobClient.upload(dataStream, dataSample.length()); -} catch (IOException e) { - e.printStackTrace(); -} -``` - -### Upload a blob from local path - -Upload a file to a blob using a `BlobClient` generated from a `BlobContainerClient`. - -```java readme-sample-uploadBlobFromFile -BlobClient blobClient = blobContainerClient.getBlobClient("myblockblob"); -blobClient.uploadFromFile("local-file.jpg"); -``` - -### Upload a blob if one does not already exist - -Upload data to a blob and fail if one already exists. - -```java readme-sample-uploadIfNotExists -/* - * Rather than use an if block conditioned on an exists call, there are three ways to upload-if-not-exists using - * one network call instead of two. Equivalent options are present on all upload methods. - */ -// 1. The minimal upload method defaults to no overwriting -String dataSample = "samples"; -try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - blobClient.upload(dataStream, dataSample.length()); -} catch (IOException e) { - e.printStackTrace(); -} - -// 2. The overwrite flag can explicitly be set to false to make intention clear -try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - blobClient.upload(dataStream, dataSample.length(), false /* overwrite */); -} catch (IOException e) { - e.printStackTrace(); -} - -// 3. If the max overload is needed, access conditions must be used to prevent overwriting -try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - BlobParallelUploadOptions options = - new BlobParallelUploadOptions(dataStream, dataSample.length()); - // Setting IfNoneMatch="*" ensures the upload will fail if there is already a blob at the destination. - options.setRequestConditions(new BlobRequestConditions().setIfNoneMatch("*")); - blobClient.uploadWithResponse(options, null, Context.NONE); -} catch (IOException e) { - e.printStackTrace(); -} -``` - -### Upload a blob and overwrite if one already exists - -Upload data to a blob and overwrite any existing data at the destination. - -```java readme-sample-overwriteBlob -/* - * Rather than use an if block conditioned on an exists call, there are three ways to upload-if-exists in one - * network call instead of two. Equivalent options are present on all upload methods. - */ -String dataSample = "samples"; +#### Select a service API version -// 1. The overwrite flag can explicitly be set to true. This will succeed as a create and overwrite. -try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - blobClient.upload(dataStream, dataSample.length(), true /* overwrite */); -} catch (IOException e) { - e.printStackTrace(); -} +You have the flexibility to explicitly select a supported service API version when initializing a service client via the service client builder. +This ensures that the client can communicate with services using the specified API version. -/* - * 2. If the max overload is needed and no access conditions are passed, the upload will succeed as both a - * create and overwrite. - */ -try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - BlobParallelUploadOptions options = - new BlobParallelUploadOptions(dataStream, dataSample.length()); - blobClient.uploadWithResponse(options, null, Context.NONE); -} catch (IOException e) { - e.printStackTrace(); -} +When selecting an API version, it is important to verify that there are no breaking changes compared to the latest API version. +If there are significant differences, API calls may fail due to incompatibility. -/* - * 3. If the max overload is needed, access conditions may be used to assert that the upload is an overwrite and - * not simply a create. - */ -try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - BlobParallelUploadOptions options = - new BlobParallelUploadOptions(dataStream, dataSample.length()); - // Setting IfMatch="*" ensures the upload will succeed only if there is already a blob at the destination. - options.setRequestConditions(new BlobRequestConditions().setIfMatch("*")); - blobClient.uploadWithResponse(options, null, Context.NONE); -} catch (IOException e) { - e.printStackTrace(); -} -``` - -### Upload a blob via an `OutputStream` - -Upload a blob by opening a `BlobOutputStream` and writing to it through standard stream APIs. - -```java readme-sample-openBlobOutputStream -/* - * Opening a blob input stream allows you to write to a blob through a normal stream interface. It will not be - * committed until the stream is closed. - * This option is convenient when the length of the data is unknown. - * This can only be done for block blobs. If the target blob already exists as another type of blob, it will - * fail. - */ -try (BlobOutputStream blobOS = blobClient.getBlockBlobClient().getBlobOutputStream()) { - blobOS.write(new byte[0]); -} catch (IOException e) { - e.printStackTrace(); -} -``` - -### Download data from a blob - -Download a blob to an `OutputStream` using a `BlobClient`. - -```java readme-sample-downloadDataFromBlob -BinaryData content = blobClient.downloadContent(); -``` - -### Download a blob to a stream - -Download a blob to an `OutputStream` using a `BlobClient`. - -```java readme-sample-downloadBlobToStream -try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { - blobClient.downloadStream(outputStream); -} catch (IOException e) { - e.printStackTrace(); -} -``` - -### Download a blob to local path - -Download blob to a local file using a `BlobClient`. - -```java readme-sample-downloadBlobToFile -blobClient.downloadToFile("downloaded-file.jpg"); -``` - -### Read a blob via an `InputStream` - -Download a blob by opening a `BlobInputStream` and reading from it through standard stream APIs. - -```java readme-sample-openBlobInputStream -/* - * Opening a blob input stream allows you to read from a blob through a normal stream interface. It is also - * mark-able. -*/ -try (BlobInputStream blobIS = blobClient.openInputStream()) { - blobIS.read(); -} catch (IOException e) { - e.printStackTrace(); -} -``` - -### Enumerate blobs - -Enumerating all blobs using a `BlobContainerClient`. - -```java readme-sample-enumerateBlobs -for (BlobItem blobItem : blobContainerClient.listBlobs()) { - System.out.println("This is the blob name: " + blobItem.getName()); -} -``` - -or - -Enumerate all blobs and create new clients pointing to the items. - -```java readme-sample-enumerateBlobsCreateClient -for (BlobItem blobItem : blobContainerClient.listBlobs()) { - BlobClient blobClient; - if (blobItem.getSnapshot() != null) { - blobClient = blobContainerClient.getBlobClient(blobItem.getName(), blobItem.getSnapshot()); - } else { - blobClient = blobContainerClient.getBlobClient(blobItem.getName()); - } - System.out.println("This is the new blob uri: " + blobClient.getBlobUrl()); -} -``` - -### Copy a blob - -Copying a blob. Please refer to the javadocs on each of these methods for more information around requirements on the -copy source and its authentication. - -```java readme-sample-copyBlob -SyncPoller poller = blobClient.beginCopy("", Duration.ofSeconds(1)); -poller.waitForCompletion(); -``` - -or - -```java readme-sample-copyBlob2 -blobClient.copyFromUrl("url-to-blob"); -``` - -### Generate a SAS token - -Use an instance of a client to generate a new SAS token. - - -```java readme-sample-generateSas -/* - * Generate an account sas. Other samples in this file will demonstrate how to create a client with the sas - * token. - */ -// Configure the sas parameters. This is the minimal set. -OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); -AccountSasPermission accountSasPermission = new AccountSasPermission().setReadPermission(true); -AccountSasService services = new AccountSasService().setBlobAccess(true); -AccountSasResourceType resourceTypes = new AccountSasResourceType().setObject(true); - -// Generate the account sas. -AccountSasSignatureValues accountSasValues = - new AccountSasSignatureValues(expiryTime, accountSasPermission, services, resourceTypes); -String sasToken = blobServiceClient.generateAccountSas(accountSasValues); - -// Generate a sas using a container client -BlobContainerSasPermission containerSasPermission = new BlobContainerSasPermission().setCreatePermission(true); -BlobServiceSasSignatureValues serviceSasValues = - new BlobServiceSasSignatureValues(expiryTime, containerSasPermission); -blobContainerClient.generateSas(serviceSasValues); - -// Generate a sas using a blob client -BlobSasPermission blobSasPermission = new BlobSasPermission().setReadPermission(true); -serviceSasValues = new BlobServiceSasSignatureValues(expiryTime, blobSasPermission); -blobClient.generateSas(serviceSasValues); -``` - -### Authenticate with Azure Identity - -The [Azure Identity library][identity] provides Azure Active Directory support for authenticating with Azure Storage. - -```java readme-sample-authWithIdentity -BlobServiceClient blobStorageClient = new BlobServiceClientBuilder() - .endpoint("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); -``` - -### Set a proxy when building a client - -```java readme-sample-setProxy -ProxyOptions options = new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 888)); -BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("") - .sasToken("") - .httpClient(new NettyAsyncHttpClientBuilder().proxy(options).build()) - .buildClient(); -``` - -or - -Allow the client builder to determine the `HttpClient` type to be used but construct it with passed configurations. - -```java readme-sample-setProxy2 -HttpClientOptions clientOptions = new HttpClientOptions() - .setProxyOptions(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 888))); -BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("") - .sasToken("") - .clientOptions(clientOptions) - .buildClient(); -``` +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. ## Troubleshooting -When interacting with blobs using this Java client library, errors returned by the service correspond to the same HTTP -status codes returned for [REST API][error_codes] requests. For example, if you try to retrieve a container or blob that -doesn't exist in your Storage Account, a `404` error is returned, indicating `Not Found`. - -### Default HTTP Client -All client libraries by default use the Netty HTTP client. Adding the above dependency will automatically configure -the client library to use the Netty HTTP client. Configuring or changing the HTTP client is detailed in the -[HTTP clients wiki](https://learn.microsoft.com/azure/developer/java/sdk/http-client-pipeline#http-clients). - -### Default SSL library -All client libraries, by default, use the Tomcat-native Boring SSL library to enable native-level performance for SSL -operations. The Boring SSL library is an uber jar containing native libraries for Linux / macOS / Windows, and provides -better performance compared to the default SSL implementation within the JDK. For more information, including how to -reduce the dependency size, refer to the [performance tuning][performance_tuning] section of the wiki. - ## Next steps -Several Storage blob Java SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Key Vault: - -## Next steps Samples -Samples are explained in detail [here][samples_readme]. - ## Contributing -This project welcomes contributions and suggestions. Most contributions require you to agree to a [Contributor License Agreement (CLA)][cla] declaring that you have the right to, and actually do, grant us the rights to use your contribution. - -When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). -This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments. +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request -[source]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src -[samples_readme]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples/README.md +[product_documentation]: https://azure.microsoft.com/services/ [docs]: https://azure.github.io/azure-sdk-for-java/ -[rest_docs]: https://learn.microsoft.com/rest/api/storageservices/blob-service-rest-api -[product_docs]: https://learn.microsoft.com/azure/storage/blobs/storage-blobs-overview -[sas_token]: https://learn.microsoft.com/azure/storage/common/storage-dotnet-shared-access-signature-part-1 -[jdk]: https://learn.microsoft.com/java/azure/jdk/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ [azure_subscription]: https://azure.microsoft.com/free/ -[storage_account]: https://learn.microsoft.com/azure/storage/common/storage-quickstart-create-account?tabs=azure-portal -[storage_account_create_cli]: https://learn.microsoft.com/azure/storage/common/storage-quickstart-create-account?tabs=azure-cli -[storage_account_create_portal]: https://learn.microsoft.com/azure/storage/common/storage-quickstart-create-account?tabs=azure-portal -[identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity/README.md -[error_codes]: https://learn.microsoft.com/rest/api/storageservices/blob-service-error-codes -[samples]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples -[cla]: https://cla.microsoft.com -[coc]: https://opensource.microsoft.com/codeofconduct/ -[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ -[coc_contact]: mailto:opencode@microsoft.com -[performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning - - +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity diff --git a/sdk/storage/azure-storage-blob/assets.json b/sdk/storage/azure-storage-blob/assets.json index 3c9c429e8a82..034610bfddce 100644 --- a/sdk/storage/azure-storage-blob/assets.json +++ b/sdk/storage/azure-storage-blob/assets.json @@ -1,6 +1 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "java", - "TagPrefix": "java/storage/azure-storage-blob", - "Tag": "java/storage/azure-storage-blob_f223d6f99b" -} +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/storage/azure-storage-blob","Tag":""} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/checkstyle-suppressions.xml b/sdk/storage/azure-storage-blob/checkstyle-suppressions.xml deleted file mode 100644 index d2e954d56ed6..000000000000 --- a/sdk/storage/azure-storage-blob/checkstyle-suppressions.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/storage/azure-storage-blob/migrationGuides/V10_V12.md b/sdk/storage/azure-storage-blob/migrationGuides/V10_V12.md deleted file mode 100644 index cd9d0bf1ade8..000000000000 --- a/sdk/storage/azure-storage-blob/migrationGuides/V10_V12.md +++ /dev/null @@ -1,377 +0,0 @@ -# Storage Blob Service SDK Migration Guide from 10.x/11.x to 12.x - -In this section, we list the main changes you need to be aware of when converting your Storage Blob SDK library from Version 10/Version 11 to Version 12. - -## Prerequisites -Java Development Kit (JDK) with version 8 or above - -## Reactor and ReactorNetty -We've updated our asynchronous framework from RxJava to Reactor. -For more info related to Reactor, please refer to [Project Reactor](https://projectreactor.io/) -For more info of the motivation behind this major change, please refer to [this guide](https://github.com/Azure/azure-storage-java/blob/master/V12%20Upgrade%20Story.md). - -## Converting Core Classes -Our core asynchronous classes have been replaced, as well as new synchronous counterparts added. - -| Core V10/11 classes | Equivalent V12 Class | NEW synchronous clients | -|---:|---:|---:| -| ServiceURL | BlobServiceAsyncClient | BlobServiceClient | -| ContainerURL | ContainerAsyncClient | ContainerClient | -| BlobURL | BlobAsyncClient | BlobClient | -| BlockBlobURL | BlockBlobAsyncClient | BlockBlobClient | -| AppendBlobURL | AppendBlobAsyncClient | AppendBlobClient | -| PageBlobURL | PageBlobAsyncClient | PageBlobClient | - -**Note:** The methods under TransferManager in V10/V11 were moved to `BlobAsyncClient` and `BlobClient` in V12. -## Updated Maven dependency -Dependency for Blob service: -```xml - - com.azure - azure-storage-blob - 12.0.0 - -``` - -## Build Client -In V10/V11, core classes were built with constructors, taking a `URL` and an already constructed `HttpPipeline`. -```java -final BlockBlobURL blobURL = new BlockBlobURL( - new URL("https://" + "" + ".blob.core.windows.net/mycontainer/myimage.jpg"), - StorageURL.createPipeline(new SharedKeyCredentials("", ""), new PipelineOptions())); -``` - -In V12, we have moved to a builder pattern. To replicate the above V10/V11 snippet: -```java -// To get the BlobClient, we can use builder to initialize. -final BlobClient blobClient = new BlobClientBuilder() - .endpoint("https://" + "" + ".blob.core.windows.net") - .containerName("mycontainer") - .blobName("myimage.jpg") - .credential(new StorageSharedKeyCredential("", "")) - .buildClient(); -// We can initialize BlockBlobClient from blobClient. -final BlockBlobClient blockBlobClient = blobClient.getBlockBlobClient(); // we can also choose PageBlobClient, AppendBlobClient, and BlobClient -``` -These builders can also build sync and async clients interchangably. Just select the correct "build" method. Additionally, if you already have the full URL, you can just specify that as the endpoint instead of naming container and blob individually, similar to V10/V11. -```java -final BlobAsyncClient blobAsyncClient = new BlobClientBuilder() - .endpoint("https://" + "" + ".blob.core.windows.net/mycontainer/myimage.jpg") - .credential(new StorageSharedKeyCredential("", "")) - .buildAsyncClient(); -final BlockBlobAsyncClient blockBlobClient = blobAsyncClient.getBlockBlobAsyncClient(); -``` - -## Generate SAS token -SAS token generation has moved from helper classes to the core clients themselves. -See section [SAS Token](#sastoken) to learn how to use them as a credential. -Not all fields being set in these samples are necessary. -At minimum, only an expiry time and permission set are necessary to create a SAS. - -In V10/V11, to generate the SAS token, you needed an instance of ServiceSASSignatureValues to fluently build out all it's options. This could then generate SASQueryParameters which contained the actual URL query string to attach to your URL. You also needed to provide container and blob names when necessary, as well as the `SharedKeyCredential` to sign the token with. -```java -// specify token properties -ServiceSASSignatureValues value = new ServiceSASSignatureValues(); -BlobSASPermission p = new BlobSASPermission() - .withRead(true) - .withWrite(true) - .withCreate(true) - .withDelete(true) - .withAdd(true); -value.withPermissions(p.toString()) - .withStartTime(OffsetDateTime.now().minusDays(1)) - .withExpiryTime(OffsetDateTime.now().plusDays(1)) - .withContainerName("") - .withBlobName(""); -IPRange ipR = new IPRange() - .withIpMin("0.0.0.0") - .withIpMax("255.255.255.255"); -value.withIpRange(ipR) - .withProtocol(SASProtocol.HTTPS_ONLY) - .withCacheControl("cache") - .withContentDisposition("disposition") - .withContentEncoding("encoding") - .withContentLanguage("language") - .withContentType("type"); - -// build the token -SASQueryParameters sasToken = value.generateSASQueryParameters(sharedKeyCredentails); -``` - -In V12, SAS tokens are generated off the client to the resource you wish to generate the SAS for. -The resource path handled automatically because of this, and the `SharedKeyCredential` authenticating the client is also used automatically to sign the SAS. See [building a client](#buildclient) for how to get an authenticated client. -```java -// specify token properties -String identifier = "identifier"; -BlobSASPermission permissions = new BlobSASPermission() - .withRead(true) - .withCreate(true) - .withDelete(true) - .withWrite(true); // We can also choose BlobContainerSasPermission, BlobServiceSasQueryParameters based on the object level we want to grant access. -OffsetDateTime startTime = OffsetDateTime.now().minusDays(1); -OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); -SasIpRange ipRange = new SasIpRange() - .setIpMax("0.0.0.0") - .setIpMax("255.255.255.255"); -SasProtocol sasProtocol = SasProtocol.HTTPS_HTTP; -String cacheControl = "cache"; -String contentDisposition = "disposition"; -String contentEncoding = "encoding"; -String contentLanguage = "language"; -String contentType = "type"; -String version = BlobServiceVersion.V2019_02_02.getVersion(); - -// build the token -BlobServiceSasSignatureValues sasSignatureValues = new BlobServiceSasSignatureValues(version, sasProtocol, startTime, expiryTime, permissions.toString(), ipRange, identifier, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType); -BlobServiceSasQueryParameters sasQueryParameters = sasSignatureValues.generateSasQueryParameters(new StorageSharedKeyCredential("", ""), StorageURL.createPipeline(credential, new PipelineOptions())); -``` - -Since the builder in V12 manages pipeline generation, you can just hand the `StorageSharedKeyCredential` to the builder. -```java -// Initialize the credentials -StorageSharedKeyCredential credential = new StorageSharedKeyCredential("${accountName}", "${accountKey}"); -// How service object take in the credentials. -BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("https://" + "" + ".blob.core.windows.net") - .credential(credential) - .buildClient(); -``` - -### SASToken -A URL with a SAS token looks like the following: `https://${accountName}.blob.core.windows.net/?${sasToken}`. -Refer the [documentation](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-file-share_12.0.0/sdk/storage/azure-storage-blob/README.md) for more info. - -See section [Generate SAS token](#generate-sas-token) for how to generate the token programmatically. - -In V10/V11, you had to provide the URL with the token attached, which often resulted in URL manipulation when a token could be used on more than one resource. -```java -// Here is how the blob object take in the sas token generated in above section. -ContainerURL containerURL = new ContainerURL(new URL(""), StorageURL.createPipeline(credential, new PipelineOptions())); -BlobURLParts parts = URLParser.parse(containerURL.createBlobURL("").toURL()); -parts.withSasQueryParameters(sasToken).withScheme("https"); -BlockBlobURL blockBlobURL = new BlockBlobURL(parts.toURL(), StorageURL.createPipeline( - new AnonymousCredentials(), new PipelineOptions())); -``` - -In V12, SAS tokens can be managed just like any other credential. -```java -// How service object take in the credentials. -BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("https://${accountName}.blob.core.windows.net") - .sasToken("${sasToken}") - .buildClient(); -``` - -However, if you already have the full URL with SAS token attached, you can use that too: -```java -BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("https://${accountName}.blob.core.windows.net/?${sasToken}") - .buildClient(); -``` - - -### Pipeline and pipeline options - -In V10/V11, pipeline options build into pipeline through StorageURL, e.g. `RequestRetryOptions`. - -```java -HttpPipeline pipeline = StorageURL.createPipeline(new SharedKeyCredentials("", ""), - new PipelineOptions().withRequestRetryOptions(new RequestRetryOptions())); -``` - -In V12, it is flattened to just be on the builder. -```java -BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("https://${accountName}.blob.core.windows.net") - .sasToken("${sasToken}") - .retryOptions(new RequestRetryOptions()) - .buildClient(); -``` -## Provide side by side sync-over-async APIs -Each type (Container, Blob, etc.) has both a sync and async client. It is easy and intuitive to use whichever one is preferable in a given context without having to bother about clutter from the other. -Suppose the Container Client been initialized as `${containerClient}` for sync and `${containerAsyncClient}` for async. Please refer the [Build Client](#build-client) section. - -* Example of using Async API in V12. -```java -Mono response = containerAsyncClient.getProperties(); -``` - -* Example of using Sync API in V12 -```java -BlobContainerProperties blobProperties = containerClient.getProperties(); -``` - -## Async APIs Comparison -In V10/V11, every RESTful API returned a reactive response of type `Single` -(see RxJava documentation for more details), which emits one and only one result. - -These returned object representations of the single HTTP response that came back. - -Single result API in V10/V11: -```java -serviceURL.getProperties(Context.NONE).subscribe( - // print the selected service property on success - response -> System.out.println(response.body().defaultServiceVersion()), - // handle error - error -> System.out.println(error.getMessage())); -``` - -Listing API in V10/V11: -```java -serviceURL.listContainersSegment(null, null, Context.NONE).subscribe( - // print the list; grab continuation token for making another call to get next list segment - response -> { - System.out.println("Page token to fetch more containers:" + response.body().nextMarker()); - response.body().containerItems().stream().forEach( - containerItem -> System.out.println("Container name: " + containerItem.name())); - }, - // handle error - error -> System.out.println(error.getMessage())); -``` - -In V12, Reactor provides an equivalent class `Mono` (0-1 response). There is also the `Flux` class for zero-to-many responses, and Azure client libraries use a subclass known at `PagedFlux` to also provide pagination and response information. - -Additionally, classes returned from APIs are the "core information" of the response, rather than the HTTP response exactly. - -Full access to all fields of the HTTP response is available available by using the methods having the suffix -withResponse, but examples of that usage are beyond the scope - -Suppose the BlobServiceClient has been initialized as `serviceClient` and the BlobServiceAsyncClient has been initialized as `serviceAsyncClient`. -Single result API in V12, similar to V10/V11: -```java -serviceAsyncClient.getProperties().subscribe( - // print the selected service property on success - properties -> System.out.println(properties.getDefaultServiceVersion()), - // handle error - error -> System.out.println(error.getMessage()), - // on completion - () -> System.out.println("Get properties request completed successfully.")); -``` - -In V12, you no longer need to worry about paginated results. -Listing API in V12: -```java -serviceAsyncClient.listBlobContainers() - // print each item in the list - .doOnNext(containerItem -> System.out.println(containerItem.getName())) - // handle error - .doOnError(error -> System.out.println(error.getMessage())) - // on completion - .doFinally(sig -> System.out.println("Paginated listing request completed successfully.")) - .subscribe(); -``` - -More on paginated requests in [this section](#pagination). - -## Minimum Overload APIs and Maxmum Overload APIs: -In V10/V11, we only provide one maximum overload API for each operation. -```java -public Single create(Metadata metadata, PublicAccessType accessType, Context context) -``` - -In V12, we provide at least one minimum and one maximum for most of the operations. - -Minimum overload in async: -```java -public Mono getProperties() -``` -Maximum overload in async: -```java -public Mono> getPropertiesWithResponse(String leaseId) -``` - -## Pagination: -Listing or Paging API returned `Single` in V10/V11, where `SomeResponseType` contained a List. You had to manually follow a continuation token if provided - -List all blobs V8: -```java -private ContainerURL containerURL; - -private List retrieveBlobsForCurrentPage(String pageToken, List results) { - if (pageToken == null) { - return results; - } - containerURL.listBlobsFlatSegment(pageToken, null, Context.NONE).subscribe( - response -> { - results.addAll((Collection) response.body().segment().blobItems()); - retrieveBlobsForCurrentPage(response.body().nextMarker(), results); - } - ); - return results; -} - -public void run() throws Exception{ - // Build ContainerURL - containerURL = new ContainerURL(new URL("https://" + "" + ".blob.core.windows.net"), - StorageURL.createPipeline(new SharedKeyCredentials("", ""), new PipelineOptions())); - // Initialize empty blob list - List results = new ArrayList<>(); - // Start from first page - containerURL.listBlobsFlatSegment(null, null, Context.NONE).subscribe( - response -> { - results.addAll((Collection) response.body().segment().blobItems()); - if (response.body().nextMarker() != null) { - results.addAll((Collection) retrieveBlobsForCurrentPage(response.body().nextMarker(), results)); - } - }); -} -``` - -V12 provides two pagination classes: `PagedIterable` for sync and `PageFlux` for async. -These allow you to consume listing operations by individual item or by response pages. The latter is needed to access general information in each HTTP response. - -List all blobs using async API V12, by page: -```java -private BlobContainerAsyncClient containerAsyncClient; -private List retrieveBlobs(String pageToken, List results) { - if (pageToken == null) { - return results; - } - containerAsyncClient.listBlobs().byPage(pageToken).subscribe( - response -> { - results.addAll((Collection) response.getValue()); - retrieveBlobs(response.getContinuationToken(), results); - } - ); - return results; -} - -public void run() { - // Build ContainerURL - containerAsyncClient = new BlobContainerClientBuilder().credential(new StorageSharedKeyCredential("", "")).buildAsyncClient(); - // Initialize empty blob list - List results = new ArrayList<>(); - // Start from first page - containerAsyncClient.listBlobs() - .byPage() - .subscribe(response -> - { - results.addAll((Collection) response.getValue()); - if (response.getContinuationToken() != null) { - results.addAll((Collection) retrieveBlobs(response.getContinuationToken(), results)); - } - }); -} -``` diff --git a/sdk/storage/azure-storage-blob/migrationGuides/V8_V12.md b/sdk/storage/azure-storage-blob/migrationGuides/V8_V12.md deleted file mode 100644 index cf2fd29b684a..000000000000 --- a/sdk/storage/azure-storage-blob/migrationGuides/V8_V12.md +++ /dev/null @@ -1,315 +0,0 @@ -# Storage Blob Service SDK Migration Guide from 8.x to 12.x - -In this section, we list the main changes you need to be aware of when converting your Storage Blob SDK library from Version 8 to Version 12. - -For more info of the motivation behind this major change, please refer to [this guide](https://github.com/Azure/azure-storage-java/blob/master/V12%20Upgrade%20Story.md). - -## Prerequisites -Java Development Kit (JDK) with version 8 or above - -## Converting Core Classes -Our core synchronous classes have been replaced, as well as new asynchronous counterparts added. - -| Core V8 classes | Equivalent V12 Class | NEW Asynchronous clients | -|---:|---:|---:| -| CloudStorageAccount | BlobServiceClientBuilder | BlobServiceClientBuilder | -| CloudBlobClient | BlobServiceClient | BlobServiceAsyncClient | -| CloudBlobContainer | ContainerClient | ContainerAsyncClient | -| CloudBlob | BlobClient | BlobAsyncClient | -| CloudBlockBlob | BlockBlobClient | BlockBlobAsyncClient | -| CloudAppendBlob | AppendBlobClient | AppendBlobAsyncClient | -| CloudPageBlob | PageBlobClient | PageBlobAsyncClient | - -## Updated Maven dependency -Dependency for Blob service: -```xml - - com.azure - azure-storage-blob - 12.0.0 - -``` - -## Build Client -In V8, core classes were built from `CloudStorageAccount` which authenticated with connection string. -```java -CloudStorageAccount storageAccount = CloudStorageAccount.parse(""); -CloudBlobContainer blobContainer = storageAccount.createCloudBlobClient().getContainerReference(""); -blobContainer.create(); - -CloudBlockBlob blockBlob = blobContainer.getBlockBlobReference(""); -``` - -In V12, we have moved to a builder pattern. To replicate the above V8 snippet: -```java -// To get the BlobClient, we can use builder to initialize. -final BlobClient blobClient = new BlobClientBuilder() - .endpoint("https://" + "" + ".blob.core.windows.net") - .containerName("mycontainer") - .blobName("myimage.jpg") - .credential(new StorageSharedKeyCredential("", "")) - .buildClient(); -// We can initialize BlockBlobClient from blobClient. -final BlockBlobClient blockBlobClient = blobClient.getBlockBlobClient(); -``` - -## Generate SAS token -SAS token generation has moved from helper classes to the core clients themselves. -See section [SAS Token](#sastoken) to learn how to use them as a credential. -Not all fields being set in these samples are necessary. -At minimum, only an expiry time and permission set are necessary to create a SAS. - -In V8, to generate the SAS token, you needed to use `SharedAccessSignatureHelper` to fluently build out all it's options. -You also needed to provide `ServiceClient` which includes `SharedKeyCredential` to sign the token with. -```java -// Build the client -CloudStorageAccount storageAccount = CloudStorageAccount.parse(""); -CloudBlobContainer blobContainer = storageAccount.createCloudBlobClient().getContainerReference(""); -blobContainer.create(); - -CloudBlockBlob blockBlob = blobContainer.getBlockBlobReference(""); - -// Initialize the properties -String identifier = "identifier"; -EnumSet permissions = EnumSet.of( - SharedAccessBlobPermissions.READ, - SharedAccessBlobPermissions.WRITE, - SharedAccessBlobPermissions.CREATE, - SharedAccessBlobPermissions.DELETE, - SharedAccessBlobPermissions.ADD); - -IPRange ipR = new IPRange("0.0.0.0", "255.255.255.255"); - -Calendar calendar = Calendar.getInstance(); -Date startDate = calendar.getTime(); -calendar.add(Calendar.DAY_OF_YEAR, 1); -Date expiryDate = calendar.getTime(); - -SharedAccessBlobHeaders headers = new SharedAccessBlobHeaders(); -headers.setCacheControl("cache"); -headers.setContentDisposition("disposition"); -headers.setContentEncoding("encoding"); -headers.setContentLanguage("language"); -headers.setContentType("type"); - -SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy(); -policy.setPermissions(permissions); -policy.setSharedAccessStartTime(startDate); -policy.setSharedAccessExpiryTime(expiryDate); - -// Build the token -String sasToken = blockBlob.generateSharedAccessSignature(policy, headers, identifier, ipR, SharedAccessProtocols.HTTPS_ONLY); -``` - -In V12, SAS tokens are generated off the client to the resource you wish to generate the SAS for. -The resource path handled automatically because of this, and the `SharedKeyCredential` authenticating the client is also used automatically to sign the SAS. See [building a client](#buildclient) for how to get an authenticated client. -```java -// specify token properties -String identifier = "identifier"; -BlobSASPermission permissions = new BlobSASPermission() - .withRead(true) - .withCreate(true) - .withDelete(true) - .withWrite(true); // We can also choose BlobContainerSasPermission, BlobServiceSasQueryParameters based on the object level we want to grant access. -OffsetDateTime startTime = OffsetDateTime.now().minusDays(1); -OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); -SasIpRange ipRange = new SasIpRange() - .setIpMax("0.0.0.0") - .setIpMax("255.255.255.255"); -SasProtocol sasProtocol = SasProtocol.HTTPS_HTTP; -String cacheControl = "cache"; -String contentDisposition = "disposition"; -String contentEncoding = "encoding"; -String contentLanguage = "language"; -String contentType = "type"; -String version = BlobServiceVersion.V2019_02_02.getVersion(); - -// build the token -BlobServiceSasSignatureValues sasSignatureValues = new BlobServiceSasSignatureValues(version, sasProtocol, startTime, expiryTime, permissions.toString(), ipRange, identifier, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType); -BlobServiceSasQueryParameters sasQueryParameters = sasSignatureValues.generateSasQueryParameters(new StorageSharedKeyCredential("", ""); -``` -In V12, our builders accept connection strings, no calls to `endpoint()` or `credential()` required. However, connection strings generally only point at the account, so you WILL need to specify container and blob names as necessary. -```java -BlobContainerClient client = new BlobContainerClientBuilder() - .connectionString("${connection-string}") - .containerName("mycontainer") - .buildClient(); -``` - -### Shared key credential -Shared key credentials can be used directly to authenticate your client. You need to fetch the `${accountName}` and `${accountKey}` from Azure Portal. -Learn More from [README](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0/sdk/storage/azure-storage-blob/README.md) - -In V8, you used the credential to build the `CloudStorageAccount`. -```java -// Initialize the credentials -StorageCredentialsAccountAndKey credential = new StorageCredentialsAccountAndKey("${accountName}", "${accountKey}"); -// CloudStorageAccount take the credential. -CloudStorageAccount storageAccount = new CloudStorageAccount(credential); -``` - -Since the builder in V12 manages pipeline generation, you can just hand the `StorageSharedKeyCredential` to the builder. -```java -// Initialize the credentials -StorageSharedKeyCredential credential = new StorageSharedKeyCredential("${accountName}", "${accountKey}"); -// How service object take in the credentials. -BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("https://" + "" + ".blob.core.windows.net") - .credential(credential) - .buildClient(); -``` - -### SASToken -A URL with a SAS token looks like the following: `https://${accountName}.blob.core.windows.net/?${sasToken}`. -Refer the [documentation](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0/sdk/storage/azure-storage-blob/README.md) for more info. - -See section [Generate SAS token](#generate-sas-token) for how to generate the token programmatically. - -In V8, you had to sasToken string, which can paste from portal or generate from session above . -```java -// Here is how the blob object take in the sas token generated in above section [Generate SAS token](#generate-sas-token). -StorageCredentialsSharedAccessSignature credential = new StorageCredentialsSharedAccessSignature("sasToken"); -CloudStorageAccount storageAccount = new CloudStorageAccount(credential); -``` - -In V12, SAS tokens can be managed just like any other credential. -```java -// How service object take in the credentials. -BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("https://${accountName}.blob.core.windows.net") - .sasToken("${sasToken}") - .buildClient(); -``` - -However, if you already have the full URL with SAS token attached, you can use that too: -```java -BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("https://${accountName}.blob.core.windows.net/?${sasToken}") - .buildClient(); -``` - -## Minimum Overload APIs and Maxmum Overload APIs: -In V8, we only provide many APIs overloads with the same return type. -```java -public BlobContainerProperties getProperties() -``` - -In V12, we provide at least one minimum and one maximum for most of the operations. - -Minimum overload returns someType of `T` directly. Maximum overload returns response of someType `Response` -which includes the information of the headers, the request, status code, and the type value. - -Minimum overload in async: -```java -public BlobContainerProperties getProperties() -``` -Maximum overload in async: -```java -public Response getPropertiesWithResponse(String leaseId, Duration timeout, Context context) -``` - -## Pagination: -Listing or Paging API returned `ResultSegment` in V8 which provided the continuation token and result list in `ResultSegment`. - -List all blobs V8: -```java -private CloudBlobContainer container; - -private List retrieveBlobsForCurrentPage(ResultContinuation pageToken, List results) throws Exception { - if (pageToken == null) { - return results; - } - results.addAll(container.listBlobsSegmented(null, false, EnumSet.noneOf(BlobListingDetails.class), null, pageToken, null, null).getResults()); - return results; -} - -public void run() throws Exception{ - // Build CloudBlobContainer - CloudStorageAccount storageAccount = CloudStorageAccount.parse(""); - CloudBlobClient blobClient = storageAccount.createCloudBlobClient(); - container = blobClient.getContainerReference(""); - // Initialize empty blob list - ResultSegment results = container.listBlobsSegmented(); - // Start from first page - retrieveBlobsForCurrentPage(results.getContinuationToken(), results.getResults()); -} -``` - -V12 provides two pagination classes: `PagedIterable` for sync and `PageFlux` for async. -These allow you to consume listing operations by individual item or by response pages. The latter is needed to access general information in each HTTP response. - -List all blobs using sync API V12, by page: -```java -private BlobContainerClient containerClient; - -private List retrieveBlobs(String pageToken, List results) { - if (pageToken == null) { - return results; - } - containerClient.listBlobs().streamByPage(pageToken).forEach( - response -> { - results.addAll((Collection) response.getValue()); - retrieveBlobs(response.getContinuationToken(), results); - } - ); - return results; -} - -public void run() { - // Build ContainerClient - containerClient = new BlobContainerClientBuilder().credential(new StorageSharedKeyCredential("", "")).buildClient(); - // Initialize empty blob list - List results = new ArrayList<>(); - // Start from first page - containerClient.listBlobs(null, Duration.ofSeconds(30)) - .streamByPage() - .forEach(response -> - { - results.addAll((Collection) response.getValue()); - if (response.getContinuationToken() != null) { - results.addAll((Collection) retrieveBlobs(response.getContinuationToken(), results)); - } - }); -} -``` - -## `BlobInputStream` and `BlobOutputStream` -In v8 and prior versions, there existed two classes: `BlobInputStream` and `BlobOutputStream`, -which simplified uploads and downloads by providing streams developers were used to. -Since Java's `InputStream` and `OutputStream` are synchronous interfaces, they were not included in V10/V11. -With the inclusion of synchronous clients in V12, customers who may have already migrated from v8 to V10/V11 will find these familiar classes, but they will be brand new to those who started with V10/V11. Note that these classes do NOT give you access to the HTTP requests/responses. - -Get an InputStream to download a blob in V12. -```java -final BlobClient blobClient = new BlobClientBuilder() - .endpoint("https://${accountName}.blob.core.windows.net") - .credential(new StorageSharedKeyCredential("", "")) - .buildClient(); -InputStream blobInputStream = blobClient.openInputStream(); -// insert your method of choice to read from an InputStream -``` - -Get an OutputStream to upload a blob in V12. -```java -final BlockBlobClient blobClient = new BlobClientBuilder() - .endpoint("https://${accountName}.blob.core.windows.net") - .credential(new StorageSharedKeyCredential("", "")) - .buildClient().getBlockBlobClient(); -OutputStream blobOutputStream = blobClient.getBlobOutputStream(); -// insert your method of choice to write to an OutputStream -``` - -## Miscellaneous -- Examples for how to approximate v8 StorageEvent behavior can be found [here][storage event sample]. -- Examples for how to approximate v8 LocationMode behavior can be found [here][location mode sample]. - -[storage event sample]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageEventExample.java -[location mode sample]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/LocationModeExample.java diff --git a/sdk/storage/azure-storage-blob/perf-resources.bicep b/sdk/storage/azure-storage-blob/perf-resources.bicep deleted file mode 100644 index f05d353d7452..000000000000 --- a/sdk/storage/azure-storage-blob/perf-resources.bicep +++ /dev/null @@ -1,21 +0,0 @@ -param baseName string = resourceGroup().name -param location string = resourceGroup().location - -resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06-01' = { - name: '${baseName}blob' - location: location - kind: 'BlockBlobStorage' - sku: { - name: 'Premium_LRS' - } -} - -var name = storageAccount.name -var key = storageAccount.listKeys().keys[0].value -var connectionString = 'DefaultEndpointsProtocol=https;AccountName=${name};AccountKey=${key}' - -output AZURE_STORAGE_ACCOUNT_NAME string = name -output AZURE_STORAGE_ACCOUNT_KEY string = key -output AZURE_STORAGE_CONNECTION_STRING string = connectionString -output STANDARD_STORAGE_CONNECTION_STRING string = connectionString -output STORAGE_CONNECTION_STRING string = connectionString diff --git a/sdk/storage/azure-storage-blob/perf-tests.yml b/sdk/storage/azure-storage-blob/perf-tests.yml deleted file mode 100644 index bbbea1973a8d..000000000000 --- a/sdk/storage/azure-storage-blob/perf-tests.yml +++ /dev/null @@ -1,61 +0,0 @@ -Service: storage-blob - -Project: sdk/storage/azure-storage-perf - -PrimaryPackage: 'com.azure:azure-storage-blob' - -PackageVersions: -- 'com.azure:azure-storage-common': 12.26.1 # {x-version-update;com.azure:azure-storage-common;dependency} - 'com.azure:azure-storage-blob': 12.27.1 # {x-version-update;com.azure:azure-storage-blob;dependency} - 'com.azure:azure-storage-blob-cryptography': 12.26.1 # {x-version-update;com.azure:azure-storage-blob-cryptography;dependency} - 'com.azure:azure-storage-file-share': 12.23.1 # {x-version-update;com.azure:azure-storage-file-share;dependency} - 'com.azure:azure-storage-file-datalake': 12.20.1 # {x-version-update;com.azure:azure-storage-file-datalake;dependency} - 'com.azure:azure-json': 1.2.0 # {x-version-update;com.azure:azure-json;dependency} - 'com.azure:azure-xml': 1.1.0 # {x-version-update;com.azure:azure-xml;dependency} - 'com.azure:azure-core': 1.51.0 # {x-version-update;com.azure:azure-core;dependency} - 'com.azure:azure-core-http-netty': 1.15.3 # {x-version-update;com.azure:azure-core-http-netty;dependency} - 'com.azure:azure-core-http-okhttp': 1.12.2 # {x-version-update;com.azure:azure-core-http-okhttp;dependency} -- 'com.azure:azure-storage-common': source - 'com.azure:azure-storage-blob': source - 'com.azure:azure-storage-blob-cryptography': source - 'com.azure:azure-storage-file-share': source - 'com.azure:azure-storage-file-datalake': source - 'com.azure:azure-json': source - 'com.azure:azure-xml': source - 'com.azure:azure-core': source - 'com.azure:azure-core-http-netty': source - 'com.azure:azure-core-http-okhttp': source - -Tests: -- Test: download - Class: downloadblob - Arguments: &sizes - - --size 10240 --parallel 64 - - --size 10485760 --parallel 32 - - --size 1073741824 --parallel 8 --warmup 30 --duration 30 - -- Test: download-file - Class: downloadblobtofile - Arguments: &file-sizes - - --size 10240 --parallel 64 - - --size 10485760 --parallel 32 - -- Test: upload - Class: uploadblob - Arguments: *sizes - -- Test: upload-file - Class: uploadfromfile - Arguments: *file-sizes - -- Test: list-blobs - Class: listblobs - Arguments: - - --count 5 --parallel 64 - - --count 500 --parallel 32 - - --count 50000 --parallel 32 --warmup 30 --duration 30 - -- Test: get-properties - Class: getproperties - Arguments: - - --parallel 64 --get-properties diff --git a/sdk/storage/azure-storage-blob/perf.yml b/sdk/storage/azure-storage-blob/perf.yml deleted file mode 100644 index ffbd6c7113ad..000000000000 --- a/sdk/storage/azure-storage-blob/perf.yml +++ /dev/null @@ -1,40 +0,0 @@ -parameters: -- name: LanguageVersion - displayName: LanguageVersion (8, 11, 17, 21) - type: string - default: '21' -- name: PackageVersions - displayName: PackageVersions (regex of package versions to run) - type: string - default: '12|source' -- name: Tests - displayName: Tests (regex of tests to run) - type: string - default: '^(download|download-file|upload|upload-file|list-blobs|get-properties)$' -- name: Arguments - displayName: Arguments (regex of arguments to run) - type: string - default: '(size (10240|10485760|1073741824))|(count (5|500|50000))|(get-properties)' -- name: Iterations - displayName: Iterations (times to run each test) - type: number - default: '5' -- name: AdditionalArguments - displayName: AdditionalArguments (passed to PerfAutomation) - type: string - default: ' ' -- name: Profile - type: boolean - default: false - -extends: - template: /eng/pipelines/templates/jobs/perf.yml - parameters: - LanguageVersion: ${{ parameters.LanguageVersion }} - ServiceDirectory: storage/azure-storage-blob - PackageVersions: ${{ parameters.PackageVersions }} - Tests: ${{ parameters.Tests }} - Arguments: ${{ parameters.Arguments }} - Iterations: ${{ parameters.Iterations }} - AdditionalArguments: ${{ parameters.AdditionalArguments }} - Profile: ${{ parameters.Profile }} diff --git a/sdk/storage/azure-storage-blob/pom.xml b/sdk/storage/azure-storage-blob/pom.xml index b4af59dd28b9..4dc6aa797b67 100644 --- a/sdk/storage/azure-storage-blob/pom.xml +++ b/sdk/storage/azure-storage-blob/pom.xml @@ -1,7 +1,10 @@ - - + + + 4.0.0 com.azure azure-client-sdk-parent @@ -9,68 +12,40 @@ ../../parents/azure-client-sdk-parent - 4.0.0 - com.azure azure-storage-blob - 12.30.0-beta.2 + 1.0.0-beta.1 + jar - Microsoft Azure client library for Blob Storage - This module contains client library for Microsoft Azure Blob Storage. + Microsoft Azure SDK for Blob + This package contains Microsoft Azure Blob client library. https://github.com/Azure/azure-sdk-for-java - - - azure-java-build-docs - ${site.url}/site/${project.artifactId} - - + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + - scm:git:https://github.com/Azure/azure-sdk-for-java + https://github.com/Azure/azure-sdk-for-java scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git HEAD - + + + microsoft + Microsoft + + - ../azure-storage-common/ci.system.properties - 8g - - - --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED - --add-exports com.azure.core/com.azure.core.implementation.serializer.jackson=ALL-UNNAMED - --add-opens com.azure.storage.common/com.azure.storage.common.implementation=ALL-UNNAMED - --add-opens com.azure.storage.common/com.azure.storage.common.sas=ALL-UNNAMED - --add-opens com.azure.storage.blob/com.azure.storage.blob=ALL-UNNAMED - --add-opens com.azure.storage.blob/com.azure.storage.blob.implementation=ALL-UNNAMED - --add-opens com.azure.storage.blob/com.azure.storage.blob.implementation.util=ALL-UNNAMED - --add-opens com.azure.storage.blob/com.azure.storage.blob.specialized=ALL-UNNAMED - --add-opens com.azure.storage.blob/com.azure.storage.blob.changefeed=ALL-UNNAMED - --add-opens com.azure.storage.blob/com.azure.storage.blob.implementation.models=ALL-UNNAMED - --add-reads com.azure.core=ALL-UNNAMED - --add-reads com.azure.core.test=ALL-UNNAMED - --add-reads com.azure.core.amqp=ALL-UNNAMED - --add-reads com.azure.storage.common=ALL-UNNAMED - --add-reads com.azure.storage.internal.avro=ALL-UNNAMED - --add-reads com.azure.storage.blob=com.azure.http.netty - --add-reads com.azure.storage.blob=com.azure.core.http.okhttp - --add-reads com.azure.storage.blob=com.azure.core.http.jdk.httpclient - --add-reads com.azure.storage.blob=com.azure.core.http.vertx - - concurrent - - checkstyle-suppressions.xml - - false - spotbugs-exclude.xml + UTF-8 + false - - - com.azure - azure-xml - 1.2.0 - com.azure azure-core @@ -81,34 +56,6 @@ azure-core-http-netty 1.15.10 - - com.azure - azure-storage-common - 12.29.0-beta.2 - - - com.azure - azure-storage-internal-avro - 12.15.0-beta.2 - - - - - com.google.code.findbugs - jsr305 - 3.0.2 - provided - - - com.azure - azure-storage-common - 12.29.0-beta.2 - tests - test-jar - test - com.azure azure-core-test @@ -121,69 +68,5 @@ 1.15.3 test - - org.mockito - mockito-core - 4.11.0 - test - - - - - net.bytebuddy - byte-buddy - 1.15.5 - test - - - net.bytebuddy - byte-buddy-agent - 1.15.5 - test - - - - - inject-sas-service-version - - - env.AZURE_LIVE_TEST_SERVICE_VERSION - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.6.0 - - - regex-property - - regex-property - - - AZURE_STORAGE_SAS_SERVICE_VERSION - ${env.AZURE_LIVE_TEST_SERVICE_VERSION} - V(\d+)_(\d+)_(\d+) - $1-$2-$3 - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.5.2 - - - ${AZURE_STORAGE_SAS_SERVICE_VERSION} - - - - - - - diff --git a/sdk/storage/azure-storage-blob/spotbugs-exclude.xml b/sdk/storage/azure-storage-blob/spotbugs-exclude.xml deleted file mode 100644 index 84fdfdc9114e..000000000000 --- a/sdk/storage/azure-storage-blob/spotbugs-exclude.xml +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/AppendBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/AppendBlobAsyncClient.java new file mode 100644 index 000000000000..9d73a031bc6a --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/AppendBlobAsyncClient.java @@ -0,0 +1,877 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.storage.blob.implementation.AppendBlobsImpl; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; +import com.azure.storage.blob.models.EncryptionAlgorithmType; +import java.time.OffsetDateTime; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class AppendBlobAsyncClient { + @Generated + private final AppendBlobsImpl serviceClient; + + /** + * Initializes an instance of AppendBlobAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AppendBlobAsyncClient(AppendBlobsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The Create operation creates a new append blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithResponse(long contentLength, RequestOptions requestOptions) { + return this.serviceClient.createWithResponseAsync(contentLength, requestOptions); + } + + /** + * The Append Block operation commits a new block of data to the end of an append blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-condition-maxsizeLongNoOptional conditional header. The max length + * in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit + * or if the blob size is already greater than the value specified in this header, the request will fail with + * MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> appendBlockWithResponse(long contentLength, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.appendBlockWithResponseAsync(contentLength, body, requestOptions); + } + + /** + * The Append Block From URL operation creates a new block to be committed as part of an append blob where the + * contents are read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-rangeStringNoBytes of source data in the specified + * range.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-condition-maxsizeLongNoOptional conditional header. The max length + * in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit + * or if the blob size is already greater than the value specified in this header, the request will fail with + * MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceUrl Specify a URL to the copy source. + * @param contentLength The length of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> appendBlockFromUrlWithResponse(String sourceUrl, long contentLength, + RequestOptions requestOptions) { + return this.serviceClient.appendBlockFromUrlWithResponseAsync(sourceUrl, contentLength, requestOptions); + } + + /** + * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 + * version or later. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> sealWithResponse(RequestOptions requestOptions) { + return this.serviceClient.sealWithResponseAsync(requestOptions); + } + + /** + * The Create operation creates a new append blob. + * + * @param contentLength The length of the request. + * @param metadata The metadata headers. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono create(long contentLength, Map metadata, Integer timeout, String blobContentType, + String blobContentEncoding, String blobContentLanguage, byte[] blobContentMd5, String blobCacheControl, + String leaseId, String blobContentDisposition, String encryptionKey, String encryptionKeySha256, + EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, String blobTagsString, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, + RequestConditions requestConditions) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return createWithResponse(contentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Create operation creates a new append blob. + * + * @param contentLength The length of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono create(long contentLength) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createWithResponse(contentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Append Block operation commits a new block of data to the end of an append blob. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append + * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value + * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - + * Precondition Failed). + * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating + * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it + * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition + * Failed). + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema + * version and properties. + * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the + * blob/file content inside the message body. Will always be smaller than Content-Length. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono appendBlock(long contentLength, BinaryData body, Integer timeout, String transactionalContentMD5, + String transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, + String structuredBodyType, Long structuredContentLength, RequestConditions requestConditions) { + // Generated convenience method for appendBlockWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (maxSize != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-maxsize"), String.valueOf(maxSize)); + } + if (appendPosition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-appendpos"), + String.valueOf(appendPosition)); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (structuredContentLength != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-content-length"), + String.valueOf(structuredContentLength)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return appendBlockWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Append Block operation commits a new block of data to the end of an append blob. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono appendBlock(long contentLength, BinaryData body) { + // Generated convenience method for appendBlockWithResponse + RequestOptions requestOptions = new RequestOptions(); + return appendBlockWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Append Block From URL operation creates a new block to be committed as part of an append blob where the + * contents are read from a URL. + * + * @param sourceUrl Specify a URL to the copy source. + * @param contentLength The length of the request. + * @param sourceRange Bytes of source data in the specified range. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param sourceContentCrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy + * source. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append + * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value + * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - + * Precondition Failed). + * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating + * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it + * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition + * Failed). + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono appendBlockFromUrl(String sourceUrl, long contentLength, String sourceRange, + String sourceContentMd5, byte[] sourceContentCrc64, Integer timeout, String transactionalContentMD5, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, + String encryptionScope, String leaseId, Long maxSize, Long appendPosition, String ifTags, + OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, + String sourceIfNoneMatch, String copySourceAuthorization, RequestConditions requestConditions) { + // Generated convenience method for appendBlockFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (sourceRange != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-range"), sourceRange); + } + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (sourceContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-crc64"), + String.valueOf(sourceContentCrc64)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (maxSize != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-maxsize"), String.valueOf(maxSize)); + } + if (appendPosition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-appendpos"), + String.valueOf(appendPosition)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return appendBlockFromUrlWithResponse(sourceUrl, contentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Append Block From URL operation creates a new block to be committed as part of an append blob where the + * contents are read from a URL. + * + * @param sourceUrl Specify a URL to the copy source. + * @param contentLength The length of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono appendBlockFromUrl(String sourceUrl, long contentLength) { + // Generated convenience method for appendBlockFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return appendBlockFromUrlWithResponse(sourceUrl, contentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 + * version or later. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating + * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it + * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition + * Failed). + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono seal(Integer timeout, String leaseId, Long appendPosition, RequestConditions requestConditions) { + // Generated convenience method for sealWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (appendPosition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-appendpos"), + String.valueOf(appendPosition)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return sealWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 + * version or later. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono seal() { + // Generated convenience method for sealWithResponse + RequestOptions requestOptions = new RequestOptions(); + return sealWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/AppendBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/AppendBlobClient.java new file mode 100644 index 000000000000..30a7029aafa7 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/AppendBlobClient.java @@ -0,0 +1,866 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.storage.blob.implementation.AppendBlobsImpl; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; +import com.azure.storage.blob.models.EncryptionAlgorithmType; +import java.time.OffsetDateTime; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class AppendBlobClient { + @Generated + private final AppendBlobsImpl serviceClient; + + /** + * Initializes an instance of AppendBlobClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AppendBlobClient(AppendBlobsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The Create operation creates a new append blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse(long contentLength, RequestOptions requestOptions) { + return this.serviceClient.createWithResponse(contentLength, requestOptions); + } + + /** + * The Append Block operation commits a new block of data to the end of an append blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-condition-maxsizeLongNoOptional conditional header. The max length + * in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit + * or if the blob size is already greater than the value specified in this header, the request will fail with + * MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response appendBlockWithResponse(long contentLength, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.appendBlockWithResponse(contentLength, body, requestOptions); + } + + /** + * The Append Block From URL operation creates a new block to be committed as part of an append blob where the + * contents are read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-rangeStringNoBytes of source data in the specified + * range.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-condition-maxsizeLongNoOptional conditional header. The max length + * in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit + * or if the blob size is already greater than the value specified in this header, the request will fail with + * MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceUrl Specify a URL to the copy source. + * @param contentLength The length of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response appendBlockFromUrlWithResponse(String sourceUrl, long contentLength, + RequestOptions requestOptions) { + return this.serviceClient.appendBlockFromUrlWithResponse(sourceUrl, contentLength, requestOptions); + } + + /** + * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 + * version or later. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response sealWithResponse(RequestOptions requestOptions) { + return this.serviceClient.sealWithResponse(requestOptions); + } + + /** + * The Create operation creates a new append blob. + * + * @param contentLength The length of the request. + * @param metadata The metadata headers. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void create(long contentLength, Map metadata, Integer timeout, String blobContentType, + String blobContentEncoding, String blobContentLanguage, byte[] blobContentMd5, String blobCacheControl, + String leaseId, String blobContentDisposition, String encryptionKey, String encryptionKeySha256, + EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, String blobTagsString, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, + RequestConditions requestConditions) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + createWithResponse(contentLength, requestOptions).getValue(); + } + + /** + * The Create operation creates a new append blob. + * + * @param contentLength The length of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void create(long contentLength) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + createWithResponse(contentLength, requestOptions).getValue(); + } + + /** + * The Append Block operation commits a new block of data to the end of an append blob. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append + * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value + * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - + * Precondition Failed). + * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating + * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it + * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition + * Failed). + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema + * version and properties. + * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the + * blob/file content inside the message body. Will always be smaller than Content-Length. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void appendBlock(long contentLength, BinaryData body, Integer timeout, String transactionalContentMD5, + String transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, + String structuredBodyType, Long structuredContentLength, RequestConditions requestConditions) { + // Generated convenience method for appendBlockWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (maxSize != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-maxsize"), String.valueOf(maxSize)); + } + if (appendPosition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-appendpos"), + String.valueOf(appendPosition)); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (structuredContentLength != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-content-length"), + String.valueOf(structuredContentLength)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + appendBlockWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Append Block operation commits a new block of data to the end of an append blob. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void appendBlock(long contentLength, BinaryData body) { + // Generated convenience method for appendBlockWithResponse + RequestOptions requestOptions = new RequestOptions(); + appendBlockWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Append Block From URL operation creates a new block to be committed as part of an append blob where the + * contents are read from a URL. + * + * @param sourceUrl Specify a URL to the copy source. + * @param contentLength The length of the request. + * @param sourceRange Bytes of source data in the specified range. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param sourceContentCrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy + * source. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append + * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value + * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - + * Precondition Failed). + * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating + * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it + * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition + * Failed). + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void appendBlockFromUrl(String sourceUrl, long contentLength, String sourceRange, String sourceContentMd5, + byte[] sourceContentCrc64, Integer timeout, String transactionalContentMD5, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String leaseId, + Long maxSize, Long appendPosition, String ifTags, OffsetDateTime sourceIfModifiedSince, + OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, + String copySourceAuthorization, RequestConditions requestConditions) { + // Generated convenience method for appendBlockFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (sourceRange != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-range"), sourceRange); + } + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (sourceContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-crc64"), + String.valueOf(sourceContentCrc64)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (maxSize != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-maxsize"), String.valueOf(maxSize)); + } + if (appendPosition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-appendpos"), + String.valueOf(appendPosition)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + appendBlockFromUrlWithResponse(sourceUrl, contentLength, requestOptions).getValue(); + } + + /** + * The Append Block From URL operation creates a new block to be committed as part of an append blob where the + * contents are read from a URL. + * + * @param sourceUrl Specify a URL to the copy source. + * @param contentLength The length of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void appendBlockFromUrl(String sourceUrl, long contentLength) { + // Generated convenience method for appendBlockFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + appendBlockFromUrlWithResponse(sourceUrl, contentLength, requestOptions).getValue(); + } + + /** + * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 + * version or later. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating + * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it + * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition + * Failed). + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void seal(Integer timeout, String leaseId, Long appendPosition, RequestConditions requestConditions) { + // Generated convenience method for sealWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (appendPosition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-condition-appendpos"), + String.valueOf(appendPosition)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + sealWithResponse(requestOptions).getValue(); + } + + /** + * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 + * version or later. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void seal() { + // Generated convenience method for sealWithResponse + RequestOptions requestOptions = new RequestOptions(); + sealWithResponse(requestOptions).getValue(); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java deleted file mode 100644 index 5c4b16b3b9e9..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java +++ /dev/null @@ -1,1075 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Contexts; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.ProgressListener; -import com.azure.core.util.ProgressReporter; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.BlobUploadFromFileOptions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockOptions; -import com.azure.storage.blob.specialized.AppendBlobAsyncClient; -import com.azure.storage.blob.specialized.BlobAsyncClientBase; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobAsyncClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.implementation.BufferStagingArea; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.implementation.UploadUtils; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.UncheckedIOException; -import java.nio.ByteBuffer; -import java.nio.channels.AsynchronousFileChannel; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Base64; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static com.azure.core.util.FluxUtil.monoError; -import static java.nio.charset.StandardCharsets.UTF_8; - -/** - * This class provides a client that contains generic blob operations for Azure Storage Blobs. Operations allowed by the - * client are uploading and downloading, copying a blob, retrieving and setting metadata, retrieving and setting HTTP - * headers, and deleting and un-deleting a blob. - * - *

- * This client is instantiated through {@link BlobClientBuilder} or retrieved via {@link - * BlobContainerAsyncClient#getBlobAsyncClient(String) getBlobAsyncClient}. - * - *

- * For operations on a specific blob type (i.e. append, block, or page) use {@link #getAppendBlobAsyncClient() - * getAppendBlobAsyncClient}, {@link #getBlockBlobAsyncClient() getBlockBlobAsyncClient}, or {@link - * #getPageBlobAsyncClient() getPageBlobAsyncClient} to construct a client that allows blob specific operations. - * - *

- * Please refer to the - * Azure - * Docs for more information. - */ -public class BlobAsyncClient extends BlobAsyncClientBase { - /** - * The block size to use if none is specified in parallel operations. - */ - public static final int BLOB_DEFAULT_UPLOAD_BLOCK_SIZE = BlobConstants.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE; - - /** - * The number of buffers to use if none is specified on the buffered upload method. - */ - public static final int BLOB_DEFAULT_NUMBER_OF_BUFFERS = BlobConstants.BLOB_DEFAULT_NUMBER_OF_BUFFERS; - - /** - * If a blob is known to be greater than 100MB, using a larger block size will trigger some server-side - * optimizations. If the block size is not set and the size of the blob is known to be greater than 100MB, this - * value will be used. - */ - public static final int BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE = BlobConstants.BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE; - - static final long BLOB_MAX_UPLOAD_BLOCK_SIZE = 4000L * Constants.MB; - - /** - * The default block size used in {@link FluxUtil#readFile(AsynchronousFileChannel)}. - * This is to make sure we're using same size when using {@link BinaryData#fromFile(Path, int)} - * and {@link BinaryData#fromFile(Path, Long, Long, int)} - * to represent the content. - */ - private static final int DEFAULT_FILE_READ_CHUNK_SIZE = BlobConstants.DEFAULT_FILE_READ_CHUNK_SIZE; - - private static final ClientLogger LOGGER = new ClientLogger(BlobAsyncClient.class); - - private BlockBlobAsyncClient blockBlobAsyncClient; - private AppendBlobAsyncClient appendBlobAsyncClient; - private PageBlobAsyncClient pageBlobAsyncClient; - - /** - * Protected constructor for use by {@link BlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - */ - protected BlobAsyncClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey) { - super(pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, customerProvidedKey); - } - - /** - * Protected constructor for use by {@link BlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - */ - protected BlobAsyncClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, - EncryptionScope encryptionScope) { - super(pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, customerProvidedKey, - encryptionScope); - } - - /** - * Protected constructor for use by {@link BlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - protected BlobAsyncClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, - EncryptionScope encryptionScope, String versionId) { - super(pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, customerProvidedKey, - encryptionScope, versionId); - } - - /** - * Creates a new {@link BlobAsyncClient} linked to the {@code snapshot} of this blob resource. - * - * @param snapshot the identifier for a specific snapshot of this blob - * @return A {@link BlobAsyncClient} used to interact with the specific snapshot. - */ - @Override - public BlobAsyncClient getSnapshotClient(String snapshot) { - return new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), snapshot, getCustomerProvidedKey(), encryptionScope, getVersionId()); - } - - /** - * Creates a new {@link BlobAsyncClient} linked to the {@code versionId} of this blob resource. - * - * @param versionId the identifier for a specific version of this blob, - * pass {@code null} to interact with the latest blob version. - * @return A {@link BlobAsyncClient} used to interact with the specific version. - */ - @Override - public BlobAsyncClient getVersionClient(String versionId) { - return new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), getCustomerProvidedKey(), encryptionScope, versionId); - } - - /** - * Creates a new {@link BlobAsyncClient} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link BlobAsyncClient} with the specified {@code encryptionScope}. - */ - @Override - public BlobAsyncClient getEncryptionScopeAsyncClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - return new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), getCustomerProvidedKey(), finalEncryptionScope, - getVersionId()); - } - - /** - * Creates a new {@link BlobAsyncClient} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link BlobAsyncClient} with the specified {@code customerProvidedKey}. - */ - @Override - public BlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - return new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), finalCustomerProvidedKey, encryptionScope, - getVersionId()); - } - - /** - * Creates a new {@link AppendBlobAsyncClient} associated with this blob. - * - * @return A {@link AppendBlobAsyncClient} associated with this blob. - */ - public AppendBlobAsyncClient getAppendBlobAsyncClient() { - if (appendBlobAsyncClient == null) { - appendBlobAsyncClient = prepareBuilder().buildAppendBlobAsyncClient(); - } - return appendBlobAsyncClient; - } - - /** - * Creates a new {@link BlockBlobAsyncClient} associated with this blob. - * - * @return A {@link BlockBlobAsyncClient} associated with this blob. - */ - public BlockBlobAsyncClient getBlockBlobAsyncClient() { - if (blockBlobAsyncClient == null) { - blockBlobAsyncClient = prepareBuilder().buildBlockBlobAsyncClient(); - } - return blockBlobAsyncClient; - } - - /** - * Creates a new {@link PageBlobAsyncClient} associated with this blob. - * - * @return A {@link PageBlobAsyncClient} associated with this blob. - */ - public PageBlobAsyncClient getPageBlobAsyncClient() { - if (pageBlobAsyncClient == null) { - pageBlobAsyncClient = prepareBuilder().buildPageBlobAsyncClient(); - } - return pageBlobAsyncClient; - } - - private SpecializedBlobClientBuilder prepareBuilder() { - SpecializedBlobClientBuilder builder = new SpecializedBlobClientBuilder().pipeline(getHttpPipeline()) - .endpoint(getBlobUrl()) - .snapshot(getSnapshotId()) - .serviceVersion(getServiceVersion()); - - CpkInfo cpk = getCustomerProvidedKey(); - if (cpk != null) { - builder.customerProvidedKey(new CustomerProvidedKey(cpk.getEncryptionKey())); - } - - if (encryptionScope != null) { - builder.encryptionScope(encryptionScope.getEncryptionScope()); - } - - return builder; - } - - /** - * Creates a new block blob. By default, this method will not overwrite an existing blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with this method; the content of the existing blob is overwritten with the new content. To perform a partial - * update of a block blob's, use {@link BlockBlobAsyncClient#stageBlock(String, Flux, long) stageBlock} and {@link - * BlockBlobAsyncClient#commitBlockList(List) commitBlockList}. For more information, see the - * Azure Docs for Put Block and the - * Azure Docs for Put Block List. - *

- * The data passed need not support multiple subscriptions/be replayable as is required in other upload methods when - * retries are enabled, and the length of the data need not be known in advance. Therefore, this method does - * support uploading any arbitrary data source, including network streams. This behavior is possible because this - * method will perform some internal buffering as configured by the blockSize and numBuffers parameters, so while - * this method may offer additional convenience, it will not be as performant as other options, which should be - * preferred when possible. - *

- * Typically, the greater the number of buffers used, the greater the possible parallelism when transferring the - * data. Larger buffers means we will have to stage fewer blocks and therefore require fewer IO operations. The - * trade-offs between these values are context-dependent, so some experimentation may be required to optimize inputs - * for a given scenario. - * - *

Code Samples

- * - * - *
-     * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions()
-     *     .setBlockSizeLong(blockSize)
-     *     .setMaxConcurrency(maxConcurrency);
-     * client.upload(data, parallelTransferOptions).subscribe(response ->
-     *     System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param data The data to write to the blob. Unlike other upload methods, this method does not require that the - * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected - * to produce the same values across subscriptions. - * @param parallelTransferOptions {@link ParallelTransferOptions} used to configure buffered uploading. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono upload(Flux data, ParallelTransferOptions parallelTransferOptions) { - return upload(data, parallelTransferOptions, false); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with this method; the content of the existing blob is overwritten with the new content. To perform a partial - * update of a block blob's, use {@link BlockBlobAsyncClient#stageBlock(String, Flux, long) stageBlock} and {@link - * BlockBlobAsyncClient#commitBlockList(List) commitBlockList}. For more information, see the - * Azure Docs for Put Block and the - * Azure Docs for Put Block List. - *

- * The data passed need not support multiple subscriptions/be replayable as is required in other upload methods when - * retries are enabled, and the length of the data need not be known in advance. Therefore, this method does - * support uploading any arbitrary data source, including network streams. This behavior is possible because this - * method will perform some internal buffering as configured by the blockSize and numBuffers parameters, so while - * this method may offer additional convenience, it will not be as performant as other options, which should be - * preferred when possible. - *

- * Typically, the greater the number of buffers used, the greater the possible parallelism when transferring the - * data. Larger buffers means we will have to stage fewer blocks and therefore require fewer IO operations. The - * trade-offs between these values are context-dependent, so some experimentation may be required to optimize inputs - * for a given scenario. - * - *

Code Samples

- * - * - *
-     * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions()
-     *     .setBlockSizeLong(blockSize)
-     *     .setMaxConcurrency(maxConcurrency);
-     * boolean overwrite = false; // Default behavior
-     * client.upload(data, parallelTransferOptions, overwrite).subscribe(response ->
-     *     System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param data The data to write to the blob. Unlike other upload methods, this method does not require that the - * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected - * to produce the same values across subscriptions. - * @param parallelTransferOptions {@link ParallelTransferOptions} used to configure buffered uploading. - * @param overwrite Whether to overwrite, should the blob already exist. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono upload(Flux data, ParallelTransferOptions parallelTransferOptions, - boolean overwrite) { - Mono overwriteCheck; - BlobRequestConditions requestConditions; - - if (overwrite) { - overwriteCheck = Mono.empty(); - requestConditions = null; - } else { - overwriteCheck = exists().flatMap(exists -> exists - ? monoError(LOGGER, new IllegalArgumentException(Constants.BLOB_ALREADY_EXISTS)) - : Mono.empty()); - requestConditions = new BlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - - return overwriteCheck - .then(uploadWithResponse(data, parallelTransferOptions, null, null, null, requestConditions)) - .flatMap(FluxUtil::toMono); - } - - /** - * Creates a new block blob. By default, this method will not overwrite an existing blob. - * - *

Code Samples

- * - * - *
-     * client.upload(BinaryData.fromString("Data!")).subscribe(response ->
-     *     System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param data The data to write to the blob. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono upload(BinaryData data) { - return upload(data, false); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default behavior
-     * client.upload(BinaryData.fromString("Data!"), overwrite).subscribe(response ->
-     *     System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param data The data to write to the blob. - * @param overwrite Whether to overwrite, should the blob already exist. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono upload(BinaryData data, boolean overwrite) { - Mono overwriteCheck; - BlobRequestConditions requestConditions; - - if (overwrite) { - overwriteCheck = Mono.empty(); - requestConditions = null; - } else { - overwriteCheck = exists().flatMap(exists -> exists - ? monoError(LOGGER, new IllegalArgumentException(Constants.BLOB_ALREADY_EXISTS)) - : Mono.empty()); - requestConditions = new BlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - - return overwriteCheck - .then(uploadWithResponse(data.toFluxByteBuffer(), null, null, null, null, requestConditions)) - .flatMap(FluxUtil::toMono); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with this method; the content of the existing blob is overwritten with the new content. To perform a partial - * update of a block blob's, use {@link BlockBlobAsyncClient#stageBlock(String, Flux, long) stageBlock} and {@link - * BlockBlobAsyncClient#commitBlockList(List) commitBlockList}. For more information, see the - * Azure Docs for Put Block and the - * Azure Docs for Put Block List. - *

- * The data passed need not support multiple subscriptions/be replayable as is required in other upload methods when - * retries are enabled, and the length of the data need not be known in advance. Therefore, this method does - * support uploading any arbitrary data source, including network streams. This behavior is possible because this - * method will perform some internal buffering as configured by the blockSize and numBuffers parameters, so while - * this method may offer additional convenience, it will not be as performant as other options, which should be - * preferred when possible. - *

- * Typically, the greater the number of buffers used, the greater the possible parallelism when transferring the - * data. Larger buffers means we will have to stage fewer blocks and therefore require fewer IO operations. The - * trade-offs between these values are context-dependent, so some experimentation may be required to optimize inputs - * for a given scenario. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions()
-     *     .setBlockSizeLong(blockSize)
-     *     .setMaxConcurrency(maxConcurrency);
-     *
-     * client.uploadWithResponse(data, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions)
-     *     .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
-     * 
- * - * - *

Using Progress Reporting

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions()
-     *     .setBlockSizeLong(blockSize)
-     *     .setMaxConcurrency(maxConcurrency)
-     *     .setProgressListener(bytesTransferred -> System.out.printf("Upload progress: %s bytes sent", bytesTransferred));
-     *
-     * client.uploadWithResponse(data, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions)
-     *     .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
-     * 
- * - * - * @param data The data to write to the blob. Unlike other upload methods, this method does not require that the - * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected - * to produce the same values across subscriptions. - * @param parallelTransferOptions {@link ParallelTransferOptions} used to configure buffered uploading. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadWithResponse(Flux data, - ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map metadata, - AccessTier tier, BlobRequestConditions requestConditions) { - try { - return this.uploadWithResponse( - new BlobParallelUploadOptions(data).setParallelTransferOptions(parallelTransferOptions) - .setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setRequestConditions(requestConditions)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with this method; the content of the existing blob is overwritten with the new content. To perform a partial - * update of a block blob's, use {@link BlockBlobAsyncClient#stageBlock(String, Flux, long) stageBlock} and {@link - * BlockBlobAsyncClient#commitBlockList(List) commitBlockList}. For more information, see the - * Azure Docs for Put Block and the - * Azure Docs for Put Block List. - *

- * The data passed need not support multiple subscriptions/be replayable as is required in other upload methods when - * retries are enabled, and the length of the data need not be known in advance. Therefore, this method does - * support uploading any arbitrary data source, including network streams. This behavior is possible because this - * method will perform some internal buffering as configured by the blockSize and numBuffers parameters, so while - * this method may offer additional convenience, it will not be as performant as other options, which should be - * preferred when possible. - *

- * Typically, the greater the number of buffers used, the greater the possible parallelism when transferring the - * data. Larger buffers means we will have to stage fewer blocks and therefore require fewer IO operations. The - * trade-offs between these values are context-dependent, so some experimentation may be required to optimize inputs - * for a given scenario. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize)
-     *     .setMaxConcurrency(maxConcurrency).setProgressListener(bytesTransferred ->
-     *         System.out.printf("Upload progress: %s bytes sent", bytesTransferred));
-     *
-     * client.uploadWithResponse(new BlobParallelUploadOptions(data)
-     *     .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata).setTags(tags)
-     *     .setTier(AccessTier.HOT).setRequestConditions(requestConditions))
-     *     .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
-     * 
- * - * - *

Using Progress Reporting

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize)
-     *     .setMaxConcurrency(maxConcurrency).setProgressListener(bytesTransferred ->
-     *         System.out.printf("Upload progress: %s bytes sent", bytesTransferred));
-     *
-     * client.uploadWithResponse(new BlobParallelUploadOptions(data)
-     *     .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata).setTags(tags)
-     *     .setTier(AccessTier.HOT).setRequestConditions(requestConditions))
-     *     .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
-     * 
- * - * - * @param options {@link BlobParallelUploadOptions}. Unlike other upload methods, this method does not require that - * the {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not - * expected to produce the same values across subscriptions. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadWithResponse(BlobParallelUploadOptions options) { - /* - * The following is catalogue of all the places we allocate memory/copy in any upload method a justification for - * that case current as of 1/13/21. - * - * - Async buffered upload chunked upload: We used an UploadBufferPool. This will allocate memory as needed up - * to the configured maximum. This is necessary to support replayability on retires. Each flux to come out of - * the pool is a Flux.just() of up to two deep copied buffers, so it is replayable. It also allows us to - * optimize the upload by uploading the maximum amount per block. Finally, in the case of chunked uploading, - * it allows the customer to pass data without knowing the size. Note that full upload does not need a deep - * copy because the Flux emitted by the PayloadSizeGate in the full upload case is already replayable and the - * length is maintained by the gate. - * - * - Sync buffered upload: converting the input stream to a flux involves creating a buffer for each stream - * read. Using a new buffer per read ensures that the reads are safe and not overwriting data in buffers that - * were passed to the async upload but have not yet been sent. This covers both full and chunked uploads in - * the sync case. - * - * - BlobOutputStream: A deep copy is made of any buffer passed to write. While async copy does streamline our - * code and allow for some potential parallelization, this extra copy is necessary to ensure that customers - * writing to the stream in a tight loop are not overwriting data previously given to the stream before it has - * been sent. - * - * Taken together, these should support retries and protect against data being overwritten in all upload - * scenarios. - * - * One note is that there is no deep copy in the uploadFull method. This is unnecessary as explained in - * uploadFullOrChunked because the Flux coming out of the size gate in that case is already replayable and - * reusing buffers is not a common scenario for async like it is in sync (and we already buffer in sync to - * convert from a stream). - */ - try { - StorageImplUtils.assertNotNull("options", options); - - final ParallelTransferOptions parallelTransferOptions - = ModelHelper.populateAndApplyDefaults(options.getParallelTransferOptions()); - final BlobHttpHeaders headers = options.getHeaders(); - final Map metadata = options.getMetadata(); - final Map tags = options.getTags(); - final AccessTier tier = options.getTier(); - final BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - final boolean computeMd5 = options.isComputeMd5(); - final BlobImmutabilityPolicy immutabilityPolicy = options.getImmutabilityPolicy() == null - ? new BlobImmutabilityPolicy() - : options.getImmutabilityPolicy(); - final Boolean legalHold = options.isLegalHold(); - - BlockBlobAsyncClient blockBlobAsyncClient = getBlockBlobAsyncClient(); - - Function, Mono>> uploadInChunksFunction - = (stream) -> uploadInChunks(blockBlobAsyncClient, stream, parallelTransferOptions, headers, metadata, - tags, tier, requestConditions, computeMd5, immutabilityPolicy, legalHold); - - BiFunction, Long, Mono>> uploadFullBlobFunction - = (stream, length) -> uploadFullBlob(blockBlobAsyncClient, stream, length, parallelTransferOptions, - headers, metadata, tags, tier, requestConditions, computeMd5, immutabilityPolicy, legalHold); - - Flux data = options.getDataFlux(); - data = UploadUtils.extractByteBuffer(data, options.getOptionalLength(), - parallelTransferOptions.getBlockSizeLong(), options.getDataStream()); - - return UploadUtils.uploadFullOrChunked(data, ModelHelper.wrapBlobOptions(parallelTransferOptions), - uploadInChunksFunction, uploadFullBlobFunction); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - private Mono> uploadFullBlob(BlockBlobAsyncClient blockBlobAsyncClient, - Flux data, long length, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, - Map metadata, Map tags, AccessTier tier, - BlobRequestConditions requestConditions, boolean computeMd5, BlobImmutabilityPolicy immutabilityPolicy, - Boolean legalHold) { - - /* - * Note that there is no need to buffer here as the flux returned by the size gate in this case is created - * from an iterable and is therefore replayable. - */ - return UploadUtils.computeMd5(data, computeMd5, LOGGER) - .map( - fluxMd5Wrapper -> new BlockBlobSimpleUploadOptions(fluxMd5Wrapper.getData(), length).setHeaders(headers) - .setMetadata(metadata) - .setTags(tags) - .setTier(tier) - .setRequestConditions(requestConditions) - .setContentMd5(fluxMd5Wrapper.getMd5()) - .setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(legalHold)) - .flatMap(options -> { - Mono> responseMono = blockBlobAsyncClient.uploadWithResponse(options); - if (parallelTransferOptions.getProgressListener() != null) { - ProgressReporter progressReporter - = ProgressReporter.withProgressListener(parallelTransferOptions.getProgressListener()); - responseMono = responseMono.contextWrite(FluxUtil.toReactorContext( - Contexts.empty().setHttpRequestProgressReporter(progressReporter).getContext())); - } - return responseMono; - }); - } - - private Mono> uploadInChunks(BlockBlobAsyncClient blockBlobAsyncClient, - Flux data, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, - Map metadata, Map tags, AccessTier tier, - BlobRequestConditions requestConditions, boolean computeMd5, BlobImmutabilityPolicy immutabilityPolicy, - Boolean legalHold) { - // TODO: Sample/api reference - - ProgressListener progressListener = parallelTransferOptions.getProgressListener(); - ProgressReporter progressReporter - = progressListener == null ? null : ProgressReporter.withProgressListener(progressListener); - - // Validation done in the constructor. - BufferStagingArea stagingArea = new BufferStagingArea(parallelTransferOptions.getBlockSizeLong(), - BlockBlobClient.MAX_STAGE_BLOCK_BYTES_LONG); - - Flux chunkedSource - = UploadUtils.chunkSource(data, ModelHelper.wrapBlobOptions(parallelTransferOptions)); - - /* - * Write to the pool and upload the output. - * maxConcurrency = 1 when writing means only 1 BufferAggregator will be accumulating at a time. - * parallelTransferOptions.getMaxConcurrency() appends will be happening at once, so we guarantee buffering of - * only concurrency + 1 chunks at a time. - */ - return chunkedSource.flatMapSequential(stagingArea::write, 1, 1) - .concatWith(Flux.defer(stagingArea::flush)) - .flatMapSequential(bufferAggregator -> { - Flux chunkData = bufferAggregator.asFlux(); - - String blockId = Base64.getEncoder().encodeToString(CoreUtils.randomUuid().toString().getBytes(UTF_8)); - return UploadUtils.computeMd5(chunkData, computeMd5, LOGGER).flatMap(fluxMd5Wrapper -> { - Mono> responseMono - = blockBlobAsyncClient.stageBlockWithResponse(blockId, fluxMd5Wrapper.getData(), - bufferAggregator.length(), fluxMd5Wrapper.getMd5(), requestConditions.getLeaseId()); - if (progressReporter != null) { - responseMono = responseMono.contextWrite(FluxUtil.toReactorContext(Contexts.empty() - .setHttpRequestProgressReporter(progressReporter.createChild()) - .getContext())); - } - return responseMono; - }) - // We only care about the stageBlock insofar as it was successful, but we need to collect the ids. - .map(x -> blockId); - }, parallelTransferOptions.getMaxConcurrency(), 1) - .collect(Collectors.toList()) - .flatMap(ids -> blockBlobAsyncClient - .commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(ids).setHeaders(headers) - .setMetadata(metadata) - .setTags(tags) - .setTier(tier) - .setRequestConditions(requestConditions) - .setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(legalHold))); - } - - /** - * Creates a new block blob with the content of the specified file. By default, this method will not overwrite an - * existing blob. - * - *

Code Samples

- * - * - *
-     * client.uploadFromFile(filePath)
-     *     .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage()))
-     *     .subscribe(completion -> System.out.println("Upload from file succeeded"));
-     * 
- * - * - * @param filePath Path to the upload file - * @return An empty response - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadFromFile(String filePath) { - return uploadFromFile(filePath, false); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob, with the content of the specified - * file. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default behavior
-     * client.uploadFromFile(filePath, overwrite)
-     *     .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage()))
-     *     .subscribe(completion -> System.out.println("Upload from file succeeded"));
-     * 
- * - * - * @param filePath Path to the upload file - * @param overwrite Whether to overwrite, should the blob already exist. - * @return An empty response - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadFromFile(String filePath, boolean overwrite) { - Mono overwriteCheck = Mono.empty(); - BlobRequestConditions requestConditions = null; - - // Note that if the file will be uploaded using a putBlob, we also can skip the exists check. - // - // Default behavior is to use uploading in chunks when the file size is greater than 256 MB. - if (!overwrite) { - if (UploadUtils.shouldUploadInChunks(filePath, ModelHelper.BLOB_DEFAULT_MAX_SINGLE_UPLOAD_SIZE, LOGGER)) { - overwriteCheck = exists().flatMap(exists -> exists - ? monoError(LOGGER, new IllegalArgumentException(Constants.BLOB_ALREADY_EXISTS)) - : Mono.empty()); - } - - requestConditions = new BlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - - return overwriteCheck.then(uploadFromFile(filePath, null, null, null, null, requestConditions)); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob, with the content of the specified - * file. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.uploadFromFile(filePath,
-     *     new ParallelTransferOptions().setBlockSizeLong(BlockBlobClient.MAX_STAGE_BLOCK_BYTES_LONG),
-     *     headers, metadata, AccessTier.HOT, requestConditions)
-     *     .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage()))
-     *     .subscribe(completion -> System.out.println("Upload from file succeeded"));
-     * 
- * - * - * @param filePath Path to the upload file - * @param parallelTransferOptions {@link ParallelTransferOptions} to use to upload from file. Number of parallel - * transfers parameter is ignored. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param requestConditions {@link BlobRequestConditions} - * @return An empty response - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadFromFile(String filePath, ParallelTransferOptions parallelTransferOptions, - BlobHttpHeaders headers, Map metadata, AccessTier tier, - BlobRequestConditions requestConditions) { - try { - return this.uploadFromFileWithResponse( - new BlobUploadFromFileOptions(filePath).setParallelTransferOptions(parallelTransferOptions) - .setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setRequestConditions(requestConditions)) - .then(); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Creates a new block blob, or updates the content of an existing block blob, with the content of the specified - * file. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Long blockSize = 100 * 1024 * 1024L; // 100 MB;
-     *
-     * client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath)
-     *     .setParallelTransferOptions(
-     *         new ParallelTransferOptions().setBlockSizeLong(blockSize))
-     *     .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
-     *     .setRequestConditions(requestConditions))
-     *     .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage()))
-     *     .subscribe(completion -> System.out.println("Upload from file succeeded"));
-     * 
- * - * - * @param options {@link BlobUploadFromFileOptions} - * @return A reactive response containing the information of the uploaded block blob. - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadFromFileWithResponse(BlobUploadFromFileOptions options) { - StorageImplUtils.assertNotNull("options", options); - Long originalBlockSize = (options.getParallelTransferOptions() == null) - ? null - : options.getParallelTransferOptions().getBlockSizeLong(); - final ParallelTransferOptions finalParallelTransferOptions - = ModelHelper.populateAndApplyDefaults(options.getParallelTransferOptions()); - try { - Path filePath = Paths.get(options.getFilePath()); - BlockBlobAsyncClient blockBlobAsyncClient = getBlockBlobAsyncClient(); - // This will retrieve file length but won't read file body. - BinaryData fullFileData = BinaryData.fromFile(filePath, DEFAULT_FILE_READ_CHUNK_SIZE); - long fileSize = fullFileData.getLength(); - - // By default, if the file is larger than 256MB chunk it and stage it as blocks. - // But, this is configurable by the user passing options with max single upload size configured. - if (fileSize > finalParallelTransferOptions.getMaxSingleUploadSizeLong()) { - return uploadFileChunks(fileSize, finalParallelTransferOptions, originalBlockSize, options.getHeaders(), - options.getMetadata(), options.getTags(), options.getTier(), options.getRequestConditions(), - filePath, blockBlobAsyncClient); - } else { - // Otherwise, we know it can be sent in a single request reducing network overhead. - Mono> responseMono = blockBlobAsyncClient - .uploadWithResponse(new BlockBlobSimpleUploadOptions(fullFileData).setHeaders(options.getHeaders()) - .setMetadata(options.getMetadata()) - .setTags(options.getTags()) - .setTier(options.getTier()) - .setRequestConditions(options.getRequestConditions())); - if (finalParallelTransferOptions.getProgressListener() != null) { - ProgressReporter progressReporter - = ProgressReporter.withProgressListener(finalParallelTransferOptions.getProgressListener()); - responseMono = responseMono.contextWrite(FluxUtil.toReactorContext( - Contexts.empty().setHttpRequestProgressReporter(progressReporter).getContext())); - } - return responseMono; - } - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - private Mono> uploadFileChunks(long fileSize, - ParallelTransferOptions parallelTransferOptions, Long originalBlockSize, BlobHttpHeaders headers, - Map metadata, Map tags, AccessTier tier, - BlobRequestConditions requestConditions, Path filePath, BlockBlobAsyncClient client) { - final BlobRequestConditions finalRequestConditions - = (requestConditions == null) ? new BlobRequestConditions() : requestConditions; - // parallelTransferOptions are finalized in the calling method. - - ProgressListener progressListener = parallelTransferOptions.getProgressListener(); - ProgressReporter progressReporter - = progressListener == null ? null : ProgressReporter.withProgressListener(progressListener); - - final SortedMap blockIds = new TreeMap<>(); - return Flux.fromIterable(sliceFile(fileSize, originalBlockSize, parallelTransferOptions.getBlockSizeLong())) - .flatMap(chunk -> { - String blockId = getBlockID(); - blockIds.put(chunk.getOffset(), blockId); - - BinaryData data - = BinaryData.fromFile(filePath, chunk.getOffset(), chunk.getCount(), DEFAULT_FILE_READ_CHUNK_SIZE); - - Mono> responseMono = client.stageBlockWithResponse( - new BlockBlobStageBlockOptions(blockId, data).setLeaseId(finalRequestConditions.getLeaseId())); - if (progressReporter != null) { - responseMono = responseMono.contextWrite(FluxUtil.toReactorContext( - Contexts.empty().setHttpRequestProgressReporter(progressReporter.createChild()).getContext())); - } - return responseMono; - }, parallelTransferOptions.getMaxConcurrency()) - .then(Mono.defer(() -> client.commitBlockListWithResponse( - new BlockBlobCommitBlockListOptions(new ArrayList<>(blockIds.values())).setHeaders(headers) - .setMetadata(metadata) - .setTags(tags) - .setTier(tier) - .setRequestConditions(finalRequestConditions)))); - } - - /** - * RESERVED FOR INTERNAL USE. - * - * Resource Supplier for UploadFile. - * - * @param filePath The path for the file - * @return {@code AsynchronousFileChannel} - * @throws UncheckedIOException an input output exception. - * @deprecated due to refactoring code to be in the common storage library. - */ - @Deprecated - protected AsynchronousFileChannel uploadFileResourceSupplier(String filePath) { - return UploadUtils.uploadFileResourceSupplier(filePath, LOGGER); - } - - private String getBlockID() { - return Base64.getEncoder().encodeToString(CoreUtils.randomUuid().toString().getBytes(StandardCharsets.UTF_8)); - } - - private List sliceFile(long fileSize, Long originalBlockSize, long blockSize) { - List ranges = new ArrayList<>(); - if (fileSize > 100 * Constants.MB && originalBlockSize == null) { - blockSize = BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE; - } - for (long pos = 0; pos < fileSize; pos += blockSize) { - long count = blockSize; - if (pos + count > fileSize) { - count = fileSize - pos; - } - ranges.add(new BlobRange(pos, count)); - } - return ranges; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java deleted file mode 100644 index 5cacdc809d46..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java +++ /dev/null @@ -1,573 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.options.BlobUploadFromFileOptions; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlobClientBase; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.implementation.UploadUtils; -import reactor.core.publisher.Mono; - -import java.io.InputStream; -import java.io.UncheckedIOException; -import java.nio.channels.AsynchronousFileChannel; -import java.nio.file.Path; -import java.time.Duration; -import java.util.Map; -import java.util.Objects; - -/** - * This class provides a client that contains generic blob operations for Azure Storage Blobs. Operations allowed by - * the client are uploading and downloading, copying a blob, retrieving and setting metadata, retrieving and setting - * HTTP headers, and deleting and un-deleting a blob. - * - *

- * This client is instantiated through {@link BlobClientBuilder} or retrieved via - * {@link BlobContainerClient#getBlobClient(String) getBlobClient}. - * - *

- * For operations on a specific blob type (i.e append, block, or page) use - * {@link #getAppendBlobClient() getAppendBlobClient}, {@link #getBlockBlobClient() getBlockBlobClient}, or - * {@link #getPageBlobClient() getPageBlobClient} to construct a client that allows blob specific operations. - * - *

- * Please refer to the Azure - * Docs for more information. - */ -@ServiceClient(builder = BlobClientBuilder.class) -public class BlobClient extends BlobClientBase { - private static final ClientLogger LOGGER = new ClientLogger(BlobClient.class); - - /** - * The block size to use if none is specified in parallel operations. - */ - public static final int BLOB_DEFAULT_UPLOAD_BLOCK_SIZE = BlobConstants.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE; - - /** - * The number of buffers to use if none is specified on the buffered upload method. - */ - public static final int BLOB_DEFAULT_NUMBER_OF_BUFFERS = BlobConstants.BLOB_DEFAULT_NUMBER_OF_BUFFERS; - /** - * If a blob is known to be greater than 100MB, using a larger block size will trigger some server-side - * optimizations. If the block size is not set and the size of the blob is known to be greater than 100MB, this - * value will be used. - */ - public static final int BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE = BlobConstants.BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE; - - /** - * The default block size used in {@link FluxUtil#readFile(AsynchronousFileChannel)}. - * This is to make sure we're using same size when using {@link BinaryData#fromFile(Path, int)} - * and {@link BinaryData#fromFile(Path, Long, Long, int)} - * to represent the content. - */ - private static final int DEFAULT_FILE_READ_CHUNK_SIZE = BlobConstants.DEFAULT_FILE_READ_CHUNK_SIZE; - private final BlobAsyncClient client; - - private BlockBlobClient blockBlobClient; - private AppendBlobClient appendBlobClient; - private PageBlobClient pageBlobClient; - - /** - * Protected constructor for use by {@link BlobClientBuilder}. - * @param client the async blob client - */ - protected BlobClient(BlobAsyncClient client) { - super(client); - this.client = client; - } - - /** - * Protected constructor for use by {@link BlobClientBuilder}. - * - * @param client the async blob client - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - protected BlobClient(BlobAsyncClient client, HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, - String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, - EncryptionScope encryptionScope, String versionId) { - super(client, pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, - customerProvidedKey, encryptionScope, versionId); - this.client = client; - } - - /** - * Creates a new {@link BlobClient} linked to the {@code snapshot} of this blob resource. - * - * @param snapshot the identifier for a specific snapshot of this blob - * @return A {@link BlobClient} used to interact with the specific snapshot. - */ - @Override - public BlobClient getSnapshotClient(String snapshot) { - BlobAsyncClient asyncClient = new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), - getAccountName(), getContainerName(), getBlobName(), snapshot, getCustomerProvidedKey(), - new EncryptionScope().setEncryptionScope(getEncryptionScope()), getVersionId()); - return new BlobClient(asyncClient, getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), snapshot, getCustomerProvidedKey(), - new EncryptionScope().setEncryptionScope(getEncryptionScope()), getVersionId()); - } - - /** - * Creates a new {@link BlobClient} linked to the {@code version} of this blob resource. - * - * @param versionId the identifier for a specific version of this blob, - * pass {@code null} to interact with the latest blob version. - * @return A {@link BlobClient} used to interact with the specific version. - */ - @Override - public BlobClient getVersionClient(String versionId) { - BlobAsyncClient asyncClient = new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), - getAccountName(), getContainerName(), getBlobName(), getSnapshotId(), getCustomerProvidedKey(), - new EncryptionScope().setEncryptionScope(getEncryptionScope()), versionId); - return new BlobClient(asyncClient, getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), getCustomerProvidedKey(), - new EncryptionScope().setEncryptionScope(getEncryptionScope()), versionId); - } - - /** - * Creates a new {@link BlobClient} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link BlobClient} with the specified {@code encryptionScope}. - */ - @Override - public BlobClient getEncryptionScopeClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - return new BlobClient(this.client.getEncryptionScopeAsyncClient(encryptionScope), getHttpPipeline(), - getAccountUrl(), getServiceVersion(), getAccountName(), getContainerName(), getBlobName(), getSnapshotId(), - getCustomerProvidedKey(), finalEncryptionScope, getVersionId()); - } - - /** - * Creates a new {@link BlobClient} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link BlobClient} with the specified {@code customerProvidedKey}. - */ - @Override - public BlobClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - return new BlobClient(this.client.getCustomerProvidedKeyAsyncClient(customerProvidedKey), getHttpPipeline(), - getAccountUrl(), getServiceVersion(), getAccountName(), getContainerName(), getBlobName(), getSnapshotId(), - finalCustomerProvidedKey, new EncryptionScope().setEncryptionScope(getEncryptionScope()), getVersionId()); - } - - /** - * Creates a new {@link AppendBlobClient} associated with this blob. - * - * @return A {@link AppendBlobClient} associated with this blob. - */ - public AppendBlobClient getAppendBlobClient() { - if (appendBlobClient == null) { - appendBlobClient = new SpecializedBlobClientBuilder().blobClient(this).buildAppendBlobClient(); - } - return appendBlobClient; - } - - /** - * Creates a new {@link BlockBlobClient} associated with this blob. - * - * @return A {@link BlockBlobClient} associated with this blob. - */ - public BlockBlobClient getBlockBlobClient() { - if (blockBlobClient == null) { - blockBlobClient = new SpecializedBlobClientBuilder().blobClient(this).buildBlockBlobClient(); - } - return blockBlobClient; - } - - /** - * Creates a new {@link PageBlobClient} associated with this blob. - * - * @return A {@link PageBlobClient} associated with this blob. - */ - public PageBlobClient getPageBlobClient() { - if (pageBlobClient == null) { - pageBlobClient = new SpecializedBlobClientBuilder().blobClient(this).buildPageBlobClient(); - } - return pageBlobClient; - } - - /** - * Creates a new blob. By default this method will not overwrite an existing blob. - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider opening a {@link com.azure.storage.blob.specialized.BlobOutputStream} and - * writing to the returned stream. Alternatively, consider wrapping your data source in a - * {@link java.io.BufferedInputStream} to add mark support. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void upload(InputStream data) { - upload(data, false); - } - - /** - * Creates a new blob. By default this method will not overwrite an existing blob. - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider opening a {@link com.azure.storage.blob.specialized.BlobOutputStream} and - * writing to the returned stream. Alternatively, consider wrapping your data source in a - * {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void upload(InputStream data, long length) { - upload(data, length, false); - } - - /** - * Creates a new blob, or updates the content of an existing blob. - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider opening a {@link com.azure.storage.blob.specialized.BlobOutputStream} and - * writing to the returned stream. Alternatively, consider wrapping your data source in a - * {@link java.io.BufferedInputStream} to add mark support. - * @param overwrite Whether or not to overwrite, should data exist on the blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void upload(InputStream data, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - uploadWithResponse(new BlobParallelUploadOptions(data).setRequestConditions(blobRequestConditions), null, - Context.NONE); - } - - /** - * Creates a new blob, or updates the content of an existing blob. - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider opening a {@link com.azure.storage.blob.specialized.BlobOutputStream} and - * writing to the returned stream. Alternatively, consider wrapping your data source in a - * {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - * @param overwrite Whether or not to overwrite, should data exist on the blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void upload(InputStream data, long length, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - uploadWithResponse(data, length, null, null, null, null, blobRequestConditions, null, Context.NONE); - } - - /** - * Creates a new blob. By default this method will not overwrite an existing blob. - * - * @param data The data to write to the blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void upload(BinaryData data) { - upload(data, false); - } - - /** - * Creates a new blob, or updates the content of an existing blob. - * - * @param data The data to write to the blob. - * @param overwrite Whether or not to overwrite, should data exist on the blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void upload(BinaryData data, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - uploadWithResponse(new BlobParallelUploadOptions(data).setRequestConditions(blobRequestConditions), null, - Context.NONE); - } - - /** - * Creates a new blob, or updates the content of an existing blob. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider opening a {@link com.azure.storage.blob.specialized.BlobOutputStream} and - * writing to the returned stream. Alternatively, consider wrapping your data source in a - * {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - * @param parallelTransferOptions {@link ParallelTransferOptions} used to configure buffered uploading. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @deprecated See {@link #uploadWithResponse(BlobParallelUploadOptions, Duration, Context)} instead - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public void uploadWithResponse(InputStream data, long length, ParallelTransferOptions parallelTransferOptions, - BlobHttpHeaders headers, Map metadata, AccessTier tier, BlobRequestConditions requestConditions, - Duration timeout, Context context) { - this.uploadWithResponse( - new BlobParallelUploadOptions(data, length).setParallelTransferOptions(parallelTransferOptions) - .setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setRequestConditions(requestConditions), - timeout, context); - } - - /** - * Creates a new blob, or updates the content of an existing blob. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * @param options {@link BlobParallelUploadOptions} - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return Information about the uploaded block blob. - * - * @deprecated Use {@link BlobClient#uploadWithResponse(BlobParallelUploadOptions, Duration, Context)} - */ - @Deprecated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadWithResponse(BlobParallelUploadOptions options, Context context) { - Objects.requireNonNull(options); - return this.uploadWithResponse(options, options.getTimeout(), context); - } - - /** - * Creates a new blob, or updates the content of an existing blob. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * @param options {@link BlobParallelUploadOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return Information about the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadWithResponse(BlobParallelUploadOptions options, Duration timeout, - Context context) { - Objects.requireNonNull(options); - Mono> upload - = client.uploadWithResponse(options).contextWrite(FluxUtil.toReactorContext(context)); - - try { - return StorageImplUtils.blockWithOptionalTimeout(upload, timeout); - } catch (UncheckedIOException e) { - throw LOGGER.logExceptionAsError(e); - } - } - - /** - * Creates a new block blob. By default this method will not overwrite an existing blob. - * - *

Code Samples

- * - * - *
-     * try {
-     *     client.uploadFromFile(filePath);
-     *     System.out.println("Upload from file succeeded");
-     * } catch (UncheckedIOException ex) {
-     *     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
-     * }
-     * 
- * - * - * @param filePath Path of the file to upload - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void uploadFromFile(String filePath) { - uploadFromFile(filePath, false); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - * - *

Code Samples

- * - * - *
-     * try {
-     *     boolean overwrite = false;
-     *     client.uploadFromFile(filePath, overwrite);
-     *     System.out.println("Upload from file succeeded");
-     * } catch (UncheckedIOException ex) {
-     *     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
-     * }
-     * 
- * - * - * @param filePath Path of the file to upload - * @param overwrite Whether or not to overwrite, should the blob already exist - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void uploadFromFile(String filePath, boolean overwrite) { - BlobRequestConditions requestConditions = null; - - if (!overwrite) { - // Note we only want to make the exists call if we will be uploading in stages. Otherwise it is superfluous. - // - // Default behavior is to use uploading in chunks when the file size is greater than 256 MB. - if (UploadUtils.shouldUploadInChunks(filePath, ModelHelper.BLOB_DEFAULT_MAX_SINGLE_UPLOAD_SIZE, LOGGER) - && exists()) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException(Constants.BLOB_ALREADY_EXISTS)); - } - requestConditions = new BlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - uploadFromFile(filePath, null, null, null, null, requestConditions, null); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Long blockSize = 100L * 1024L * 1024L; // 100 MB;
-     * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);
-     *
-     * try {
-     *     client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata,
-     *         AccessTier.HOT, requestConditions, timeout);
-     *     System.out.println("Upload from file succeeded");
-     * } catch (UncheckedIOException ex) {
-     *     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
-     * }
-     * 
- * - * - * @param filePath Path of the file to upload - * @param parallelTransferOptions {@link ParallelTransferOptions} to use to upload from file. Number of parallel - * transfers parameter is ignored. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the uploaded blob - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void uploadFromFile(String filePath, ParallelTransferOptions parallelTransferOptions, - BlobHttpHeaders headers, Map metadata, AccessTier tier, BlobRequestConditions requestConditions, - Duration timeout) { - this.uploadFromFileWithResponse( - new BlobUploadFromFileOptions(filePath).setParallelTransferOptions(parallelTransferOptions) - .setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setRequestConditions(requestConditions), - timeout, null); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Long blockSize = 100 * 1024 * 1024L; // 100 MB;
-     * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);
-     *
-     * try {
-     *     client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath)
-     *         .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata)
-     *         .setTags(tags).setTier(AccessTier.HOT).setRequestConditions(requestConditions), timeout,
-     *         new Context(key2, value2));
-     *     System.out.println("Upload from file succeeded");
-     * } catch (UncheckedIOException ex) {
-     *     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
-     * }
-     * 
- * - * - * @param options {@link BlobUploadFromFileOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return Information about the uploaded block blob. - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadFromFileWithResponse(BlobUploadFromFileOptions options, Duration timeout, - Context context) { - Mono> upload - = this.client.uploadFromFileWithResponse(options).contextWrite(FluxUtil.toReactorContext(context)); - - try { - return StorageImplUtils.blockWithOptionalTimeout(upload, timeout); - } catch (UncheckedIOException e) { - throw LOGGER.logExceptionAsError(e); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java deleted file mode 100644 index d5ca70babfb9..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java +++ /dev/null @@ -1,643 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.AzureNamedKeyCredentialTrait; -import com.azure.core.client.traits.AzureSasCredentialTrait; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.ConnectionStringTrait; -import com.azure.core.client.traits.EndpointTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.client.traits.TokenCredentialTrait; -import com.azure.core.credential.AzureNamedKeyCredential; -import com.azure.core.credential.AzureSasCredential; -import com.azure.core.credential.TokenCredential; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.HttpClientOptions; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BuilderHelper; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.connectionstring.StorageAuthenticationSettings; -import com.azure.storage.common.implementation.connectionstring.StorageConnectionString; -import com.azure.storage.common.implementation.connectionstring.StorageEndpoint; -import com.azure.storage.common.policy.RequestRetryOptions; - -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * This class provides a fluent builder API to help aid the configuration and instantiation of {@link BlobClient - * BlobClients} and {@link BlobAsyncClient BlobAsyncClients}, call {@link #buildClient() buildClient} and {@link - * #buildAsyncClient() buildAsyncClient} respectively to construct an instance of the desired client. - * - *

- * The following information must be provided on this builder: - * - *

    - *
  • the endpoint through {@code .endpoint()}, including the container name and blob name, in the format of - * {@code https://{accountName}.blob.core.windows.net/{containerName}/{blobName}}. - *
  • the credential through {@code .credential()} or {@code .connectionString()} if the container is not publicly - * accessible. - *
- */ -@ServiceClientBuilder(serviceClients = { BlobClient.class, BlobAsyncClient.class }) -public final class BlobClientBuilder - implements TokenCredentialTrait, ConnectionStringTrait, - AzureNamedKeyCredentialTrait, AzureSasCredentialTrait, - HttpTrait, ConfigurationTrait, EndpointTrait { - private static final ClientLogger LOGGER = new ClientLogger(BlobClientBuilder.class); - - private String endpoint; - private String accountName; - private String containerName; - private String blobName; - private String snapshot; - private String versionId; - - private CpkInfo customerProvidedKey; - private EncryptionScope encryptionScope; - private StorageSharedKeyCredential storageSharedKeyCredential; - private TokenCredential tokenCredential; - private AzureSasCredential azureSasCredential; - private String sasToken; - - private HttpClient httpClient; - private final List perCallPolicies = new ArrayList<>(); - private final List perRetryPolicies = new ArrayList<>(); - private HttpLogOptions logOptions; - private RetryOptions coreRetryOptions; - private RequestRetryOptions retryOptions; - private HttpPipeline httpPipeline; - - private ClientOptions clientOptions = new ClientOptions(); - private Configuration configuration; - private BlobServiceVersion version; - private BlobAudience audience; - - /** - * Creates a builder instance that is able to configure and construct {@link BlobClient BlobClients} and {@link - * BlobAsyncClient BlobAsyncClients}. - */ - public BlobClientBuilder() { - logOptions = getDefaultHttpLogOptions(); - } - - /** - * Creates a {@link BlobClient} based on options set in the builder. BlobClients are used to perform generic blob - * methods such as {@link BlobClient#download(OutputStream) download} and {@link BlobClient#getProperties() get - * properties}, use this when the blob type is unknown. - * - *

Code Samples

- * - * - *
-     * BlobClient client = new BlobClientBuilder()
-     *     .connectionString(connectionString)
-     *     .buildClient();
-     * 
- * - * - * @return a {@link BlobClient} created from the configurations in this builder. - * @throws NullPointerException If {@code endpoint} or {@code blobName} is {@code null}. - * @throws IllegalStateException If multiple credentials have been specified. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryOptions(RequestRetryOptions)} have been set. - */ - public BlobClient buildClient() { - Objects.requireNonNull(blobName, "'blobName' cannot be null."); - Objects.requireNonNull(endpoint, "'endpoint' cannot be null"); - - BuilderHelper.httpsValidation(customerProvidedKey, "customer provided key", endpoint, LOGGER); - - if (Objects.nonNull(customerProvidedKey) && Objects.nonNull(encryptionScope)) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("Customer provided key and encryption " + "scope cannot both be set")); - } - - /* - Implicit and explicit root container access are functionally equivalent, but explicit references are easier - to read and debug. - */ - String blobContainerName - = CoreUtils.isNullOrEmpty(containerName) ? BlobContainerClient.ROOT_CONTAINER_NAME : containerName; - - BlobServiceVersion serviceVersion = version != null ? version : BlobServiceVersion.getLatest(); - - BlobAsyncClient asyncClient = buildAsyncClient(); - - return new BlobClient(asyncClient, asyncClient.getHttpPipeline(), endpoint, serviceVersion, accountName, - blobContainerName, blobName, snapshot, customerProvidedKey, encryptionScope, versionId); - } - - /** - * Creates a {@link BlobAsyncClient} based on options set in the builder. BlobAsyncClients are used to perform - * generic blob methods such as {@link BlobAsyncClient#download() download} and {@link - * BlobAsyncClient#getProperties()}, use this when the blob type is unknown. - * - *

Code Samples

- * - * - *
-     * BlobAsyncClient client = new BlobClientBuilder()
-     *     .connectionString(connectionString)
-     *     .buildAsyncClient();
-     * 
- * - * - * @return a {@link BlobAsyncClient} created from the configurations in this builder. - * @throws NullPointerException If {@code endpoint} or {@code blobName} is {@code null}. - * @throws IllegalStateException If multiple credentials have been specified. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryOptions(RequestRetryOptions)} have been set. - */ - public BlobAsyncClient buildAsyncClient() { - Objects.requireNonNull(blobName, "'blobName' cannot be null."); - Objects.requireNonNull(endpoint, "'endpoint' cannot be null"); - - BuilderHelper.httpsValidation(customerProvidedKey, "customer provided key", endpoint, LOGGER); - - if (Objects.nonNull(customerProvidedKey) && Objects.nonNull(encryptionScope)) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("Customer provided key and encryption " + "scope cannot both be set")); - } - - /* - Implicit and explicit root container access are functionally equivalent, but explicit references are easier - to read and debug. - */ - String blobContainerName - = CoreUtils.isNullOrEmpty(containerName) ? BlobContainerAsyncClient.ROOT_CONTAINER_NAME : containerName; - - BlobServiceVersion serviceVersion = version != null ? version : BlobServiceVersion.getLatest(); - - HttpPipeline pipeline = constructPipeline(); - - return new BlobAsyncClient(pipeline, endpoint, serviceVersion, accountName, blobContainerName, blobName, - snapshot, customerProvidedKey, encryptionScope, versionId); - } - - private HttpPipeline constructPipeline() { - return (httpPipeline != null) - ? httpPipeline - : BuilderHelper.buildPipeline(storageSharedKeyCredential, tokenCredential, azureSasCredential, sasToken, - endpoint, retryOptions, coreRetryOptions, logOptions, clientOptions, httpClient, perCallPolicies, - perRetryPolicies, configuration, audience, LOGGER); - } - - /** - * Sets the {@link CustomerProvidedKey customer provided key} that is used to encrypt blob contents on the server. - * - * @param customerProvidedKey {@link CustomerProvidedKey} - * @return the updated BlobClientBuilder object - */ - public BlobClientBuilder customerProvidedKey(CustomerProvidedKey customerProvidedKey) { - if (customerProvidedKey == null) { - this.customerProvidedKey = null; - } else { - this.customerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - - return this; - } - - /** - * Sets the {@code encryption scope} that is used to encrypt blob contents on the server. - * - * @param encryptionScope Encryption scope containing the encryption key information. - * @return the updated BlobClientBuilder object - */ - public BlobClientBuilder encryptionScope(String encryptionScope) { - if (encryptionScope == null) { - this.encryptionScope = null; - } else { - this.encryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - - return this; - } - - /** - * Sets the {@link StorageSharedKeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link StorageSharedKeyCredential}. - * @return the updated BlobClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - public BlobClientBuilder credential(StorageSharedKeyCredential credential) { - this.storageSharedKeyCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - this.tokenCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the {@link AzureNamedKeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link AzureNamedKeyCredential}. - * @return the updated BlobClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public BlobClientBuilder credential(AzureNamedKeyCredential credential) { - Objects.requireNonNull(credential, "'credential' cannot be null."); - return credential(StorageSharedKeyCredential.fromAzureNamedKeyCredential(credential)); - } - - /** - * Sets the {@link TokenCredential} used to authorize requests sent to the service. Refer to the Azure SDK for Java - * identity and authentication - * documentation for more details on proper usage of the {@link TokenCredential} type. - * - * @param credential {@link TokenCredential} used to authorize requests sent to the service. - * @return the updated BlobClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public BlobClientBuilder credential(TokenCredential credential) { - this.tokenCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - this.storageSharedKeyCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the SAS token used to authorize requests sent to the service. - * - * @param sasToken The SAS token to use for authenticating requests. This string should only be the query parameters - * (with or without a leading '?') and not a full url. - * @return the updated BlobClientBuilder - * @throws NullPointerException If {@code sasToken} is {@code null}. - */ - public BlobClientBuilder sasToken(String sasToken) { - this.sasToken = Objects.requireNonNull(sasToken, "'sasToken' cannot be null."); - this.storageSharedKeyCredential = null; - this.tokenCredential = null; - return this; - } - - /** - * Sets the {@link AzureSasCredential} used to authorize requests sent to the service. - * - * @param credential {@link AzureSasCredential} used to authorize requests sent to the service. - * @return the updated BlobClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public BlobClientBuilder credential(AzureSasCredential credential) { - this.azureSasCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - return this; - } - - /** - * Clears the credential used to authorize the request. - * - *

This is for blobs that are publicly accessible.

- * - * @return the updated BlobClientBuilder - */ - public BlobClientBuilder setAnonymousAccess() { - this.storageSharedKeyCredential = null; - this.tokenCredential = null; - this.azureSasCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the connection string to connect to the service. - * - * @param connectionString Connection string of the storage account. - * @return the updated BlobClientBuilder - * @throws IllegalArgumentException If {@code connectionString} in invalid. - */ - @Override - public BlobClientBuilder connectionString(String connectionString) { - StorageConnectionString storageConnectionString = StorageConnectionString.create(connectionString, LOGGER); - StorageEndpoint endpoint = storageConnectionString.getBlobEndpoint(); - if (endpoint == null || endpoint.getPrimaryUri() == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException( - "connectionString missing required settings to derive blob service endpoint.")); - } - this.endpoint(endpoint.getPrimaryUri()); - if (storageConnectionString.getAccountName() != null) { - this.accountName = storageConnectionString.getAccountName(); - } - StorageAuthenticationSettings authSettings = storageConnectionString.getStorageAuthSettings(); - if (authSettings.getType() == StorageAuthenticationSettings.Type.ACCOUNT_NAME_KEY) { - this.credential(new StorageSharedKeyCredential(authSettings.getAccount().getName(), - authSettings.getAccount().getAccessKey())); - } else if (authSettings.getType() == StorageAuthenticationSettings.Type.SAS_TOKEN) { - this.sasToken(authSettings.getSasToken()); - } - return this; - } - - /** - * Sets the service endpoint, additionally parses it for information (SAS token, container name, blob name) - * - *

If the endpoint is to a blob in the root container, this method will fail as it will interpret the blob name - * as the container name. With only one path element, it is impossible to distinguish between a container name and - * a blob in the root container, so it is assumed to be the container name as this is much more common. When working - * with blobs in the root container, it is best to set the endpoint to the account url and specify the blob name - * separately using the {@link BlobClientBuilder#blobName(String) blobName} method.

- * - * @param endpoint URL of the service - * @return the updated BlobClientBuilder object - * @throws IllegalArgumentException If {@code endpoint} is {@code null} or is a malformed URL. - */ - @Override - public BlobClientBuilder endpoint(String endpoint) { - try { - URL url = new URL(endpoint); - BlobUrlParts parts = BlobUrlParts.parse(url); - - this.accountName = parts.getAccountName(); - this.endpoint = BuilderHelper.getEndpoint(parts); - this.containerName - = parts.getBlobContainerName() == null ? this.containerName : parts.getBlobContainerName(); - this.blobName = parts.getBlobName() == null ? this.blobName : parts.getBlobName(); - this.snapshot = parts.getSnapshot(); - this.versionId = parts.getVersionId(); - - String sasToken = parts.getCommonSasQueryParameters().encode(); - if (!CoreUtils.isNullOrEmpty(sasToken)) { - this.sasToken(sasToken); - } - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("The Azure Storage Blob endpoint url is malformed.", ex)); - } - return this; - } - - /** - * Sets the name of the container that contains the blob. - * - * @param containerName Name of the container. If the value {@code null} or empty the root container, {@code $root} - * , will be used. - * @return the updated BlobClientBuilder object - */ - public BlobClientBuilder containerName(String containerName) { - this.containerName = containerName; - return this; - } - - /** - * Sets the name of the blob. - * - * @param blobName Name of the blob. - * @return the updated BlobClientBuilder object - * @throws NullPointerException If {@code blobName} is {@code null} - */ - public BlobClientBuilder blobName(String blobName) { - this.blobName = Objects.requireNonNull(blobName, "'blobName' cannot be null."); - return this; - } - - /** - * Sets the snapshot identifier of the blob. - * - * @param snapshot Snapshot identifier for the blob. - * @return the updated BlobClientBuilder object - */ - public BlobClientBuilder snapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - /** - * Sets the version identifier of the blob. - * - * @param versionId Version identifier for the blob, pass {@code null} to interact with the latest blob version. - * @return the updated BlobClientBuilder object - */ - public BlobClientBuilder versionId(String versionId) { - this.versionId = versionId; - return this; - } - - /** - * Sets the {@link HttpClient} to use for sending and receiving requests to and from the service. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param httpClient The {@link HttpClient} to use for requests. - * @return the updated BlobClientBuilder object - */ - @Override - public BlobClientBuilder httpClient(HttpClient httpClient) { - if (this.httpClient != null && httpClient == null) { - LOGGER.info("'httpClient' is being set to 'null' when it was previously configured."); - } - - this.httpClient = httpClient; - return this; - } - - /** - * Adds a {@link HttpPipelinePolicy pipeline policy} to apply on each request sent. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param pipelinePolicy A {@link HttpPipelinePolicy pipeline policy}. - * @return the updated BlobClientBuilder object - * @throws NullPointerException If {@code pipelinePolicy} is {@code null}. - */ - @Override - public BlobClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) { - Objects.requireNonNull(pipelinePolicy, "'pipelinePolicy' cannot be null"); - if (pipelinePolicy.getPipelinePosition() == HttpPipelinePosition.PER_CALL) { - perCallPolicies.add(pipelinePolicy); - } else { - perRetryPolicies.add(pipelinePolicy); - } - return this; - } - - /** - * Sets the {@link HttpLogOptions logging configuration} to use when sending and receiving requests to and from - * the service. If a {@code logLevel} is not provided, default value of {@link HttpLogDetailLevel#NONE} is set. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param logOptions The {@link HttpLogOptions logging configuration} to use when sending and receiving requests to - * and from the service. - * @return the updated BlobClientBuilder object - * @throws NullPointerException If {@code logOptions} is {@code null}. - */ - @Override - public BlobClientBuilder httpLogOptions(HttpLogOptions logOptions) { - this.logOptions = Objects.requireNonNull(logOptions, "'logOptions' cannot be null."); - return this; - } - - /** - * Gets the default Storage allowlist log headers and query parameters. - * - * @return the default http log options. - */ - public static HttpLogOptions getDefaultHttpLogOptions() { - return BuilderHelper.getDefaultHttpLogOptions(); - } - - /** - * Sets the configuration object used to retrieve environment configuration values during building of the client. - * - * @param configuration Configuration store used to retrieve environment configurations. - * @return the updated BlobClientBuilder object - */ - @Override - public BlobClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /** - * Sets the request retry options for all the requests made through the client. - * - * Setting this is mutually exclusive with using {@link #retryOptions(RetryOptions)}. - * - * @param retryOptions {@link RequestRetryOptions}. - * @return the updated BlobClientBuilder object - */ - public BlobClientBuilder retryOptions(RequestRetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * Sets the {@link RetryOptions} for all the requests made through the client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * Setting this is mutually exclusive with using {@link #retryOptions(RequestRetryOptions)}. - * Consider using {@link #retryOptions(RequestRetryOptions)} to also set storage specific options. - * - * @param retryOptions The {@link RetryOptions} to use for all the requests made through the client. - * @return the updated BlobClientBuilder object - */ - @Override - public BlobClientBuilder retryOptions(RetryOptions retryOptions) { - this.coreRetryOptions = retryOptions; - return this; - } - - /** - * Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is - * recommended that this method be called with an instance of the {@link HttpClientOptions} - * class (a subclass of the {@link ClientOptions} base class). The HttpClientOptions subclass provides more - * configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait - * interface. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param clientOptions A configured instance of {@link HttpClientOptions}. - * @see HttpClientOptions - * @return the updated BlobClientBuilder object - * @throws NullPointerException If {@code clientOptions} is {@code null}. - */ - @Override - public BlobClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = Objects.requireNonNull(clientOptions, "'clientOptions' cannot be null."); - return this; - } - - /** - * Sets the {@link HttpPipeline} to use for the service client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * The {@link #endpoint(String) endpoint} is not ignored when {@code pipeline} is set. - * - * @param httpPipeline {@link HttpPipeline} to use for sending service requests and receiving responses. - * @return the updated BlobClientBuilder object - */ - @Override - public BlobClientBuilder pipeline(HttpPipeline httpPipeline) { - if (this.httpPipeline != null && httpPipeline == null) { - LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured."); - } - - this.httpPipeline = httpPipeline; - return this; - } - - /** - * Sets the {@link BlobServiceVersion} that is used when making API requests. - *

- * If a service version is not provided, the service version that will be used will be the latest known service - * version based on the version of the client library being used. If no service version is specified, updating to a - * newer version of the client library will have the result of potentially moving to a newer service version. - *

- * Targeting a specific service version may also mean that the service will return an error for newer APIs. - * - * @param version {@link BlobServiceVersion} of the service to be used when making requests. - * @return the updated BlobClientBuilder object - */ - public BlobClientBuilder serviceVersion(BlobServiceVersion version) { - this.version = version; - return this; - } - - /** - * Sets the Audience to use for authentication with Azure Active Directory (AAD). The audience is not considered - * when using a shared key. - * @param audience {@link BlobAudience} to be used when requesting a token from Azure Active Directory (AAD). - * @return the updated BlobClientBuilder object - */ - public BlobClientBuilder audience(BlobAudience audience) { - this.audience = audience; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java deleted file mode 100644 index 3313a5d32be7..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java +++ /dev/null @@ -1,1700 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedFlux; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.PagedResponseBase; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.AzureBlobStorageImpl; -import com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder; -import com.azure.storage.blob.implementation.accesshelpers.BlobItemConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobHierarchyListSegment; -import com.azure.storage.blob.implementation.models.ContainersGetAccountInfoHeaders; -import com.azure.storage.blob.implementation.models.ContainersGetPropertiesHeaders; -import com.azure.storage.blob.implementation.models.ContainersListBlobFlatSegmentHeaders; -import com.azure.storage.blob.implementation.models.ContainersListBlobHierarchySegmentHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.ListBlobsFlatSegmentResponse; -import com.azure.storage.blob.implementation.models.ListBlobsHierarchySegmentResponse; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobContainerAccessPolicies; -import com.azure.storage.blob.models.BlobContainerEncryptionScope; -import com.azure.storage.blob.models.BlobContainerProperties; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.ListBlobsIncludeItem; -import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.TaggedBlobItem; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Mono; - -import java.net.URI; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.core.util.FluxUtil.pagedFluxError; -import static com.azure.core.util.FluxUtil.withContext; - -/** - * Client to a container. It may only be instantiated through a {@link BlobContainerClientBuilder} or via the method - * {@link BlobServiceAsyncClient#getBlobContainerAsyncClient(String)}. This class does not hold any state about a - * particular blob but is instead a convenient way of sending off appropriate requests to the resource on the service. - * It may also be used to construct URLs to blobs. - * - *

- * This client contains operations on a container. Operations on a blob are available on {@link BlobAsyncClient} through - * {@link #getBlobAsyncClient(String)}, and operations on the service are available on {@link BlobServiceAsyncClient}. - * - *

- * Please refer to the Azure - * Docs for more information on containers. - * - *

- * Note this client is an async client that returns reactive responses from Spring Reactor Core project - * (https://projectreactor.io/). Calling the methods in this client will NOT start the actual network - * operation, until {@code .subscribe()} is called on the reactive response. You can simply convert one of these - * responses to a {@link java.util.concurrent.CompletableFuture} object through {@link Mono#toFuture()}. - */ -@ServiceClient(builder = BlobContainerClientBuilder.class, isAsync = true) -public final class BlobContainerAsyncClient { - /** - * Special container name for the root container in the Storage account. - */ - public static final String ROOT_CONTAINER_NAME = BlobConstants.ROOT_CONTAINER_NAME; - - /** - * Special container name for the static website container in the Storage account. - */ - public static final String STATIC_WEBSITE_CONTAINER_NAME = BlobConstants.STATIC_WEBSITE_CONTAINER_NAME; - - /** - * Special container name for the logs container in the Storage account. - */ - public static final String LOG_CONTAINER_NAME = BlobConstants.LOG_CONTAINER_NAME; - - private static final ClientLogger LOGGER = new ClientLogger(BlobContainerAsyncClient.class); - private final AzureBlobStorageImpl azureBlobStorage; - - private final String accountName; - private final String containerName; - private final BlobServiceVersion serviceVersion; - private final CpkInfo customerProvidedKey; // only used to pass down to blob clients - private final EncryptionScope encryptionScope; // only used to pass down to blob clients - private final BlobContainerEncryptionScope blobContainerEncryptionScope; - - /** - * Package-private constructor for use by {@link BlobContainerClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - */ - BlobContainerAsyncClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - String containerName, CpkInfo customerProvidedKey, EncryptionScope encryptionScope, - BlobContainerEncryptionScope blobContainerEncryptionScope) { - this.azureBlobStorage = new AzureBlobStorageImplBuilder().pipeline(pipeline) - .url(url) - .version(serviceVersion.getVersion()) - .buildClient(); - this.serviceVersion = serviceVersion; - - this.accountName = accountName; - this.containerName = containerName; - this.customerProvidedKey = customerProvidedKey; - this.encryptionScope = encryptionScope; - this.blobContainerEncryptionScope = blobContainerEncryptionScope; - /* Check to make sure the uri is valid. We don't want the error to occur later in the generated layer - when the sas token has already been applied. */ - try { - URI.create(getBlobContainerUrl()); - } catch (IllegalArgumentException ex) { - throw LOGGER.logExceptionAsError(ex); - } - } - - /** - * Creates a new BlobAsyncClient object by concatenating blobName to the end of ContainerAsyncClient's URL. The new - * BlobAsyncClient uses the same request policy pipeline as the ContainerAsyncClient. - * - *

Code Samples

- * - * - *
-     * BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName);
-     * 
- * - * - * @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters, - * pass in the url encoded version of the blob name. - * @return A new {@link BlobAsyncClient} object which references the blob with the specified name in this container. - */ - public BlobAsyncClient getBlobAsyncClient(String blobName) { - return getBlobAsyncClient(blobName, null); - } - - /** - * Creates a new BlobAsyncClient object by concatenating blobName to the end of ContainerAsyncClient's URL. The new - * BlobAsyncClient uses the same request policy pipeline as the ContainerAsyncClient. - * - *

Code Samples

- * - * - *
-     * BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName, snapshot);
-     * 
- * - * - * @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters, - * pass in the url encoded version of the blob name. - * @param snapshot the snapshot identifier for the blob. - * @return A new {@link BlobAsyncClient} object which references the blob with the specified name in this container. - */ - public BlobAsyncClient getBlobAsyncClient(String blobName, String snapshot) { - return new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getBlobContainerName(), blobName, snapshot, getCustomerProvidedKey(), encryptionScope); - } - - /** - * Creates a new BlobAsyncClient object by concatenating blobName to the end of ContainerAsyncClient's URL. The new - * BlobAsyncClient uses the same request policy pipeline as the ContainerAsyncClient. - * - * @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters, - * pass in the url encoded version of the blob name. - * @param versionId the version identifier for the blob, pass {@code null} to interact with the latest blob version. - * @return A new {@link BlobAsyncClient} object which references the blob with the specified name in this container. - */ - public BlobAsyncClient getBlobVersionAsyncClient(String blobName, String versionId) { - return new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getBlobContainerName(), blobName, null, getCustomerProvidedKey(), encryptionScope, versionId); - } - - /** - * Get the url of the storage account. - * - * @return the URL of the storage account - */ - public String getAccountUrl() { - return azureBlobStorage.getUrl(); - } - - /** - * Gets the URL of the container represented by this client. - * - * @return the URL. - */ - public String getBlobContainerUrl() { - return azureBlobStorage.getUrl() + "/" + containerName; - } - - /** - * Get the container name. - * - *

Code Samples

- * - * - *
-     * String containerName = client.getBlobContainerName();
-     * System.out.println("The name of the blob is " + containerName);
-     * 
- * - * - * @return The name of container. - */ - public String getBlobContainerName() { - return containerName; - } - - /** - * Get associated account name. - * - * @return account name associated with this storage resource. - */ - public String getAccountName() { - return this.accountName; - } - - /** - * Get an async client pointing to the account. - * - * @return {@link BlobServiceAsyncClient} - */ - public BlobServiceAsyncClient getServiceAsyncClient() { - return getServiceClientBuilder().buildAsyncClient(); - } - - BlobServiceClientBuilder getServiceClientBuilder() { - CustomerProvidedKey encryptionKey = this.customerProvidedKey == null - ? null - : new CustomerProvidedKey(this.customerProvidedKey.getEncryptionKey()); - return new BlobServiceClientBuilder().endpoint(this.getBlobContainerUrl()) - .pipeline(this.getHttpPipeline()) - .serviceVersion(this.serviceVersion) - .blobContainerEncryptionScope(this.blobContainerEncryptionScope) - .encryptionScope(this.getEncryptionScope()) - .customerProvidedKey(encryptionKey); - } - - /** - * Gets the service version the client is using. - * - * @return the service version the client is using. - */ - public BlobServiceVersion getServiceVersion() { - return serviceVersion; - } - - /** - * Gets the {@link HttpPipeline} powering this client. - * - * @return The pipeline. - */ - public HttpPipeline getHttpPipeline() { - return azureBlobStorage.getHttpPipeline(); - } - - /** - * Gets the {@link CpkInfo} associated with this client that will be passed to {@link BlobAsyncClient - * BlobAsyncClients} when {@link #getBlobAsyncClient(String) getBlobAsyncClient} is called. - * - * @return the customer provided key used for encryption. - */ - public CpkInfo getCustomerProvidedKey() { - return customerProvidedKey; - } - - /** - * Gets the {@link EncryptionScope} used to encrypt this blob's content on the server. - * - * @return the encryption scope used for encryption. - */ - public String getEncryptionScope() { - if (encryptionScope == null) { - return null; - } - return encryptionScope.getEncryptionScope(); - } - - /** - * Gets if the container this client represents exists in the cloud. - * - *

Code Samples

- * - * - *
-     * client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
-     * 
- * - * - * @return true if the container exists, false if it doesn't - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono exists() { - return existsWithResponse().flatMap(FluxUtil::toMono); - } - - /** - * Gets if the container this client represents exists in the cloud. - * - *

Code Samples

- * - * - *
-     * client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
-     * 
- * - * - * @return true if the container exists, false if it doesn't - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> existsWithResponse() { - try { - return withContext(this::existsWithResponse); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Gets if the container this client represents exists in the cloud. - * - * @return true if the container exists, false if it doesn't - */ - Mono> existsWithResponse(Context context) { - return this.getPropertiesWithResponse(null, context) - .map(cp -> (Response) new SimpleResponse<>(cp, true)) - .onErrorResume(t -> t instanceof BlobStorageException && ((BlobStorageException) t).getStatusCode() == 404, - t -> { - HttpResponse response = ((BlobStorageException) t).getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), false)); - }); - } - - /** - * Creates a new container within a storage account. If a container with the same name already exists, the operation - * fails. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.create().subscribe(
-     *     response -> System.out.printf("Create completed%n"),
-     *     error -> System.out.printf("Error while creating container %s%n", error));
-     * 
- * - * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono create() { - return createWithResponse(null, null).flatMap(FluxUtil::toMono); - } - - /** - * Creates a new container within a storage account. If a container with the same name already exists, the operation - * fails. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * client.createWithResponse(metadata, PublicAccessType.CONTAINER).subscribe(response ->
-     *     System.out.printf("Create completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param accessType Specifies how the data in this container is available to the public. See the - * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponse(Map metadata, PublicAccessType accessType) { - try { - return withContext(context -> createWithResponse(metadata, accessType, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> createWithResponse(Map metadata, PublicAccessType accessType, - Context context) { - context = context == null ? Context.NONE : context; - return this.azureBlobStorage.getContainers() - .createNoCustomHeadersWithResponseAsync(containerName, null, metadata, accessType, null, - blobContainerEncryptionScope, context); - } - - /** - * Creates a new container within a storage account if it does not exist. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.createIfNotExists().subscribe(created -> {
-     *     if (created) {
-     *         System.out.println("successfully created.");
-     *     } else {
-     *         System.out.println("Already exists.");
-     *     }
-     * });
-     * 
- * - * - * @return A reactive response signaling completion. {@code true} indicates a new container was created, - * {@code true} indicates a container already existed at this location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createIfNotExists() { - return createIfNotExistsWithResponse(null).flatMap(FluxUtil::toMono); - } - - /** - * Creates a new container within a storage account if it does not exist. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata)
-     *     .setPublicAccessType(PublicAccessType.CONTAINER);
-     *
-     * client.createIfNotExistsWithResponse(options).subscribe(response -> {
-     *     if (response.getStatusCode() == 409) {
-     *         System.out.println("Already exists.");
-     *     } else {
-     *         System.out.println("successfully created.");
-     *     }
-     * });
-     * 
- * - * - * @param options {@link BlobContainerCreateOptions} - * @return A reactive response signaling completion. If {@link Response}'s status code is 201, a new container was - * successfully created. If status code is 409, a container already existed at this location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createIfNotExistsWithResponse(BlobContainerCreateOptions options) { - try { - return createIfNotExistsWithResponse(options, null); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> createIfNotExistsWithResponse(BlobContainerCreateOptions options, Context context) { - try { - options = options == null ? new BlobContainerCreateOptions() : options; - return createWithResponse(options.getMetadata(), options.getPublicAccessType(), context) - .map(response -> (Response) new SimpleResponse<>(response, true)) - .onErrorResume( - t -> t instanceof BlobStorageException && ((BlobStorageException) t).getStatusCode() == 409, t -> { - HttpResponse response = ((BlobStorageException) t).getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), false)); - }); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Marks the specified container for deletion. The container and any blobs contained within it are later deleted - * during garbage collection. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.delete().subscribe(
-     *     response -> System.out.printf("Delete completed%n"),
-     *     error -> System.out.printf("Delete failed: %s%n", error));
-     * 
- * - * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono delete() { - return deleteWithResponse(null).flatMap(FluxUtil::toMono); - } - - /** - * Marks the specified container for deletion. The container and any blobs contained within it are later deleted - * during garbage collection. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.deleteWithResponse(requestConditions).subscribe(response ->
-     *     System.out.printf("Delete completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response signalling completion. - * @throws UnsupportedOperationException If either {@link BlobRequestConditions#getIfMatch()} or - * {@link BlobRequestConditions#getIfNoneMatch()} is set. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithResponse(BlobRequestConditions requestConditions) { - try { - return withContext(context -> deleteWithResponse(requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> deleteWithResponse(BlobRequestConditions requestConditions, Context context) { - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - if (!ModelHelper.validateNoETag(requestConditions)) { - // Throwing is preferred to Mono.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new UnsupportedOperationException("ETag access conditions are not supported for this API.")); - } - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getContainers() - .deleteNoCustomHeadersWithResponseAsync(containerName, null, requestConditions.getLeaseId(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), null, context); - } - - /** - * Marks the specified container for deletion if it exists. The container and any blobs contained within it are later deleted - * during garbage collection. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.deleteIfExists().subscribe(deleted -> {
-     *     if (deleted) {
-     *         System.out.println("Successfully deleted.");
-     *     } else {
-     *         System.out.println("Does not exist.");
-     *     }
-     * });
-     * 
- * - * - * @return A reactive response signaling completion. {@code true} indicates the container was deleted, - * {@code false} indicates the container does not exist. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteIfExists() { - return deleteIfExistsWithResponse(null).flatMap(FluxUtil::toMono); - } - - /** - * Marks the specified container for deletion if it exists. The container and any blobs contained within it are - * later deleted during garbage collection. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.deleteIfExistsWithResponse(requestConditions).subscribe(response -> {
-     *     if (response.getStatusCode() == 404) {
-     *         System.out.println("Does not exist.");
-     *     } else {
-     *         System.out.println("successfully deleted.");
-     *     }
-     * });
-     * 
- * - * - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response signaling completion. If {@link Response}'s status code is 202, the container was - * successfully deleted. If status code is 404, the container does not exist. - * @throws UnsupportedOperationException If either {@link BlobRequestConditions#getIfMatch()} or - * {@link BlobRequestConditions#getIfNoneMatch()} is set. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteIfExistsWithResponse(BlobRequestConditions requestConditions) { - try { - return deleteIfExistsWithResponse(requestConditions, null); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> deleteIfExistsWithResponse(BlobRequestConditions requestConditions, Context context) { - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - try { - return deleteWithResponse(requestConditions, context) - .map(response -> (Response) new SimpleResponse<>(response, true)) - .onErrorResume( - t -> t instanceof BlobStorageException && ((BlobStorageException) t).getStatusCode() == 404, t -> { - HttpResponse response = ((BlobStorageException) t).getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), false)); - }); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Returns the container's metadata and system properties. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getProperties().subscribe(response ->
-     *     System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
-     *         response.getBlobPublicAccess(),
-     *         response.hasLegalHold(),
-     *         response.hasImmutabilityPolicy()));
-     * 
- * - * - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} containing the - * container properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getProperties() { - return getPropertiesWithResponse(null).flatMap(FluxUtil::toMono); - } - - /** - * Returns the container's metadata and system properties. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getPropertiesWithResponse(leaseId).subscribe(response ->
-     *     System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
-     *         response.getValue().getBlobPublicAccess(),
-     *         response.getValue().hasLegalHold(),
-     *         response.getValue().hasImmutabilityPolicy()));
-     * 
- * - * - * @param leaseId The lease ID the active lease on the container must match. - * @return A reactive response containing the container properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesWithResponse(String leaseId) { - try { - return withContext(context -> getPropertiesWithResponse(leaseId, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getPropertiesWithResponse(String leaseId, Context context) { - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getContainers() - .getPropertiesWithResponseAsync(containerName, null, leaseId, null, context) - .map(rb -> { - ContainersGetPropertiesHeaders hd = rb.getDeserializedHeaders(); - BlobContainerProperties properties = new BlobContainerProperties(hd.getXMsMeta(), hd.getETag(), - hd.getLastModified(), hd.getXMsLeaseDuration(), hd.getXMsLeaseState(), hd.getXMsLeaseStatus(), - hd.getXMsBlobPublicAccess(), Boolean.TRUE.equals(hd.isXMsHasImmutabilityPolicy()), - Boolean.TRUE.equals(hd.isXMsHasLegalHold()), hd.getXMsDefaultEncryptionScope(), - hd.isXMsDenyEncryptionScopeOverride(), hd.isXMsImmutableStorageWithVersioningEnabled()); - return new SimpleResponse<>(rb, properties); - }); - } - - /** - * Sets the container's metadata. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * client.setMetadata(metadata).subscribe(
-     *     response -> System.out.printf("Set metadata completed%n"),
-     *     error -> System.out.printf("Set metadata failed: %s%n", error));
-     * 
- * - * - * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains signalling - * completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setMetadata(Map metadata) { - return setMetadataWithResponse(metadata, null).flatMap(FluxUtil::toMono); - } - - /** - * Sets the container's metadata. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.setMetadataWithResponse(metadata, requestConditions).subscribe(response ->
-     *     System.out.printf("Set metadata completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response signalling completion. - * @throws UnsupportedOperationException If one of {@link BlobRequestConditions#getIfMatch()}, - * {@link BlobRequestConditions#getIfNoneMatch()}, or {@link BlobRequestConditions#getIfUnmodifiedSince()} is set. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataWithResponse(Map metadata, - BlobRequestConditions requestConditions) { - try { - return withContext(context -> setMetadataWithResponse(metadata, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> setMetadataWithResponse(Map metadata, BlobRequestConditions requestConditions, - Context context) { - context = context == null ? Context.NONE : context; - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - if (!ModelHelper.validateNoETag(requestConditions) || requestConditions.getIfUnmodifiedSince() != null) { - // Throwing is preferred to Mono.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError(new UnsupportedOperationException( - "If-Modified-Since is the only HTTP access condition supported for this API")); - } - - return this.azureBlobStorage.getContainers() - .setMetadataNoCustomHeadersWithResponseAsync(containerName, null, requestConditions.getLeaseId(), metadata, - requestConditions.getIfModifiedSince(), null, context); - } - - /** - * Returns the container's permissions. The permissions indicate whether container's blobs may be accessed publicly. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getAccessPolicy().subscribe(response -> {
-     *     System.out.printf("Blob Access Type: %s%n", response.getBlobAccessType());
-     *
-     *     for (BlobSignedIdentifier identifier : response.getIdentifiers()) {
-     *         System.out.printf("Identifier Name: %s, Permissions %s%n",
-     *             identifier.getId(),
-     *             identifier.getAccessPolicy().getPermissions());
-     *     }
-     * });
-     * 
- * - * - * @return A reactive response containing the container access policy. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccessPolicy() { - return getAccessPolicyWithResponse(null).flatMap(FluxUtil::toMono); - } - - /** - * Returns the container's permissions. The permissions indicate whether container's blobs may be accessed publicly. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getAccessPolicyWithResponse(leaseId).subscribe(response -> {
-     *     System.out.printf("Blob Access Type: %s%n", response.getValue().getBlobAccessType());
-     *
-     *     for (BlobSignedIdentifier identifier : response.getValue().getIdentifiers()) {
-     *         System.out.printf("Identifier Name: %s, Permissions %s%n",
-     *             identifier.getId(),
-     *             identifier.getAccessPolicy().getPermissions());
-     *     }
-     * });
-     * 
- * - * - * @param leaseId The lease ID the active lease on the container must match. - * @return A reactive response containing the container access policy. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccessPolicyWithResponse(String leaseId) { - try { - return withContext(context -> getAccessPolicyWithResponse(leaseId, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getAccessPolicyWithResponse(String leaseId, Context context) { - context = context == null ? Context.NONE : context; - return this.azureBlobStorage.getContainers() - .getAccessPolicyWithResponseAsync(containerName, null, leaseId, null, context) - .map(response -> new SimpleResponse<>(response, new BlobContainerAccessPolicies( - response.getDeserializedHeaders().getXMsBlobPublicAccess(), response.getValue().items()))); - } - - /** - * Sets the container's permissions. The permissions indicate whether blobs in a container may be accessed publicly. - * Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to - * ensure the time formatting is compatible with the service. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobSignedIdentifier identifier = new BlobSignedIdentifier()
-     *     .setId("name")
-     *     .setAccessPolicy(new BlobAccessPolicy()
-     *         .setStartsOn(OffsetDateTime.now())
-     *         .setExpiresOn(OffsetDateTime.now().plusDays(7))
-     *         .setPermissions("permissionString"));
-     *
-     * client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)).subscribe(
-     *     response -> System.out.printf("Set access policy completed%n"),
-     *     error -> System.out.printf("Set access policy failed: %s%n", error));
-     * 
- * - * - * @param accessType Specifies how the data in this container is available to the public. See the - * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. - * @param identifiers A list of {@link BlobSignedIdentifier} objects that specify the permissions for the container. - * Please see - * here - * for more information. Passing null will clear all access policies. - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setAccessPolicy(PublicAccessType accessType, List identifiers) { - return setAccessPolicyWithResponse(accessType, identifiers, null).flatMap(FluxUtil::toMono); - } - - /** - * Sets the container's permissions. The permissions indicate whether blobs in a container may be accessed publicly. - * Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to - * ensure the time formatting is compatible with the service. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobSignedIdentifier identifier = new BlobSignedIdentifier()
-     *     .setId("name")
-     *     .setAccessPolicy(new BlobAccessPolicy()
-     *         .setStartsOn(OffsetDateTime.now())
-     *         .setExpiresOn(OffsetDateTime.now().plusDays(7))
-     *         .setPermissions("permissionString"));
-     *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, Collections.singletonList(identifier), requestConditions)
-     *     .subscribe(response ->
-     *         System.out.printf("Set access policy completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param accessType Specifies how the data in this container is available to the public. See the - * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. - * @param identifiers A list of {@link BlobSignedIdentifier} objects that specify the permissions for the container. - * Please see - * here - * for more information. Passing null will clear all access policies. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response signalling completion. - * @throws UnsupportedOperationException If either {@link BlobRequestConditions#getIfMatch()} or - * {@link BlobRequestConditions#getIfNoneMatch()} is set. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setAccessPolicyWithResponse(PublicAccessType accessType, - List identifiers, BlobRequestConditions requestConditions) { - try { - return withContext( - context -> setAccessPolicyWithResponse(accessType, identifiers, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> setAccessPolicyWithResponse(PublicAccessType accessType, - List identifiers, BlobRequestConditions requestConditions, Context context) { - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - if (!ModelHelper.validateNoETag(requestConditions)) { - // Throwing is preferred to Mono.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new UnsupportedOperationException("ETag access conditions are not supported for this API.")); - } - - List finalIdentifiers = ModelHelper.truncateTimeForBlobSignedIdentifier(identifiers); - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getContainers() - .setAccessPolicyNoCustomHeadersWithResponseAsync(containerName, null, requestConditions.getLeaseId(), - accessType, requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), null, - finalIdentifiers, context); - } - - /** - * Returns a reactive Publisher emitting all the blobs in this container lazily as needed. The directories are - * flattened and only actual blobs and no directories are returned. - * - *

- * Blob names are returned in lexicographic order. For more information, see the - * Azure Docs. - * - *

- * E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the - * root level 'bar', will return - * - *

    - *
  • foo/foo1 - *
  • foo/foo2 - *
  • bar - *
- * - *

Code Samples

- * - * - *
-     * client.listBlobs().subscribe(blob ->
-     *     System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix()));
-     * 
- * - * - * @return A reactive response emitting the flattened blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobs() { - return this.listBlobs(new ListBlobsOptions()); - } - - /** - * Returns a reactive Publisher emitting all the blobs in this container lazily as needed. The directories are - * flattened and only actual blobs and no directories are returned. - * - *

- * Blob names are returned in lexicographic order. For more information, see the - * Azure Docs. - * - *

- * E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the - * root level 'bar', will return - * - *

    - *
  • foo/foo1 - *
  • foo/foo2 - *
  • bar - *
- * - * - * - * - *
-     * ListBlobsOptions options = new ListBlobsOptions()
-     *     .setPrefix("prefixToMatch")
-     *     .setDetails(new BlobListDetails()
-     *         .setRetrieveDeletedBlobs(true)
-     *         .setRetrieveSnapshots(true));
-     *
-     * client.listBlobs(options).subscribe(blob ->
-     *     System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
-     *         blob.getName(),
-     *         blob.isPrefix(),
-     *         blob.isDeleted(),
-     *         blob.getSnapshot()));
-     * 
- * - * - * @param options {@link ListBlobsOptions} - * @return A reactive response emitting the listed blobs, flattened. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobs(ListBlobsOptions options) { - return listBlobs(options, null); - } - - /** - * Returns a reactive Publisher emitting all the blobs in this container lazily as needed. The directories are - * flattened and only actual blobs and no directories are returned. - * - *

- * Blob names are returned in lexicographic order. For more information, see the - * Azure Docs. - * - *

- * E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the - * root level 'bar', will return - * - *

    - *
  • foo/foo1 - *
  • foo/foo2 - *
  • bar - *
- * - * - * - * - *
-     * ListBlobsOptions options = new ListBlobsOptions()
-     *     .setPrefix("prefixToMatch")
-     *     .setDetails(new BlobListDetails()
-     *         .setRetrieveDeletedBlobs(true)
-     *         .setRetrieveSnapshots(true));
-     *
-     * String continuationToken = "continuationToken";
-     *
-     * client.listBlobs(options, continuationToken).subscribe(blob ->
-     *     System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
-     *         blob.getName(),
-     *         blob.isPrefix(),
-     *         blob.isDeleted(),
-     *         blob.getSnapshot()));
-     * 
- * - * - * @param options {@link ListBlobsOptions} - * @param continuationToken Identifies the portion of the list to be returned with the next list operation. - * @return A reactive response emitting the listed blobs, flattened. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobs(ListBlobsOptions options, String continuationToken) { - try { - return listBlobsFlatWithOptionalTimeout(options, continuationToken, null); - } catch (RuntimeException ex) { - return pagedFluxError(LOGGER, ex); - } - } - - /* - * Implementation for this paged listing operation, supporting an optional timeout provided by the synchronous - * ContainerClient. Applies the given timeout to each - * Mono> backing the PagedFlux. - * - * @param options {@link ListBlobsOptions}. - * @param timeout An optional timeout to be applied to the network asynchronous operations. - * @return A reactive response emitting the listed blobs, flattened. - */ - PagedFlux listBlobsFlatWithOptionalTimeout(ListBlobsOptions options, String continuationToken, - Duration timeout) { - BiFunction>> func = (marker, pageSize) -> { - ListBlobsOptions finalOptions; - if (pageSize != null) { - if (options == null) { - finalOptions = new ListBlobsOptions().setMaxResultsPerPage(pageSize); - } else { - finalOptions = new ListBlobsOptions().setMaxResultsPerPage(pageSize) - .setPrefix(options.getPrefix()) - .setDetails(options.getDetails()); - } - } else { - finalOptions = options; - } - - return listBlobsFlatSegment(marker, finalOptions, timeout).map(response -> { - List value = response.getValue().getSegment() == null - ? Collections.emptyList() - : response.getValue() - .getSegment() - .getBlobItems() - .stream() - .map(ModelHelper::populateBlobItem) - .collect(Collectors.toList()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - value, response.getValue().getNextMarker(), response.getDeserializedHeaders()); - }); - }; - return new PagedFlux<>(pageSize -> func.apply(continuationToken, pageSize), func); - } - - /* - * Returns a single segment of blobs starting from the specified Marker. Use an empty - * marker to start enumeration from the beginning. Blob names are returned in lexicographic order. - * After getting a segment, process it, and then call ListBlobs again (passing the previously-returned - * Marker) to get the next segment. For more information, see the - * Azure Docs. - * - * @param marker - * Identifies the portion of the list to be returned with the next list operation. - * This value is returned by the response of a previous list operation as the - * ListBlobsFlatSegmentResponse.body().getNextMarker(). Set to null to list the first segment. - * @param options - * {@link ListBlobsOptions} - * - * @return Emits the successful response. - */ - private Mono> - listBlobsFlatSegment(String marker, ListBlobsOptions options, Duration timeout) { - options = options == null ? new ListBlobsOptions() : options; - - ArrayList include - = options.getDetails().toList().isEmpty() ? null : options.getDetails().toList(); - - return StorageImplUtils.applyOptionalTimeout(this.azureBlobStorage.getContainers() - .listBlobFlatSegmentWithResponseAsync(containerName, options.getPrefix(), marker, - options.getMaxResultsPerPage(), include, null, null, Context.NONE), - timeout); - } - - /** - * Returns a reactive Publisher emitting all the blobs and directories (prefixes) under the given directory - * (prefix). Directories will have {@link BlobItem#isPrefix()} set to true. - * - *

- * Blob names are returned in lexicographic order. For more information, see the - * Azure Docs. - * - *

- * E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the - * root level 'bar', will return the following results when prefix=null: - * - *

    - *
  • foo/ (isPrefix = true) - *
  • bar (isPrefix = false) - *
- *

- * will return the following results when prefix="foo/": - * - *

    - *
  • foo/foo1 (isPrefix = false) - *
  • foo/foo2 (isPrefix = false) - *
- * - *

Code Samples

- * - * - *
-     * client.listBlobsByHierarchy("directoryName").subscribe(blob ->
-     *     System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isDeleted()));
-     * 
- * - * - * @param directory The directory to list blobs underneath - * @return A reactive response emitting the prefixes and blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobsByHierarchy(String directory) { - return this.listBlobsByHierarchy("/", new ListBlobsOptions().setPrefix(directory)); - } - - /** - * Returns a reactive Publisher emitting all the blobs and prefixes (directories) under the given prefix - * (directory). Directories will have {@link BlobItem#isPrefix()} set to true. - * - *

- * Blob names are returned in lexicographic order. For more information, see the - * Azure Docs. - * - *

- * E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the - * root level 'bar', will return the following results when prefix=null: - * - *

    - *
  • foo/ (isPrefix = true) - *
  • bar (isPrefix = false) - *
- *

- * will return the following results when prefix="foo/": - * - *

    - *
  • foo/foo1 (isPrefix = false) - *
  • foo/foo2 (isPrefix = false) - *
- * - *

Code Samples

- * - * - *
-     * ListBlobsOptions options = new ListBlobsOptions()
-     *     .setPrefix("directoryName")
-     *     .setDetails(new BlobListDetails()
-     *         .setRetrieveDeletedBlobs(true)
-     *         .setRetrieveSnapshots(true));
-     *
-     * client.listBlobsByHierarchy("/", options).subscribe(blob ->
-     *     System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
-     *         blob.getName(),
-     *         blob.isPrefix(),
-     *         blob.isDeleted(),
-     *         blob.getSnapshot()));
-     * 
- * - * - * @param delimiter The delimiter for blob hierarchy, "/" for hierarchy based on directories - * @param options {@link ListBlobsOptions} - * @return A reactive response emitting the prefixes and blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobsByHierarchy(String delimiter, ListBlobsOptions options) { - try { - return listBlobsHierarchyWithOptionalTimeout(delimiter, options, null); - } catch (RuntimeException ex) { - return pagedFluxError(LOGGER, ex); - } - } - - /* - * Implementation for this paged listing operation, supporting an optional timeout provided by the synchronous - * ContainerClient. Applies the given timeout to each - * Mono> backing the - * PagedFlux. - * - * @param delimiter The delimiter for blob hierarchy, "/" for hierarchy based on directories - * @param options {@link ListBlobsOptions} - * @param timeout An optional timeout to be applied to the network asynchronous operations. - * @return A reactive response emitting the listed blobs, flattened. - */ - PagedFlux listBlobsHierarchyWithOptionalTimeout(String delimiter, ListBlobsOptions options, - Duration timeout) { - BiFunction>> func = (marker, pageSize) -> { - ListBlobsOptions finalOptions; - /* - If pageSize was not set in a .byPage(int) method, the page size from options will be preserved. - Otherwise, prefer the new value. - */ - if (pageSize != null) { - if (options == null) { - finalOptions = new ListBlobsOptions().setMaxResultsPerPage(pageSize); - } else { - // Note that this prefers the value passed to .byPage(int) over the value on the options - finalOptions = new ListBlobsOptions().setMaxResultsPerPage(pageSize) - .setPrefix(options.getPrefix()) - .setDetails(options.getDetails()); - } - } else { - finalOptions = options; - } - return listBlobsHierarchySegment(marker, delimiter, finalOptions, timeout).map(response -> { - BlobHierarchyListSegment segment = response.getValue().getSegment(); - List value; - if (segment == null) { - value = Collections.emptyList(); - } else { - value = new ArrayList<>(segment.getBlobItems().size() + segment.getBlobPrefixes().size()); - segment.getBlobItems().forEach(item -> value.add(BlobItemConstructorProxy.create(item))); - segment.getBlobPrefixes() - .forEach(prefix -> value.add( - new BlobItem().setName(ModelHelper.toBlobNameString(prefix.getName())).setIsPrefix(true))); - } - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - value, response.getValue().getNextMarker(), response.getDeserializedHeaders()); - }); - }; - return new PagedFlux<>(pageSize -> func.apply(null, pageSize), func); - } - - private Mono> - listBlobsHierarchySegment(String marker, String delimiter, ListBlobsOptions options, Duration timeout) { - options = options == null ? new ListBlobsOptions() : options; - if (options.getDetails().getRetrieveSnapshots()) { - throw LOGGER.logExceptionAsError( - new UnsupportedOperationException("Including snapshots in a hierarchical listing is not supported.")); - } - - ArrayList include - = options.getDetails().toList().isEmpty() ? null : options.getDetails().toList(); - - return StorageImplUtils.applyOptionalTimeout(this.azureBlobStorage.getContainers() - .listBlobHierarchySegmentWithResponseAsync(containerName, delimiter, options.getPrefix(), marker, - options.getMaxResultsPerPage(), include, null, null, Context.NONE), - timeout); - } - - /** - * Returns a reactive Publisher emitting the blobs in this container whose tags match the query expression. For more - * information, including information on the query syntax, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.findBlobsByTags("where=tag=value").subscribe(blob -> System.out.printf("Name: %s%n", blob.getName()));
-     * 
- * - * - * @param query Filters the results to return only blobs whose tags match the specified expression. - * @return A reactive response emitting the list of blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux findBlobsByTags(String query) { - try { - return this.findBlobsByTags(new FindBlobsOptions(query)); - } catch (RuntimeException ex) { - return pagedFluxError(LOGGER, ex); - } - } - - /** - * Returns a reactive Publisher emitting the blobs in this container whose tags match the query expression. For more - * information, including information on the query syntax, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10))
-     *     .subscribe(blob -> System.out.printf("Name: %s%n", blob.getName()));
-     * 
- * - * - * @param options {@link FindBlobsOptions} - * @return A reactive response emitting the list of blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux findBlobsByTags(FindBlobsOptions options) { - try { - return findBlobsByTags(options, null); - } catch (RuntimeException ex) { - return pagedFluxError(LOGGER, ex); - } - } - - PagedFlux findBlobsByTags(FindBlobsOptions options, Duration timeout) { - StorageImplUtils.assertNotNull("options", options); - BiFunction>> func = (marker, pageSize) -> withContext( - context -> this.findBlobsByTags(new FindBlobsOptions(options.getQuery()).setMaxResultsPerPage(pageSize), - marker, timeout, context)); - return new PagedFlux<>(pageSize -> func.apply(null, pageSize), func); - } - - PagedFlux findBlobsByTags(FindBlobsOptions options, Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", options); - BiFunction>> func = (marker, pageSize) -> { - FindBlobsOptions finalOptions; - if (pageSize != null) { - finalOptions = new FindBlobsOptions(options.getQuery()).setMaxResultsPerPage(pageSize); - } else { - finalOptions = options; - } - return this.findBlobsByTags(finalOptions, marker, timeout, context); - }; - return new PagedFlux<>(pageSize -> func.apply(null, pageSize), func); - } - - private Mono> findBlobsByTags(FindBlobsOptions options, String marker, - Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", options); - return StorageImplUtils.applyOptionalTimeout(this.azureBlobStorage.getContainers() - .filterBlobsWithResponseAsync(containerName, null, null, options.getQuery(), marker, - options.getMaxResultsPerPage(), null, context), - timeout).map(response -> { - List value = response.getValue() - .getBlobs() - .stream() - .map(ModelHelper::populateTaggedBlobItem) - .collect(Collectors.toList()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - value, response.getValue().getNextMarker(), response.getDeserializedHeaders()); - }); - } - - /** - * Returns the sku name and account kind for the account. For more information, please see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getAccountInfo().subscribe(response ->
-     *     System.out.printf("Account Kind: %s, SKU: %s%n",
-     *         response.getAccountKind(),
-     *         response.getSkuName()));
-     * 
- * - * - * @return A reactive response containing the account info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccountInfo() { - return getAccountInfoWithResponse().flatMap(FluxUtil::toMono); - } - - /** - * Returns the sku name and account kind for the account. For more information, please see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getAccountInfoWithResponse().subscribe(response ->
-     *     System.out.printf("Account Kind: %s, SKU: %s%n",
-     *         response.getValue().getAccountKind(),
-     *         response.getValue().getSkuName()));
-     * 
- * - * - * @return A reactive response containing the account info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoWithResponse() { - try { - return withContext(this::getAccountInfoWithResponse); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getAccountInfoWithResponse(Context context) { - context = context == null ? Context.NONE : context; - return this.azureBlobStorage.getContainers() - .getAccountInfoWithResponseAsync(containerName, null, null, context) - .map(rb -> { - ContainersGetAccountInfoHeaders hd = rb.getDeserializedHeaders(); - return new SimpleResponse<>(rb, - new StorageAccountInfo(hd.getXMsSkuName(), hd.getXMsAccountKind(), hd.isXMsIsHnsEnabled())); - }); - } - - // TODO: Reintroduce this API once service starts supporting it. - // Mono rename(String destinationContainerName) { - // return renameWithResponse(new BlobContainerRenameOptions(destinationContainerName)).flatMap(FluxUtil::toMono); - // } - - // TODO: Reintroduce this API once service starts supporting it. - // Mono> renameWithResponse(BlobContainerRenameOptions options) { - // try { - // return withContext(context -> this.renameWithResponse(options, context)); - // } catch (RuntimeException ex) { - // return monoError(LOGGER, ex); - // } - // } - - // Mono> renameWithResponse(BlobContainerRenameOptions options, Context context) { - // BlobContainerAsyncClient destinationContainerClient = getServiceAsyncClient() - // .getBlobContainerAsyncClient(options.getDestinationContainerName()); - // return destinationContainerClient.renameWithResponseHelper(this.getBlobContainerName(), options, context); - // } - - // Mono> renameWithResponseHelper(String sourceContainerName, - // BlobContainerRenameOptions options, Context context) { - // StorageImplUtils.assertNotNull("options", options); - // BlobRequestConditions requestConditions = options.getRequestConditions() == null ? new BlobRequestConditions() - // : options.getRequestConditions(); - // context = context == null ? Context.NONE : context; - // - // if (!validateNoETag(requestConditions) || !validateNoTime(requestConditions) - // || requestConditions.getTagsConditions() != null) { - // throw LOGGER.logExceptionAsError(new UnsupportedOperationException( - // "Lease-Id is the only HTTP access condition supported for this API")); - // } - // - // return this.azureBlobStorage.getContainers().renameWithResponseAsync(containerName, - // sourceContainerName, null, null, requestConditions.getLeaseId(), - // context) - // .onErrorMap(ModelHelper::mapToBlobStorageException) - // .map(response -> new SimpleResponse<>(response, this)); - // } - - /** - * Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateUserDelegationSas(values, userDelegationKey);
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey) { - return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, getAccountName(), - Context.NONE); - } - - /** - * Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value"));
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * @param accountName The account name. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey, String accountName, Context context) { - return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, accountName, null, context); - } - - /** - * Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * @param accountName The account name. - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey, String accountName, Consumer stringToSignHandler, - Context context) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName()) - .generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context); - } - - /** - * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return generateSas(blobServiceSasSignatureValues, Context.NONE); - } - - /** - * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * // Client must be authenticated via StorageSharedKeyCredential
-     * client.generateSas(values, new Context("key", "value"));
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context) { - return generateSas(blobServiceSasSignatureValues, null, context); - } - - /** - * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - Consumer stringToSignHandler, Context context) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName()) - .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); - } - - // private boolean validateNoTime(BlobRequestConditions modifiedRequestConditions) { - // if (modifiedRequestConditions == null) { - // return true; - // } - // return modifiedRequestConditions.getIfModifiedSince() == null - // && modifiedRequestConditions.getIfUnmodifiedSince() == null; - // } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java deleted file mode 100644 index 1724f308270c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java +++ /dev/null @@ -1,1511 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.PagedResponseBase; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.AzureBlobStorageImpl; -import com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder; -import com.azure.storage.blob.implementation.accesshelpers.BlobItemConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobHierarchyListSegment; -import com.azure.storage.blob.implementation.models.BlobSignedIdentifierWrapper; -import com.azure.storage.blob.implementation.models.ContainersFilterBlobsHeaders; -import com.azure.storage.blob.implementation.models.ContainersGetAccessPolicyHeaders; -import com.azure.storage.blob.implementation.models.ContainersGetAccountInfoHeaders; -import com.azure.storage.blob.implementation.models.ContainersGetPropertiesHeaders; -import com.azure.storage.blob.implementation.models.ContainersListBlobFlatSegmentHeaders; -import com.azure.storage.blob.implementation.models.ContainersListBlobHierarchySegmentHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.FilterBlobSegment; -import com.azure.storage.blob.implementation.models.ListBlobsFlatSegmentResponse; -import com.azure.storage.blob.implementation.models.ListBlobsHierarchySegmentResponse; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobContainerAccessPolicies; -import com.azure.storage.blob.models.BlobContainerEncryptionScope; -import com.azure.storage.blob.models.BlobContainerProperties; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.ListBlobsIncludeItem; -import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.TaggedBlobItem; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.net.URI; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.function.BiFunction; -import java.util.stream.Collectors; -import java.util.function.Consumer; - -import static com.azure.storage.common.implementation.StorageImplUtils.sendRequest; - -/** - * Client to a container. It may only be instantiated through a {@link BlobContainerClientBuilder} or via the method - * {@link BlobServiceClient#getBlobContainerClient(String)}. This class does not hold any state about a particular - * container but is instead a convenient way of sending off appropriate requests to the resource on the service. It may - * also be used to construct URLs to blobs. - * - *

- * This client contains operations on a container. Operations on a blob are available on {@link BlobClient} through - * {@link #getBlobClient(String)}, and operations on the service are available on {@link BlobServiceClient}. - * - *

- * Please refer to the Azure - * Docs for more information on containers. - */ -@ServiceClient(builder = BlobContainerClientBuilder.class) -public final class BlobContainerClient { - /** - * Special container name for the root container in the Storage account. - */ - public static final String ROOT_CONTAINER_NAME = BlobConstants.ROOT_CONTAINER_NAME; - - /** - * Special container name for the static website container in the Storage account. - */ - public static final String STATIC_WEBSITE_CONTAINER_NAME = BlobConstants.STATIC_WEBSITE_CONTAINER_NAME; - - /** - * Special container name for the logs container in the Storage account. - */ - public static final String LOG_CONTAINER_NAME = BlobConstants.LOG_CONTAINER_NAME; - private static final ClientLogger LOGGER = new ClientLogger(BlobContainerClient.class); - private final AzureBlobStorageImpl azureBlobStorage; - - private final String accountName; - private final String containerName; - private final BlobServiceVersion serviceVersion; - private final CpkInfo customerProvidedKey; // only used to pass down to blob clients - private final EncryptionScope encryptionScope; // only used to pass down to blob clients - private final BlobContainerEncryptionScope blobContainerEncryptionScope; - - /** - * Package-private constructor for use by {@link BlobContainerClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - */ - BlobContainerClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - String containerName, CpkInfo customerProvidedKey, EncryptionScope encryptionScope, - BlobContainerEncryptionScope blobContainerEncryptionScope) { - this.azureBlobStorage = new AzureBlobStorageImplBuilder().pipeline(pipeline) - .url(url) - .version(serviceVersion.getVersion()) - .buildClient(); - this.serviceVersion = serviceVersion; - - this.accountName = accountName; - this.containerName = containerName; - this.customerProvidedKey = customerProvidedKey; - this.encryptionScope = encryptionScope; - this.blobContainerEncryptionScope = blobContainerEncryptionScope; - /* Check to make sure the uri is valid. We don't want the error to occur later in the generated layer - when the sas token has already been applied. */ - try { - URI.create(getBlobContainerUrl()); - } catch (IllegalArgumentException ex) { - throw LOGGER.logExceptionAsError(ex); - } - } - - /** - * Initializes a new BlobClient object by concatenating blobName to the end of ContainerAsyncClient's URL. The new - * BlobClient uses the same request policy pipeline as the ContainerAsyncClient. - * - * @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters, - * pass in the url encoded version of the blob name. - * - *

Code Samples

- * - * - *
-     * BlobClient blobClient = client.getBlobClient(blobName);
-     * 
- * - * @return A new {@link BlobClient} object which references the blob with the specified name in this container. - */ - public BlobClient getBlobClient(String blobName) { - return getBlobClient(blobName, null); - } - - /** - * Initializes a new BlobClient object by concatenating blobName to the end of ContainerAsyncClient's URL. The new - * BlobClient uses the same request policy pipeline as the ContainerAsyncClient. - * - *

Code Samples

- * - * - *
-     * BlobClient blobClient = client.getBlobClient(blobName, snapshot);
-     * 
- * - * - * @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters, - * pass in the url encoded version of the blob name. - * @param snapshot the snapshot identifier for the blob. - * @return A new {@link BlobClient} object which references the blob with the specified name in this container. - */ - public BlobClient getBlobClient(String blobName, String snapshot) { - return new BlobClient(new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), - getAccountName(), getBlobContainerName(), blobName, snapshot, getCustomerProvidedKey(), encryptionScope)); - } - - /** - * Initializes a new BlobClient object by concatenating blobName to the end of ContainerAsyncClient's URL. The new - * BlobClient uses the same request policy pipeline as the ContainerAsyncClient. - * - * @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters, - * pass in the url encoded version of the blob name. - * @param versionId the version identifier for the blob, pass {@code null} to interact with the latest blob version. - * @return A new {@link BlobClient} object which references the blob with the specified name in this container. - */ - public BlobClient getBlobVersionClient(String blobName, String versionId) { - return new BlobClient( - new BlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getBlobContainerName(), blobName, null, getCustomerProvidedKey(), encryptionScope, versionId)); - } - - /** - * Get the container name. - * - *

Code Samples

- * - * - *
-     * String containerName = client.getBlobContainerName();
-     * System.out.println("The name of the blob is " + containerName);
-     * 
- * - * - * @return The name of container. - */ - public String getBlobContainerName() { - return containerName; - } - - /** - * Get the url of the storage account. - * - * @return the URL of the storage account - */ - public String getAccountUrl() { - return azureBlobStorage.getUrl(); - } - - /** - * Gets the URL of the container represented by this client. - * - * @return the URL. - */ - public String getBlobContainerUrl() { - return azureBlobStorage.getUrl() + "/" + containerName; - } - - /** - * Get associated account name. - * - * @return account name associated with this storage resource. - */ - public String getAccountName() { - return this.accountName; - } - - /** - * Get a client pointing to the account. - * - * @return {@link BlobServiceClient} - */ - public BlobServiceClient getServiceClient() { - CustomerProvidedKey encryptionKey = this.customerProvidedKey == null - ? null - : new CustomerProvidedKey(this.customerProvidedKey.getEncryptionKey()); - return new BlobServiceClientBuilder().endpoint(this.getBlobContainerUrl()) - .pipeline(this.getHttpPipeline()) - .serviceVersion(this.serviceVersion) - .blobContainerEncryptionScope(this.blobContainerEncryptionScope) - .encryptionScope(this.getEncryptionScope()) - .customerProvidedKey(encryptionKey) - .buildClient(); - } - - /** - * Gets the service version the client is using. - * - * @return the service version the client is using. - */ - public BlobServiceVersion getServiceVersion() { - return serviceVersion; - } - - /** - * Gets the {@link HttpPipeline} powering this client. - * - * @return The pipeline. - */ - public HttpPipeline getHttpPipeline() { - return azureBlobStorage.getHttpPipeline(); - } - - /** - * Gets the {@link CpkInfo} associated with this client that will be passed to {@link BlobClient BlobClients} when - * {@link #getBlobClient(String) getBlobClient} is called. - * - * @return the customer provided key used for encryption. - */ - public CpkInfo getCustomerProvidedKey() { - return customerProvidedKey; - } - - /** - * Gets the {@code encryption scope} used to encrypt this blob's content on the server. - * - * @return the encryption scope used for encryption. - */ - public String getEncryptionScope() { - if (encryptionScope == null) { - return null; - } - return encryptionScope.getEncryptionScope(); - } - - /** - * Gets if the container this client represents exists in the cloud. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Exists? %b%n", client.exists());
-     * 
- * - * - * @return true if the container exists, false if it doesn't - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public boolean exists() { - return existsWithResponse(null, Context.NONE).getValue(); - } - - /** - * Gets if the container this client represents exists in the cloud. - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     * System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, context).getValue());
-     * 
- * - * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return true if the container exists, false if it doesn't - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response existsWithResponse(Duration timeout, Context context) { - try { - Response response = getPropertiesWithResponse(null, timeout, context); - return new SimpleResponse<>(response, true); - } catch (RuntimeException e) { - if (e instanceof BlobStorageException && ((BlobStorageException) e).getResponse().getStatusCode() == 404) { - HttpResponse response = ((BlobStorageException) e).getResponse(); - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - false); - } else { - throw LOGGER.logExceptionAsError(e); - } - } - } - - /** - * Creates a new container within a storage account. If a container with the same name already exists, the operation - * fails. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * try {
-     *     client.create();
-     *     System.out.printf("Create completed%n");
-     * } catch (BlobStorageException error) {
-     *     if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_ALREADY_EXISTS)) {
-     *         System.out.printf("Can't create container. It already exists %n");
-     *     }
-     * }
-     * 
- * - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void create() { - createWithResponse(null, null, null, Context.NONE); - } - - /** - * Creates a new container within a storage account. If a container with the same name already exists, the operation - * fails. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Context context = new Context("Key", "Value");
-     *
-     * System.out.printf("Create completed with status %d%n",
-     *     client.createWithResponse(metadata, PublicAccessType.CONTAINER, timeout, context).getStatusCode());
-     * 
- * - * - * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param accessType Specifies how the data in this container is available to the public. See the - * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createWithResponse(Map metadata, PublicAccessType accessType, - Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getContainers() - .createNoCustomHeadersWithResponse(containerName, null, metadata, accessType, null, - blobContainerEncryptionScope, finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Creates a new container within a storage account if it does not exist. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean result = client.createIfNotExists();
-     * System.out.println("Create completed: " + result);
-     * 
- * - * - * @return {@code true} if container is successfully created, {@code false} if container already exists. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public boolean createIfNotExists() { - return createIfNotExistsWithResponse(null, null, null).getValue(); - } - - /** - * Creates a new container within a storage account if it does not exist. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Context context = new Context("Key", "Value");
-     * BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata)
-     *     .setPublicAccessType(PublicAccessType.CONTAINER);
-     *
-     * Response<Boolean> response = client.createIfNotExistsWithResponse(options, timeout, context);
-     * if (response.getStatusCode() == 409) {
-     *     System.out.println("Already existed.");
-     * } else {
-     *     System.out.printf("Create completed with status %d%n", response.getStatusCode());
-     * }
-     * 
- * - * - * @param options {@link BlobContainerCreateOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. If {@link Response}'s status code is 201, a new - * container was successfully created. If status code is 409, a container already existed at this location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createIfNotExistsWithResponse(BlobContainerCreateOptions options, Duration timeout, - Context context) { - BlobContainerCreateOptions finalOptions = options == null ? new BlobContainerCreateOptions() : options; - try { - Response response - = createWithResponse(finalOptions.getMetadata(), finalOptions.getPublicAccessType(), timeout, context); - return new SimpleResponse<>(response, true); - } catch (BlobStorageException e) { - if (e.getStatusCode() == 409) { - HttpResponse res = e.getResponse(); - return new SimpleResponse<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), false); - } else { - throw LOGGER.logExceptionAsError(e); - } - } catch (RuntimeException e) { - throw LOGGER.logExceptionAsError(e); - } - } - - /** - * Marks the specified container for deletion. The container and any blobs contained within it are later deleted - * during garbage collection. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * try {
-     *     client.delete();
-     *     System.out.printf("Delete completed%n");
-     * } catch (BlobStorageException error) {
-     *     if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_NOT_FOUND)) {
-     *         System.out.printf("Delete failed. Container was not found %n");
-     *     }
-     * }
-     * 
- * - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void delete() { - deleteWithResponse(null, null, Context.NONE); - } - - /** - * Marks the specified container for deletion. The container and any blobs contained within it are later deleted - * during garbage collection. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("Key", "Value");
-     *
-     * System.out.printf("Delete completed with status %d%n", client.deleteWithResponse(
-     *     requestConditions, timeout, context).getStatusCode());
-     * 
- * - * - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteWithResponse(BlobRequestConditions requestConditions, Duration timeout, - Context context) { - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - if (!ModelHelper.validateNoETag(requestConditions)) { - throw LOGGER.logExceptionAsError( - new UnsupportedOperationException("ETag access conditions are not supported for this API.")); - } - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation = () -> this.azureBlobStorage.getContainers() - .deleteNoCustomHeadersWithResponse(containerName, null, finalRequestConditions.getLeaseId(), - finalRequestConditions.getIfModifiedSince(), finalRequestConditions.getIfUnmodifiedSince(), null, - finalContext); - - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Marks the specified container for deletion if it exists. The container and any blobs contained within - * it are later deleted during garbage collection. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean result = client.deleteIfExists();
-     * System.out.println("Delete completed: " + result);
-     * 
- * - * @return {@code true} if container is successfully deleted, {@code false} if container does not exist. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public boolean deleteIfExists() { - return deleteIfExistsWithResponse(null, null, Context.NONE).getValue(); - } - - /** - * Marks the specified container for deletion if it exists. The container and any blobs contained within it - * are later deleted during garbage collection. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("Key", "Value");
-     *
-     * Response<Boolean> response = client.deleteIfExistsWithResponse(requestConditions, timeout, context);
-     * if (response.getStatusCode() == 404) {
-     *     System.out.println("Does not exist.");
-     * } else {
-     *     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
-     * }
-     * 
- * - * - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. If {@link Response}'s status code is 202, the container - * was successfully deleted. If status code is 404, the container does not exist. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteIfExistsWithResponse(BlobRequestConditions requestConditions, Duration timeout, - Context context) { - try { - Response response = this.deleteWithResponse(requestConditions, timeout, context); - return new SimpleResponse<>(response, true); - } catch (BlobStorageException e) { - if (e.getStatusCode() == 404) { - HttpResponse res = e.getResponse(); - return new SimpleResponse<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), false); - } else { - throw LOGGER.logExceptionAsError(e); - } - } - } - - /** - * Returns the container's metadata and system properties. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobContainerProperties properties = client.getProperties();
-     * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
-     *     properties.getBlobPublicAccess(),
-     *     properties.hasLegalHold(),
-     *     properties.hasImmutabilityPolicy());
-     * 
- * - * - * @return The container properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobContainerProperties getProperties() { - return getPropertiesWithResponse(null, null, Context.NONE).getValue(); - } - - /** - * Returns the container's metadata and system properties. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     *
-     * BlobContainerProperties properties = client.getPropertiesWithResponse(leaseId, timeout, context)
-     *     .getValue();
-     * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
-     *     properties.getBlobPublicAccess(),
-     *     properties.hasLegalHold(),
-     *     properties.hasImmutabilityPolicy());
-     * 
- * - * - * @param leaseId The lease ID the active lease on the container must match. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The container properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesWithResponse(String leaseId, Duration timeout, - Context context) { - Context finalContext = context == null ? Context.NONE : context; - Callable> operation - = () -> this.azureBlobStorage.getContainers() - .getPropertiesWithResponse(containerName, null, leaseId, null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - ContainersGetPropertiesHeaders hd = response.getDeserializedHeaders(); - BlobContainerProperties properties = new BlobContainerProperties(hd.getXMsMeta(), hd.getETag(), - hd.getLastModified(), hd.getXMsLeaseDuration(), hd.getXMsLeaseState(), hd.getXMsLeaseStatus(), - hd.getXMsBlobPublicAccess(), Boolean.TRUE.equals(hd.isXMsHasImmutabilityPolicy()), - Boolean.TRUE.equals(hd.isXMsHasLegalHold()), hd.getXMsDefaultEncryptionScope(), - hd.isXMsDenyEncryptionScopeOverride(), hd.isXMsImmutableStorageWithVersioningEnabled()); - return new SimpleResponse<>(response, properties); - } - - /** - * Sets the container's metadata. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * try {
-     *     client.setMetadata(metadata);
-     *     System.out.printf("Set metadata completed with status %n");
-     * } catch (UnsupportedOperationException error) {
-     *     System.out.printf("Fail while setting metadata %n");
-     * }
-     * 
- * - * - * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setMetadata(Map metadata) { - setMetadataWithResponse(metadata, null, null, Context.NONE); - } - - /** - * Sets the container's metadata. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("Key", "Value");
-     *
-     * System.out.printf("Set metadata completed with status %d%n",
-     *     client.setMetadataWithResponse(metadata, requestConditions, timeout, context).getStatusCode());
-     * 
- * - * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setMetadataWithResponse(Map metadata, BlobRequestConditions requestConditions, - Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - if (!ModelHelper.validateNoETag(finalRequestConditions) - || finalRequestConditions.getIfUnmodifiedSince() != null) { - throw LOGGER.logExceptionAsError(new UnsupportedOperationException( - "If-Modified-Since is the only HTTP access condition supported for this API")); - } - Callable> operation = () -> azureBlobStorage.getContainers() - .setMetadataWithResponse(containerName, null, finalRequestConditions.getLeaseId(), metadata, - finalRequestConditions.getIfModifiedSince(), null, finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Returns the container's permissions. The permissions indicate whether container's blobs may be accessed publicly. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobContainerAccessPolicies accessPolicies = client.getAccessPolicy();
-     * System.out.printf("Blob Access Type: %s%n", accessPolicies.getBlobAccessType());
-     *
-     * for (BlobSignedIdentifier identifier : accessPolicies.getIdentifiers()) {
-     *     System.out.printf("Identifier Name: %s, Permissions %s%n",
-     *         identifier.getId(),
-     *         identifier.getAccessPolicy().getPermissions());
-     * }
-     * 
- * - * - * @return The container access policy. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobContainerAccessPolicies getAccessPolicy() { - return getAccessPolicyWithResponse(null, null, Context.NONE).getValue(); - } - - /** - * Returns the container's permissions. The permissions indicate whether container's blobs may be accessed publicly. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     * BlobContainerAccessPolicies accessPolicies = client.getAccessPolicyWithResponse(leaseId, timeout, context)
-     *     .getValue();
-     * System.out.printf("Blob Access Type: %s%n", accessPolicies.getBlobAccessType());
-     *
-     * for (BlobSignedIdentifier identifier : accessPolicies.getIdentifiers()) {
-     *     System.out.printf("Identifier Name: %s, Permissions %s%n",
-     *         identifier.getId(),
-     *         identifier.getAccessPolicy().getPermissions());
-     * }
-     * 
- * - * - * @param leaseId The lease ID the active lease on the container must match. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The container access policy. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getAccessPolicyWithResponse(String leaseId, Duration timeout, - Context context) { - Context finalContext = context == null ? Context.NONE : context; - Callable> operation - = () -> this.azureBlobStorage.getContainers() - .getAccessPolicyWithResponse(containerName, null, leaseId, null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, new BlobContainerAccessPolicies( - response.getDeserializedHeaders().getXMsBlobPublicAccess(), response.getValue().items())); - } - - /** - * Sets the container's permissions. The permissions indicate whether blobs in a container may be accessed publicly. - * Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to - * ensure the time formatting is compatible with the service. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobSignedIdentifier identifier = new BlobSignedIdentifier()
-     *     .setId("name")
-     *     .setAccessPolicy(new BlobAccessPolicy()
-     *         .setStartsOn(OffsetDateTime.now())
-     *         .setExpiresOn(OffsetDateTime.now().plusDays(7))
-     *         .setPermissions("permissionString"));
-     *
-     * try {
-     *     client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier));
-     *     System.out.printf("Set Access Policy completed %n");
-     * } catch (UnsupportedOperationException error) {
-     *     System.out.printf("Set Access Policy completed %s%n", error);
-     * }
-     * 
- * - * - * @param accessType Specifies how the data in this container is available to the public. See the - * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. - * @param identifiers A list of {@link BlobSignedIdentifier} objects that specify the permissions for the container. - * Please see - * here - * for more information. Passing null will clear all access policies. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setAccessPolicy(PublicAccessType accessType, List identifiers) { - setAccessPolicyWithResponse(accessType, identifiers, null, null, Context.NONE); - } - - /** - * Sets the container's permissions. The permissions indicate whether blobs in a container may be accessed publicly. - * Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to - * ensure the time formatting is compatible with the service. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobSignedIdentifier identifier = new BlobSignedIdentifier()
-     *     .setId("name")
-     *     .setAccessPolicy(new BlobAccessPolicy()
-     *         .setStartsOn(OffsetDateTime.now())
-     *         .setExpiresOn(OffsetDateTime.now().plusDays(7))
-     *         .setPermissions("permissionString"));
-     *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * Context context = new Context("Key", "Value");
-     *
-     * System.out.printf("Set access policy completed with status %d%n",
-     *     client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER,
-     *         Collections.singletonList(identifier),
-     *         requestConditions,
-     *         timeout,
-     *         context).getStatusCode());
-     * 
- * - * - * @param accessType Specifies how the data in this container is available to the public. See the - * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. - * @param identifiers A list of {@link BlobSignedIdentifier} objects that specify the permissions for the container. - * Please see - * here - * for more information. Passing null will clear all access policies. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setAccessPolicyWithResponse(PublicAccessType accessType, - List identifiers, BlobRequestConditions requestConditions, Duration timeout, - Context context) { - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - if (!ModelHelper.validateNoETag(requestConditions)) { - throw LOGGER.logExceptionAsError( - new UnsupportedOperationException("ETag access conditions are not supported for this API.")); - } - List finalIdentifiers = ModelHelper.truncateTimeForBlobSignedIdentifier(identifiers); - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getContainers() - .setAccessPolicyNoCustomHeadersWithResponse(containerName, null, finalRequestConditions.getLeaseId(), - accessType, finalRequestConditions.getIfModifiedSince(), finalRequestConditions.getIfUnmodifiedSince(), - null, finalIdentifiers, finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Returns a lazy loaded list of blobs in this container, with folder structures flattened. The returned {@link - * PagedIterable} can be consumed through while new items are automatically retrieved as needed. - * - *

- * Blob names are returned in lexicographic order. - * - *

- * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.listBlobs().forEach(blob ->
-     *     System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix()));
-     * 
- * - * - * @return The listed blobs, flattened. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobs() { - return this.listBlobs(new ListBlobsOptions(), null); - } - - /** - * Returns a lazy loaded list of blobs in this container, with folder structures flattened. The returned {@link - * PagedIterable} can be consumed through while new items are automatically retrieved as needed. - * - *

- * Blob names are returned in lexicographic order. - * - *

- * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * ListBlobsOptions options = new ListBlobsOptions()
-     *     .setPrefix("prefixToMatch")
-     *     .setDetails(new BlobListDetails()
-     *         .setRetrieveDeletedBlobs(true)
-     *         .setRetrieveSnapshots(true));
-     *
-     * client.listBlobs(options, timeout).forEach(blob ->
-     *     System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
-     *         blob.getName(),
-     *         blob.isPrefix(),
-     *         blob.isDeleted(),
-     *         blob.getSnapshot()));
-     * 
- * - * - * @param options {@link ListBlobsOptions}. If iterating by page, the page size passed to byPage methods such as - * {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @return The listed blobs, flattened. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobs(ListBlobsOptions options, Duration timeout) { - return this.listBlobs(options, null, timeout); - } - - /** - * Returns a lazy loaded list of blobs in this container, with folder structures flattened. The returned {@link - * PagedIterable} can be consumed through while new items are automatically retrieved as needed. - * - *

- * Blob names are returned in lexicographic order. - * - *

- * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * ListBlobsOptions options = new ListBlobsOptions()
-     *     .setPrefix("prefixToMatch")
-     *     .setDetails(new BlobListDetails()
-     *         .setRetrieveDeletedBlobs(true)
-     *         .setRetrieveSnapshots(true));
-     *
-     * String continuationToken = "continuationToken";
-     *
-     * client.listBlobs(options, continuationToken, timeout).forEach(blob ->
-     *     System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
-     *         blob.getName(),
-     *         blob.isPrefix(),
-     *         blob.isDeleted(),
-     *         blob.getSnapshot()));
-     * 
- * - * - * @param options {@link ListBlobsOptions}. If iterating by page, the page size passed to byPage methods such as - * {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options. - * @param continuationToken Identifies the portion of the list to be returned with the next list operation. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @return The listed blobs, flattened. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobs(ListBlobsOptions options, String continuationToken, Duration timeout) { - BiFunction> retriever = (nextMarker, pageSize) -> { - ListBlobsOptions finalOptions = new ListBlobsOptions(); - if (options != null) { - finalOptions.setMaxResultsPerPage(options.getMaxResultsPerPage()) - .setPrefix(options.getPrefix()) - .setDetails(options.getDetails()); - } - /* - If pageSize was not set in a .byPage(int) method, the page size from options will be preserved. - Otherwise, prefer the new value. - */ - if (pageSize != null) { - finalOptions.setMaxResultsPerPage(pageSize); - } - ArrayList include - = finalOptions.getDetails().toList().isEmpty() ? null : finalOptions.getDetails().toList(); - - Callable> operation - = () -> this.azureBlobStorage.getContainers() - .listBlobFlatSegmentWithResponse(containerName, finalOptions.getPrefix(), nextMarker, - finalOptions.getMaxResultsPerPage(), include, null, null, Context.NONE); - - ResponseBase response - = StorageImplUtils.sendRequest(operation, timeout, BlobStorageException.class); - - List value = response.getValue().getSegment() == null - ? Collections.emptyList() - : response.getValue() - .getSegment() - .getBlobItems() - .stream() - .map(ModelHelper::populateBlobItem) - .collect(Collectors.toList()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - value, response.getValue().getNextMarker(), response.getDeserializedHeaders()); - }; - - return new PagedIterable<>(pageSize -> retriever.apply(continuationToken, pageSize), retriever); - } - - /** - * Returns a reactive Publisher emitting all the blobs and directories (prefixes) under the given directory - * (prefix). Directories will have {@link BlobItem#isPrefix()} set to true. - * - *

- * Blob names are returned in lexicographic order. For more information, see the - * Azure Docs. - * - *

- * E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the - * root level 'bar', will return the following results when prefix=null: - * - *

    - *
  • foo/ (isPrefix = true) - *
  • bar (isPrefix = false) - *
- *

- * will return the following results when prefix="foo/": - * - *

    - *
  • foo/foo1 (isPrefix = false) - *
  • foo/foo2 (isPrefix = false) - *
- * - *

Code Samples

- * - * - *
-     * client.listBlobsByHierarchy("directoryName").forEach(blob ->
-     *     System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix()));
-     * 
- * - * - * @param directory The directory to list blobs underneath - * @return A reactive response emitting the prefixes and blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobsByHierarchy(String directory) { - return this.listBlobsByHierarchy("/", new ListBlobsOptions().setPrefix(directory), null); - } - - /** - * Returns a reactive Publisher emitting all the blobs and prefixes (directories) under the given prefix - * (directory). Directories will have {@link BlobItem#isPrefix()} set to true. - * - *

- * Blob names are returned in lexicographic order. For more information, see the - * Azure Docs. - * - *

- * E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the - * root level 'bar', will return the following results when prefix=null: - * - *

    - *
  • foo/ (isPrefix = true) - *
  • bar (isPrefix = false) - *
- *

- * will return the following results when prefix="foo/": - * - *

    - *
  • foo/foo1 (isPrefix = false) - *
  • foo/foo2 (isPrefix = false) - *
- * - *

Code Samples

- * - * - *
-     * ListBlobsOptions options = new ListBlobsOptions()
-     *     .setPrefix("directoryName")
-     *     .setDetails(new BlobListDetails()
-     *         .setRetrieveDeletedBlobs(true)
-     *         .setRetrieveSnapshots(false));
-     *
-     * client.listBlobsByHierarchy("/", options, timeout).forEach(blob ->
-     *     System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n",
-     *         blob.getName(),
-     *         blob.isPrefix(),
-     *         blob.isDeleted(),
-     *         blob.getSnapshot()));
-     * 
- * - * - * @param delimiter The delimiter for blob hierarchy, "/" for hierarchy based on directories - * @param options {@link ListBlobsOptions}. If iterating by page, the page size passed to byPage methods such as - * {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @return A reactive response emitting the prefixes and blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobsByHierarchy(String delimiter, ListBlobsOptions options, Duration timeout) { - BiFunction> func = (marker, pageSize) -> { - ListBlobsOptions finalOptions = new ListBlobsOptions(); - if (options != null) { - finalOptions.setMaxResultsPerPage(options.getMaxResultsPerPage()) - .setPrefix(options.getPrefix()) - .setDetails(options.getDetails()); - } - /* - If pageSize was not set in a .byPage(int) method, the page size from options will be preserved. - Otherwise, prefer the new value. - */ - if (pageSize != null) { - finalOptions.setMaxResultsPerPage(pageSize); - } - return listBlobsHierarchySegment(marker, delimiter, finalOptions, timeout); - }; - return new PagedIterable<>(pageSize -> func.apply(null, pageSize), func); - } - - private PagedResponse listBlobsHierarchySegment(String marker, String delimiter, ListBlobsOptions options, - Duration timeout) { - if (options.getDetails().getRetrieveSnapshots()) { - throw LOGGER.logExceptionAsError( - new UnsupportedOperationException("Including snapshots in a hierarchical listing is not supported.")); - } - ArrayList include - = options.getDetails().toList().isEmpty() ? null : options.getDetails().toList(); - - Callable> operation - = () -> azureBlobStorage.getContainers() - .listBlobHierarchySegmentWithResponse(containerName, delimiter, options.getPrefix(), marker, - options.getMaxResultsPerPage(), include, null, null, Context.NONE); - - ResponseBase response - = StorageImplUtils.sendRequest(operation, timeout, BlobStorageException.class); - - BlobHierarchyListSegment segment = response.getValue().getSegment(); - List value = new ArrayList<>(); - if (segment != null) { - segment.getBlobItems().forEach(item -> value.add(BlobItemConstructorProxy.create(item))); - segment.getBlobPrefixes() - .forEach(prefix -> value - .add(new BlobItem().setName(ModelHelper.toBlobNameString(prefix.getName())).setIsPrefix(true))); - } - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), value, - response.getValue().getNextMarker(), response.getDeserializedHeaders()); - } - - /** - * Returns a lazy loaded list of blobs in this container whose tags match the query expression. The returned - * {@link PagedIterable} can be consumed while new items are automatically retrieved as needed. For more - * information, including information on the query syntax, see the Azure Docs. - * - *

Code Samples

- * - * TODO - * - *
-     * client.findBlobsByTags("where=tag=value").forEach(blob -> System.out.printf("Name: %s%n", blob.getName()));
-     * 
- * - * - * @param query Filters the results to return only blobs whose tags match the specified expression. - * @return The list of blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable findBlobsByTags(String query) { - return this.findBlobsByTags(new FindBlobsOptions(query), null, Context.NONE); - } - - /** - * Returns a lazy loaded list of blobs in this account whose tags match the query expression. The returned - * {@link PagedIterable} can be consumed while new items are automatically retrieved as needed. For more - * information, including information on the query syntax, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     * client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10), timeout, context)
-     *     .forEach(blob -> System.out.printf("Name: %s%n", blob.getName()));
-     * 
- * - * - * @param options {@link FindBlobsOptions}. If iterating by page, the page size passed to byPage methods such as - * {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The list of blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable findBlobsByTags(FindBlobsOptions options, Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", options); - BiFunction> func = (marker, pageSize) -> { - // Use pageSize if provided, otherwise use maxResultsPerPage from options - FindBlobsOptions finalOptions = (pageSize != null) - ? new FindBlobsOptions(options.getQuery()).setMaxResultsPerPage(pageSize) - : options; - - return findBlobsByTagsHelper(finalOptions, marker, timeout, context); - }; - return new PagedIterable<>(pageSize -> func.apply(null, pageSize), func); - } - - private PagedResponse findBlobsByTagsHelper(FindBlobsOptions options, String marker, - Duration timeout, Context context) { - Callable> operation - = () -> this.azureBlobStorage.getContainers() - .filterBlobsWithResponse(containerName, null, null, options.getQuery(), marker, - options.getMaxResultsPerPage(), null, context); - - ResponseBase response - = StorageImplUtils.sendRequest(operation, timeout, BlobStorageException.class); - - List value = response.getValue() - .getBlobs() - .stream() - .map(ModelHelper::populateTaggedBlobItem) - .collect(Collectors.toList()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), value, - response.getValue().getNextMarker(), response.getDeserializedHeaders()); - } - - /** - * Returns the sku name and account kind for the account. For more information, please see the - * Azure Docs. - * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * - *

Code Samples

- * - * - *
-     * StorageAccountInfo accountInfo = client.getAccountInfo(timeout);
-     * System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());
-     * 
- * - * @return The account info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public StorageAccountInfo getAccountInfo(Duration timeout) { - return getAccountInfoWithResponse(timeout, Context.NONE).getValue(); - } - - /** - * Returns the sku name and account kind for the account. For more information, please see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     * StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, context).getValue();
-     * System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());
-     * 
- * - * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The account info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getAccountInfoWithResponse(Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - Callable> operation - = () -> this.azureBlobStorage.getContainers() - .getAccountInfoWithResponse(containerName, null, null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - ContainersGetAccountInfoHeaders hd = response.getDeserializedHeaders(); - return new SimpleResponse<>(response, new StorageAccountInfo(hd.getXMsSkuName(), hd.getXMsAccountKind())); - } - - // TODO: Reintroduce this API once service starts supporting it. - // BlobContainerClient rename(String destinationContainerName) { - // return renameWithResponse(new BlobContainerRenameOptions(destinationContainerName - // ), null, Context.NONE).getValue(); - // } - - // TODO: Reintroduce this API once service starts supporting it. - // Response renameWithResponse(BlobContainerRenameOptions options, Duration timeout, - // Context context) { - // Mono> response = this.client.renameWithResponse(options, context) - // .map(r -> new SimpleResponse<>(r, new BlobContainerClient(r.getValue()))); - // - // return StorageImplUtils.blockWithOptionalTimeout(response, timeout); - // } - - /** - * Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateUserDelegationSas(values, userDelegationKey);
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey) { - return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, getAccountName(), - Context.NONE); - } - - /** - * Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value"));
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key.. - * @param accountName The account name. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey, String accountName, Context context) { - return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, accountName, null, context); - } - - /** - * Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key.. - * @param accountName The account name. - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey, String accountName, Consumer stringToSignHandler, - Context context) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName()) - .generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context); - } - - /** - * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return generateSas(blobServiceSasSignatureValues, Context.NONE); - } - - /** - * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * // Client must be authenticated via StorageSharedKeyCredential
-     * client.generateSas(values, new Context("key", "value"));
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context) { - return generateSas(blobServiceSasSignatureValues, null, context); - } - - /** - * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - Consumer stringToSignHandler, Context context) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName()) - .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java deleted file mode 100644 index d8413a535783..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java +++ /dev/null @@ -1,599 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.AzureNamedKeyCredentialTrait; -import com.azure.core.client.traits.AzureSasCredentialTrait; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.ConnectionStringTrait; -import com.azure.core.client.traits.EndpointTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.client.traits.TokenCredentialTrait; -import com.azure.core.credential.AzureNamedKeyCredential; -import com.azure.core.credential.AzureSasCredential; -import com.azure.core.credential.TokenCredential; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.HttpClientOptions; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BuilderHelper; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobContainerEncryptionScope; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.connectionstring.StorageAuthenticationSettings; -import com.azure.storage.common.implementation.connectionstring.StorageConnectionString; -import com.azure.storage.common.implementation.connectionstring.StorageEndpoint; -import com.azure.storage.common.policy.RequestRetryOptions; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * This class provides a fluent builder API to help aid the configuration and instantiation of {@link - * BlobContainerClient BlobContainerClients} and {@link BlobContainerAsyncClient BlobContainerAsyncClients}, call - * {@link #buildClient() buildClient} and {@link #buildAsyncClient() buildAsyncClient} respectively to construct an - * instance of the desired client. - * - *

- * The following information must be provided on this builder: - * - *

    - *
  • the endpoint through {@code .endpoint()}, including the container name, in the format of {@code - * https://{accountName}.blob.core.windows.net/{containerName}}. - *
  • the credential through {@code .credential()} or {@code .connectionString()} if the container is not publicly - * accessible. - *
- */ -@ServiceClientBuilder(serviceClients = { BlobContainerClient.class, BlobContainerAsyncClient.class }) -public final class BlobContainerClientBuilder implements TokenCredentialTrait, - ConnectionStringTrait, AzureSasCredentialTrait, - AzureNamedKeyCredentialTrait, HttpTrait, - ConfigurationTrait, EndpointTrait { - private static final ClientLogger LOGGER = new ClientLogger(BlobContainerClientBuilder.class); - - private String endpoint; - private String accountName; - private String containerName; - - private CpkInfo customerProvidedKey; - private EncryptionScope encryptionScope; - private BlobContainerEncryptionScope blobContainerEncryptionScope; - private StorageSharedKeyCredential storageSharedKeyCredential; - private TokenCredential tokenCredential; - private AzureSasCredential azureSasCredential; - private String sasToken; - - private HttpClient httpClient; - private final List perCallPolicies = new ArrayList<>(); - private final List perRetryPolicies = new ArrayList<>(); - private HttpLogOptions logOptions; - private RequestRetryOptions retryOptions; - private RetryOptions coreRetryOptions; - private HttpPipeline httpPipeline; - - private ClientOptions clientOptions = new ClientOptions(); - private Configuration configuration; - private BlobServiceVersion version; - private BlobAudience audience; - - /** - * Creates a builder instance that is able to configure and construct {@link BlobContainerClient ContainerClients} - * and {@link BlobContainerAsyncClient ContainerAsyncClients}. - */ - public BlobContainerClientBuilder() { - logOptions = getDefaultHttpLogOptions(); - } - - /** - * Creates a {@link BlobContainerClient} from the configured options. - * - *

Code Samples

- * - * - *
-     * BlobContainerClient client = new BlobContainerClientBuilder()
-     *     .connectionString(connectionString)
-     *     .buildClient();
-     * 
- * - * - * @return a {@link BlobContainerClient} created from the configurations in this builder. - * @throws IllegalStateException If multiple credentials have been specified. - */ - public BlobContainerClient buildClient() { - BuilderHelper.httpsValidation(customerProvidedKey, "customer provided key", endpoint, LOGGER); - - if (Objects.nonNull(customerProvidedKey) && Objects.nonNull(encryptionScope)) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("Customer provided key and encryption " + "scope cannot both be set")); - } - - /* - Implicit and explicit root container access are functionally equivalent, but explicit references are easier - to read and debug. - */ - String blobContainerName - = CoreUtils.isNullOrEmpty(containerName) ? BlobContainerClient.ROOT_CONTAINER_NAME : containerName; - - BlobServiceVersion serviceVersion = version != null ? version : BlobServiceVersion.getLatest(); - - HttpPipeline pipeline = constructPipeline(); - - return new BlobContainerClient(pipeline, endpoint, serviceVersion, accountName, blobContainerName, - customerProvidedKey, encryptionScope, blobContainerEncryptionScope); - } - - /** - * Creates a {@link BlobContainerAsyncClient} from the configured options. - * - *

Code Samples

- * - * - *
-     * BlobContainerAsyncClient client = new BlobContainerClientBuilder()
-     *     .connectionString(connectionString)
-     *     .buildAsyncClient();
-     * 
- * - * - * @return a {@link BlobContainerAsyncClient} created from the configurations in this builder. - * @throws IllegalStateException If multiple credentials have been specified. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryOptions(RequestRetryOptions)} have been set. - */ - public BlobContainerAsyncClient buildAsyncClient() { - BuilderHelper.httpsValidation(customerProvidedKey, "customer provided key", endpoint, LOGGER); - - if (Objects.nonNull(customerProvidedKey) && Objects.nonNull(encryptionScope)) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("Customer provided key and encryption " + "scope cannot both be set")); - } - - /* - Implicit and explicit root container access are functionally equivalent, but explicit references are easier - to read and debug. - */ - String blobContainerName - = CoreUtils.isNullOrEmpty(containerName) ? BlobContainerAsyncClient.ROOT_CONTAINER_NAME : containerName; - - BlobServiceVersion serviceVersion = version != null ? version : BlobServiceVersion.getLatest(); - - HttpPipeline pipeline = constructPipeline(); - - return new BlobContainerAsyncClient(pipeline, endpoint, serviceVersion, accountName, blobContainerName, - customerProvidedKey, encryptionScope, blobContainerEncryptionScope); - } - - private HttpPipeline constructPipeline() { - return (httpPipeline != null) - ? httpPipeline - : BuilderHelper.buildPipeline(storageSharedKeyCredential, tokenCredential, azureSasCredential, sasToken, - endpoint, retryOptions, coreRetryOptions, logOptions, clientOptions, httpClient, perCallPolicies, - perRetryPolicies, configuration, audience, LOGGER); - } - - /** - * Sets the service endpoint, additionally parses it for information (SAS token, container name) - * - * @param endpoint URL of the service - * @return the updated BlobContainerClientBuilder object - * @throws IllegalArgumentException If {@code endpoint} is {@code null} or is a malformed URL. - */ - @Override - public BlobContainerClientBuilder endpoint(String endpoint) { - try { - URL url = new URL(endpoint); - BlobUrlParts parts = BlobUrlParts.parse(url); - - this.accountName = parts.getAccountName(); - this.containerName - = parts.getBlobContainerName() == null ? this.containerName : parts.getBlobContainerName(); - this.endpoint = BuilderHelper.getEndpoint(parts); - - String sasToken = parts.getCommonSasQueryParameters().encode(); - if (!CoreUtils.isNullOrEmpty(sasToken)) { - this.sasToken(sasToken); - } - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("The Azure Storage Blob endpoint url is malformed.", ex)); - } - - return this; - } - - /** - * Sets the {@link CustomerProvidedKey customer provided key} that is used to encrypt blob contents on the server. - * - * @param customerProvidedKey Customer provided key containing the encryption key information. - * @return the updated BlobContainerClientBuilder object - */ - public BlobContainerClientBuilder customerProvidedKey(CustomerProvidedKey customerProvidedKey) { - if (customerProvidedKey == null) { - this.customerProvidedKey = null; - } else { - this.customerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - - return this; - } - - /** - * Sets the {@code encryption scope} that is used to encrypt blob contents on the server. - * - * @param encryptionScope Encryption scope containing the encryption key information. - * @return the updated BlobContainerClientBuilder object - */ - public BlobContainerClientBuilder encryptionScope(String encryptionScope) { - if (encryptionScope == null) { - this.encryptionScope = null; - } else { - this.encryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - - return this; - } - - /** - * Sets the {@link BlobContainerEncryptionScope encryption scope} that is used to determine how blob contents are - * encrypted on the server. - * - * @param blobContainerEncryptionScope Encryption scope containing the encryption key information. - * @return the updated BlobContainerClientBuilder object - */ - public BlobContainerClientBuilder - blobContainerEncryptionScope(BlobContainerEncryptionScope blobContainerEncryptionScope) { - this.blobContainerEncryptionScope = blobContainerEncryptionScope; - return this; - } - - /** - * Sets the {@link StorageSharedKeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link StorageSharedKeyCredential}. - * @return the updated BlobContainerClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - public BlobContainerClientBuilder credential(StorageSharedKeyCredential credential) { - this.storageSharedKeyCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - this.tokenCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the {@link AzureNamedKeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link AzureNamedKeyCredential}. - * @return the updated BlobContainerClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public BlobContainerClientBuilder credential(AzureNamedKeyCredential credential) { - Objects.requireNonNull(credential, "'credential' cannot be null."); - return credential(StorageSharedKeyCredential.fromAzureNamedKeyCredential(credential)); - } - - /** - * Sets the {@link TokenCredential} used to authorize requests sent to the service. Refer to the Azure SDK for Java - * identity and authentication - * documentation for more details on proper usage of the {@link TokenCredential} type. - * - * @param credential {@link TokenCredential} used to authorize requests sent to the service. - * @return the updated BlobContainerClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public BlobContainerClientBuilder credential(TokenCredential credential) { - this.tokenCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - this.storageSharedKeyCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the SAS token used to authorize requests sent to the service. - * - * @param sasToken The SAS token to use for authenticating requests. This string should only be the query parameters - * (with or without a leading '?') and not a full url. - * @return the updated BlobContainerClientBuilder - * @throws NullPointerException If {@code sasToken} is {@code null}. - */ - public BlobContainerClientBuilder sasToken(String sasToken) { - this.sasToken = Objects.requireNonNull(sasToken, "'sasToken' cannot be null."); - this.storageSharedKeyCredential = null; - this.tokenCredential = null; - return this; - } - - /** - * Sets the {@link AzureSasCredential} used to authorize requests sent to the service. - * - * @param credential {@link AzureSasCredential} used to authorize requests sent to the service. - * @return the updated BlobContainerClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public BlobContainerClientBuilder credential(AzureSasCredential credential) { - this.azureSasCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - return this; - } - - /** - * Clears the credential used to authorize the request. - * - *

This is for containers that are publicly accessible.

- * - * @return the updated BlobContainerClientBuilder - */ - public BlobContainerClientBuilder setAnonymousAccess() { - this.storageSharedKeyCredential = null; - this.tokenCredential = null; - this.azureSasCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the connection string to connect to the service. - * - * @param connectionString Connection string of the storage account. - * @return the updated BlobContainerClientBuilder - * @throws IllegalArgumentException If {@code connectionString} in invalid. - */ - @Override - public BlobContainerClientBuilder connectionString(String connectionString) { - StorageConnectionString storageConnectionString = StorageConnectionString.create(connectionString, LOGGER); - StorageEndpoint endpoint = storageConnectionString.getBlobEndpoint(); - if (endpoint == null || endpoint.getPrimaryUri() == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException( - "connectionString missing required settings to derive blob service endpoint.")); - } - this.endpoint(endpoint.getPrimaryUri()); - if (storageConnectionString.getAccountName() != null) { - this.accountName = storageConnectionString.getAccountName(); - } - StorageAuthenticationSettings authSettings = storageConnectionString.getStorageAuthSettings(); - if (authSettings.getType() == StorageAuthenticationSettings.Type.ACCOUNT_NAME_KEY) { - this.credential(new StorageSharedKeyCredential(authSettings.getAccount().getName(), - authSettings.getAccount().getAccessKey())); - } else if (authSettings.getType() == StorageAuthenticationSettings.Type.SAS_TOKEN) { - this.sasToken(authSettings.getSasToken()); - } - return this; - } - - /** - * Sets the name of the container. - * - * @param containerName Name of the container. If the value {@code null} or empty the root container, {@code $root} - * , will be used. - * @return the updated BlobContainerClientBuilder object - */ - public BlobContainerClientBuilder containerName(String containerName) { - this.containerName = containerName; - return this; - } - - /** - * Sets the {@link HttpClient} to use for sending and receiving requests to and from the service. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param httpClient The {@link HttpClient} to use for requests. - * @return the updated BlobContainerClientBuilder object - */ - @Override - public BlobContainerClientBuilder httpClient(HttpClient httpClient) { - if (this.httpClient != null && httpClient == null) { - LOGGER.info("'httpClient' is being set to 'null' when it was previously configured."); - } - - this.httpClient = httpClient; - return this; - } - - /** - * Adds a {@link HttpPipelinePolicy pipeline policy} to apply on each request sent. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param pipelinePolicy A {@link HttpPipelinePolicy pipeline policy}. - * @return the updated BlobContainerClientBuilder object - * @throws NullPointerException If {@code pipelinePolicy} is {@code null}. - */ - @Override - public BlobContainerClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) { - Objects.requireNonNull(pipelinePolicy, "'pipelinePolicy' cannot be null"); - if (pipelinePolicy.getPipelinePosition() == HttpPipelinePosition.PER_CALL) { - perCallPolicies.add(pipelinePolicy); - } else { - perRetryPolicies.add(pipelinePolicy); - } - return this; - } - - /** - * Sets the {@link HttpLogOptions logging configuration} to use when sending and receiving requests to and from - * the service. If a {@code logLevel} is not provided, default value of {@link HttpLogDetailLevel#NONE} is set. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param logOptions The {@link HttpLogOptions logging configuration} to use when sending and receiving requests to - * and from the service. - * @return the updated BlobContainerClientBuilder object - * @throws NullPointerException If {@code logOptions} is {@code null}. - */ - @Override - public BlobContainerClientBuilder httpLogOptions(HttpLogOptions logOptions) { - this.logOptions = Objects.requireNonNull(logOptions, "'logOptions' cannot be null."); - return this; - } - - /** - * Gets the default Storage allowlist log headers and query parameters. - * - * @return the default http log options. - */ - public static HttpLogOptions getDefaultHttpLogOptions() { - return BuilderHelper.getDefaultHttpLogOptions(); - } - - /** - * Sets the configuration object used to retrieve environment configuration values during building of the client. - * - * @param configuration Configuration store used to retrieve environment configurations. - * @return the updated BlobContainerClientBuilder object - */ - @Override - public BlobContainerClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /** - * Sets the request retry options for all the requests made through the client. - * - * Setting this is mutually exclusive with using {@link #retryOptions(RetryOptions)}. - * - * @param retryOptions {@link RequestRetryOptions}. - * @return the updated BlobContainerClientBuilder object - */ - public BlobContainerClientBuilder retryOptions(RequestRetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * Sets the {@link RetryOptions} for all the requests made through the client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * Setting this is mutually exclusive with using {@link #retryOptions(RequestRetryOptions)}. - * Consider using {@link #retryOptions(RequestRetryOptions)} to also set storage specific options. - * - * @param retryOptions The {@link RetryOptions} to use for all the requests made through the client. - * @return the updated BlobContainerClientBuilder object - */ - @Override - public BlobContainerClientBuilder retryOptions(RetryOptions retryOptions) { - this.coreRetryOptions = retryOptions; - return this; - } - - /** - * Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is - * recommended that this method be called with an instance of the {@link HttpClientOptions} - * class (a subclass of the {@link ClientOptions} base class). The HttpClientOptions subclass provides more - * configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait - * interface. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param clientOptions A configured instance of {@link HttpClientOptions}. - * @see HttpClientOptions - * @return the updated BlobContainerClientBuilder object - * @throws NullPointerException If {@code clientOptions} is {@code null}. - */ - @Override - public BlobContainerClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = Objects.requireNonNull(clientOptions, "'clientOptions' cannot be null."); - return this; - } - - /** - * Sets the {@link HttpPipeline} to use for the service client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * The {@link #endpoint(String) endpoint} is not ignored when {@code pipeline} is set. - * - * @param httpPipeline {@link HttpPipeline} to use for sending service requests and receiving responses. - * @return the updated BlobContainerClientBuilder object - */ - @Override - public BlobContainerClientBuilder pipeline(HttpPipeline httpPipeline) { - if (this.httpPipeline != null && httpPipeline == null) { - LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured."); - } - - this.httpPipeline = httpPipeline; - return this; - } - - /** - * Sets the {@link BlobServiceVersion} that is used when making API requests. - *

- * If a service version is not provided, the service version that will be used will be the latest known service - * version based on the version of the client library being used. If no service version is specified, updating to a - * newer version of the client library will have the result of potentially moving to a newer service version. - *

- * Targeting a specific service version may also mean that the service will return an error for newer APIs. - * - * @param version {@link BlobServiceVersion} of the service to be used when making requests. - * @return the updated BlobContainerClientBuilder object - */ - public BlobContainerClientBuilder serviceVersion(BlobServiceVersion version) { - this.version = version; - return this; - } - - /** - * Sets the Audience to use for authentication with Azure Active Directory (AAD). The audience is not considered - * when using a shared key. - * @param audience {@link BlobAudience} to be used when requesting a token from Azure Active Directory (AAD). - * @return the updated BlobContainerClientBuilder object - */ - public BlobContainerClientBuilder audience(BlobAudience audience) { - this.audience = audience; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java deleted file mode 100644 index 873060f2a5b2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java +++ /dev/null @@ -1,1269 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.credential.TokenCredential; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedFlux; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.PagedResponseBase; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.AzureBlobStorageImpl; -import com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.ServicesGetAccountInfoHeaders; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobContainerEncryptionScope; -import com.azure.storage.blob.models.BlobContainerItem; -import com.azure.storage.blob.models.BlobCorsRule; -import com.azure.storage.blob.models.BlobServiceProperties; -import com.azure.storage.blob.models.BlobServiceStatistics; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.KeyInfo; -import com.azure.storage.blob.models.ListBlobContainersOptions; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.TaggedBlobItem; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.options.UndeleteBlobContainerOptions; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.AccountSasImplUtil; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import reactor.core.publisher.Mono; - -import java.net.URI; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.core.util.FluxUtil.pagedFluxError; -import static com.azure.core.util.FluxUtil.withContext; - -/** - * Client to a storage account. It may only be instantiated through a {@link BlobServiceClientBuilder}. This class does - * not hold any state about a particular storage account but is instead a convenient way of sending off appropriate - * requests to the resource on the service. It may also be used to construct URLs to blobs and containers. - * - *

- * This client contains operations on a blob. Operations on a container are available on {@link - * BlobContainerAsyncClient} through {@link #getBlobContainerAsyncClient(String)}, and operations on a blob are - * available on {@link BlobAsyncClient}. - * - *

- * Please see the Azure Docs for - * more information on containers. - * - *

- * Note this client is an async client that returns reactive responses from Spring Reactor Core project - * (https://projectreactor.io/). Calling the methods in this client will NOT start the actual network - * operation, until {@code .subscribe()} is called on the reactive response. You can simply convert one of these - * responses to a {@link java.util.concurrent.CompletableFuture} object through {@link Mono#toFuture()}. - */ -@ServiceClient(builder = BlobServiceClientBuilder.class, isAsync = true) -public final class BlobServiceAsyncClient { - private static final ClientLogger LOGGER = new ClientLogger(BlobServiceAsyncClient.class); - - private final AzureBlobStorageImpl azureBlobStorage; - - private final String accountName; - private final BlobServiceVersion serviceVersion; - private final CpkInfo customerProvidedKey; // only used to pass down to blob clients - private final EncryptionScope encryptionScope; // only used to pass down to blob clients - private final BlobContainerEncryptionScope blobContainerEncryptionScope; // only used to pass down to container - // clients - private final boolean anonymousAccess; - - /** - * Package-private constructor for use by {@link BlobServiceClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param anonymousAccess Whether the client was built with anonymousAccess - */ - BlobServiceAsyncClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - CpkInfo customerProvidedKey, EncryptionScope encryptionScope, - BlobContainerEncryptionScope blobContainerEncryptionScope, boolean anonymousAccess) { - /* Check to make sure the uri is valid. We don't want the error to occur later in the generated layer - when the sas token has already been applied. */ - try { - URI.create(url); - } catch (IllegalArgumentException ex) { - throw LOGGER.logExceptionAsError(ex); - } - this.azureBlobStorage = new AzureBlobStorageImplBuilder().pipeline(pipeline) - .url(url) - .version(serviceVersion.getVersion()) - .buildClient(); - this.serviceVersion = serviceVersion; - - this.accountName = accountName; - this.customerProvidedKey = customerProvidedKey; - this.encryptionScope = encryptionScope; - this.blobContainerEncryptionScope = blobContainerEncryptionScope; - this.anonymousAccess = anonymousAccess; - } - - /** - * Initializes a {@link BlobContainerAsyncClient} object pointing to the specified container. This method does not - * create a container. It simply constructs the URL to the container and offers access to methods relevant to - * containers. - * - *

Code Samples

- * - * - *
-     * BlobContainerAsyncClient blobContainerAsyncClient = client.getBlobContainerAsyncClient("containerName");
-     * 
- * - * - * @param containerName The name of the container to point to. A value of null or empty string will be interpreted - * as pointing to the root container and will be replaced by "$root". - * @return A {@link BlobContainerAsyncClient} object pointing to the specified container - */ - public BlobContainerAsyncClient getBlobContainerAsyncClient(String containerName) { - if (CoreUtils.isNullOrEmpty(containerName)) { - containerName = BlobContainerAsyncClient.ROOT_CONTAINER_NAME; - } - - return new BlobContainerAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - containerName, customerProvidedKey, encryptionScope, blobContainerEncryptionScope); - } - - /** - * Gets the {@link HttpPipeline} powering this client. - * - * @return The pipeline. - */ - public HttpPipeline getHttpPipeline() { - return azureBlobStorage.getHttpPipeline(); - } - - /** - * Gets the service version the client is using. - * - * @return the service version the client is using. - */ - public BlobServiceVersion getServiceVersion() { - return serviceVersion; - } - - CpkInfo getCustomerProvidedKey() { - return customerProvidedKey; - } - - EncryptionScope getEncryptionScope() { - return encryptionScope; - } - - BlobContainerEncryptionScope getBlobContainerEncryptionScope() { - return blobContainerEncryptionScope; - } - - boolean isAnonymousAccess() { - return anonymousAccess; - } - - /** - * Creates a new container within a storage account. If a container with the same name already exists, the operation - * fails. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobContainerAsyncClient blobContainerAsyncClient =
-     *     client.createBlobContainer("containerName").block();
-     * 
- * - * - * @param containerName Name of the container to create - * @return A {@link Mono} containing a {@link BlobContainerAsyncClient} used to interact with the container created. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createBlobContainer(String containerName) { - return createBlobContainerWithResponse(containerName, null, null).flatMap(FluxUtil::toMono); - } - - /** - * Creates a new container within a storage account. If a container with the same name already exists, the operation - * fails. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     *
-     * BlobContainerAsyncClient containerClient = client
-     *     .createBlobContainerWithResponse("containerName", metadata, PublicAccessType.CONTAINER).block().getValue();
-     * 
- * - * - * @param containerName Name of the container to create - * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param accessType Specifies how the data in this container is available to the public. See the - * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains a {@link - * BlobContainerAsyncClient} used to interact with the container created. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createBlobContainerWithResponse(String containerName, - Map metadata, PublicAccessType accessType) { - try { - return withContext( - context -> createBlobContainerWithResponse(containerName, metadata, accessType, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> createBlobContainerWithResponse(String containerName, - Map metadata, PublicAccessType accessType, Context context) { - throwOnAnonymousAccess(); - BlobContainerAsyncClient blobContainerAsyncClient = getBlobContainerAsyncClient(containerName); - - return blobContainerAsyncClient.createWithResponse(metadata, accessType, context) - .map(response -> new SimpleResponse<>(response, blobContainerAsyncClient)); - } - - /** - * Creates a new container within a storage account if it does not exist. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobContainerAsyncClient blobContainerAsyncClient =
-     *     client.createBlobContainerIfNotExists("containerName").block();
-     * 
- * - * - * @param containerName Name of the container to create - * @return A {@link Mono} containing a {@link BlobContainerAsyncClient} used to interact with the container created. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createBlobContainerIfNotExists(String containerName) { - return createBlobContainerIfNotExistsWithResponse(containerName, null, null).flatMap(FluxUtil::toMono); - } - - /** - * Creates a new container within a storage account if it does not exist. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata)
-     *     .setPublicAccessType(PublicAccessType.CONTAINER);
-     *
-     * client.createBlobContainerIfNotExistsWithResponse("containerName", options).subscribe(response -> {
-     *     if (response.getStatusCode() == 409) {
-     *         System.out.println("Already exists.");
-     *     } else {
-     *         System.out.println("successfully created.");
-     *     }
-     * });
-     * 
- * - * - * @param containerName Name of the container to create - * @param options {@link BlobContainerCreateOptions} - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains a {@link - * BlobContainerAsyncClient} used to interact with the container created. If {@link Response}'s status code is 201, - * a new container was successfully created. If status code is 409, a container with the same name already existed - * at this location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createBlobContainerIfNotExistsWithResponse(String containerName, - BlobContainerCreateOptions options) { - try { - return withContext(context -> createBlobContainerIfNotExistsWithResponse(containerName, options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> createBlobContainerIfNotExistsWithResponse(String containerName, - BlobContainerCreateOptions options, Context context) { - try { - options = options == null ? new BlobContainerCreateOptions() : options; - return createBlobContainerWithResponse(containerName, options.getMetadata(), options.getPublicAccessType(), - context).onErrorResume( - t -> t instanceof BlobStorageException && ((BlobStorageException) t).getStatusCode() == 409, t -> { - HttpResponse response = ((BlobStorageException) t).getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), this.getBlobContainerAsyncClient(containerName))); - }); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Deletes the specified container in the storage account. If the container doesn't exist the operation fails. For - * more information see the Azure Docs. - *

Code Samples

- * - * - *
-     * client.deleteBlobContainer("containerName").subscribe(
-     *     response -> System.out.printf("Delete container completed%n"),
-     *     error -> System.out.printf("Delete container failed: %s%n", error));
-     * 
- * - * - * @param containerName Name of the container to delete - * @return A {@link Mono} containing status code and HTTP headers - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteBlobContainer(String containerName) { - return deleteBlobContainerWithResponse(containerName).flatMap(FluxUtil::toMono); - } - - /** - * Deletes the specified container in the storage account. If the container doesn't exist the operation fails. For - * more information see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     * client.deleteBlobContainerWithResponse("containerName").subscribe(response ->
-     *     System.out.printf("Delete container completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param containerName Name of the container to delete - * @return A {@link Mono} containing status code and HTTP headers - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteBlobContainerWithResponse(String containerName) { - try { - return withContext(context -> deleteBlobContainerWithResponse(containerName, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> deleteBlobContainerWithResponse(String containerName, Context context) { - throwOnAnonymousAccess(); - return getBlobContainerAsyncClient(containerName).deleteWithResponse(null, context); - } - - /** - * Deletes the specified container in the storage account if it exists. For - * more information see the Azure - * Docs. - *

Code Samples

- * - * - *
-     * client.deleteBlobContainerIfExists("containerName").subscribe(deleted -> {
-     *     if (deleted) {
-     *         System.out.println("Successfully deleted.");
-     *     } else {
-     *         System.out.println("Does not exist.");
-     *     }
-     * });
-     * 
- * - * - * @param containerName Name of the container to delete - * @return A reactive {@link Mono} signaling completion. {@code true} indicates that the container was deleted. - * {@code false} indicates the container does not exist at this location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteBlobContainerIfExists(String containerName) { - return deleteBlobContainerIfExistsWithResponse(containerName).flatMap(FluxUtil::toMono); - } - - /** - * Deletes the specified container in the storage account if it exists. - * For more information see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     * client.deleteBlobContainerIfExistsWithResponse("containerName").subscribe(response -> {
-     *     if (response.getStatusCode() == 404) {
-     *         System.out.println("Does not exist.");
-     *     } else {
-     *         System.out.println("successfully deleted.");
-     *     }
-     * });
-     * 
- * - * - * @param containerName Name of the container to delete - * @return A reactive response signaling completion. If {@link Response}'s status code is 202, the blob container was - * successfully deleted. If status code is 404, the blob container does not exist. - * - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteBlobContainerIfExistsWithResponse(String containerName) { - try { - return withContext(context -> deleteBlobContainerIfExistsWithResponse(containerName, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> deleteBlobContainerIfExistsWithResponse(String containerName, Context context) { - try { - return deleteBlobContainerWithResponse(containerName, context) - .map(response -> (Response) new SimpleResponse<>(response, true)) - .onErrorResume( - t -> t instanceof BlobStorageException && ((BlobStorageException) t).getStatusCode() == 404, t -> { - HttpResponse response = ((BlobStorageException) t).getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), false)); - }); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Gets the URL of the storage account represented by this client. - * - * @return the URL. - */ - public String getAccountUrl() { - return azureBlobStorage.getUrl(); - } - - /** - * Returns a reactive Publisher emitting all the containers in this account lazily as needed. For more information, - * see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.listBlobContainers().subscribe(container -> System.out.printf("Name: %s%n", container.getName()));
-     * 
- * - * - * @return A reactive response emitting the list of containers. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobContainers() { - return this.listBlobContainers(new ListBlobContainersOptions()); - } - - /** - * Returns a reactive Publisher emitting all the containers in this account lazily as needed. For more information, - * see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * ListBlobContainersOptions options = new ListBlobContainersOptions()
-     *     .setPrefix("containerNamePrefixToMatch")
-     *     .setDetails(new BlobContainerListDetails().setRetrieveMetadata(true));
-     *
-     * client.listBlobContainers(options).subscribe(container -> System.out.printf("Name: %s%n", container.getName()));
-     * 
- * - * - * @param options A {@link ListBlobContainersOptions} which specifies what data should be returned by the service. - * @return A reactive response emitting the list of containers. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobContainers(ListBlobContainersOptions options) { - try { - return listBlobContainersWithOptionalTimeout(options, null); - } catch (RuntimeException ex) { - return pagedFluxError(LOGGER, ex); - } - } - - PagedFlux listBlobContainersWithOptionalTimeout(ListBlobContainersOptions options, - Duration timeout) { - throwOnAnonymousAccess(); - BiFunction>> func = (marker, pageSize) -> { - ListBlobContainersOptions finalOptions; - if (pageSize != null) { - if (options == null) { - finalOptions = new ListBlobContainersOptions().setMaxResultsPerPage(pageSize); - } else { - finalOptions = new ListBlobContainersOptions().setMaxResultsPerPage(pageSize) - .setDetails(options.getDetails()) - .setPrefix(options.getPrefix()); - } - } else { - finalOptions = options; - } - return listBlobContainersSegment(marker, finalOptions, timeout); - }; - - return new PagedFlux<>(pageSize -> func.apply(null, pageSize), func); - } - - private Mono> listBlobContainersSegment(String marker, - ListBlobContainersOptions options, Duration timeout) { - options = options == null ? new ListBlobContainersOptions() : options; - - return StorageImplUtils.applyOptionalTimeout(this.azureBlobStorage.getServices() - .listBlobContainersSegmentSinglePageAsync(options.getPrefix(), marker, options.getMaxResultsPerPage(), - ModelHelper.toIncludeTypes(options.getDetails()), null, null, Context.NONE), - timeout); - } - - /** - * Returns a reactive Publisher emitting the blobs in this account whose tags match the query expression. For more - * information, including information on the query syntax, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.findBlobsByTags("where=tag=value").subscribe(blob -> System.out.printf("Name: %s%n", blob.getName()));
-     * 
- * - * - * @param query Filters the results to return only blobs whose tags match the specified expression. - * @return A reactive response emitting the list of blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux findBlobsByTags(String query) { - return this.findBlobsByTags(new FindBlobsOptions(query)); - } - - /** - * Returns a reactive Publisher emitting the blobs in this account whose tags match the query expression. For more - * information, including information on the query syntax, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10))
-     *     .subscribe(blob -> System.out.printf("Name: %s%n", blob.getName()));
-     * 
- * - * - * @param options {@link FindBlobsOptions} - * @return A reactive response emitting the list of blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux findBlobsByTags(FindBlobsOptions options) { - try { - return findBlobsByTags(options, null, Context.NONE); - } catch (RuntimeException ex) { - return pagedFluxError(LOGGER, ex); - } - } - - PagedFlux findBlobsByTags(FindBlobsOptions options, Duration timeout, Context context) { - throwOnAnonymousAccess(); - StorageImplUtils.assertNotNull("options", options); - BiFunction>> func = (marker, pageSize) -> { - FindBlobsOptions finalOptions; - if (pageSize != null) { - finalOptions = new FindBlobsOptions(options.getQuery()).setMaxResultsPerPage(pageSize); - } else { - finalOptions = options; - } - return this.findBlobsByTags(finalOptions, marker, timeout, context); - }; - return new PagedFlux<>(pageSize -> func.apply(null, pageSize), func); - } - - private Mono> findBlobsByTags(FindBlobsOptions options, String marker, - Duration timeout, Context context) { - throwOnAnonymousAccess(); - StorageImplUtils.assertNotNull("options", options); - return StorageImplUtils.applyOptionalTimeout(this.azureBlobStorage.getServices() - .filterBlobsWithResponseAsync(null, null, options.getQuery(), marker, options.getMaxResultsPerPage(), null, - context), - timeout).map(response -> { - List value = response.getValue() - .getBlobs() - .stream() - .map(ModelHelper::populateTaggedBlobItem) - .collect(Collectors.toList()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - value, response.getValue().getNextMarker(), response.getDeserializedHeaders()); - }); - } - - /** - * Gets the properties of a storage account’s Blob service. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getProperties().subscribe(response ->
-     *     System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
-     *         response.getHourMetrics().isEnabled(),
-     *         response.getMinuteMetrics().isEnabled()));
-     * 
- * - * - * @return A reactive response containing the storage account properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getProperties() { - return getPropertiesWithResponse().flatMap(FluxUtil::toMono); - } - - /** - * Gets the properties of a storage account’s Blob service. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getPropertiesWithResponse().subscribe(response ->
-     *     System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
-     *         response.getValue().getHourMetrics().isEnabled(),
-     *         response.getValue().getMinuteMetrics().isEnabled()));
-     * 
- * - * - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the storage - * account properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesWithResponse() { - try { - return withContext(this::getPropertiesWithResponse); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getPropertiesWithResponse(Context context) { - context = context == null ? Context.NONE : context; - throwOnAnonymousAccess(); - return this.azureBlobStorage.getServices() - .getPropertiesWithResponseAsync(null, null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getValue())); - } - - /** - * Sets properties for a storage account's Blob service endpoint. For more information, see the - * Azure Docs. - * Note that setting the default service version has no effect when using this client because this client explicitly - * sets the version header on each request, overriding the default. - *

This method checks to ensure the properties being sent follow the specifications indicated in the Azure Docs. - * If CORS policies are set, CORS parameters that are not set default to the empty string.

- * - *

Code Samples

- * - * - *
-     * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3);
-     * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1);
-     *
-     * BlobServiceProperties properties = new BlobServiceProperties()
-     *     .setLogging(new BlobAnalyticsLogging()
-     *         .setWrite(true)
-     *         .setDelete(true)
-     *         .setRetentionPolicy(loggingRetentionPolicy))
-     *     .setHourMetrics(new BlobMetrics()
-     *         .setEnabled(true)
-     *         .setRetentionPolicy(metricsRetentionPolicy))
-     *     .setMinuteMetrics(new BlobMetrics()
-     *         .setEnabled(true)
-     *         .setRetentionPolicy(metricsRetentionPolicy));
-     *
-     * client.setProperties(properties).subscribe(
-     *     response -> System.out.printf("Setting properties completed%n"),
-     *     error -> System.out.printf("Setting properties failed: %s%n", error));
-     * 
- * - * - * @param properties Configures the service. - * @return A {@link Mono} containing the storage account properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setProperties(BlobServiceProperties properties) { - return setPropertiesWithResponse(properties).flatMap(FluxUtil::toMono); - } - - /** - * Sets properties for a storage account's Blob service endpoint. For more information, see the - * Azure Docs. - * Note that setting the default service version has no effect when using this client because this client explicitly - * sets the version header on each request, overriding the default. - *

This method checks to ensure the properties being sent follow the specifications indicated in the Azure Docs. - * If CORS policies are set, CORS parameters that are not set default to the empty string.

- *

Code Samples

- * - * - *
-     * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3);
-     * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1);
-     *
-     * BlobServiceProperties properties = new BlobServiceProperties()
-     *     .setLogging(new BlobAnalyticsLogging()
-     *         .setWrite(true)
-     *         .setDelete(true)
-     *         .setRetentionPolicy(loggingRetentionPolicy))
-     *     .setHourMetrics(new BlobMetrics()
-     *         .setEnabled(true)
-     *         .setRetentionPolicy(metricsRetentionPolicy))
-     *     .setMinuteMetrics(new BlobMetrics()
-     *         .setEnabled(true)
-     *         .setRetentionPolicy(metricsRetentionPolicy));
-     *
-     * client.setPropertiesWithResponse(properties).subscribe(response ->
-     *     System.out.printf("Setting properties completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param properties Configures the service. - * @return A {@link Mono} containing the storage account properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setPropertiesWithResponse(BlobServiceProperties properties) { - try { - return withContext(context -> setPropertiesWithResponse(properties, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> setPropertiesWithResponse(BlobServiceProperties properties, Context context) { - throwOnAnonymousAccess(); - BlobServiceProperties finalProperties = null; - if (properties != null) { - finalProperties = new BlobServiceProperties(); - - // Logging - finalProperties.setLogging(properties.getLogging()); - if (finalProperties.getLogging() != null) { - StorageImplUtils.assertNotNull("Logging Version", finalProperties.getLogging().getVersion()); - ModelHelper.validateRetentionPolicy(finalProperties.getLogging().getRetentionPolicy(), - "Logging Retention Policy"); - } - - // Hour Metrics - finalProperties.setHourMetrics(properties.getHourMetrics()); - if (finalProperties.getHourMetrics() != null) { - StorageImplUtils.assertNotNull("HourMetrics Version", finalProperties.getHourMetrics().getVersion()); - ModelHelper.validateRetentionPolicy(finalProperties.getHourMetrics().getRetentionPolicy(), - "HourMetrics Retention " + "Policy"); - if (finalProperties.getHourMetrics().isEnabled()) { - StorageImplUtils.assertNotNull("HourMetrics IncludeApis", - finalProperties.getHourMetrics().isIncludeApis()); - } - } - - // Minute Metrics - finalProperties.setMinuteMetrics(properties.getMinuteMetrics()); - if (finalProperties.getMinuteMetrics() != null) { - StorageImplUtils.assertNotNull("MinuteMetrics Version", - finalProperties.getMinuteMetrics().getVersion()); - ModelHelper.validateRetentionPolicy(finalProperties.getMinuteMetrics().getRetentionPolicy(), - "MinuteMetrics " + "Retention Policy"); - if (finalProperties.getMinuteMetrics().isEnabled()) { - StorageImplUtils.assertNotNull("MinuteMetrics IncludeApis", - finalProperties.getHourMetrics().isIncludeApis()); - } - } - - // CORS - List corsRules = new ArrayList<>(); - for (BlobCorsRule rule : properties.getCors()) { - corsRules.add(ModelHelper.validatedCorsRule(rule)); - } - finalProperties.setCors(corsRules); - - // Default Service Version - finalProperties.setDefaultServiceVersion(properties.getDefaultServiceVersion()); - - // Delete Retention Policy - finalProperties.setDeleteRetentionPolicy(properties.getDeleteRetentionPolicy()); - ModelHelper.validateRetentionPolicy(finalProperties.getDeleteRetentionPolicy(), - "DeleteRetentionPolicy Days"); - - // Static Website - finalProperties.setStaticWebsite(properties.getStaticWebsite()); - - } - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getServices() - .setPropertiesNoCustomHeadersWithResponseAsync(finalProperties, null, null, context); - } - - /** - * Gets a user delegation key for use with this account's blob storage. Note: This method call is only valid when - * using {@link TokenCredential} in this object's {@link HttpPipeline}. - * - *

Code Samples

- * - * - *
-     * client.getUserDelegationKey(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response ->
-     *     System.out.printf("User delegation key: %s%n", response.getValue()));
-     * 
- * - * - * @param start Start time for the key's validity. Null indicates immediate start. - * @param expiry Expiration of the key's validity. - * @return A {@link Mono} containing the user delegation key. - * @throws IllegalArgumentException If {@code start} isn't null and is after {@code expiry}. - * @throws NullPointerException If {@code expiry} is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry) { - return getUserDelegationKeyWithResponse(start, expiry).flatMap(FluxUtil::toMono); - } - - /** - * Gets a user delegation key for use with this account's blob storage. Note: This method call is only valid when - * using {@link TokenCredential} in this object's {@link HttpPipeline}. - * - *

Code Samples

- * - * - *
-     * client.getUserDelegationKeyWithResponse(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response ->
-     *     System.out.printf("User delegation key: %s%n", response.getValue().getValue()));
-     * 
- * - * - * @param start Start time for the key's validity. Null indicates immediate start. - * @param expiry Expiration of the key's validity. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} containing the user - * delegation key. - * @throws IllegalArgumentException If {@code start} isn't null and is after {@code expiry}. - * @throws NullPointerException If {@code expiry} is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getUserDelegationKeyWithResponse(OffsetDateTime start, - OffsetDateTime expiry) { - try { - return withContext(context -> getUserDelegationKeyWithResponse(start, expiry, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getUserDelegationKeyWithResponse(OffsetDateTime start, OffsetDateTime expiry, - Context context) { - StorageImplUtils.assertNotNull("expiry", expiry); - if (start != null && !start.isBefore(expiry)) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("`start` must be null or a datetime before `expiry`.")); - } - throwOnAnonymousAccess(); - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getServices() - .getUserDelegationKeyWithResponseAsync( - new KeyInfo().setStart(start == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(start)) - .setExpiry(Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiry)), - null, null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getValue())); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. For more information, see - * the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getStatistics().subscribe(response ->
-     *     System.out.printf("Geo-replication status: %s%n", response.getGeoReplication().getStatus()));
-     * 
- * - * - * @return A {@link Mono} containing the storage account statistics. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getStatistics() { - return getStatisticsWithResponse().flatMap(FluxUtil::toMono); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. For more information, see - * the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getStatisticsWithResponse().subscribe(response ->
-     *     System.out.printf("Geo-replication status: %s%n", response.getValue().getGeoReplication().getStatus()));
-     * 
- * - * - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} containing the - * storage account statistics. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getStatisticsWithResponse() { - try { - return withContext(this::getStatisticsWithResponse); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getStatisticsWithResponse(Context context) { - throwOnAnonymousAccess(); - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getServices() - .getStatisticsWithResponseAsync(null, null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getValue())); - } - - /** - * Returns the sku name and account kind for the account. For more information, please see the - * Azure Docs. - *

Code Samples

- * - * - *
-     * client.getAccountInfo().subscribe(response ->
-     *     System.out.printf("Account kind: %s, SKU: %s%n", response.getAccountKind(), response.getSkuName()));
-     * 
- * - * - * @return A {@link Mono} containing the storage account info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccountInfo() { - return getAccountInfoWithResponse().flatMap(FluxUtil::toMono); - } - - /** - * Returns the sku name and account kind for the account. For more information, please see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.getAccountInfoWithResponse().subscribe(response ->
-     *     System.out.printf("Account kind: %s, SKU: %s%n", response.getValue().getAccountKind(),
-     *         response.getValue().getSkuName()));
-     * 
- * - * - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} the storage account - * info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoWithResponse() { - try { - return withContext(this::getAccountInfoWithResponse); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getAccountInfoWithResponse(Context context) { - throwOnAnonymousAccess(); - return this.azureBlobStorage.getServices().getAccountInfoWithResponseAsync(null, null, context).map(rb -> { - ServicesGetAccountInfoHeaders hd = rb.getDeserializedHeaders(); - return new SimpleResponse<>(rb, - new StorageAccountInfo(hd.getXMsSkuName(), hd.getXMsAccountKind(), hd.isXMsIsHnsEnabled())); - }); - } - - /** - * Get associated account name. - * - * @return account name associated with this storage resource. - */ - public String getAccountName() { - return this.accountName; - } - - /** - * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

- * - *

The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob - * containers and file shares.

- * - *
-     * AccountSasPermission permissions = new AccountSasPermission()
-     *     .setListPermission(true)
-     *     .setReadPermission(true);
-     * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true);
-     * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true);
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
-     *
-     * AccountSasSignatureValues sasValues =
-     *     new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
-     *
-     * // Client must be authenticated via StorageSharedKeyCredential
-     * String sas = client.generateAccountSas(sasValues);
-     * 
- * - * - * @param accountSasSignatureValues {@link AccountSasSignatureValues} - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues) { - return generateAccountSas(accountSasSignatureValues, Context.NONE); - } - - /** - * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

- * - *

The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob - * containers and file shares.

- * - *
-     * AccountSasPermission permissions = new AccountSasPermission()
-     *     .setListPermission(true)
-     *     .setReadPermission(true);
-     * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true);
-     * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true);
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
-     *
-     * AccountSasSignatureValues sasValues =
-     *     new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
-     *
-     * // Client must be authenticated via StorageSharedKeyCredential
-     * String sas = client.generateAccountSas(sasValues, new Context("key", "value"));
-     * 
- * - * - * @param accountSasSignatureValues {@link AccountSasSignatureValues} - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues, Context context) { - return generateAccountSas(accountSasSignatureValues, null, context); - } - - /** - * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

- * - * @param accountSasSignatureValues {@link AccountSasSignatureValues} - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues, - Consumer stringToSignHandler, Context context) { - throwOnAnonymousAccess(); - return new AccountSasImplUtil(accountSasSignatureValues, - this.encryptionScope == null ? null : this.encryptionScope.getEncryptionScope()) - .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); - } - - /** - * Checks if service client was built with credentials. - */ - private void throwOnAnonymousAccess() { - if (anonymousAccess) { - throw LOGGER.logExceptionAsError( - new IllegalStateException("Service client cannot be accessed without " + "credentials")); - } - } - - /** - * Restores a previously deleted container. - * If the container associated with provided deletedContainerName - * already exists, this call will result in a 409 (conflict). - * This API is only functional if Container Soft Delete is enabled - * for the storage account associated with the container. - * - *

Code Samples

- * - * - *
-     * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions();
-     * listBlobContainersOptions.getDetails().setRetrieveDeleted(true);
-     * client.listBlobContainers(listBlobContainersOptions).flatMap(
-     *     deletedContainer -> {
-     *         Mono<BlobContainerAsyncClient> blobContainerClient = client.undeleteBlobContainer(
-     *             deletedContainer.getName(), deletedContainer.getVersion());
-     *         return blobContainerClient;
-     *     }
-     * ).then().block();
-     * 
- * - * - * @param deletedContainerName The name of the previously deleted container. - * @param deletedContainerVersion The version of the previously deleted container. - * @return A {@link Mono} containing a {@link BlobContainerAsyncClient} used - * to interact with the restored container. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono undeleteBlobContainer(String deletedContainerName, - String deletedContainerVersion) { - try { - return this - .undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(deletedContainerName, deletedContainerVersion)) - .flatMap(FluxUtil::toMono); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Restores a previously deleted container. The restored container - * will be renamed to the destinationContainerName if provided in options. - * Otherwise deletedContainerName is used as destination container name. - * If the container associated with provided destinationContainerName - * already exists, this call will result in a 409 (conflict). - * This API is only functional if Container Soft Delete is enabled - * for the storage account associated with the container. - * - *

Code Samples

- * - * - *
-     * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions();
-     * listBlobContainersOptions.getDetails().setRetrieveDeleted(true);
-     * client.listBlobContainers(listBlobContainersOptions).flatMap(
-     *     deletedContainer -> {
-     *         Mono<BlobContainerAsyncClient> blobContainerClient = client.undeleteBlobContainerWithResponse(
-     *             new UndeleteBlobContainerOptions(deletedContainer.getName(), deletedContainer.getVersion()))
-     *             .map(Response::getValue);
-     *         return blobContainerClient;
-     *     }
-     * ).then().block();
-     * 
- * - * - * @param options {@link UndeleteBlobContainerOptions}. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains a {@link - * BlobContainerAsyncClient} used to interact with the restored container. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - undeleteBlobContainerWithResponse(UndeleteBlobContainerOptions options) { - try { - return withContext(context -> undeleteBlobContainerWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> undeleteBlobContainerWithResponse(UndeleteBlobContainerOptions options, - Context context) { - StorageImplUtils.assertNotNull("options", options); - boolean hasOptionalDestinationContainerName = options.getDestinationContainerName() != null; - String finalDestinationContainerName = hasOptionalDestinationContainerName - ? options.getDestinationContainerName() - : options.getDeletedContainerName(); - context = context == null ? Context.NONE : context; - return this.azureBlobStorage.getContainers() - .restoreWithResponseAsync(finalDestinationContainerName, null, null, options.getDeletedContainerName(), - options.getDeletedContainerVersion(), context) - .map( - response -> new SimpleResponse<>(response, getBlobContainerAsyncClient(finalDestinationContainerName))); - } - - // /** - // * Renames an existing blob container. - // * - // *

Code Samples

- // * - // * - // * - // * - // * @param sourceContainerName The current name of the container. - // * @param destinationContainerName The new name of the container. - // * @return A {@link Mono} containing a {@link BlobContainerAsyncClient} used to interact with the renamed container. - // */ - // @ServiceMethod(returns = ReturnType.SINGLE) - // Mono renameBlobContainer(String sourceContainerName, - // String destinationContainerName) { - // return renameBlobContainerWithResponse(sourceContainerName, - // new BlobContainerRenameOptions(destinationContainerName)).flatMap(FluxUtil::toMono); - // } - // - // /** - // * Renames an existing blob container. - // * - // *

Code Samples

- // * - // * - // * - // * - // * @param sourceContainerName The current name of the container. - // * @param options {@link BlobContainerRenameOptions} - // * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains a - // * {@link BlobContainerAsyncClient} used to interact with the renamed container. - // */ - // @ServiceMethod(returns = ReturnType.SINGLE) - // Mono> renameBlobContainerWithResponse(String sourceContainerName, - // BlobContainerRenameOptions options) { - // try { - // return withContext(context -> renameBlobContainerWithResponse(sourceContainerName, options, context)); - // } catch (RuntimeException ex) { - // return monoError(logger, ex); - // } - // } - // - // Mono> renameBlobContainerWithResponse(String sourceContainerName, - // BlobContainerRenameOptions options, Context context) { - // BlobContainerAsyncClient destinationContainerClient = getBlobContainerAsyncClient( - // options.getDestinationContainerName()); - // return destinationContainerClient.renameWithResponseHelper(sourceContainerName, options, context); - // } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java deleted file mode 100644 index 2b7da8cad0b1..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java +++ /dev/null @@ -1,1129 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.credential.TokenCredential; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.PagedResponseBase; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.AzureBlobStorageImpl; -import com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder; -import com.azure.storage.blob.implementation.models.ContainersRestoreHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.FilterBlobSegment; -import com.azure.storage.blob.implementation.models.ServicesFilterBlobsHeaders; -import com.azure.storage.blob.implementation.models.ServicesGetAccountInfoHeaders; -import com.azure.storage.blob.implementation.models.ServicesGetPropertiesHeaders; -import com.azure.storage.blob.implementation.models.ServicesGetStatisticsHeaders; -import com.azure.storage.blob.implementation.models.ServicesGetUserDelegationKeyHeaders; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobContainerEncryptionScope; -import com.azure.storage.blob.models.BlobContainerItem; -import com.azure.storage.blob.models.BlobContainerListDetails; -import com.azure.storage.blob.models.BlobCorsRule; -import com.azure.storage.blob.models.BlobServiceProperties; -import com.azure.storage.blob.models.BlobServiceStatistics; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.KeyInfo; -import com.azure.storage.blob.models.ListBlobContainersIncludeType; -import com.azure.storage.blob.models.ListBlobContainersOptions; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.TaggedBlobItem; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.options.UndeleteBlobContainerOptions; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.AccountSasImplUtil; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.sas.AccountSasSignatureValues; - -import java.net.URI; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.function.BiFunction; -import java.util.stream.Collectors; - -import static com.azure.storage.common.implementation.StorageImplUtils.sendRequest; -import java.util.function.Consumer; - -/** - * Client to a storage account. It may only be instantiated through a {@link BlobServiceClientBuilder}. This class does - * not hold any state about a particular storage account but is instead a convenient way of sending off appropriate - * requests to the resource on the service. It may also be used to construct URLs to blobs and containers. - * - *

- * This client contains operations on a blob. Operations on a container are available on {@link BlobContainerClient} - * through {@link #getBlobContainerClient(String)}, and operations on a blob are available on {@link BlobClient}. - * - *

- * Please see here for more - * information on containers. - */ -@ServiceClient(builder = BlobServiceClientBuilder.class) -public final class BlobServiceClient { - private static final ClientLogger LOGGER = new ClientLogger(BlobServiceClient.class); - private final AzureBlobStorageImpl azureBlobStorage; - private final String accountName; - private final BlobServiceVersion serviceVersion; - private final CpkInfo customerProvidedKey; // only used to pass down to blob clients - private final EncryptionScope encryptionScope; // only used to pass down to blob clients - private final BlobContainerEncryptionScope blobContainerEncryptionScope; // only used to pass down to container - // clients - private final boolean anonymousAccess; - - /** - * Package-private constructor for use by {@link BlobServiceClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param anonymousAccess Whether the client was built with anonymousAccess - */ - BlobServiceClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - CpkInfo customerProvidedKey, EncryptionScope encryptionScope, - BlobContainerEncryptionScope blobContainerEncryptionScope, boolean anonymousAccess) { - /* Check to make sure the uri is valid. We don't want the error to occur later in the generated layer - when the sas token has already been applied. */ - try { - URI.create(url); - } catch (IllegalArgumentException ex) { - throw LOGGER.logExceptionAsError(ex); - } - this.azureBlobStorage = new AzureBlobStorageImplBuilder().pipeline(pipeline) - .url(url) - .version(serviceVersion.getVersion()) - .buildClient(); - this.serviceVersion = serviceVersion; - - this.accountName = accountName; - this.customerProvidedKey = customerProvidedKey; - this.encryptionScope = encryptionScope; - this.blobContainerEncryptionScope = blobContainerEncryptionScope; - this.anonymousAccess = anonymousAccess; - } - - /** - * Initializes a {@link BlobContainerClient} object pointing to the specified container. This method does not create - * a container. It simply constructs the URL to the container and offers access to methods relevant to containers. - * - *

Code Samples

- * - * - *
-     * BlobContainerClient blobContainerClient = client.getBlobContainerClient("containerName");
-     * 
- * - * - * @param containerName The name of the container to point to. - * @return A {@link BlobContainerClient} object pointing to the specified container - */ - public BlobContainerClient getBlobContainerClient(String containerName) { - if (CoreUtils.isNullOrEmpty(containerName)) { - containerName = BlobContainerClient.ROOT_CONTAINER_NAME; - } - return new BlobContainerClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - containerName, customerProvidedKey, encryptionScope, blobContainerEncryptionScope); - } - - /** - * Gets the {@link HttpPipeline} powering this client. - * - * @return The pipeline. - */ - public HttpPipeline getHttpPipeline() { - return azureBlobStorage.getHttpPipeline(); - } - - /** - * Gets the service version the client is using. - * - * @return the service version the client is using. - */ - public BlobServiceVersion getServiceVersion() { - return serviceVersion; - } - - /** - * Creates a new container within a storage account. If a container with the same name already exists, the operation - * fails. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobContainerClient blobContainerClient = client.createBlobContainer("containerName");
-     * 
- * - * - * @param containerName Name of the container to create - * @return The {@link BlobContainerClient} used to interact with the container created. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobContainerClient createBlobContainer(String containerName) { - return createBlobContainerWithResponse(containerName, null, null, Context.NONE).getValue(); - } - - /** - * Creates a new container within a storage account. If a container with the same name already exists, the operation - * fails. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Context context = new Context("Key", "Value");
-     *
-     * BlobContainerClient blobContainerClient = client.createBlobContainerWithResponse(
-     *     "containerName",
-     *     metadata,
-     *     PublicAccessType.CONTAINER,
-     *     context).getValue();
-     * 
- * - * - * @param containerName Name of the container to create - * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param accessType Specifies how the data in this container is available to the public. See the - * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} contains the {@link BlobContainerClient} used - * to interact with the container created. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createBlobContainerWithResponse(String containerName, - Map metadata, PublicAccessType accessType, Context context) { - BlobContainerClient client = getBlobContainerClient(containerName); - return new SimpleResponse<>(client.createWithResponse(metadata, accessType, null, context), client); - } - - /** - * Creates a new container within a storage account if it does not exist. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobContainerClient blobContainerClient = client.createBlobContainerIfNotExists("containerName");
-     * 
- * - * - * @param containerName Name of the container to create - * @return The {@link BlobContainerClient} used to interact with the container created. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobContainerClient createBlobContainerIfNotExists(String containerName) { - return createBlobContainerIfNotExistsWithResponse(containerName, null, Context.NONE).getValue(); - } - - /** - * Creates a new container within a storage account if it does not exist. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Context context = new Context("Key", "Value");
-     * BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata)
-     *     .setPublicAccessType(PublicAccessType.CONTAINER);
-     *
-     * Response<BlobContainerClient> response = client.createBlobContainerIfNotExistsWithResponse("containerName",
-     *     options, context);
-     *
-     * if (response.getStatusCode() == 409) {
-     *     System.out.println("Already existed.");
-     * } else {
-     *     System.out.printf("Create completed with status %d%n", response.getStatusCode());
-     * }
-     * 
- * - * - * @param containerName Name of the container to create - * @param options {@link BlobContainerCreateOptions} - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} contains the {@link BlobContainerClient} used - * to interact with the container created. If {@link Response}'s status code is 201, a new container was - * successfully created. If status code is 409, a container with the same name already existed at this location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createBlobContainerIfNotExistsWithResponse(String containerName, - BlobContainerCreateOptions options, Context context) { - BlobContainerClient client = getBlobContainerClient(containerName); - return new SimpleResponse<>(client.createIfNotExistsWithResponse(options, null, context), client); - } - - /** - * Deletes the specified container in the storage account. If the container doesn't exist the operation fails. For - * more information see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * try {
-     *     client.deleteBlobContainer("container Name");
-     *     System.out.printf("Delete container completed with status %n");
-     * } catch (UnsupportedOperationException error) {
-     *     System.out.printf("Delete container failed: %s%n", error);
-     * }
-     * 
- * - * - * @param containerName Name of the container to delete - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void deleteBlobContainer(String containerName) { - deleteBlobContainerWithResponse(containerName, Context.NONE); - } - - /** - * Deletes the specified container in the storage account. If the container doesn't exist the operation fails. For - * more information see the Azure - * Docs. - * - * @param containerName Name of the container to delete - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteBlobContainerWithResponse(String containerName, Context context) { - return getBlobContainerClient(containerName).deleteWithResponse(null, null, context); - } - - /** - * Deletes the specified container in the storage account if it exists. For - * more information see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * boolean result = client.deleteBlobContainerIfExists("container Name");
-     * System.out.println("Delete container completed: " + result);
-     * 
- * - * - * @param containerName Name of the container to delete - * @return {@code true} if the container is successfully deleted, {@code false} if the container does not exist. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public boolean deleteBlobContainerIfExists(String containerName) { - return deleteBlobContainerIfExistsWithResponse(containerName, Context.NONE).getValue(); - } - - /** - * Deletes the specified container in the storage account if it exists. For - * more information see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     *
-     * Response<Boolean> response = client.deleteBlobContainerIfExistsWithResponse("containerName", context);
-     * if (response.getStatusCode() == 404) {
-     *     System.out.println("Does not exist.");
-     * } else {
-     *     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
-     * }
-     * 
- * - * - * @param containerName Name of the container to delete - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. If {@link Response}'s status code is 202, the blob - * container was successfully deleted. If status code is 404, the container does not exist. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteBlobContainerIfExistsWithResponse(String containerName, Context context) { - return getBlobContainerClient(containerName).deleteIfExistsWithResponse(null, null, context); - } - - /** - * Gets the URL of the storage account represented by this client. - * - * @return the URL. - */ - public String getAccountUrl() { - return azureBlobStorage.getUrl(); - } - - /** - * Returns a lazy loaded list of containers in this account. The returned {@link PagedIterable} can be consumed - * while new items are automatically retrieved as needed. For more information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.listBlobContainers().forEach(container -> System.out.printf("Name: %s%n", container.getName()));
-     * 
- * - * - * @return The list of containers. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobContainers() { - return this.listBlobContainers(new ListBlobContainersOptions(), null); - } - - /** - * Returns a lazy loaded list of containers in this account. The returned {@link PagedIterable} can be consumed - * while new items are automatically retrieved as needed. For more information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * ListBlobContainersOptions options = new ListBlobContainersOptions()
-     *     .setPrefix("containerNamePrefixToMatch")
-     *     .setDetails(new BlobContainerListDetails().setRetrieveMetadata(true));
-     *
-     * client.listBlobContainers(options, timeout).forEach(container -> System.out.printf("Name: %s%n", container.getName()));
-     * 
- * - * - * @param options A {@link ListBlobContainersOptions} which specifies what data should be returned by the service. - * If iterating by page, the page size passed to byPage methods such as - * {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @return The list of containers. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobContainers(ListBlobContainersOptions options, Duration timeout) { - throwOnAnonymousAccess(); - BiFunction> pageRetriever = (marker, pageSize) -> { - ListBlobContainersOptions finalOptions = options != null ? options : new ListBlobContainersOptions(); - Integer finalPageSize = pageSize != null ? pageSize : finalOptions.getMaxResultsPerPage(); - return listBlobContainersSegment(marker, finalOptions.getDetails(), finalOptions.getPrefix(), finalPageSize, - timeout); - }; - return new PagedIterable<>(pageSize -> pageRetriever.apply(null, pageSize), pageRetriever); - - } - - private PagedResponse listBlobContainersSegment(String marker, BlobContainerListDetails details, - String prefix, Integer maxResultsPerPage, Duration timeout) { - // Set up the include types based on the details provided in the options - List include = ModelHelper.toIncludeTypes(details); - - Callable> operation = () -> this.azureBlobStorage.getServices() - .listBlobContainersSegmentSinglePage(prefix, marker, maxResultsPerPage, include, null, null, Context.NONE); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Returns a lazy loaded list of blobs in this account whose tags match the query expression. The returned - * {@link PagedIterable} can be consumed while new items are automatically retrieved as needed. For more - * information, including information on the query syntax, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.findBlobsByTags("where=tag=value").forEach(blob -> System.out.printf("Name: %s%n", blob.getName()));
-     * 
- * - * - * @param query Filters the results to return only blobs whose tags match the specified expression. - * @return The list of blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable findBlobsByTags(String query) { - return this.findBlobsByTags(new FindBlobsOptions(query), null, Context.NONE); - } - - /** - * Returns a lazy loaded list of blobs in this account whose tags match the query expression. The returned - * {@link PagedIterable} can be consumed while new items are automatically retrieved as needed. For more - * information, including information on the query syntax, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     * client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10), timeout, context)
-     *     .forEach(blob -> System.out.printf("Name: %s%n", blob.getName()));
-     * 
- * - * - * @param options {@link FindBlobsOptions}. If iterating by page, the page size passed to byPage methods such as - * {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The list of blobs. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable findBlobsByTags(FindBlobsOptions options, Duration timeout, Context context) { - throwOnAnonymousAccess(); - StorageImplUtils.assertNotNull("options", options); - BiFunction> func = (marker, pageSize) -> { - FindBlobsOptions finalOptions = (pageSize != null) - ? new FindBlobsOptions(options.getQuery()).setMaxResultsPerPage(pageSize) - : options; - return findBlobsByTagsHelper(finalOptions, marker, timeout, context); - }; - return new PagedIterable<>(pageSize -> func.apply(null, pageSize), func); - } - - private PagedResponse findBlobsByTagsHelper(FindBlobsOptions options, String marker, - Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - - StorageImplUtils.assertNotNull("options", options); - Callable> operation - = () -> this.azureBlobStorage.getServices() - .filterBlobsWithResponse(null, null, options.getQuery(), marker, options.getMaxResultsPerPage(), null, - finalContext); - - ResponseBase response - = StorageImplUtils.sendRequest(operation, timeout, BlobStorageException.class); - - List value = response.getValue() - .getBlobs() - .stream() - .map(ModelHelper::populateTaggedBlobItem) - .collect(Collectors.toList()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), value, - response.getValue().getNextMarker(), response.getDeserializedHeaders()); - } - - /** - * Gets the properties of a storage account’s Blob service. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobServiceProperties properties = client.getProperties();
-     *
-     * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
-     *     properties.getHourMetrics().isEnabled(),
-     *     properties.getMinuteMetrics().isEnabled());
-     * 
- * - * - * @return The storage account properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobServiceProperties getProperties() { - return getPropertiesWithResponse(null, Context.NONE).getValue(); - } - - /** - * Gets the properties of a storage account’s Blob service. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("Key", "Value");
-     * BlobServiceProperties properties = client.getPropertiesWithResponse(timeout, context).getValue();
-     *
-     * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
-     *     properties.getHourMetrics().isEnabled(),
-     *     properties.getMinuteMetrics().isEnabled());
-     * 
- * - * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} contains the storage account properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesWithResponse(Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - throwOnAnonymousAccess(); - Callable> operation - = () -> this.azureBlobStorage.getServices().getPropertiesWithResponse(null, null, finalContext); - ResponseBase response - = StorageImplUtils.sendRequest(operation, timeout, BlobStorageException.class); - - return new SimpleResponse<>(response, response.getValue()); - } - - /** - * Sets properties for a storage account's Blob service endpoint. For more information, see the - * Azure Docs. - * Note that setting the default service version has no effect when using this client because this client explicitly - * sets the version header on each request, overriding the default. - *

This method checks to ensure the properties being sent follow the specifications indicated in the Azure Docs. - * If CORS policies are set, CORS parameters that are not set default to the empty string.

- * - *

Code Samples

- * - * - *
-     * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3);
-     * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1);
-     *
-     * BlobServiceProperties properties = new BlobServiceProperties()
-     *     .setLogging(new BlobAnalyticsLogging()
-     *         .setWrite(true)
-     *         .setDelete(true)
-     *         .setVersion("1.0")
-     *         .setRetentionPolicy(loggingRetentionPolicy))
-     *     .setHourMetrics(new BlobMetrics()
-     *         .setEnabled(true)
-     *         .setVersion("1.0")
-     *         .setIncludeApis(true)
-     *         .setRetentionPolicy(metricsRetentionPolicy))
-     *     .setMinuteMetrics(new BlobMetrics()
-     *         .setEnabled(true)
-     *         .setVersion("1.0")
-     *         .setIncludeApis(true)
-     *         .setRetentionPolicy(metricsRetentionPolicy));
-     *
-     * try {
-     *     client.setProperties(properties);
-     *     System.out.printf("Setting properties completed%n");
-     * } catch (UnsupportedOperationException error) {
-     *     System.out.printf("Setting properties failed: %s%n", error);
-     * }
-     * 
- * - * - * @param properties Configures the service. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setProperties(BlobServiceProperties properties) { - setPropertiesWithResponse(properties, null, Context.NONE); - } - - /** - * Sets properties for a storage account's Blob service endpoint. For more information, see the - * Azure Docs. - * Note that setting the default service version has no effect when using this client because this client explicitly - * sets the version header on each request, overriding the default. - *

This method checks to ensure the properties being sent follow the specifications indicated in the Azure Docs. - * If CORS policies are set, CORS parameters that are not set default to the empty string.

- * - *

Code Samples

- * - * - *
-     * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3);
-     * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1);
-     *
-     * BlobServiceProperties properties = new BlobServiceProperties()
-     *     .setLogging(new BlobAnalyticsLogging()
-     *         .setWrite(true)
-     *         .setDelete(true)
-     *         .setVersion("1.0")
-     *         .setRetentionPolicy(loggingRetentionPolicy))
-     *     .setHourMetrics(new BlobMetrics()
-     *         .setEnabled(true)
-     *         .setVersion("1.0")
-     *         .setIncludeApis(true)
-     *         .setRetentionPolicy(metricsRetentionPolicy))
-     *     .setMinuteMetrics(new BlobMetrics()
-     *         .setEnabled(true)
-     *         .setVersion("1.0")
-     *         .setIncludeApis(true)
-     *         .setRetentionPolicy(metricsRetentionPolicy));
-     *
-     * Context context = new Context("Key", "Value");
-     *
-     * System.out.printf("Setting properties completed with status %d%n",
-     *     client.setPropertiesWithResponse(properties, timeout, context).getStatusCode());
-     * 
- * - * - * @param properties Configures the service. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The storage account properties. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setPropertiesWithResponse(BlobServiceProperties properties, Duration timeout, - Context context) { - throwOnAnonymousAccess(); - BlobServiceProperties finalProperties; - if (properties != null) { - finalProperties = new BlobServiceProperties(); - - // Logging - finalProperties.setLogging(properties.getLogging()); - if (finalProperties.getLogging() != null) { - StorageImplUtils.assertNotNull("Logging Version", finalProperties.getLogging().getVersion()); - ModelHelper.validateRetentionPolicy(finalProperties.getLogging().getRetentionPolicy(), - "Logging Retention Policy"); - } - - // Hour Metrics - finalProperties.setHourMetrics(properties.getHourMetrics()); - if (finalProperties.getHourMetrics() != null) { - StorageImplUtils.assertNotNull("HourMetrics Version", finalProperties.getHourMetrics().getVersion()); - ModelHelper.validateRetentionPolicy(finalProperties.getHourMetrics().getRetentionPolicy(), - "HourMetrics Retention " + "Policy"); - if (finalProperties.getHourMetrics().isEnabled()) { - StorageImplUtils.assertNotNull("HourMetrics IncludeApis", - finalProperties.getHourMetrics().isIncludeApis()); - } - } - - // Minute Metrics - finalProperties.setMinuteMetrics(properties.getMinuteMetrics()); - if (finalProperties.getMinuteMetrics() != null) { - StorageImplUtils.assertNotNull("MinuteMetrics Version", - finalProperties.getMinuteMetrics().getVersion()); - ModelHelper.validateRetentionPolicy(finalProperties.getMinuteMetrics().getRetentionPolicy(), - "MinuteMetrics " + "Retention Policy"); - if (finalProperties.getMinuteMetrics().isEnabled()) { - StorageImplUtils.assertNotNull("MinuteMetrics IncludeApis", - finalProperties.getHourMetrics().isIncludeApis()); - } - } - - // CORS - List corsRules = new ArrayList<>(); - for (BlobCorsRule rule : properties.getCors()) { - corsRules.add(ModelHelper.validatedCorsRule(rule)); - } - finalProperties.setCors(corsRules); - - // Default Service Version - finalProperties.setDefaultServiceVersion(properties.getDefaultServiceVersion()); - - // Delete Retention Policy - finalProperties.setDeleteRetentionPolicy(properties.getDeleteRetentionPolicy()); - ModelHelper.validateRetentionPolicy(finalProperties.getDeleteRetentionPolicy(), - "DeleteRetentionPolicy Days"); - - // Static Website - finalProperties.setStaticWebsite(properties.getStaticWebsite()); - } else { - finalProperties = null; - } - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getServices() - .setPropertiesNoCustomHeadersWithResponse(finalProperties, null, null, finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Gets a user delegation key for use with this account's blob storage. Note: This method call is only valid when - * using {@link TokenCredential} in this object's {@link HttpPipeline}. - * - *

Code Samples

- * - * - *
-     * System.out.printf("User delegation key: %s%n",
-     *     client.getUserDelegationKey(delegationKeyStartTime, delegationKeyExpiryTime));
-     * 
- * - * - * @param start Start time for the key's validity. Null indicates immediate start. - * @param expiry Expiration of the key's validity. - * @return The user delegation key. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public UserDelegationKey getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry) { - return getUserDelegationKeyWithResponse(start, expiry, null, Context.NONE).getValue(); - } - - /** - * Gets a user delegation key for use with this account's blob storage. Note: This method call is only valid when - * using {@link TokenCredential} in this object's {@link HttpPipeline}. - * - *

Code Samples

- * - * - *
-     * System.out.printf("User delegation key: %s%n",
-     *     client.getUserDelegationKeyWithResponse(delegationKeyStartTime, delegationKeyExpiryTime, timeout, context));
-     * 
- * - * - * @param start Start time for the key's validity. Null indicates immediate start. - * @param expiry Expiration of the key's validity. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} contains the user delegation key. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getUserDelegationKeyWithResponse(OffsetDateTime start, OffsetDateTime expiry, - Duration timeout, Context context) { - StorageImplUtils.assertNotNull("expiry", expiry); - if (start != null && !start.isBefore(expiry)) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("`start` must be null or a datetime before `expiry`.")); - } - throwOnAnonymousAccess(); - Context finalContext = context == null ? Context.NONE : context; - Callable> operation - = () -> this.azureBlobStorage.getServices() - .getUserDelegationKeyWithResponse( - new KeyInfo().setStart(start == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(start)) - .setExpiry(Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiry)), - null, null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, response.getValue()); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. For more information, see - * the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Geo-replication status: %s%n",
-     *     client.getStatistics().getGeoReplication().getStatus());
-     * 
- * - * - * @return The storage account statistics. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobServiceStatistics getStatistics() { - return getStatisticsWithResponse(null, Context.NONE).getValue(); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. For more information, see - * the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Geo-replication status: %s%n",
-     *     client.getStatisticsWithResponse(timeout, context).getValue().getGeoReplication().getStatus());
-     * 
- * - * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} the storage account statistics. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getStatisticsWithResponse(Duration timeout, Context context) { - throwOnAnonymousAccess(); - Context finalContext = context == null ? Context.NONE : context; - Callable> operation - = () -> this.azureBlobStorage.getServices().getStatisticsWithResponse(null, null, finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Returns the sku name and account kind for the account. For more information, please see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * StorageAccountInfo accountInfo = client.getAccountInfo();
-     *
-     * System.out.printf("Account kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());
-     * 
- * - * - * @return The storage account info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public StorageAccountInfo getAccountInfo() { - return getAccountInfoWithResponse(null, Context.NONE).getValue(); - } - - /** - * Returns the sku name and account kind for the account. For more information, please see the - * Azure Docs. - * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} contains the storage account info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getAccountInfoWithResponse(Duration timeout, Context context) { - throwOnAnonymousAccess(); - Context finalContext = context == null ? Context.NONE : context; - Callable> operation - = () -> this.azureBlobStorage.getServices().getAccountInfoWithResponse(null, null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - ServicesGetAccountInfoHeaders hd = response.getDeserializedHeaders(); - return new SimpleResponse<>(response, - new StorageAccountInfo(hd.getXMsSkuName(), hd.getXMsAccountKind(), hd.isXMsIsHnsEnabled())); - } - - /** - * Get associated account name. - * - * @return account name associated with this storage resource. - */ - public String getAccountName() { - return this.accountName; - } - - /** - * Checks if service client was built with credentials. - */ - private void throwOnAnonymousAccess() { - if (anonymousAccess) { - throw LOGGER.logExceptionAsError( - new IllegalStateException("Service client cannot be accessed without " + "credentials")); - } - } - - /** - * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

- * - *

Generating an account SAS

- *

The snippet below generates an AccountSasSignatureValues object that lasts for two days and gives the user - * read and list access to blob and file shares.

- * - *
-     * AccountSasPermission permissions = new AccountSasPermission()
-     *     .setListPermission(true)
-     *     .setReadPermission(true);
-     * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true);
-     * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true);
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
-     *
-     * AccountSasSignatureValues sasValues =
-     *     new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
-     *
-     * // Client must be authenticated via StorageSharedKeyCredential
-     * String sas = client.generateAccountSas(sasValues);
-     * 
- * - * - * @param accountSasSignatureValues {@link AccountSasSignatureValues} - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues) { - return generateAccountSas(accountSasSignatureValues, Context.NONE); - } - - /* TODO(gapra): REST Docs*/ - /** - * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

- * - *

Generating an account SAS

- *

The snippet below generates an AccountSasSignatureValues object that lasts for two days and gives the user - * read and list access to blob and file shares.

- * - *
-     * AccountSasPermission permissions = new AccountSasPermission()
-     *     .setListPermission(true)
-     *     .setReadPermission(true);
-     * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true);
-     * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true);
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
-     *
-     * AccountSasSignatureValues sasValues =
-     *     new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
-     *
-     * // Client must be authenticated via StorageSharedKeyCredential
-     * String sas = client.generateAccountSas(sasValues, new Context("key", "value"));
-     * 
- * - * - * @param accountSasSignatureValues {@link AccountSasSignatureValues} - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues, Context context) { - return generateAccountSas(accountSasSignatureValues, null, context); - } - - /** - * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

- * - * @param accountSasSignatureValues {@link AccountSasSignatureValues} - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues, - Consumer stringToSignHandler, Context context) { - throwOnAnonymousAccess(); - return new AccountSasImplUtil(accountSasSignatureValues, - this.encryptionScope == null ? null : this.encryptionScope.getEncryptionScope()) - .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); - } - - /** - * Restores a previously deleted container. - * If the container associated with provided deletedContainerName - * already exists, this call will result in a 409 (conflict). - * This API is only functional if Container Soft Delete is enabled - * for the storage account associated with the container. - * - *

Code Samples

- * - * - *
-     * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions();
-     * listBlobContainersOptions.getDetails().setRetrieveDeleted(true);
-     * client.listBlobContainers(listBlobContainersOptions, null).forEach(
-     *     deletedContainer -> {
-     *         BlobContainerClient blobContainerClient = client.undeleteBlobContainer(
-     *             deletedContainer.getName(), deletedContainer.getVersion());
-     *     }
-     * );
-     * 
- * - * - * @param deletedContainerName The name of the previously deleted container. - * @param deletedContainerVersion The version of the previously deleted container. - * @return The {@link BlobContainerClient} used to interact with the restored container. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobContainerClient undeleteBlobContainer(String deletedContainerName, String deletedContainerVersion) { - return this - .undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(deletedContainerName, deletedContainerVersion), null, Context.NONE) - .getValue(); - } - - /** - * Restores a previously deleted container. The restored container - * will be renamed to the destinationContainerName if provided in options. - * Otherwise deletedContainerName is used as destination container name. - * If the container associated with provided destinationContainerName - * already exists, this call will result in a 409 (conflict). - * This API is only functional if Container Soft Delete is enabled - * for the storage account associated with the container. - * - *

Code Samples

- * - * - *
-     * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions();
-     * listBlobContainersOptions.getDetails().setRetrieveDeleted(true);
-     * client.listBlobContainers(listBlobContainersOptions, null).forEach(
-     *     deletedContainer -> {
-     *         BlobContainerClient blobContainerClient = client.undeleteBlobContainerWithResponse(
-     *             new UndeleteBlobContainerOptions(deletedContainer.getName(), deletedContainer.getVersion()),
-     *             timeout, context).getValue();
-     *     }
-     * );
-     * 
- * - * - * @param options {@link UndeleteBlobContainerOptions}. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} contains the {@link BlobContainerClient} used - * to interact with the restored container. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response undeleteBlobContainerWithResponse(UndeleteBlobContainerOptions options, - Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", options); - boolean hasOptionalDestinationContainerName = options.getDestinationContainerName() != null; - String finalDestinationContainerName = hasOptionalDestinationContainerName - ? options.getDestinationContainerName() - : options.getDeletedContainerName(); - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getContainers() - .restoreWithResponse(finalDestinationContainerName, null, null, options.getDeletedContainerName(), - options.getDeletedContainerVersion(), finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, getBlobContainerClient(finalDestinationContainerName)); - } - - // /** - // * Renames an existing blob container. - // * - // *

Code Samples

- // * - // * - // * - // * - // * @param sourceContainerName The current name of the container. - // * @param destinationContainerName The new name of the container. - // * @return A {@link BlobContainerClient} used to interact with the renamed container. - // */ - // @ServiceMethod(returns = ReturnType.SINGLE) - // BlobContainerClient renameBlobContainer(String sourceContainerName, String destinationContainerName) { - // return renameBlobContainerWithResponse(sourceContainerName, new BlobContainerRenameOptions(destinationContainerName - // ), null, Context.NONE).getValue(); - // } - // - // /** - // * Renames an existing blob container. - // * - // *

Code Samples

- // * - // * - // * - // * - // * @param options {@link BlobContainerRenameOptions} - // * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - // * @param context Additional context that is passed through the Http pipeline during the service call. - // * @return A {@link Response} whose {@link Response#getValue() value} contains a - // * {@link BlobContainerClient} used to interact with the renamed container. - // */ - // @ServiceMethod(returns = ReturnType.SINGLE) - // Response renameBlobContainerWithResponse(String sourceContainerName, - // BlobContainerRenameOptions options, Duration timeout, Context context) { - // Mono> response = - // this.blobServiceAsyncClient.renameBlobContainerWithResponse(sourceContainerName, options, context) - // .map(r -> new SimpleResponse<>(r, getBlobContainerClient(r.getValue().getBlobContainerName()))); - // - // return StorageImplUtils.blockWithOptionalTimeout(response, timeout); - // } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java deleted file mode 100644 index 66731774d9e0..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java +++ /dev/null @@ -1,580 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.AzureNamedKeyCredentialTrait; -import com.azure.core.client.traits.AzureSasCredentialTrait; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.ConnectionStringTrait; -import com.azure.core.client.traits.EndpointTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.client.traits.TokenCredentialTrait; -import com.azure.core.credential.AzureNamedKeyCredential; -import com.azure.core.credential.AzureSasCredential; -import com.azure.core.credential.TokenCredential; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.policy.AzureSasCredentialPolicy; -import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.HttpClientOptions; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BuilderHelper; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobContainerEncryptionScope; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.connectionstring.StorageAuthenticationSettings; -import com.azure.storage.common.implementation.connectionstring.StorageConnectionString; -import com.azure.storage.common.implementation.connectionstring.StorageEndpoint; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * This class provides a fluent builder API to help aid the configuration and instantiation of {@link BlobServiceClient - * BlobServiceClients} and {@link BlobServiceAsyncClient BlobServiceAsyncClients}, call {@link #buildClient() - * buildClient} and {@link #buildAsyncClient() buildAsyncClient} respectively to construct an instance of the desired - * client. - * - *

- * The following information must be provided on this builder: - * - *

    - *
  • the endpoint through {@code .endpoint()}, in the format of {@code https://{accountName}.blob.core.windows.net}. - *
  • the credential through {@code .credential()} or {@code .connectionString()} if the container is not publicly - * accessible. - *
- */ -@ServiceClientBuilder(serviceClients = { BlobServiceClient.class, BlobServiceAsyncClient.class }) -public final class BlobServiceClientBuilder implements TokenCredentialTrait, - ConnectionStringTrait, AzureNamedKeyCredentialTrait, - AzureSasCredentialTrait, HttpTrait, - ConfigurationTrait, EndpointTrait { - private static final ClientLogger LOGGER = new ClientLogger(BlobServiceClientBuilder.class); - - private String endpoint; - private String accountName; - - private CpkInfo customerProvidedKey; - private EncryptionScope encryptionScope; - private BlobContainerEncryptionScope blobContainerEncryptionScope; - private StorageSharedKeyCredential storageSharedKeyCredential; - private TokenCredential tokenCredential; - private AzureSasCredential azureSasCredential; - private String sasToken; - - private HttpClient httpClient; - private final List perCallPolicies = new ArrayList<>(); - private final List perRetryPolicies = new ArrayList<>(); - private HttpLogOptions logOptions; - private RequestRetryOptions retryOptions; - private RetryOptions coreRetryOptions; - private HttpPipeline httpPipeline; - - private ClientOptions clientOptions = new ClientOptions(); - private Configuration configuration; - private BlobServiceVersion version; - private BlobAudience audience; - private boolean anonymousAccess; - - /** - * Creates a builder instance that is able to configure and construct {@link BlobServiceClient BlobServiceClients} - * and {@link BlobServiceAsyncClient BlobServiceAsyncClients}. - */ - public BlobServiceClientBuilder() { - logOptions = getDefaultHttpLogOptions(); - } - - /** - * Creates a {@link BlobServiceClient} based on options set in the builder. Every time {@code buildClient()} is - * called, a new instance of {@link BlobServiceClient} is created. - * - * @return a {@link BlobServiceClient} created from the configurations in this builder. - * @throws IllegalArgumentException If no credentials are provided. - * @throws IllegalStateException If multiple credentials have been specified. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryOptions(RequestRetryOptions)} have been set. - */ - public BlobServiceClient buildClient() { - BuilderHelper.httpsValidation(customerProvidedKey, "customer provided key", endpoint, LOGGER); - - anonymousAccess = false; - - if (Objects.nonNull(customerProvidedKey) && Objects.nonNull(encryptionScope)) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("Customer provided key and encryption " + "scope cannot both be set")); - } - - BlobServiceVersion serviceVersion = version != null ? version : BlobServiceVersion.getLatest(); - HttpPipeline pipeline = constructPipeline(); - - boolean foundCredential = false; - for (int i = 0; i < pipeline.getPolicyCount(); i++) { - if (pipeline.getPolicy(i) instanceof StorageSharedKeyCredentialPolicy) { - foundCredential = true; - break; - } - if (pipeline.getPolicy(i) instanceof BearerTokenAuthenticationPolicy) { - foundCredential = true; - break; - } - if (pipeline.getPolicy(i) instanceof AzureSasCredentialPolicy) { - foundCredential = true; - break; - } - } - anonymousAccess = !foundCredential; - - return new BlobServiceClient(pipeline, endpoint, serviceVersion, accountName, customerProvidedKey, - encryptionScope, blobContainerEncryptionScope, anonymousAccess); - } - - private HttpPipeline constructPipeline() { - return (httpPipeline != null) - ? httpPipeline - : BuilderHelper.buildPipeline(storageSharedKeyCredential, tokenCredential, azureSasCredential, sasToken, - endpoint, retryOptions, coreRetryOptions, logOptions, clientOptions, httpClient, perCallPolicies, - perRetryPolicies, configuration, audience, LOGGER); - } - - /** - * Creates a {@link BlobServiceAsyncClient} based on options set in the builder. Every time - * {@code buildAsyncClient()} is called, a new instance of {@link BlobServiceAsyncClient} is created. - * - * @return a {@link BlobServiceAsyncClient} created from the configurations in this builder. - * @throws IllegalArgumentException If no credentials are provided. - * @throws IllegalStateException If multiple credentials have been specified. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryOptions(RequestRetryOptions)} have been set. - */ - public BlobServiceAsyncClient buildAsyncClient() { - BuilderHelper.httpsValidation(customerProvidedKey, "customer provided key", endpoint, LOGGER); - - anonymousAccess = false; - - if (Objects.nonNull(customerProvidedKey) && Objects.nonNull(encryptionScope)) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("Customer provided key and encryption " + "scope cannot both be set")); - } - - BlobServiceVersion serviceVersion = version != null ? version : BlobServiceVersion.getLatest(); - HttpPipeline pipeline = constructPipeline(); - - boolean foundCredential = false; - for (int i = 0; i < pipeline.getPolicyCount(); i++) { - if (pipeline.getPolicy(i) instanceof StorageSharedKeyCredentialPolicy) { - foundCredential = true; - break; - } - if (pipeline.getPolicy(i) instanceof BearerTokenAuthenticationPolicy) { - foundCredential = true; - break; - } - if (pipeline.getPolicy(i) instanceof AzureSasCredentialPolicy) { - foundCredential = true; - break; - } - } - anonymousAccess = !foundCredential; - - return new BlobServiceAsyncClient(pipeline, endpoint, serviceVersion, accountName, customerProvidedKey, - encryptionScope, blobContainerEncryptionScope, anonymousAccess); - } - - /** - * Sets the blob service endpoint, additionally parses it for information (SAS token) - * - * @param endpoint URL of the service - * @return the updated BlobServiceClientBuilder object - * @throws IllegalArgumentException If {@code endpoint} is {@code null} or is a malformed URL. - */ - @Override - public BlobServiceClientBuilder endpoint(String endpoint) { - try { - BlobUrlParts parts = BlobUrlParts.parse(new URL(endpoint)); - - this.accountName = parts.getAccountName(); - this.endpoint = BuilderHelper.getEndpoint(parts); - - String sasToken = parts.getCommonSasQueryParameters().encode(); - if (!CoreUtils.isNullOrEmpty(sasToken)) { - this.sasToken(sasToken); - } - } catch (MalformedURLException ex) { - throw LOGGER - .logExceptionAsError(new IllegalArgumentException("The Azure Storage endpoint url is malformed.", ex)); - } - - return this; - } - - /** - * Sets the {@link CustomerProvidedKey customer provided key} that is used to encrypt blob contents on the server. - * - * @param customerProvidedKey Customer provided key containing the encryption key information. - * @return the updated BlobServiceClientBuilder object - */ - public BlobServiceClientBuilder customerProvidedKey(CustomerProvidedKey customerProvidedKey) { - if (customerProvidedKey == null) { - this.customerProvidedKey = null; - } else { - this.customerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - - return this; - } - - /** - * Sets the {@code encryption scope} that is used to encrypt blob contents on the server. - * - * @param encryptionScope Encryption scope containing the encryption key information. - * @return the updated BlobServiceClientBuilder object - */ - public BlobServiceClientBuilder encryptionScope(String encryptionScope) { - if (encryptionScope == null) { - this.encryptionScope = null; - } else { - this.encryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - - return this; - } - - /** - * Sets the {@link BlobContainerEncryptionScope encryption scope} that is used to determine how blob contents are - * encrypted on the server. - * - * @param blobContainerEncryptionScope Encryption scope containing the encryption key information. - * @return the updated BlobServiceClientBuilder object - */ - public BlobServiceClientBuilder - blobContainerEncryptionScope(BlobContainerEncryptionScope blobContainerEncryptionScope) { - this.blobContainerEncryptionScope = blobContainerEncryptionScope; - return this; - } - - /** - * Sets the {@link StorageSharedKeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link StorageSharedKeyCredential}. - * @return the updated BlobServiceClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - public BlobServiceClientBuilder credential(StorageSharedKeyCredential credential) { - this.storageSharedKeyCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - this.tokenCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the {@link AzureNamedKeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link AzureNamedKeyCredential}. - * @return the updated BlobServiceClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public BlobServiceClientBuilder credential(AzureNamedKeyCredential credential) { - Objects.requireNonNull(credential, "'credential' cannot be null."); - return credential(StorageSharedKeyCredential.fromAzureNamedKeyCredential(credential)); - } - - /** - * Sets the {@link TokenCredential} used to authorize requests sent to the service. Refer to the Azure SDK for Java - * identity and authentication - * documentation for more details on proper usage of the {@link TokenCredential} type. - * - * @param credential {@link TokenCredential} used to authorize requests sent to the service. - * @return the updated BlobServiceClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public BlobServiceClientBuilder credential(TokenCredential credential) { - this.tokenCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - this.storageSharedKeyCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the SAS token used to authorize requests sent to the service. - * - * @param sasToken The SAS token to use for authenticating requests. This string should only be the query parameters - * (with or without a leading '?') and not a full url. - * @return the updated BlobServiceClientBuilder - * @throws NullPointerException If {@code sasToken} is {@code null}. - */ - public BlobServiceClientBuilder sasToken(String sasToken) { - this.sasToken = Objects.requireNonNull(sasToken, "'sasToken' cannot be null."); - this.storageSharedKeyCredential = null; - this.tokenCredential = null; - return this; - } - - /** - * Sets the {@link AzureSasCredential} used to authorize requests sent to the service. - * - * @param credential {@link AzureSasCredential} used to authorize requests sent to the service. - * @return the updated BlobServiceClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public BlobServiceClientBuilder credential(AzureSasCredential credential) { - this.azureSasCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - return this; - } - - /** - * Sets the connection string to connect to the service. - * - * @param connectionString Connection string of the storage account. - * @return the updated BlobServiceClientBuilder - * @throws IllegalArgumentException If {@code connectionString} in invalid. - * @throws NullPointerException If {@code connectionString} is {@code null}. - */ - @Override - public BlobServiceClientBuilder connectionString(String connectionString) { - StorageConnectionString storageConnectionString = StorageConnectionString.create(connectionString, LOGGER); - StorageEndpoint endpoint = storageConnectionString.getBlobEndpoint(); - if (endpoint == null || endpoint.getPrimaryUri() == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException( - "connectionString missing required settings to derive blob service endpoint.")); - } - this.endpoint(endpoint.getPrimaryUri()); - if (storageConnectionString.getAccountName() != null) { - this.accountName = storageConnectionString.getAccountName(); - } - StorageAuthenticationSettings authSettings = storageConnectionString.getStorageAuthSettings(); - if (authSettings.getType() == StorageAuthenticationSettings.Type.ACCOUNT_NAME_KEY) { - this.credential(new StorageSharedKeyCredential(authSettings.getAccount().getName(), - authSettings.getAccount().getAccessKey())); - } else if (authSettings.getType() == StorageAuthenticationSettings.Type.SAS_TOKEN) { - this.sasToken(authSettings.getSasToken()); - } - return this; - } - - /** - * Sets the {@link HttpClient} to use for sending and receiving requests to and from the service. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param httpClient The {@link HttpClient} to use for requests. - * @return the updated BlobServiceClientBuilder object - */ - @Override - public BlobServiceClientBuilder httpClient(HttpClient httpClient) { - if (this.httpClient != null && httpClient == null) { - LOGGER.info("'httpClient' is being set to 'null' when it was previously configured."); - } - - this.httpClient = httpClient; - return this; - } - - /** - * Adds a {@link HttpPipelinePolicy pipeline policy} to apply on each request sent. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param pipelinePolicy A {@link HttpPipelinePolicy pipeline policy}. - * @return the updated BlobServiceClientBuilder object - * @throws NullPointerException If {@code pipelinePolicy} is {@code null}. - */ - @Override - public BlobServiceClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) { - Objects.requireNonNull(pipelinePolicy, "'pipelinePolicy' cannot be null"); - if (pipelinePolicy.getPipelinePosition() == HttpPipelinePosition.PER_CALL) { - perCallPolicies.add(pipelinePolicy); - } else { - perRetryPolicies.add(pipelinePolicy); - } - return this; - } - - /** - * Sets the {@link HttpLogOptions logging configuration} to use when sending and receiving requests to and from - * the service. If a {@code logLevel} is not provided, default value of {@link HttpLogDetailLevel#NONE} is set. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param logOptions The {@link HttpLogOptions logging configuration} to use when sending and receiving requests to - * and from the service. - * @return the updated BlobServiceClientBuilder object - * @throws NullPointerException If {@code logOptions} is {@code null}. - */ - @Override - public BlobServiceClientBuilder httpLogOptions(HttpLogOptions logOptions) { - this.logOptions = Objects.requireNonNull(logOptions, "'logOptions' cannot be null."); - return this; - } - - /** - * Gets the default Storage allowlist log headers and query parameters. - * - * @return the default http log options. - */ - public static HttpLogOptions getDefaultHttpLogOptions() { - return BuilderHelper.getDefaultHttpLogOptions(); - } - - /** - * Sets the configuration object used to retrieve environment configuration values during building of the client. - * - * @param configuration Configuration store used to retrieve environment configurations. - * @return the updated BlobServiceClientBuilder object - */ - @Override - public BlobServiceClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /** - * Sets the request retry options for all the requests made through the client. - * - * Setting this is mutually exclusive with using {@link #retryOptions(RetryOptions)}. - * - * @param retryOptions {@link RequestRetryOptions}. - * @return the updated BlobServiceClientBuilder object - */ - public BlobServiceClientBuilder retryOptions(RequestRetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * Sets the {@link RetryOptions} for all the requests made through the client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * Setting this is mutually exclusive with using {@link #retryOptions(RequestRetryOptions)}. - * Consider using {@link #retryOptions(RequestRetryOptions)} to also set storage specific options. - * - * @param retryOptions The {@link RetryOptions} to use for all the requests made through the client. - * @return the updated BlobServiceClientBuilder object - */ - @Override - public BlobServiceClientBuilder retryOptions(RetryOptions retryOptions) { - this.coreRetryOptions = retryOptions; - return this; - } - - /** - * Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is - * recommended that this method be called with an instance of the {@link HttpClientOptions} - * class (a subclass of the {@link ClientOptions} base class). The HttpClientOptions subclass provides more - * configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait - * interface. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param clientOptions A configured instance of {@link HttpClientOptions}. - * @see HttpClientOptions - * @return the updated BlobServiceClientBuilder object - * @throws NullPointerException If {@code clientOptions} is {@code null}. - */ - @Override - public BlobServiceClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = Objects.requireNonNull(clientOptions, "'clientOptions' cannot be null."); - return this; - } - - /** - * Sets the {@link HttpPipeline} to use for the service client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * The {@link #endpoint(String) endpoint} is not ignored when {@code pipeline} is set. - * - * @param httpPipeline {@link HttpPipeline} to use for sending service requests and receiving responses. - * @return the updated BlobServiceClientBuilder object - */ - @Override - public BlobServiceClientBuilder pipeline(HttpPipeline httpPipeline) { - if (this.httpPipeline != null && httpPipeline == null) { - LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured."); - } - - this.httpPipeline = httpPipeline; - return this; - } - - /** - * Sets the {@link BlobServiceVersion} that is used when making API requests. - *

- * If a service version is not provided, the service version that will be used will be the latest known service - * version based on the version of the client library being used. If no service version is specified, updating to a - * newer version of the client library will have the result of potentially moving to a newer service version. - *

- * Targeting a specific service version may also mean that the service will return an error for newer APIs. - * - * @param version {@link BlobServiceVersion} of the service to be used when making requests. - * @return the updated BlobServiceClientBuilder object - */ - public BlobServiceClientBuilder serviceVersion(BlobServiceVersion version) { - this.version = version; - return this; - } - - /** - * Sets the Audience to use for authentication with Azure Active Directory (AAD). The audience is not considered - * when using a shared key. - * @param audience {@link BlobAudience} to be used when requesting a token from Azure Active Directory (AAD). - * @return the updated BlobServiceClientBuilder object - */ - public BlobServiceClientBuilder audience(BlobAudience audience) { - this.audience = audience; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceVersion.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceVersion.java index ce390841d0a5..5aefd207292d 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceVersion.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceVersion.java @@ -1,143 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob; import com.azure.core.util.ServiceVersion; /** - * The versions of Azure Storage Blob supported by this client library. + * Service version of BlobClient. */ public enum BlobServiceVersion implements ServiceVersion { /** - * Service version {@code 2019-02-02}. + * Enum value 2025-01-05. */ - V2019_02_02("2019-02-02"), - - /** - * Service version {@code 2019-07-07}. - */ - V2019_07_07("2019-07-07"), - - /** - * Service version {@code 2019-12-12}. - */ - V2019_12_12("2019-12-12"), - - /** - * Service version {@code 2020-02-10}. - */ - V2020_02_10("2020-02-10"), - - /** - * Service version {@code 2020-04-08}. - */ - V2020_04_08("2020-04-08"), - - /** - * Service version {@code 2020-06-12}. - */ - V2020_06_12("2020-06-12"), - - /** - * Service version {@code 2020-08-04}. - */ - V2020_08_04("2020-08-04"), - - /** - * Service version {@code 2020-10-02}. - */ - V2020_10_02("2020-10-02"), - - /** - * Service version {@code 2020-12-06}. - */ - V2020_12_06("2020-12-06"), - - /** - * Service version {@code 2021-02-12}. - */ - V2021_02_12("2021-02-12"), - - /** - * Service version {@code 2021-04-10}. - */ - V2021_04_10("2021-04-10"), - - /** - * Service version {@code 2021-06-08}. - */ - V2021_06_08("2021-06-08"), - - /** - * Service version {@code 2021-08-06}. - */ - V2021_08_06("2021-08-06"), - - /** - * Service version {@code 2021-10-04}. - */ - V2021_10_04("2021-10-04"), - - /** - * Service version {@code 2021-12-02}. - */ - V2021_12_02("2021-12-02"), - - /** - * Service version {@code 2022-11-02}. - */ - V2022_11_02("2022-11-02"), - - /** - * Service version {@code 2023-01-03}. - */ - V2023_01_03("2023-01-03"), - - /** - * Service version {@code 2023-05-03}. - */ - V2023_05_03("2023-05-03"), - - /** - * Service version {@code 2023-08-03}. - */ - V2023_08_03("2023-08-03"), - - /** - * Service version {@code 2023-11-03}. - */ - V2023_11_03("2023-11-03"), - - /** - * Service version {@code 2024-02-04}. - */ - V2024_02_04("2024-02-04"), - - /** - * Service version {@code 2024-05-04}. - */ - V2024_05_04("2024-05-04"), - - /** - * Service version {@code 2024-08-04}. - */ - V2024_08_04("2024-08-04"), - - /** - * Service version {@code 2024-11-04}. - */ - V2024_11_04("2024-11-04"), - - /** - * Service version {@code 2025-01-05}. - */ - V2025_01_05("2025-01-05"), - - /** - * Service version {@code 2025-05-05}. - */ - V2025_05_05("2025-05-05"); + V2025_01_05("2025-01-05"); private final String version; @@ -154,11 +30,11 @@ public String getVersion() { } /** - * Gets the latest service version supported by this client library - * - * @return the latest {@link BlobServiceVersion} + * Gets the latest service version supported by this client library. + * + * @return The latest {@link BlobServiceVersion}. */ public static BlobServiceVersion getLatest() { - return V2025_05_05; + return V2025_01_05; } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobUrlParts.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobUrlParts.java deleted file mode 100644 index bad85339ebe8..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobUrlParts.java +++ /dev/null @@ -1,471 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.UrlBuilder; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.sas.BlobServiceSasQueryParameters; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.sas.CommonSasQueryParameters; -import com.azure.storage.common.implementation.Constants; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -/** - * This class represents the components that make up an Azure Storage Container/Blob URL. You may parse an - * existing URL into its parts with the {@link #parse(URL)} class. You may construct a URL from parts by calling {@link - * #toUrl()}. - */ -public final class BlobUrlParts { - private static final ClientLogger LOGGER = new ClientLogger(BlobUrlParts.class); - - private String scheme; - private String host; - private String containerName; - private String blobName; - private String snapshot; - private String versionId; - private String accountName; - private boolean isIpUrl; - private CommonSasQueryParameters commonSasQueryParameters; - private Map unparsedParameters; - - /** - * Initializes a BlobUrlParts object which helps aid in the construction of a Blob Storage URL. - */ - public BlobUrlParts() { - unparsedParameters = new HashMap<>(); - } - - /** - * Gets the accountname, ex. "myaccountname". - * - * @return the account name. - */ - public String getAccountName() { - return accountName; - } - - /** - * Sets the account name. - * - * @param accountName The account name. - * @return the updated BlobURLParts object. - */ - public BlobUrlParts setAccountName(String accountName) { - this.accountName = accountName; - return this; - } - - /** - * Gets the URL scheme, ex. "https". - * - * @return the URL scheme. - */ - public String getScheme() { - return scheme; - } - - /** - * Sets the URL scheme, ex. "https". - * - * @param scheme The URL scheme. - * @return the updated BlobUrlParts object. - */ - public BlobUrlParts setScheme(String scheme) { - this.scheme = scheme; - return this; - } - - /** - * Gets the URL host, ex. "account.blob.core.windows.net" or "127.0.0.1:10000". - * - * @return the URL host. - */ - public String getHost() { - return host; - } - - /** - * Sets the URL host, ex. "account.blob.core.windows.net" or "127.0.0.1:10000". - * - * @param host The URL host. - * @return the updated BlobUrlParts object. - */ - public BlobUrlParts setHost(String host) { - this.host = host; - try { - this.isIpUrl = ModelHelper.determineAuthorityIsIpStyle(host); - } catch (MalformedURLException e) { - throw LOGGER.logExceptionAsError(new IllegalStateException("Authority is malformed. Host: " + host, e)); - } - return this; - } - - /** - * Gets the container name that will be used as part of the URL path. - * - * @return the container name. - */ - public String getBlobContainerName() { - return containerName; - } - - /** - * Sets the container name that will be used as part of the URL path. - * - * @param containerName The container nme. - * @return the updated BlobUrlParts object. - */ - public BlobUrlParts setContainerName(String containerName) { - this.containerName = containerName; - return this; - } - - /** - * Decodes and gets the blob name that will be used as part of the URL path. - * - * @return the decoded blob name. - */ - public String getBlobName() { - return (blobName == null) ? null : Utility.urlDecode(blobName); - } - - /** - * Sets the blob name that will be used as part of the URL path. - * - * @param blobName The blob name. If the blob name contains special characters, pass in the url encoded version - * of the blob name. - * @return the updated BlobUrlParts object. - */ - public BlobUrlParts setBlobName(String blobName) { - this.blobName = Utility.urlEncode(Utility.urlDecode(blobName)); - return this; - } - - /** - * Gets the snapshot identifier that will be used as part of the query string if set. - * - * @return the snapshot identifier. - */ - public String getSnapshot() { - return snapshot; - } - - /** - * Sets the snapshot identifier that will be used as part of the query string if set. - * - * @param snapshot The snapshot identifier. - * @return the updated BlobUrlParts object. - */ - public BlobUrlParts setSnapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - /** - * Gets the version identifier that will be used as part of the query string if set. - * - * @return the version identifier. - */ - public String getVersionId() { - return versionId; - } - - /** - * Sets the version identifier that will be used as part of the query string if set. - * - * @param versionId The version identifier. - * @return the updated BlobUrlParts object. - */ - public BlobUrlParts setVersionId(String versionId) { - this.versionId = versionId; - return this; - } - - /** - * Gets the {@link BlobServiceSasQueryParameters} representing the SAS query parameters - * - * @return the {@link BlobServiceSasQueryParameters} of the URL - * @deprecated Please use {@link #getCommonSasQueryParameters()} - */ - @Deprecated - public BlobServiceSasQueryParameters getSasQueryParameters() { - String encodedSas = commonSasQueryParameters.encode(); - return new BlobServiceSasQueryParameters(SasImplUtils.parseQueryString(encodedSas), true); - } - - /** - * Sets the {@link BlobServiceSasQueryParameters} representing the SAS query parameters. - * - * @param blobServiceSasQueryParameters The SAS query parameters. - * @return the updated BlobUrlParts object. - * @deprecated Please use {@link #setCommonSasQueryParameters(CommonSasQueryParameters)} - */ - @Deprecated - public BlobUrlParts setSasQueryParameters(BlobServiceSasQueryParameters blobServiceSasQueryParameters) { - String encodedBlobSas = blobServiceSasQueryParameters.encode(); - this.commonSasQueryParameters - = new CommonSasQueryParameters(SasImplUtils.parseQueryString(encodedBlobSas), true); - return this; - } - - /** - * Gets the {@link CommonSasQueryParameters} representing the SAS query parameters that will be used to - * generate the SAS token for this URL. - * - * @return the {@link CommonSasQueryParameters} of the URL - */ - public CommonSasQueryParameters getCommonSasQueryParameters() { - return commonSasQueryParameters; - } - - /** - * Sets the {@link CommonSasQueryParameters} representing the SAS query parameters that will be used to - * generate the SAS token for this URL. - * - * @param commonSasQueryParameters The SAS query parameters. - * @return the updated BlobUrlParts object. - */ - public BlobUrlParts setCommonSasQueryParameters(CommonSasQueryParameters commonSasQueryParameters) { - this.commonSasQueryParameters = commonSasQueryParameters; - return this; - } - - /** - * Sets the {@link CommonSasQueryParameters} representing the SAS query parameters that will be used to - * generate the SAS token for this URL. - * - * @param queryParams The SAS query parameter string. - * @return the updated BlobUrlParts object. - */ - public BlobUrlParts parseSasQueryParameters(String queryParams) { - this.commonSasQueryParameters = new CommonSasQueryParameters(SasImplUtils.parseQueryString(queryParams), true); - return this; - } - - /** - * Gets the query string parameters that aren't part of the SAS token that will be used by this URL. - * - * @return the non-SAS token query string values. - */ - public Map getUnparsedParameters() { - return unparsedParameters; - } - - /** - * Sets the query string parameters that aren't part of the SAS token that will be used by this URL. - * - * @param unparsedParameters The non-SAS token query string values. - * @return the updated BlobUrlParts object. - */ - public BlobUrlParts setUnparsedParameters(Map unparsedParameters) { - this.unparsedParameters = unparsedParameters; - return this; - } - - /** - * Converts the blob URL parts to a {@link URL}. - * - * @return A {@code URL} to the blob resource composed of all the elements in this object. - * @throws IllegalStateException The fields present on the BlobUrlParts object were insufficient to construct a - * valid URL or were ill-formatted. - */ - public URL toUrl() { - UrlBuilder url = new UrlBuilder().setScheme(this.scheme).setHost(this.host); - - StringBuilder path = new StringBuilder(); - - if (CoreUtils.isNullOrEmpty(this.containerName) && this.blobName != null) { - this.containerName = BlobContainerAsyncClient.ROOT_CONTAINER_NAME; - } - - if (this.isIpUrl) { - path.append(this.accountName); - } - - if (this.containerName != null) { - path.append("/").append(this.containerName); - if (this.blobName != null) { - path.append("/").append(this.blobName); - } - } - - url.setPath(path.toString()); - - if (this.snapshot != null) { - url.setQueryParameter(Constants.UrlConstants.SNAPSHOT_QUERY_PARAMETER, this.snapshot); - } - if (this.versionId != null) { - url.setQueryParameter(Constants.UrlConstants.VERSIONID_QUERY_PARAMETER, this.versionId); - } - if (this.commonSasQueryParameters != null) { - String encodedSAS = this.commonSasQueryParameters.encode(); - if (encodedSAS.length() != 0) { - url.setQuery(encodedSAS); - } - } - - for (Map.Entry entry : this.unparsedParameters.entrySet()) { - // The commas are intentionally encoded. - url.setQueryParameter(entry.getKey(), Utility.urlEncode(String.join(",", entry.getValue()))); - } - - try { - return url.toUrl(); - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError(new IllegalStateException("The URL parts created a malformed URL.", ex)); - } - } - - /** - * Parses a string into a BlobUrlParts. - * - *

Query parameters will be parsed into two properties, {@link BlobServiceSasQueryParameters} which contains - * all SAS token related values and {@link #getUnparsedParameters() unparsedParameters} which is all other query - * parameters.

- * - *

If a URL points to a blob in the root container, and the root container is referenced implicitly, i.e. there - * is no path element for the container, the name of this blob in the root container will be set as the - * containerName field in the resulting {@code BlobURLParts}.

- * - * @param url The {@code URL} to be parsed. - * @return A {@link BlobUrlParts} object containing all the components of a BlobURL. - * @throws IllegalArgumentException If {@code url} is a malformed {@link URL}. - */ - public static BlobUrlParts parse(String url) { - try { - return parse(new URL(url)); - } catch (MalformedURLException e) { - throw new IllegalArgumentException("Invalid URL format. URL: " + url, e); - } - } - - /** - * Parses an existing URL into a BlobUrlParts. - * - *

Query parameters will be parsed into two properties, {@link BlobServiceSasQueryParameters} which contains - * all SAS token related values and {@link #getUnparsedParameters() unparsedParameters} which is all other query - * parameters.

- * - *

If a URL points to a blob in the root container, and the root container is referenced implicitly, i.e. there - * is no path element for the container, the name of this blob in the root container will be set as the - * containerName field in the resulting {@code BlobURLParts}.

- * - * @param url The {@code URL} to be parsed. - * @return A {@link BlobUrlParts} object containing all the components of a BlobURL. - */ - public static BlobUrlParts parse(URL url) { - BlobUrlParts parts = new BlobUrlParts().setScheme(url.getProtocol()); - - try { - if (ModelHelper.determineAuthorityIsIpStyle(url.getAuthority())) { - parseIpUrl(url, parts); - } else { - parseNonIpUrl(url, parts); - } - } catch (MalformedURLException e) { - throw LOGGER.logExceptionAsError( - new IllegalStateException("Authority is malformed. Host: " + url.getAuthority(), e)); - } - - Map queryParamsMap = SasImplUtils.parseQueryString(url.getQuery()); - - String[] snapshotArray = queryParamsMap.remove("snapshot"); - if (snapshotArray != null) { - parts.setSnapshot(snapshotArray[0]); - } - - String[] versionIdArray = queryParamsMap.remove("versionid"); - if (versionIdArray != null) { - parts.setVersionId(versionIdArray[0]); - } - - CommonSasQueryParameters commonSasQueryParameters = new CommonSasQueryParameters(queryParamsMap, true); - - return parts.setCommonSasQueryParameters(commonSasQueryParameters).setUnparsedParameters(queryParamsMap); - } - - /* - * Parse the IP url into its host, account name, container name, and blob name. - */ - private static void parseIpUrl(URL url, BlobUrlParts parts) { - parts.setHost(url.getAuthority()); - parts.isIpUrl = true; - - String path = url.getPath(); - int previousIndex = 0; - if (!path.isEmpty() && path.charAt(0) == '/') { - previousIndex = 1; - } - - int index = path.indexOf('/', previousIndex); - if (index == -1) { - // The entire path is the account name. - parts.setAccountName(path.substring(previousIndex)); - return; - } - - parts.setAccountName(path.substring(previousIndex, index)); - previousIndex = index + 1; - - index = path.indexOf('/', previousIndex); - if (index == -1) { - // Container name was the last part of the path, substring the rest of the path and return. - parts.setContainerName(path.substring(previousIndex)); - return; - } - - parts.setContainerName(path.substring(previousIndex, index)); - parts.setBlobName(path.substring(index + 1)); - } - - /* - * Parse the non-IP url into its host, account name, container name, and blob name. - */ - private static void parseNonIpUrl(URL url, BlobUrlParts parts) { - String host = url.getHost(); - parts.setHost(host); - - //Parse host to get account name - // host will look like this : .blob.core.windows.net - if (!CoreUtils.isNullOrEmpty(host)) { - int accountNameIndex = host.indexOf('.'); - if (accountNameIndex == -1) { - // host only contains account name - parts.setAccountName(host); - } else { - // if host is separated by . - parts.setAccountName(host.substring(0, accountNameIndex)); - } - } - - // find the container & blob names (if any) - String path = url.getPath(); - if (!CoreUtils.isNullOrEmpty(path)) { - // if the path starts with a slash remove it - if (path.charAt(0) == '/') { - path = path.substring(1); - } - - int containerEndIndex = path.indexOf('/'); - if (containerEndIndex == -1) { - // path contains only a container name and no blob name - parts.setContainerName(path); - } else { - // path contains the container name up until the slash and blob name is everything after the slash - parts.setContainerName(path.substring(0, containerEndIndex)); - parts.setBlobName(path.substring(containerEndIndex + 1)); - } - } - - parts.isIpUrl = false; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlockBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlockBlobAsyncClient.java new file mode 100644 index 000000000000..7727a7c4e3f0 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlockBlobAsyncClient.java @@ -0,0 +1,1656 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.storage.blob.implementation.BlockBlobsImpl; +import com.azure.storage.blob.models.AccessTier; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; +import com.azure.storage.blob.models.BlockList; +import com.azure.storage.blob.models.BlockListType; +import com.azure.storage.blob.models.BlockLookupList; +import com.azure.storage.blob.models.EncryptionAlgorithmType; +import com.azure.storage.blob.models.QueryRequest; +import java.time.OffsetDateTime; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class BlockBlobAsyncClient { + @Generated + private final BlockBlobsImpl serviceClient; + + /** + * Initializes an instance of BlockBlobAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BlockBlobAsyncClient(BlockBlobsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob + * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the + * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a + * block blob, use the Put Block List operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> uploadWithResponse(long contentLength, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.uploadWithResponseAsync(contentLength, body, requestOptions); + } + + /** + * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given + * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob + * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial + * updates to a block blob’s contents using a source URL, use the Put Block from URL API in conjunction with Put + * Block List. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-source-if-tagsStringNoSpecify a SQL where clause on blob tags to operate + * only on blobs with a matching value.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-copy-source-blob-propertiesBooleanNoOptional, default is true. Indicates + * if properties from the source blob should be copied.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
x-ms-copy-source-tagsStringNoOptional, default 'replace'. Indicates if source + * tags should be copied or replaced with the tags specified by x-ms-tags.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putBlobFromUrlWithResponse(long contentLength, String copySource, + RequestOptions requestOptions) { + return this.serviceClient.putBlobFromUrlWithResponseAsync(contentLength, copySource, requestOptions); + } + + /** + * The Stage Block operation creates a new block to be committed as part of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> stageBlockWithResponse(String blockId, long contentLength, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.stageBlockWithResponseAsync(blockId, contentLength, body, requestOptions); + } + + /** + * The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are + * read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-rangeStringNoBytes of source data in the specified + * range.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param sourceUrl Specify a URL to the copy source. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> stageBlockFromUrlWithResponse(String blockId, long contentLength, String sourceUrl, + RequestOptions requestOptions) { + return this.serviceClient.stageBlockFromUrlWithResponseAsync(blockId, contentLength, sourceUrl, requestOptions); + } + + /** + * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order + * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block + * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then + * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the + * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the + * block, whichever list it may belong to. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     committed (Optional): [
+     *         String (Optional)
+     *     ]
+     *     uncommitted (Optional): [
+     *         String (Optional)
+     *     ]
+     *     latest (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param blocks Blob Blocks. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> commitBlockListWithResponse(BinaryData blocks, RequestOptions requestOptions) { + return this.serviceClient.commitBlockListWithResponseAsync(blocks, requestOptions); + } + + /** + * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     committedBlocks (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             size: long (Required)
+     *         }
+     *     ]
+     *     uncommittedBlocks (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both + * lists together. Allowed values: "committed", "uncommitted", "all". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return contains the committed and uncommitted blocks in a block blob along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getBlockListWithResponse(String listType, RequestOptions requestOptions) { + return this.serviceClient.getBlockListWithResponseAsync(listType, requestOptions); + } + + /** + * The Query operation enables users to select/project on blob data by providing simple query expressions. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     queryType: String(SQL) (Required)
+     *     expression: String (Required)
+     *     inputSerialization (Optional): {
+     *         format (Required): {
+     *             type: String(delimited/json/arrow/parquet) (Required)
+     *             delimitedTextConfiguration (Optional): {
+     *                 columnSeparator: String (Optional)
+     *                 fieldQuote: String (Optional)
+     *                 recordSeparator: String (Optional)
+     *                 escapeChar: String (Optional)
+     *                 headersPresent: Boolean (Optional)
+     *             }
+     *             jsonTextConfiguration (Optional): {
+     *                 recordSeparator: String (Optional)
+     *             }
+     *             arrowConfiguration (Optional): {
+     *                 schema (Required): [
+     *                      (Required){
+     *                         type: String (Required)
+     *                         name: String (Optional)
+     *                         precision: Integer (Optional)
+     *                         scale: Integer (Optional)
+     *                     }
+     *                 ]
+     *             }
+     *             parquetTextConfiguration (Optional): {
+     *                  (Optional): {
+     *                     String: BinaryData (Required)
+     *                 }
+     *             }
+     *         }
+     *     }
+     *     outputSerialization (Optional): (recursive schema, see outputSerialization above)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param queryRequest The query request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> queryWithResponse(BinaryData queryRequest, RequestOptions requestOptions) { + return this.serviceClient.queryWithResponseAsync(queryRequest, requestOptions); + } + + /** + * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob + * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the + * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a + * block blob, use the Put Block List operation. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param metadata The metadata headers. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param tier The tier to be set on the blob. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema + * version and properties. + * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the + * blob/file content inside the message body. Will always be smaller than Content-Length. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono upload(long contentLength, BinaryData body, Map metadata, Integer timeout, + String transactionalContentMD5, String blobContentType, String blobContentEncoding, String blobContentLanguage, + byte[] blobContentMd5, String blobCacheControl, String leaseId, String blobContentDisposition, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, + String encryptionScope, AccessTier tier, String ifTags, String blobTagsString, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, + String transactionalContentCrc64, String structuredBodyType, Long structuredContentLength, + RequestConditions requestConditions) { + // Generated convenience method for uploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (structuredContentLength != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-content-length"), + String.valueOf(structuredContentLength)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return uploadWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob + * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the + * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a + * block blob, use the Put Block List operation. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono upload(long contentLength, BinaryData body) { + // Generated convenience method for uploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given + * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob + * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial + * updates to a block blob’s contents using a source URL, use the Put Block from URL API in conjunction with Put + * Block List. + * + * @param contentLength The length of the request. + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param metadata The metadata headers. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param tier The tier to be set on the blob. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be + * copied. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the + * tags specified by x-ms-tags. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putBlobFromUrl(long contentLength, String copySource, Map metadata, + Integer timeout, String transactionalContentMD5, String blobContentType, String blobContentEncoding, + String blobContentLanguage, byte[] blobContentMd5, String blobCacheControl, String leaseId, + String blobContentDisposition, String encryptionKey, String encryptionKeySha256, + EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, AccessTier tier, String ifTags, + OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, + String sourceIfNoneMatch, String sourceIfTags, String sourceContentMd5, String blobTagsString, + Boolean copySourceBlobProperties, String copySourceAuthorization, String copySourceTags, + RequestConditions requestConditions) { + // Generated convenience method for putBlobFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (sourceIfTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-tags"), sourceIfTags); + } + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (copySourceBlobProperties != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-blob-properties"), + String.valueOf(copySourceBlobProperties)); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + if (copySourceTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-tags"), copySourceTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return putBlobFromUrlWithResponse(contentLength, copySource, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given + * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob + * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial + * updates to a block blob’s contents using a source URL, use the Put Block from URL API in conjunction with Put + * Block List. + * + * @param contentLength The length of the request. + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putBlobFromUrl(long contentLength, String copySource) { + // Generated convenience method for putBlobFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putBlobFromUrlWithResponse(contentLength, copySource, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Stage Block operation creates a new block to be committed as part of a blob. + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param body The body of the request. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema + * version and properties. + * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the + * blob/file content inside the message body. Will always be smaller than Content-Length. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono stageBlock(String blockId, long contentLength, BinaryData body, String transactionalContentMD5, + String transactionalContentCrc64, Integer timeout, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, + String structuredBodyType, Long structuredContentLength) { + // Generated convenience method for stageBlockWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (structuredContentLength != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-content-length"), + String.valueOf(structuredContentLength)); + } + return stageBlockWithResponse(blockId, contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Stage Block operation creates a new block to be committed as part of a blob. + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono stageBlock(String blockId, long contentLength, BinaryData body) { + // Generated convenience method for stageBlockWithResponse + RequestOptions requestOptions = new RequestOptions(); + return stageBlockWithResponse(blockId, contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are + * read from a URL. + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param sourceContentCrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy + * source. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono stageBlockFromUrl(String blockId, long contentLength, String sourceUrl, String sourceRange, + String sourceContentMd5, byte[] sourceContentCrc64, Integer timeout, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String leaseId, + OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, + String sourceIfNoneMatch, String copySourceAuthorization) { + // Generated convenience method for stageBlockFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (sourceRange != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-range"), sourceRange); + } + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (sourceContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-crc64"), + String.valueOf(sourceContentCrc64)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + return stageBlockFromUrlWithResponse(blockId, contentLength, sourceUrl, requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are + * read from a URL. + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param sourceUrl Specify a URL to the copy source. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono stageBlockFromUrl(String blockId, long contentLength, String sourceUrl) { + // Generated convenience method for stageBlockFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return stageBlockFromUrlWithResponse(blockId, contentLength, sourceUrl, requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order + * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block + * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then + * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the + * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the + * block, whichever list it may belong to. + * + * @param blocks Blob Blocks. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param metadata The metadata headers. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param tier The tier to be set on the blob. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono commitBlockList(BlockLookupList blocks, Integer timeout, String blobCacheControl, + String blobContentType, String blobContentEncoding, String blobContentLanguage, byte[] blobContentMd5, + String transactionalContentMD5, String transactionalContentCrc64, Map metadata, String leaseId, + String blobContentDisposition, String encryptionKey, String encryptionKeySha256, + EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, AccessTier tier, String ifTags, + String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, + BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, RequestConditions requestConditions) { + // Generated convenience method for commitBlockListWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return commitBlockListWithResponse(BinaryData.fromObject(blocks), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order + * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block + * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then + * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the + * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the + * block, whichever list it may belong to. + * + * @param blocks Blob Blocks. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono commitBlockList(BlockLookupList blocks) { + // Generated convenience method for commitBlockListWithResponse + RequestOptions requestOptions = new RequestOptions(); + return commitBlockListWithResponse(BinaryData.fromObject(blocks), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. + * + * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both + * lists together. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return contains the committed and uncommitted blocks in a block blob on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getBlockList(BlockListType listType, String snapshot, Integer timeout, String leaseId, + String ifTags) { + // Generated convenience method for getBlockListWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + return getBlockListWithResponse(listType.toString(), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BlockList.class)); + } + + /** + * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. + * + * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both + * lists together. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return contains the committed and uncommitted blocks in a block blob on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getBlockList(BlockListType listType) { + // Generated convenience method for getBlockListWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getBlockListWithResponse(listType.toString(), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BlockList.class)); + } + + /** + * The Query operation enables users to select/project on blob data by providing simple query expressions. + * + * @param queryRequest The query request. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono query(QueryRequest queryRequest, String snapshot, Integer timeout, String leaseId, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for queryWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return queryWithResponse(BinaryData.fromObject(queryRequest), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Query operation enables users to select/project on blob data by providing simple query expressions. + * + * @param queryRequest The query request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono query(QueryRequest queryRequest) { + // Generated convenience method for queryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return queryWithResponse(BinaryData.fromObject(queryRequest), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlockBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlockBlobClient.java new file mode 100644 index 000000000000..3ab032e6d5e0 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlockBlobClient.java @@ -0,0 +1,1638 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.storage.blob.implementation.BlockBlobsImpl; +import com.azure.storage.blob.models.AccessTier; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; +import com.azure.storage.blob.models.BlockList; +import com.azure.storage.blob.models.BlockListType; +import com.azure.storage.blob.models.BlockLookupList; +import com.azure.storage.blob.models.EncryptionAlgorithmType; +import com.azure.storage.blob.models.QueryRequest; +import java.time.OffsetDateTime; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class BlockBlobClient { + @Generated + private final BlockBlobsImpl serviceClient; + + /** + * Initializes an instance of BlockBlobClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BlockBlobClient(BlockBlobsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob + * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the + * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a + * block blob, use the Put Block List operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response uploadWithResponse(long contentLength, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.uploadWithResponse(contentLength, body, requestOptions); + } + + /** + * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given + * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob + * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial + * updates to a block blob’s contents using a source URL, use the Put Block from URL API in conjunction with Put + * Block List. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-source-if-tagsStringNoSpecify a SQL where clause on blob tags to operate + * only on blobs with a matching value.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-copy-source-blob-propertiesBooleanNoOptional, default is true. Indicates + * if properties from the source blob should be copied.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
x-ms-copy-source-tagsStringNoOptional, default 'replace'. Indicates if source + * tags should be copied or replaced with the tags specified by x-ms-tags.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putBlobFromUrlWithResponse(long contentLength, String copySource, + RequestOptions requestOptions) { + return this.serviceClient.putBlobFromUrlWithResponse(contentLength, copySource, requestOptions); + } + + /** + * The Stage Block operation creates a new block to be committed as part of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response stageBlockWithResponse(String blockId, long contentLength, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.stageBlockWithResponse(blockId, contentLength, body, requestOptions); + } + + /** + * The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are + * read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-rangeStringNoBytes of source data in the specified + * range.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param sourceUrl Specify a URL to the copy source. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response stageBlockFromUrlWithResponse(String blockId, long contentLength, String sourceUrl, + RequestOptions requestOptions) { + return this.serviceClient.stageBlockFromUrlWithResponse(blockId, contentLength, sourceUrl, requestOptions); + } + + /** + * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order + * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block + * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then + * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the + * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the + * block, whichever list it may belong to. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     committed (Optional): [
+     *         String (Optional)
+     *     ]
+     *     uncommitted (Optional): [
+     *         String (Optional)
+     *     ]
+     *     latest (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param blocks Blob Blocks. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response commitBlockListWithResponse(BinaryData blocks, RequestOptions requestOptions) { + return this.serviceClient.commitBlockListWithResponse(blocks, requestOptions); + } + + /** + * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     committedBlocks (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             size: long (Required)
+     *         }
+     *     ]
+     *     uncommittedBlocks (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both + * lists together. Allowed values: "committed", "uncommitted", "all". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return contains the committed and uncommitted blocks in a block blob along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getBlockListWithResponse(String listType, RequestOptions requestOptions) { + return this.serviceClient.getBlockListWithResponse(listType, requestOptions); + } + + /** + * The Query operation enables users to select/project on blob data by providing simple query expressions. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     queryType: String(SQL) (Required)
+     *     expression: String (Required)
+     *     inputSerialization (Optional): {
+     *         format (Required): {
+     *             type: String(delimited/json/arrow/parquet) (Required)
+     *             delimitedTextConfiguration (Optional): {
+     *                 columnSeparator: String (Optional)
+     *                 fieldQuote: String (Optional)
+     *                 recordSeparator: String (Optional)
+     *                 escapeChar: String (Optional)
+     *                 headersPresent: Boolean (Optional)
+     *             }
+     *             jsonTextConfiguration (Optional): {
+     *                 recordSeparator: String (Optional)
+     *             }
+     *             arrowConfiguration (Optional): {
+     *                 schema (Required): [
+     *                      (Required){
+     *                         type: String (Required)
+     *                         name: String (Optional)
+     *                         precision: Integer (Optional)
+     *                         scale: Integer (Optional)
+     *                     }
+     *                 ]
+     *             }
+     *             parquetTextConfiguration (Optional): {
+     *                  (Optional): {
+     *                     String: BinaryData (Required)
+     *                 }
+     *             }
+     *         }
+     *     }
+     *     outputSerialization (Optional): (recursive schema, see outputSerialization above)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param queryRequest The query request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response queryWithResponse(BinaryData queryRequest, RequestOptions requestOptions) { + return this.serviceClient.queryWithResponse(queryRequest, requestOptions); + } + + /** + * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob + * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the + * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a + * block blob, use the Put Block List operation. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param metadata The metadata headers. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param tier The tier to be set on the blob. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema + * version and properties. + * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the + * blob/file content inside the message body. Will always be smaller than Content-Length. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void upload(long contentLength, BinaryData body, Map metadata, Integer timeout, + String transactionalContentMD5, String blobContentType, String blobContentEncoding, String blobContentLanguage, + byte[] blobContentMd5, String blobCacheControl, String leaseId, String blobContentDisposition, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, + String encryptionScope, AccessTier tier, String ifTags, String blobTagsString, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, + String transactionalContentCrc64, String structuredBodyType, Long structuredContentLength, + RequestConditions requestConditions) { + // Generated convenience method for uploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (structuredContentLength != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-content-length"), + String.valueOf(structuredContentLength)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + uploadWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob + * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the + * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a + * block blob, use the Put Block List operation. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void upload(long contentLength, BinaryData body) { + // Generated convenience method for uploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given + * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob + * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial + * updates to a block blob’s contents using a source URL, use the Put Block from URL API in conjunction with Put + * Block List. + * + * @param contentLength The length of the request. + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param metadata The metadata headers. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param tier The tier to be set on the blob. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be + * copied. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the + * tags specified by x-ms-tags. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void putBlobFromUrl(long contentLength, String copySource, Map metadata, Integer timeout, + String transactionalContentMD5, String blobContentType, String blobContentEncoding, String blobContentLanguage, + byte[] blobContentMd5, String blobCacheControl, String leaseId, String blobContentDisposition, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, + String encryptionScope, AccessTier tier, String ifTags, OffsetDateTime sourceIfModifiedSince, + OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, + String sourceContentMd5, String blobTagsString, Boolean copySourceBlobProperties, + String copySourceAuthorization, String copySourceTags, RequestConditions requestConditions) { + // Generated convenience method for putBlobFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (sourceIfTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-tags"), sourceIfTags); + } + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (copySourceBlobProperties != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-blob-properties"), + String.valueOf(copySourceBlobProperties)); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + if (copySourceTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-tags"), copySourceTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + putBlobFromUrlWithResponse(contentLength, copySource, requestOptions).getValue(); + } + + /** + * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given + * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob + * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial + * updates to a block blob’s contents using a source URL, use the Put Block from URL API in conjunction with Put + * Block List. + * + * @param contentLength The length of the request. + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void putBlobFromUrl(long contentLength, String copySource) { + // Generated convenience method for putBlobFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + putBlobFromUrlWithResponse(contentLength, copySource, requestOptions).getValue(); + } + + /** + * The Stage Block operation creates a new block to be committed as part of a blob. + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param body The body of the request. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema + * version and properties. + * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the + * blob/file content inside the message body. Will always be smaller than Content-Length. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void stageBlock(String blockId, long contentLength, BinaryData body, String transactionalContentMD5, + String transactionalContentCrc64, Integer timeout, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, + String structuredBodyType, Long structuredContentLength) { + // Generated convenience method for stageBlockWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (structuredContentLength != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-content-length"), + String.valueOf(structuredContentLength)); + } + stageBlockWithResponse(blockId, contentLength, body, requestOptions).getValue(); + } + + /** + * The Stage Block operation creates a new block to be committed as part of a blob. + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void stageBlock(String blockId, long contentLength, BinaryData body) { + // Generated convenience method for stageBlockWithResponse + RequestOptions requestOptions = new RequestOptions(); + stageBlockWithResponse(blockId, contentLength, body, requestOptions).getValue(); + } + + /** + * The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are + * read from a URL. + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param sourceContentCrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy + * source. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void stageBlockFromUrl(String blockId, long contentLength, String sourceUrl, String sourceRange, + String sourceContentMd5, byte[] sourceContentCrc64, Integer timeout, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String leaseId, + OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, + String sourceIfNoneMatch, String copySourceAuthorization) { + // Generated convenience method for stageBlockFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (sourceRange != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-range"), sourceRange); + } + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (sourceContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-crc64"), + String.valueOf(sourceContentCrc64)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + stageBlockFromUrlWithResponse(blockId, contentLength, sourceUrl, requestOptions).getValue(); + } + + /** + * The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are + * read from a URL. + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. + * @param contentLength The length of the request. + * @param sourceUrl Specify a URL to the copy source. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void stageBlockFromUrl(String blockId, long contentLength, String sourceUrl) { + // Generated convenience method for stageBlockFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + stageBlockFromUrlWithResponse(blockId, contentLength, sourceUrl, requestOptions).getValue(); + } + + /** + * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order + * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block + * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then + * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the + * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the + * block, whichever list it may belong to. + * + * @param blocks Blob Blocks. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param metadata The metadata headers. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param tier The tier to be set on the blob. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void commitBlockList(BlockLookupList blocks, Integer timeout, String blobCacheControl, + String blobContentType, String blobContentEncoding, String blobContentLanguage, byte[] blobContentMd5, + String transactionalContentMD5, String transactionalContentCrc64, Map metadata, String leaseId, + String blobContentDisposition, String encryptionKey, String encryptionKeySha256, + EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, AccessTier tier, String ifTags, + String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, + BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, RequestConditions requestConditions) { + // Generated convenience method for commitBlockListWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + commitBlockListWithResponse(BinaryData.fromObject(blocks), requestOptions).getValue(); + } + + /** + * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order + * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block + * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then + * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the + * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the + * block, whichever list it may belong to. + * + * @param blocks Blob Blocks. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void commitBlockList(BlockLookupList blocks) { + // Generated convenience method for commitBlockListWithResponse + RequestOptions requestOptions = new RequestOptions(); + commitBlockListWithResponse(BinaryData.fromObject(blocks), requestOptions).getValue(); + } + + /** + * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. + * + * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both + * lists together. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return contains the committed and uncommitted blocks in a block blob. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BlockList getBlockList(BlockListType listType, String snapshot, Integer timeout, String leaseId, + String ifTags) { + // Generated convenience method for getBlockListWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + return getBlockListWithResponse(listType.toString(), requestOptions).getValue().toObject(BlockList.class); + } + + /** + * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. + * + * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both + * lists together. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return contains the committed and uncommitted blocks in a block blob. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BlockList getBlockList(BlockListType listType) { + // Generated convenience method for getBlockListWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getBlockListWithResponse(listType.toString(), requestOptions).getValue().toObject(BlockList.class); + } + + /** + * The Query operation enables users to select/project on blob data by providing simple query expressions. + * + * @param queryRequest The query request. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData query(QueryRequest queryRequest, String snapshot, Integer timeout, String leaseId, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for queryWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return queryWithResponse(BinaryData.fromObject(queryRequest), requestOptions).getValue(); + } + + /** + * The Query operation enables users to select/project on blob data by providing simple query expressions. + * + * @param queryRequest The query request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData query(QueryRequest queryRequest) { + // Generated convenience method for queryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return queryWithResponse(BinaryData.fromObject(queryRequest), requestOptions).getValue(); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerAsyncClient.java new file mode 100644 index 000000000000..de1628676a26 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerAsyncClient.java @@ -0,0 +1,2097 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.TypeReference; +import com.azure.storage.blob.implementation.ContainersImpl; +import com.azure.storage.blob.models.FilterBlobSegment; +import com.azure.storage.blob.models.FilterBlobsIncludeItem; +import com.azure.storage.blob.models.ListBlobsFlatSegmentResponse; +import com.azure.storage.blob.models.ListBlobsHierarchySegmentResponse; +import com.azure.storage.blob.models.ListBlobsIncludeItem; +import com.azure.storage.blob.models.PublicAccessType; +import com.azure.storage.blob.models.SignedIdentifier; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class ContainerAsyncClient { + @Generated + private final ContainersImpl serviceClient; + + /** + * Initializes an instance of ContainerAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ContainerAsyncClient(ContainersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new container under the specified account. If the container with the same name already exists, the + * operation fails. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-blob-public-accessStringNoThe public access setting for the container. + * Allowed values: "blob", "container".
x-ms-default-encryption-scopeStringNoOptional. Version 2019-07-07 and later. + * Specifies the default encryption scope to set on the container and use for all future writes.
x-ms-deny-encryption-scope-overrideBooleanNoIf a blob has a lease and the + * lease is of infinite duration then the value of this header is set to true, otherwise it is set to + * false.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithResponse(RequestOptions requestOptions) { + return this.serviceClient.createWithResponseAsync(requestOptions); + } + + /** + * returns all user-defined metadata and system properties for the specified container. The data returned does not + * include the container's list of blobs. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPropertiesWithResponseAsync(requestOptions); + } + + /** + * operation marks the specified container for deletion. The container and any blobs contained within it are later + * deleted during garbage collection. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponseAsync(requestOptions); + } + + /** + * operation sets one or more user-defined name-value pairs for the specified container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-metaMap<String, String>NoThe metadata headers.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setMetadataWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setMetadataWithResponseAsync(requestOptions); + } + + /** + * gets the permissions for the specified container. The permissions indicate whether container data may be accessed + * publicly. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         accessPolicy (Required): {
+     *             start: OffsetDateTime (Required)
+     *             expiry: OffsetDateTime (Required)
+     *             permission: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the permissions for the specified container along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccessPolicyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAccessPolicyWithResponseAsync(requestOptions); + } + + /** + * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be + * accessed publicly. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-public-accessStringNoThe public access setting for the container. + * Allowed values: "blob", "container".
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         accessPolicy (Required): {
+     *             start: OffsetDateTime (Required)
+     *             expiry: OffsetDateTime (Required)
+     *             permission: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param containerAcl The access control list for the container. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setAccessPolicyWithResponse(BinaryData containerAcl, RequestOptions requestOptions) { + return this.serviceClient.setAccessPolicyWithResponseAsync(containerAcl, requestOptions); + } + + /** + * Restores a previously-deleted container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-deleted-container-nameStringNoOptional. Version 2019-12-12 and later. + * Specifies the name of the deleted container to restore.
x-ms-deleted-container-versionStringNoOptional. Version 2019-12-12 and later. + * Specifies the version of the deleted container to restore.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> restoreWithResponse(RequestOptions requestOptions) { + return this.serviceClient.restoreWithResponseAsync(requestOptions); + } + + /** + * Renames an existing container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-lease-idStringNoA lease ID for the source path. If specified, the + * source path must have an active lease and the lease ID must match.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceContainerName Required. Specifies the name of the container to rename. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> renameWithResponse(String sourceContainerName, RequestOptions requestOptions) { + return this.serviceClient.renameWithResponseAsync(sourceContainerName, requestOptions); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> submitBatchWithResponse(long contentLength, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.submitBatchWithResponseAsync(contentLength, body, requestOptions); + } + + /** + * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search + * expression. Filter blobs searches within the given container. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
whereStringNoFilters the results to return only to return only blobs whose + * tags match the specified expression.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     where: String (Required)
+     *     blobs (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             containerName: String (Required)
+     *             tags (Optional): {
+     *                 blobTagSet (Required): [
+     *                      (Required){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *             versionId: String (Optional)
+     *             isCurrentVersion: Boolean (Optional)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the result of a Filter Blobs API call along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> filterBlobsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.filterBlobsWithResponseAsync(requestOptions); + } + + /** + * The Acquire Lease operation requests a new lease on a container. The lease lock duration can be 15 to 60 seconds, + * or can be infinite. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-durationIntegerNoSpecifies the duration of the lease, in seconds, + * or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A + * lease duration cannot be changed using renew or change.
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> acquireLeaseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.acquireLeaseWithResponseAsync(requestOptions); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> releaseLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.releaseLeaseWithResponseAsync(leaseId, requestOptions); + } + + /** + * The Renew Lease operation renews an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> renewLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.renewLeaseWithResponseAsync(leaseId, requestOptions); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
x-ms-lease-break-periodIntegerNoFor a break operation, proposed duration the + * lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is + * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease + * will not be available before the break period has expired, but the lease may be held for longer than the break + * period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining + * lease period elapses, and an infinite lease breaks immediately.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> breakLeaseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.breakLeaseWithResponseAsync(requestOptions); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param proposedLeaseId Required. The proposed lease ID for the container. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> changeLeaseWithResponse(String leaseId, String proposedLeaseId, + RequestOptions requestOptions) { + return this.serviceClient.changeLeaseWithResponseAsync(leaseId, proposedLeaseId, requestOptions); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     containerName: String (Required)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     segment (Required): {
+     *         blobItems (Required): [
+     *              (Required){
+     *                 name (Required): {
+     *                     encoded: boolean (Required)
+     *                     content: String (Required)
+     *                 }
+     *                 deleted: boolean (Required)
+     *                 snapshot: String (Required)
+     *                 versionId: String (Optional)
+     *                 isCurrentVersion: Boolean (Optional)
+     *                 properties (Required): {
+     *                     creationTime: DateTimeRfc1123 (Optional)
+     *                     lastModified: DateTimeRfc1123 (Required)
+     *                     eTag: String (Required)
+     *                     contentLength: Long (Optional)
+     *                     contentType: String (Optional)
+     *                     contentEncoding: String (Optional)
+     *                     contentLanguage: String (Optional)
+     *                     contentMd5: byte[] (Optional)
+     *                     contentDisposition: String (Optional)
+     *                     cacheControl: String (Optional)
+     *                     blobSequenceNumber: Long (Optional)
+     *                     blobType: String(BlockBlob/PageBlob/AppendBlob) (Optional)
+     *                     leaseStatus: String(unlocked/locked) (Optional)
+     *                     leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                     leaseDuration: String(infinite/fixed) (Optional)
+     *                     copyId: String (Optional)
+     *                     copyStatus: String(pending/success/failed/aborted) (Optional)
+     *                     copySource: String (Optional)
+     *                     copyProgress: String (Optional)
+     *                     copyCompletionTime: DateTimeRfc1123 (Optional)
+     *                     copyStatusDescription: String (Optional)
+     *                     serverEncrypted: Boolean (Optional)
+     *                     incrementalCopy: Boolean (Optional)
+     *                     destinationSnapshot: String (Optional)
+     *                     deletedTime: DateTimeRfc1123 (Optional)
+     *                     remainingRetentionDays: Integer (Optional)
+     *                     accessTier: String(P4/P6/P10/P15/P20/P30/P40/P50/P60/P70/P80/Hot/Cool/Archive/Premium/Cold) (Optional)
+     *                     accessTierInferred: Boolean (Optional)
+     *                     archiveStatus: String(rehydrate-pending-to-hot/rehydrate-pending-to-cool/rehydrate-pending-to-cold) (Optional)
+     *                     customerProvidedKeySha256: String (Optional)
+     *                     encryptionScope: String (Optional)
+     *                     accessTierChangeTime: DateTimeRfc1123 (Optional)
+     *                     tagCount: Integer (Optional)
+     *                     expiryTime: DateTimeRfc1123 (Optional)
+     *                     sealed: Boolean (Optional)
+     *                     rehydratePriority: String(High/Standard) (Optional)
+     *                     lastAccessTime: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyUntilDate: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyMode: String(Mutable/Locked/Unlocked) (Optional)
+     *                     legalHold: Boolean (Optional)
+     *                 }
+     *                 metadata (Optional): {
+     *                     encrypted: String (Optional)
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 blobTags (Optional): {
+     *                     blobTagSet (Required): [
+     *                          (Required){
+     *                             key: String (Required)
+     *                             value: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *                 objectReplicationMetadata (Optional): {
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 hasVersionsOnly: Boolean (Optional)
+     *             }
+     *         ]
+     *     }
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an enumeration of blobs along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listBlobFlatSegmentWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listBlobFlatSegmentWithResponseAsync(requestOptions); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. A delimiter can be used to + * traverse a virtual hierarchy of blobs as though it were a file system. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     containerName: String (Required)
+     *     delimiter: String (Optional)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     segment (Required): {
+     *         blobItems (Required): [
+     *              (Required){
+     *                 name (Required): {
+     *                     encoded: boolean (Required)
+     *                     content: String (Required)
+     *                 }
+     *                 deleted: boolean (Required)
+     *                 snapshot: String (Required)
+     *                 versionId: String (Optional)
+     *                 isCurrentVersion: Boolean (Optional)
+     *                 properties (Required): {
+     *                     creationTime: DateTimeRfc1123 (Optional)
+     *                     lastModified: DateTimeRfc1123 (Required)
+     *                     eTag: String (Required)
+     *                     contentLength: Long (Optional)
+     *                     contentType: String (Optional)
+     *                     contentEncoding: String (Optional)
+     *                     contentLanguage: String (Optional)
+     *                     contentMd5: byte[] (Optional)
+     *                     contentDisposition: String (Optional)
+     *                     cacheControl: String (Optional)
+     *                     blobSequenceNumber: Long (Optional)
+     *                     blobType: String(BlockBlob/PageBlob/AppendBlob) (Optional)
+     *                     leaseStatus: String(unlocked/locked) (Optional)
+     *                     leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                     leaseDuration: String(infinite/fixed) (Optional)
+     *                     copyId: String (Optional)
+     *                     copyStatus: String(pending/success/failed/aborted) (Optional)
+     *                     copySource: String (Optional)
+     *                     copyProgress: String (Optional)
+     *                     copyCompletionTime: DateTimeRfc1123 (Optional)
+     *                     copyStatusDescription: String (Optional)
+     *                     serverEncrypted: Boolean (Optional)
+     *                     incrementalCopy: Boolean (Optional)
+     *                     destinationSnapshot: String (Optional)
+     *                     deletedTime: DateTimeRfc1123 (Optional)
+     *                     remainingRetentionDays: Integer (Optional)
+     *                     accessTier: String(P4/P6/P10/P15/P20/P30/P40/P50/P60/P70/P80/Hot/Cool/Archive/Premium/Cold) (Optional)
+     *                     accessTierInferred: Boolean (Optional)
+     *                     archiveStatus: String(rehydrate-pending-to-hot/rehydrate-pending-to-cool/rehydrate-pending-to-cold) (Optional)
+     *                     customerProvidedKeySha256: String (Optional)
+     *                     encryptionScope: String (Optional)
+     *                     accessTierChangeTime: DateTimeRfc1123 (Optional)
+     *                     tagCount: Integer (Optional)
+     *                     expiryTime: DateTimeRfc1123 (Optional)
+     *                     sealed: Boolean (Optional)
+     *                     rehydratePriority: String(High/Standard) (Optional)
+     *                     lastAccessTime: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyUntilDate: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyMode: String(Mutable/Locked/Unlocked) (Optional)
+     *                     legalHold: Boolean (Optional)
+     *                 }
+     *                 metadata (Optional): {
+     *                     encrypted: String (Optional)
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 blobTags (Optional): {
+     *                     blobTagSet (Required): [
+     *                          (Required){
+     *                             key: String (Required)
+     *                             value: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *                 objectReplicationMetadata (Optional): {
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 hasVersionsOnly: Boolean (Optional)
+     *             }
+     *         ]
+     *         blobPrefixes (Optional): [
+     *              (Optional){
+     *                 name (Required): (recursive schema, see name above)
+     *             }
+     *         ]
+     *     }
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the + * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the + * appearance of the delimiter character. The delimiter may be a single character or a string. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an enumeration of blobs along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listBlobHierarchySegmentWithResponse(String delimiter, + RequestOptions requestOptions) { + return this.serviceClient.listBlobHierarchySegmentWithResponseAsync(delimiter, requestOptions); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccountInfoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAccountInfoWithResponseAsync(requestOptions); + } + + /** + * Creates a new container under the specified account. If the container with the same name already exists, the + * operation fails. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param access The public access setting for the container. + * @param defaultEncryptionScope Optional. Version 2019-07-07 and later. Specifies the default encryption scope to + * set on the container and use for all future writes. + * @param preventEncryptionScopeOverride If a blob has a lease and the lease is of infinite duration then the value + * of this header is set to true, otherwise it is set to false. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono create(Integer timeout, Map metadata, PublicAccessType access, + String defaultEncryptionScope, Boolean preventEncryptionScopeOverride) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (access != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-public-access"), access.toString()); + } + if (defaultEncryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-default-encryption-scope"), + defaultEncryptionScope); + } + if (preventEncryptionScopeOverride != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-deny-encryption-scope-override"), + String.valueOf(preventEncryptionScopeOverride)); + } + return createWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Creates a new container under the specified account. If the container with the same name already exists, the + * operation fails. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono create() { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * returns all user-defined metadata and system properties for the specified container. The data returned does not + * include the container's list of blobs. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getProperties(Integer timeout, String leaseId) { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + return getPropertiesWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * returns all user-defined metadata and system properties for the specified container. The data returned does not + * include the container's list of blobs. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getProperties() { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPropertiesWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * operation marks the specified container for deletion. The container and any blobs contained within it are later + * deleted during garbage collection. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono delete(Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, + OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + return deleteWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * operation marks the specified container for deletion. The container and any blobs contained within it are later + * deleted during garbage collection. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono delete() { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * operation sets one or more user-defined name-value pairs for the specified container. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param metadata The metadata headers. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setMetadata(Integer timeout, String leaseId, Map metadata, + OffsetDateTime ifModifiedSince) { + // Generated convenience method for setMetadataWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return setMetadataWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * operation sets one or more user-defined name-value pairs for the specified container. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setMetadata() { + // Generated convenience method for setMetadataWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setMetadataWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * gets the permissions for the specified container. The permissions indicate whether container data may be accessed + * publicly. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the permissions for the specified container on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccessPolicy(Integer timeout, String leaseId) { + // Generated convenience method for getAccessPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + return getAccessPolicyWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_SIGNED_IDENTIFIER)); + } + + /** + * gets the permissions for the specified container. The permissions indicate whether container data may be accessed + * publicly. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the permissions for the specified container on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccessPolicy() { + // Generated convenience method for getAccessPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAccessPolicyWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_SIGNED_IDENTIFIER)); + } + + /** + * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be + * accessed publicly. + * + * @param containerAcl The access control list for the container. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param access The public access setting for the container. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setAccessPolicy(List containerAcl, Integer timeout, String leaseId, + PublicAccessType access, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for setAccessPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (access != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-public-access"), access.toString()); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + return setAccessPolicyWithResponse(BinaryData.fromObject(containerAcl), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be + * accessed publicly. + * + * @param containerAcl The access control list for the container. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setAccessPolicy(List containerAcl) { + // Generated convenience method for setAccessPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setAccessPolicyWithResponse(BinaryData.fromObject(containerAcl), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * Restores a previously-deleted container. + * + * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container + * to restore. + * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted + * container to restore. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono restore(String deletedContainerName, String deletedContainerVersion, Integer timeout) { + // Generated convenience method for restoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (deletedContainerName != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-deleted-container-name"), deletedContainerName); + } + if (deletedContainerVersion != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-deleted-container-version"), + deletedContainerVersion); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return restoreWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Restores a previously-deleted container. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono restore() { + // Generated convenience method for restoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + return restoreWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Renames an existing container. + * + * @param sourceContainerName Required. Specifies the name of the container to rename. + * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and + * the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono rename(String sourceContainerName, String sourceLeaseId, Integer timeout) { + // Generated convenience method for renameWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (sourceLeaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-lease-id"), sourceLeaseId); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return renameWithResponse(sourceContainerName, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Renames an existing container. + * + * @param sourceContainerName Required. Specifies the name of the container to rename. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono rename(String sourceContainerName) { + // Generated convenience method for renameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renameWithResponse(sourceContainerName, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono submitBatch(long contentLength, BinaryData body, Integer timeout) { + // Generated convenience method for submitBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return submitBatchWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono submitBatch(long contentLength, BinaryData body) { + // Generated convenience method for submitBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return submitBatchWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search + * expression. Filter blobs searches within the given container. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param where Filters the results to return only to return only blobs whose tags match the specified expression. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param include Include this parameter to specify one or more datasets to include in the response. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of a Filter Blobs API call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono filterBlobs(Integer timeout, String where, String marker, Integer maxresults, + List include) { + // Generated convenience method for filterBlobsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (where != null) { + requestOptions.addQueryParam("where", where, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return filterBlobsWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FilterBlobSegment.class)); + } + + /** + * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search + * expression. Filter blobs searches within the given container. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of a Filter Blobs API call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono filterBlobs() { + // Generated convenience method for filterBlobsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return filterBlobsWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FilterBlobSegment.class)); + } + + /** + * The Acquire Lease operation requests a new lease on a container. The lease lock duration can be 15 to 60 seconds, + * or can be infinite. + * + * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never + * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or + * change. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param proposedLeaseId Optional. The proposed lease ID for the container. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono acquireLease(Integer duration, Integer timeout, String proposedLeaseId, + OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for acquireLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (duration != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-duration"), String.valueOf(duration)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (proposedLeaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-proposed-lease-id"), proposedLeaseId); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + return acquireLeaseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Acquire Lease operation requests a new lease on a container. The lease lock duration can be 15 to 60 seconds, + * or can be infinite. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono acquireLease() { + // Generated convenience method for acquireLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return acquireLeaseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the container. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono releaseLease(String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, + OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for releaseLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + return releaseLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the container. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono releaseLease(String leaseId) { + // Generated convenience method for releaseLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return releaseLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Renew Lease operation renews an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renewLease(String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, + OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for renewLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + return renewLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Renew Lease operation renews an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renewLease(String leaseId) { + // Generated convenience method for renewLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renewLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in + * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. + * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has + * expired, but the lease may be held for longer than the break period. If this header does not appear with a break + * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks + * immediately. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono breakLease(Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, + Integer breakPeriod) { + // Generated convenience method for breakLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (breakPeriod != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-break-period"), String.valueOf(breakPeriod)); + } + return breakLeaseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono breakLease() { + // Generated convenience method for breakLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return breakLeaseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param proposedLeaseId Required. The proposed lease ID for the container. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono changeLease(String leaseId, String proposedLeaseId, Integer timeout, + OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for changeLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + return changeLeaseWithResponse(leaseId, proposedLeaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param proposedLeaseId Required. The proposed lease ID for the container. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono changeLease(String leaseId, String proposedLeaseId) { + // Generated convenience method for changeLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return changeLeaseWithResponse(leaseId, proposedLeaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. + * + * @param prefix Filters the results to return only containers whose name begins with the specified prefix. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param include Include this parameter to specify one or more datasets to include in the response. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an enumeration of blobs on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listBlobFlatSegment(String prefix, String marker, Integer maxresults, + List include, Integer timeout) { + // Generated convenience method for listBlobFlatSegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (prefix != null) { + requestOptions.addQueryParam("prefix", prefix, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return listBlobFlatSegmentWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ListBlobsFlatSegmentResponse.class)); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an enumeration of blobs on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listBlobFlatSegment() { + // Generated convenience method for listBlobFlatSegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listBlobFlatSegmentWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ListBlobsFlatSegmentResponse.class)); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. A delimiter can be used to + * traverse a virtual hierarchy of blobs as though it were a file system. + * + * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the + * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the + * appearance of the delimiter character. The delimiter may be a single character or a string. + * @param prefix Filters the results to return only containers whose name begins with the specified prefix. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param include Include this parameter to specify one or more datasets to include in the response. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an enumeration of blobs on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listBlobHierarchySegment(String delimiter, String prefix, + String marker, Integer maxresults, List include, Integer timeout) { + // Generated convenience method for listBlobHierarchySegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (prefix != null) { + requestOptions.addQueryParam("prefix", prefix, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return listBlobHierarchySegmentWithResponse(delimiter, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ListBlobsHierarchySegmentResponse.class)); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. A delimiter can be used to + * traverse a virtual hierarchy of blobs as though it were a file system. + * + * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the + * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the + * appearance of the delimiter character. The delimiter may be a single character or a string. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an enumeration of blobs on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listBlobHierarchySegment(String delimiter) { + // Generated convenience method for listBlobHierarchySegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listBlobHierarchySegmentWithResponse(delimiter, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ListBlobsHierarchySegmentResponse.class)); + } + + /** + * Returns the sku name and account kind. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAccountInfo(Integer timeout) { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return getAccountInfoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Returns the sku name and account kind. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAccountInfo() { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAccountInfoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_SIGNED_IDENTIFIER + = new TypeReference>() { + }; +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerBlobAsyncClient.java new file mode 100644 index 000000000000..c6033b1246b4 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerBlobAsyncClient.java @@ -0,0 +1,3117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.storage.blob.implementation.ContainerBlobsImpl; +import com.azure.storage.blob.models.AccessTier; +import com.azure.storage.blob.models.BlobDeleteType; +import com.azure.storage.blob.models.BlobExpiryOptions; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; +import com.azure.storage.blob.models.BlobTags; +import com.azure.storage.blob.models.DeleteSnapshotsOptionType; +import com.azure.storage.blob.models.EncryptionAlgorithmType; +import com.azure.storage.blob.models.RehydratePriority; +import java.time.OffsetDateTime; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class ContainerBlobAsyncClient { + @Generated + private final ContainerBlobsImpl serviceClient; + + /** + * Initializes an instance of ContainerBlobAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ContainerBlobAsyncClient(ContainerBlobsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can + * also call Download to read a snapshot. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-range-get-content-md5BooleanNoWhen set to true and specified together + * with the Range, the service returns the MD5 hash for the range, as long as the range is less than or equal to 4 + * MB in size.
x-ms-range-get-content-crc64BooleanNoOptional. When this header is set to true + * and specified together with the Range header, the service returns the CRC64 hash for the range, as long as the + * range is less than or equal to 4 MB in size.
x-ms-structured-bodyStringNoSpecifies the response content should be returned + * as a structured message and specifies the message schema version and properties.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> downloadWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadWithResponseAsync(requestOptions); + } + + /** + * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties + * for the blob. It does not return the content of the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPropertiesWithResponseAsync(requestOptions); + } + + /** + * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed + * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, + * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or + * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] + * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently + * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until + * it is permanently removed. Use the List Blobs API and specify the \"include=deleted\" query parameter to discover + * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a + * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP + * status code of 404 (ResourceNotFound). + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
deletetypeStringNoOptional. Only possible value is 'permanent', which + * specifies to permanently delete a blob if blob soft delete is enabled. Allowed values: "Permanent".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-delete-snapshotsStringNoRequired if the blob has associated snapshots. + * Specify one of the following two options: include: Delete the base blob and all of its snapshots. only: Delete + * only the blob's snapshots and not the blob itself. Allowed values: "only", "include".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponseAsync(requestOptions); + } + + /** + * Undelete a blob that was previously soft deleted. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> undeleteWithResponse(RequestOptions requestOptions) { + return this.serviceClient.undeleteWithResponseAsync(requestOptions); + } + + /** + * Set the expiration time of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-expiry-timeOffsetDateTimeNoThe time this blob will expire.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param expiryOptions Required. Indicates mode of the expiry time. Allowed values: "NeverExpire", + * "RelativeToCreation", "RelativeToNow", "Absolute". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setExpiryWithResponse(String expiryOptions, RequestOptions requestOptions) { + return this.serviceClient.setExpiryWithResponseAsync(expiryOptions, requestOptions); + } + + /** + * The Set HTTP Headers operation sets system properties on the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setHttpHeadersWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setHttpHeadersWithResponseAsync(requestOptions); + } + + /** + * Set the immutability policy of a blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setImmutabilityPolicyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setImmutabilityPolicyWithResponseAsync(requestOptions); + } + + /** + * The Delete Immutability Policy operation deletes the immutability policy on the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteImmutabilityPolicyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteImmutabilityPolicyWithResponseAsync(requestOptions); + } + + /** + * The Set Legal Hold operation sets a legal hold on the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param legalHold Required. Specifies the legal hold status to set on the blob. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setLegalHoldWithResponse(boolean legalHold, RequestOptions requestOptions) { + return this.serviceClient.setLegalHoldWithResponseAsync(legalHold, requestOptions); + } + + /** + * The Set Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setMetadataWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setMetadataWithResponseAsync(requestOptions); + } + + /** + * The Acquire Lease operation requests a new lease on a blob. The lease lock duration can be 15 to 60 seconds, or + * can be infinite. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-durationIntegerNoSpecifies the duration of the lease, in seconds, + * or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A + * lease duration cannot be changed using renew or change.
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> acquireLeaseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.acquireLeaseWithResponseAsync(requestOptions); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> releaseLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.releaseLeaseWithResponseAsync(leaseId, requestOptions); + } + + /** + * The Renew Lease operation renews an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> renewLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.renewLeaseWithResponseAsync(leaseId, requestOptions); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> changeLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.changeLeaseWithResponseAsync(leaseId, requestOptions); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-break-periodIntegerNoFor a break operation, proposed duration the + * lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is + * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease + * will not be available before the break period has expired, but the lease may be held for longer than the break + * period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining + * lease period elapses, and an infinite lease breaks immediately.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> breakLeaseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.breakLeaseWithResponseAsync(requestOptions); + } + + /** + * The Create Snapshot operation creates a read-only snapshot of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createSnapshotWithResponse(RequestOptions requestOptions) { + return this.serviceClient.createSnapshotWithResponseAsync(requestOptions); + } + + /** + * The Start Copy From URL operation copies a blob or an internet resource to a new blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
x-ms-rehydrate-priorityStringNoIf an object is in rehydrate pending state then + * this header is returned with priority of rehydrate. Valid values are High and Standard. Allowed values: "High", + * "Standard".
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-source-if-tagsStringNoSpecify a SQL where clause on blob tags to operate + * only on blobs with a matching value.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-seal-blobBooleanNoOverrides the sealed state of the destination blob. + * Service version 2019-12-12 and newer.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> startCopyFromUrlWithResponse(String copySource, RequestOptions requestOptions) { + return this.serviceClient.startCopyFromUrlWithResponseAsync(copySource, requestOptions); + } + + /** + * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response + * until the copy is complete. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-copy-source-tagsStringNoOptional, default 'replace'. Indicates if source + * tags should be copied or replaced with the tags specified by x-ms-tags.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> copyFromUrlWithResponse(String copySource, RequestOptions requestOptions) { + return this.serviceClient.copyFromUrlWithResponseAsync(copySource, requestOptions); + } + + /** + * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with + * zero length and full metadata. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> abortCopyFromUrlWithResponse(String copyId, RequestOptions requestOptions) { + return this.serviceClient.abortCopyFromUrlWithResponseAsync(copyId, requestOptions); + } + + /** + * The Set Tier operation sets the tier on a block blob. The operation is allowed on a page blob or block blob, but + * not on an append blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not + * update the blob's ETag. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rehydrate-priorityStringNoIf an object is in rehydrate pending state then + * this header is returned with priority of rehydrate. Valid values are High and Standard. Allowed values: "High", + * "Standard".
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param tier Indicates the tier to be set on the blob. Allowed values: "P4", "P6", "P10", "P15", "P20", "P30", + * "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", "Cold". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setTierWithResponse(String tier, RequestOptions requestOptions) { + return this.serviceClient.setTierWithResponseAsync(tier, requestOptions); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccountInfoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAccountInfoWithResponseAsync(requestOptions); + } + + /** + * The Get Blob Tags operation enables users to get tags on a blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobTagSet (Required): [
+     *          (Required){
+     *             key: String (Required)
+     *             value: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents blob tags along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getTagsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getTagsWithResponseAsync(requestOptions); + } + + /** + * The Set Tags operation enables users to set tags on a blob. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobTagSet (Required): [
+     *          (Required){
+     *             key: String (Required)
+     *             value: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param tags The blob tags. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setTagsWithResponse(BinaryData tags, RequestOptions requestOptions) { + return this.serviceClient.setTagsWithResponseAsync(tags, requestOptions); + } + + /** + * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can + * also call Download to read a snapshot. + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param rangeGetContentMd5 When set to true and specified together with the Range, the service returns the MD5 + * hash for the range, as long as the range is less than or equal to 4 MB in size. + * @param rangeGetContentCrc64 Optional. When this header is set to true and specified together with the Range + * header, the service returns the CRC64 hash for the range, as long as the range is less than or equal to 4 MB in + * size. + * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies + * the message schema version and properties. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono download(String snapshot, String versionId, Integer timeout, String range, String leaseId, + Boolean rangeGetContentMd5, Boolean rangeGetContentCrc64, String structuredBodyType, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for downloadWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (rangeGetContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range-get-content-md5"), + String.valueOf(rangeGetContentMd5)); + } + if (rangeGetContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range-get-content-crc64"), + String.valueOf(rangeGetContentCrc64)); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return downloadWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can + * also call Download to read a snapshot. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono download() { + // Generated convenience method for downloadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties + * for the blob. It does not return the content of the blob. + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getProperties(String snapshot, String versionId, Integer timeout, String leaseId, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return getPropertiesWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties + * for the blob. It does not return the content of the blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getProperties() { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPropertiesWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed + * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, + * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or + * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] + * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently + * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until + * it is permanently removed. Use the List Blobs API and specify the \"include=deleted\" query parameter to discover + * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a + * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP + * status code of 404 (ResourceNotFound). + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: + * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob + * itself. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob + * if blob soft delete is enabled. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono delete(String snapshot, String versionId, Integer timeout, String leaseId, + DeleteSnapshotsOptionType deleteSnapshots, String ifTags, BlobDeleteType blobDeleteType, + RequestConditions requestConditions) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (deleteSnapshots != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-delete-snapshots"), deleteSnapshots.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobDeleteType != null) { + requestOptions.addQueryParam("deletetype", blobDeleteType.toString(), false); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return deleteWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed + * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, + * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or + * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] + * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently + * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until + * it is permanently removed. Use the List Blobs API and specify the \"include=deleted\" query parameter to discover + * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a + * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP + * status code of 404 (ResourceNotFound). + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono delete() { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Undelete a blob that was previously soft deleted. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono undelete(Integer timeout) { + // Generated convenience method for undeleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return undeleteWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Undelete a blob that was previously soft deleted. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono undelete() { + // Generated convenience method for undeleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + return undeleteWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Set the expiration time of a blob. + * + * @param expiryOptions Required. Indicates mode of the expiry time. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param expiresOn The time this blob will expire. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setExpiry(BlobExpiryOptions expiryOptions, Integer timeout, OffsetDateTime expiresOn) { + // Generated convenience method for setExpiryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (expiresOn != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-expiry-time"), + String.valueOf(new DateTimeRfc1123(expiresOn))); + } + return setExpiryWithResponse(expiryOptions.toString(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Set the expiration time of a blob. + * + * @param expiryOptions Required. Indicates mode of the expiry time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setExpiry(BlobExpiryOptions expiryOptions) { + // Generated convenience method for setExpiryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setExpiryWithResponse(expiryOptions.toString(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Set HTTP Headers operation sets system properties on the blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setHttpHeaders(Integer timeout, String blobCacheControl, String blobContentType, + byte[] blobContentMd5, String blobContentEncoding, String blobContentLanguage, String leaseId, + String blobContentDisposition, String ifTags, RequestConditions requestConditions) { + // Generated convenience method for setHttpHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return setHttpHeadersWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Set HTTP Headers operation sets system properties on the blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setHttpHeaders() { + // Generated convenience method for setHttpHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setHttpHeadersWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Set the immutability policy of a blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setImmutabilityPolicy(Integer timeout, OffsetDateTime ifUnmodifiedSince, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, + String versionId) { + // Generated convenience method for setImmutabilityPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + return setImmutabilityPolicyWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Set the immutability policy of a blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setImmutabilityPolicy() { + // Generated convenience method for setImmutabilityPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setImmutabilityPolicyWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Delete Immutability Policy operation deletes the immutability policy on the blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteImmutabilityPolicy(Integer timeout, String snapshot, String versionId) { + // Generated convenience method for deleteImmutabilityPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + return deleteImmutabilityPolicyWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Delete Immutability Policy operation deletes the immutability policy on the blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteImmutabilityPolicy() { + // Generated convenience method for deleteImmutabilityPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteImmutabilityPolicyWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Set Legal Hold operation sets a legal hold on the blob. + * + * @param legalHold Required. Specifies the legal hold status to set on the blob. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setLegalHold(boolean legalHold, Integer timeout, String snapshot, String versionId) { + // Generated convenience method for setLegalHoldWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + return setLegalHoldWithResponse(legalHold, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Set Legal Hold operation sets a legal hold on the blob. + * + * @param legalHold Required. Specifies the legal hold status to set on the blob. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setLegalHold(boolean legalHold) { + // Generated convenience method for setLegalHoldWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setLegalHoldWithResponse(legalHold, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Set Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setMetadata(Integer timeout, Map metadata, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for setMetadataWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return setMetadataWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Set Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setMetadata() { + // Generated convenience method for setMetadataWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setMetadataWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Acquire Lease operation requests a new lease on a blob. The lease lock duration can be 15 to 60 seconds, or + * can be infinite. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never + * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or + * change. + * @param proposedLeaseId Optional. The proposed lease ID for the container. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono acquireLease(Integer timeout, Integer duration, String proposedLeaseId, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for acquireLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (duration != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-duration"), String.valueOf(duration)); + } + if (proposedLeaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-proposed-lease-id"), proposedLeaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return acquireLeaseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Acquire Lease operation requests a new lease on a blob. The lease lock duration can be 15 to 60 seconds, or + * can be infinite. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono acquireLease() { + // Generated convenience method for acquireLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return acquireLeaseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the blob. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono releaseLease(String leaseId, Integer timeout, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for releaseLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return releaseLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the blob. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono releaseLease(String leaseId) { + // Generated convenience method for releaseLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return releaseLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Renew Lease operation renews an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renewLease(String leaseId, Integer timeout, String ifTags, RequestConditions requestConditions) { + // Generated convenience method for renewLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return renewLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Renew Lease operation renews an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renewLease(String leaseId) { + // Generated convenience method for renewLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renewLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param proposedLeaseId Optional. The proposed lease ID for the container. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono changeLease(String leaseId, Integer timeout, String proposedLeaseId, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for changeLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (proposedLeaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-proposed-lease-id"), proposedLeaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return changeLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono changeLease(String leaseId) { + // Generated convenience method for changeLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return changeLeaseWithResponse(leaseId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in + * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. + * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has + * expired, but the lease may be held for longer than the break period. If this header does not appear with a break + * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks + * immediately. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono breakLease(Integer timeout, Integer breakPeriod, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for breakLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (breakPeriod != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-break-period"), String.valueOf(breakPeriod)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return breakLeaseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono breakLease() { + // Generated convenience method for breakLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return breakLeaseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Create Snapshot operation creates a read-only snapshot of a blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createSnapshot(Integer timeout, Map metadata, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, + String leaseId, RequestConditions requestConditions) { + // Generated convenience method for createSnapshotWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return createSnapshotWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Create Snapshot operation creates a read-only snapshot of a blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createSnapshot() { + // Generated convenience method for createSnapshotWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createSnapshotWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Start Copy From URL operation copies a blob or an internet resource to a new blob. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param tier The tier to be set on the blob. + * @param rehydratePriority If an object is in rehydrate pending state then this header is returned with priority of + * rehydrate. Valid values are High and Standard. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono startCopyFromUrl(String copySource, Integer timeout, Map metadata, + AccessTier tier, RehydratePriority rehydratePriority, OffsetDateTime sourceIfModifiedSince, + OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, + String ifTags, String leaseId, String blobTagsString, Boolean sealBlob, OffsetDateTime immutabilityPolicyExpiry, + BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, RequestConditions requestConditions) { + // Generated convenience method for startCopyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (rehydratePriority != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-rehydrate-priority"), + rehydratePriority.toString()); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (sourceIfTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-tags"), sourceIfTags); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (sealBlob != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-seal-blob"), String.valueOf(sealBlob)); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return startCopyFromUrlWithResponse(copySource, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Start Copy From URL operation copies a blob or an internet resource to a new blob. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono startCopyFromUrl(String copySource) { + // Generated convenience method for startCopyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return startCopyFromUrlWithResponse(copySource, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response + * until the copy is complete. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param tier The tier to be set on the blob. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the + * tags specified by x-ms-tags. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono copyFromUrl(String copySource, Integer timeout, Map metadata, AccessTier tier, + OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, + String sourceIfNoneMatch, String ifTags, String leaseId, String sourceContentMd5, String blobTagsString, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, + String copySourceAuthorization, String encryptionScope, String copySourceTags, + RequestConditions requestConditions) { + // Generated convenience method for copyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (copySourceTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-tags"), copySourceTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return copyFromUrlWithResponse(copySource, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response + * until the copy is complete. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono copyFromUrl(String copySource) { + // Generated convenience method for copyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return copyFromUrlWithResponse(copySource, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with + * zero length and full metadata. + * + * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono abortCopyFromUrl(String copyId, Integer timeout, String leaseId) { + // Generated convenience method for abortCopyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + return abortCopyFromUrlWithResponse(copyId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with + * zero length and full metadata. + * + * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono abortCopyFromUrl(String copyId) { + // Generated convenience method for abortCopyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return abortCopyFromUrlWithResponse(copyId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Set Tier operation sets the tier on a block blob. The operation is allowed on a page blob or block blob, but + * not on an append blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not + * update the blob's ETag. + * + * @param tier Indicates the tier to be set on the blob. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param rehydratePriority If an object is in rehydrate pending state then this header is returned with priority of + * rehydrate. Valid values are High and Standard. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setTier(AccessTier tier, String snapshot, String versionId, Integer timeout, + RehydratePriority rehydratePriority, String leaseId, String ifTags) { + // Generated convenience method for setTierWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (rehydratePriority != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-rehydrate-priority"), + rehydratePriority.toString()); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + return setTierWithResponse(tier.toString(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Set Tier operation sets the tier on a block blob. The operation is allowed on a page blob or block blob, but + * not on an append blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not + * update the blob's ETag. + * + * @param tier Indicates the tier to be set on the blob. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setTier(AccessTier tier) { + // Generated convenience method for setTierWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setTierWithResponse(tier.toString(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Returns the sku name and account kind. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAccountInfo(Integer timeout) { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return getAccountInfoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Returns the sku name and account kind. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAccountInfo() { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAccountInfoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Get Blob Tags operation enables users to get tags on a blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents blob tags on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getTags(Integer timeout, String snapshot, String versionId, String leaseId, String ifTags) { + // Generated convenience method for getTagsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + return getTagsWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BlobTags.class)); + } + + /** + * The Get Blob Tags operation enables users to get tags on a blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents blob tags on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getTags() { + // Generated convenience method for getTagsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getTagsWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BlobTags.class)); + } + + /** + * The Set Tags operation enables users to set tags on a blob. + * + * @param tags The blob tags. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setTags(BlobTags tags, Integer timeout, String versionId, String transactionalContentMD5, + String transactionalContentCrc64, String ifTags, String leaseId) { + // Generated convenience method for setTagsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + return setTagsWithResponse(BinaryData.fromObject(tags), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Set Tags operation enables users to set tags on a blob. + * + * @param tags The blob tags. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setTags(BlobTags tags) { + // Generated convenience method for setTagsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setTagsWithResponse(BinaryData.fromObject(tags), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerBlobClient.java new file mode 100644 index 000000000000..c5ef231d74ad --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerBlobClient.java @@ -0,0 +1,3069 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.storage.blob.implementation.ContainerBlobsImpl; +import com.azure.storage.blob.models.AccessTier; +import com.azure.storage.blob.models.BlobDeleteType; +import com.azure.storage.blob.models.BlobExpiryOptions; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; +import com.azure.storage.blob.models.BlobTags; +import com.azure.storage.blob.models.DeleteSnapshotsOptionType; +import com.azure.storage.blob.models.EncryptionAlgorithmType; +import com.azure.storage.blob.models.RehydratePriority; +import java.time.OffsetDateTime; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class ContainerBlobClient { + @Generated + private final ContainerBlobsImpl serviceClient; + + /** + * Initializes an instance of ContainerBlobClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ContainerBlobClient(ContainerBlobsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can + * also call Download to read a snapshot. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-range-get-content-md5BooleanNoWhen set to true and specified together + * with the Range, the service returns the MD5 hash for the range, as long as the range is less than or equal to 4 + * MB in size.
x-ms-range-get-content-crc64BooleanNoOptional. When this header is set to true + * and specified together with the Range header, the service returns the CRC64 hash for the range, as long as the + * range is less than or equal to 4 MB in size.
x-ms-structured-bodyStringNoSpecifies the response content should be returned + * as a structured message and specifies the message schema version and properties.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response downloadWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadWithResponse(requestOptions); + } + + /** + * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties + * for the blob. It does not return the content of the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPropertiesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPropertiesWithResponse(requestOptions); + } + + /** + * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed + * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, + * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or + * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] + * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently + * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until + * it is permanently removed. Use the List Blobs API and specify the \"include=deleted\" query parameter to discover + * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a + * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP + * status code of 404 (ResourceNotFound). + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
deletetypeStringNoOptional. Only possible value is 'permanent', which + * specifies to permanently delete a blob if blob soft delete is enabled. Allowed values: "Permanent".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-delete-snapshotsStringNoRequired if the blob has associated snapshots. + * Specify one of the following two options: include: Delete the base blob and all of its snapshots. only: Delete + * only the blob's snapshots and not the blob itself. Allowed values: "only", "include".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponse(requestOptions); + } + + /** + * Undelete a blob that was previously soft deleted. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response undeleteWithResponse(RequestOptions requestOptions) { + return this.serviceClient.undeleteWithResponse(requestOptions); + } + + /** + * Set the expiration time of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-expiry-timeOffsetDateTimeNoThe time this blob will expire.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param expiryOptions Required. Indicates mode of the expiry time. Allowed values: "NeverExpire", + * "RelativeToCreation", "RelativeToNow", "Absolute". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setExpiryWithResponse(String expiryOptions, RequestOptions requestOptions) { + return this.serviceClient.setExpiryWithResponse(expiryOptions, requestOptions); + } + + /** + * The Set HTTP Headers operation sets system properties on the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setHttpHeadersWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setHttpHeadersWithResponse(requestOptions); + } + + /** + * Set the immutability policy of a blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setImmutabilityPolicyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setImmutabilityPolicyWithResponse(requestOptions); + } + + /** + * The Delete Immutability Policy operation deletes the immutability policy on the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteImmutabilityPolicyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteImmutabilityPolicyWithResponse(requestOptions); + } + + /** + * The Set Legal Hold operation sets a legal hold on the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param legalHold Required. Specifies the legal hold status to set on the blob. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setLegalHoldWithResponse(boolean legalHold, RequestOptions requestOptions) { + return this.serviceClient.setLegalHoldWithResponse(legalHold, requestOptions); + } + + /** + * The Set Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setMetadataWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setMetadataWithResponse(requestOptions); + } + + /** + * The Acquire Lease operation requests a new lease on a blob. The lease lock duration can be 15 to 60 seconds, or + * can be infinite. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-durationIntegerNoSpecifies the duration of the lease, in seconds, + * or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A + * lease duration cannot be changed using renew or change.
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response acquireLeaseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.acquireLeaseWithResponse(requestOptions); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response releaseLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.releaseLeaseWithResponse(leaseId, requestOptions); + } + + /** + * The Renew Lease operation renews an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response renewLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.renewLeaseWithResponse(leaseId, requestOptions); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response changeLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.changeLeaseWithResponse(leaseId, requestOptions); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-break-periodIntegerNoFor a break operation, proposed duration the + * lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is + * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease + * will not be available before the break period has expired, but the lease may be held for longer than the break + * period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining + * lease period elapses, and an infinite lease breaks immediately.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response breakLeaseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.breakLeaseWithResponse(requestOptions); + } + + /** + * The Create Snapshot operation creates a read-only snapshot of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createSnapshotWithResponse(RequestOptions requestOptions) { + return this.serviceClient.createSnapshotWithResponse(requestOptions); + } + + /** + * The Start Copy From URL operation copies a blob or an internet resource to a new blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
x-ms-rehydrate-priorityStringNoIf an object is in rehydrate pending state then + * this header is returned with priority of rehydrate. Valid values are High and Standard. Allowed values: "High", + * "Standard".
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-source-if-tagsStringNoSpecify a SQL where clause on blob tags to operate + * only on blobs with a matching value.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-seal-blobBooleanNoOverrides the sealed state of the destination blob. + * Service version 2019-12-12 and newer.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response startCopyFromUrlWithResponse(String copySource, RequestOptions requestOptions) { + return this.serviceClient.startCopyFromUrlWithResponse(copySource, requestOptions); + } + + /** + * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response + * until the copy is complete. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-copy-source-tagsStringNoOptional, default 'replace'. Indicates if source + * tags should be copied or replaced with the tags specified by x-ms-tags.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response copyFromUrlWithResponse(String copySource, RequestOptions requestOptions) { + return this.serviceClient.copyFromUrlWithResponse(copySource, requestOptions); + } + + /** + * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with + * zero length and full metadata. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response abortCopyFromUrlWithResponse(String copyId, RequestOptions requestOptions) { + return this.serviceClient.abortCopyFromUrlWithResponse(copyId, requestOptions); + } + + /** + * The Set Tier operation sets the tier on a block blob. The operation is allowed on a page blob or block blob, but + * not on an append blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not + * update the blob's ETag. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rehydrate-priorityStringNoIf an object is in rehydrate pending state then + * this header is returned with priority of rehydrate. Valid values are High and Standard. Allowed values: "High", + * "Standard".
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param tier Indicates the tier to be set on the blob. Allowed values: "P4", "P6", "P10", "P15", "P20", "P30", + * "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", "Cold". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setTierWithResponse(String tier, RequestOptions requestOptions) { + return this.serviceClient.setTierWithResponse(tier, requestOptions); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAccountInfoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAccountInfoWithResponse(requestOptions); + } + + /** + * The Get Blob Tags operation enables users to get tags on a blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobTagSet (Required): [
+     *          (Required){
+     *             key: String (Required)
+     *             value: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents blob tags along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getTagsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getTagsWithResponse(requestOptions); + } + + /** + * The Set Tags operation enables users to set tags on a blob. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobTagSet (Required): [
+     *          (Required){
+     *             key: String (Required)
+     *             value: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param tags The blob tags. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setTagsWithResponse(BinaryData tags, RequestOptions requestOptions) { + return this.serviceClient.setTagsWithResponse(tags, requestOptions); + } + + /** + * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can + * also call Download to read a snapshot. + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param rangeGetContentMd5 When set to true and specified together with the Range, the service returns the MD5 + * hash for the range, as long as the range is less than or equal to 4 MB in size. + * @param rangeGetContentCrc64 Optional. When this header is set to true and specified together with the Range + * header, the service returns the CRC64 hash for the range, as long as the range is less than or equal to 4 MB in + * size. + * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies + * the message schema version and properties. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData download(String snapshot, String versionId, Integer timeout, String range, String leaseId, + Boolean rangeGetContentMd5, Boolean rangeGetContentCrc64, String structuredBodyType, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for downloadWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (rangeGetContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range-get-content-md5"), + String.valueOf(rangeGetContentMd5)); + } + if (rangeGetContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range-get-content-crc64"), + String.valueOf(rangeGetContentCrc64)); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return downloadWithResponse(requestOptions).getValue(); + } + + /** + * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can + * also call Download to read a snapshot. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData download() { + // Generated convenience method for downloadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadWithResponse(requestOptions).getValue(); + } + + /** + * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties + * for the blob. It does not return the content of the blob. + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getProperties(String snapshot, String versionId, Integer timeout, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + getPropertiesWithResponse(requestOptions).getValue(); + } + + /** + * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties + * for the blob. It does not return the content of the blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getProperties() { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + getPropertiesWithResponse(requestOptions).getValue(); + } + + /** + * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed + * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, + * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or + * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] + * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently + * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until + * it is permanently removed. Use the List Blobs API and specify the \"include=deleted\" query parameter to discover + * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a + * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP + * status code of 404 (ResourceNotFound). + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: + * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob + * itself. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob + * if blob soft delete is enabled. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String snapshot, String versionId, Integer timeout, String leaseId, + DeleteSnapshotsOptionType deleteSnapshots, String ifTags, BlobDeleteType blobDeleteType, + RequestConditions requestConditions) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (deleteSnapshots != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-delete-snapshots"), deleteSnapshots.toString()); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobDeleteType != null) { + requestOptions.addQueryParam("deletetype", blobDeleteType.toString(), false); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + deleteWithResponse(requestOptions).getValue(); + } + + /** + * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed + * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, + * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or + * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] + * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently + * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until + * it is permanently removed. Use the List Blobs API and specify the \"include=deleted\" query parameter to discover + * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a + * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP + * status code of 404 (ResourceNotFound). + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete() { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteWithResponse(requestOptions).getValue(); + } + + /** + * Undelete a blob that was previously soft deleted. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void undelete(Integer timeout) { + // Generated convenience method for undeleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + undeleteWithResponse(requestOptions).getValue(); + } + + /** + * Undelete a blob that was previously soft deleted. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void undelete() { + // Generated convenience method for undeleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + undeleteWithResponse(requestOptions).getValue(); + } + + /** + * Set the expiration time of a blob. + * + * @param expiryOptions Required. Indicates mode of the expiry time. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param expiresOn The time this blob will expire. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setExpiry(BlobExpiryOptions expiryOptions, Integer timeout, OffsetDateTime expiresOn) { + // Generated convenience method for setExpiryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (expiresOn != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-expiry-time"), + String.valueOf(new DateTimeRfc1123(expiresOn))); + } + setExpiryWithResponse(expiryOptions.toString(), requestOptions).getValue(); + } + + /** + * Set the expiration time of a blob. + * + * @param expiryOptions Required. Indicates mode of the expiry time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setExpiry(BlobExpiryOptions expiryOptions) { + // Generated convenience method for setExpiryWithResponse + RequestOptions requestOptions = new RequestOptions(); + setExpiryWithResponse(expiryOptions.toString(), requestOptions).getValue(); + } + + /** + * The Set HTTP Headers operation sets system properties on the blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setHttpHeaders(Integer timeout, String blobCacheControl, String blobContentType, byte[] blobContentMd5, + String blobContentEncoding, String blobContentLanguage, String leaseId, String blobContentDisposition, + String ifTags, RequestConditions requestConditions) { + // Generated convenience method for setHttpHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + setHttpHeadersWithResponse(requestOptions).getValue(); + } + + /** + * The Set HTTP Headers operation sets system properties on the blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setHttpHeaders() { + // Generated convenience method for setHttpHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + setHttpHeadersWithResponse(requestOptions).getValue(); + } + + /** + * Set the immutability policy of a blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setImmutabilityPolicy(Integer timeout, OffsetDateTime ifUnmodifiedSince, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, + String versionId) { + // Generated convenience method for setImmutabilityPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + setImmutabilityPolicyWithResponse(requestOptions).getValue(); + } + + /** + * Set the immutability policy of a blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setImmutabilityPolicy() { + // Generated convenience method for setImmutabilityPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + setImmutabilityPolicyWithResponse(requestOptions).getValue(); + } + + /** + * The Delete Immutability Policy operation deletes the immutability policy on the blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteImmutabilityPolicy(Integer timeout, String snapshot, String versionId) { + // Generated convenience method for deleteImmutabilityPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + deleteImmutabilityPolicyWithResponse(requestOptions).getValue(); + } + + /** + * The Delete Immutability Policy operation deletes the immutability policy on the blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteImmutabilityPolicy() { + // Generated convenience method for deleteImmutabilityPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteImmutabilityPolicyWithResponse(requestOptions).getValue(); + } + + /** + * The Set Legal Hold operation sets a legal hold on the blob. + * + * @param legalHold Required. Specifies the legal hold status to set on the blob. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setLegalHold(boolean legalHold, Integer timeout, String snapshot, String versionId) { + // Generated convenience method for setLegalHoldWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + setLegalHoldWithResponse(legalHold, requestOptions).getValue(); + } + + /** + * The Set Legal Hold operation sets a legal hold on the blob. + * + * @param legalHold Required. Specifies the legal hold status to set on the blob. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setLegalHold(boolean legalHold) { + // Generated convenience method for setLegalHoldWithResponse + RequestOptions requestOptions = new RequestOptions(); + setLegalHoldWithResponse(legalHold, requestOptions).getValue(); + } + + /** + * The Set Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setMetadata(Integer timeout, Map metadata, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for setMetadataWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + setMetadataWithResponse(requestOptions).getValue(); + } + + /** + * The Set Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setMetadata() { + // Generated convenience method for setMetadataWithResponse + RequestOptions requestOptions = new RequestOptions(); + setMetadataWithResponse(requestOptions).getValue(); + } + + /** + * The Acquire Lease operation requests a new lease on a blob. The lease lock duration can be 15 to 60 seconds, or + * can be infinite. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never + * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or + * change. + * @param proposedLeaseId Optional. The proposed lease ID for the container. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void acquireLease(Integer timeout, Integer duration, String proposedLeaseId, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for acquireLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (duration != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-duration"), String.valueOf(duration)); + } + if (proposedLeaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-proposed-lease-id"), proposedLeaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + acquireLeaseWithResponse(requestOptions).getValue(); + } + + /** + * The Acquire Lease operation requests a new lease on a blob. The lease lock duration can be 15 to 60 seconds, or + * can be infinite. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void acquireLease() { + // Generated convenience method for acquireLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + acquireLeaseWithResponse(requestOptions).getValue(); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the blob. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void releaseLease(String leaseId, Integer timeout, String ifTags, RequestConditions requestConditions) { + // Generated convenience method for releaseLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + releaseLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the blob. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void releaseLease(String leaseId) { + // Generated convenience method for releaseLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + releaseLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Renew Lease operation renews an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renewLease(String leaseId, Integer timeout, String ifTags, RequestConditions requestConditions) { + // Generated convenience method for renewLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + renewLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Renew Lease operation renews an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renewLease(String leaseId) { + // Generated convenience method for renewLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + renewLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param proposedLeaseId Optional. The proposed lease ID for the container. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void changeLease(String leaseId, Integer timeout, String proposedLeaseId, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for changeLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (proposedLeaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-proposed-lease-id"), proposedLeaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + changeLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void changeLease(String leaseId) { + // Generated convenience method for changeLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + changeLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in + * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. + * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has + * expired, but the lease may be held for longer than the break period. If this header does not appear with a break + * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks + * immediately. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void breakLease(Integer timeout, Integer breakPeriod, String ifTags, RequestConditions requestConditions) { + // Generated convenience method for breakLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (breakPeriod != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-break-period"), String.valueOf(breakPeriod)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + breakLeaseWithResponse(requestOptions).getValue(); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void breakLease() { + // Generated convenience method for breakLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + breakLeaseWithResponse(requestOptions).getValue(); + } + + /** + * The Create Snapshot operation creates a read-only snapshot of a blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void createSnapshot(Integer timeout, Map metadata, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, + String leaseId, RequestConditions requestConditions) { + // Generated convenience method for createSnapshotWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + createSnapshotWithResponse(requestOptions).getValue(); + } + + /** + * The Create Snapshot operation creates a read-only snapshot of a blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void createSnapshot() { + // Generated convenience method for createSnapshotWithResponse + RequestOptions requestOptions = new RequestOptions(); + createSnapshotWithResponse(requestOptions).getValue(); + } + + /** + * The Start Copy From URL operation copies a blob or an internet resource to a new blob. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param tier The tier to be set on the blob. + * @param rehydratePriority If an object is in rehydrate pending state then this header is returned with priority of + * rehydrate. Valid values are High and Standard. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void startCopyFromUrl(String copySource, Integer timeout, Map metadata, AccessTier tier, + RehydratePriority rehydratePriority, OffsetDateTime sourceIfModifiedSince, + OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, + String ifTags, String leaseId, String blobTagsString, Boolean sealBlob, OffsetDateTime immutabilityPolicyExpiry, + BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, RequestConditions requestConditions) { + // Generated convenience method for startCopyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (rehydratePriority != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-rehydrate-priority"), + rehydratePriority.toString()); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (sourceIfTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-tags"), sourceIfTags); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (sealBlob != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-seal-blob"), String.valueOf(sealBlob)); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + startCopyFromUrlWithResponse(copySource, requestOptions).getValue(); + } + + /** + * The Start Copy From URL operation copies a blob or an internet resource to a new blob. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void startCopyFromUrl(String copySource) { + // Generated convenience method for startCopyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + startCopyFromUrlWithResponse(copySource, requestOptions).getValue(); + } + + /** + * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response + * until the copy is complete. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param tier The tier to be set on the blob. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the + * tags specified by x-ms-tags. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void copyFromUrl(String copySource, Integer timeout, Map metadata, AccessTier tier, + OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, + String sourceIfNoneMatch, String ifTags, String leaseId, String sourceContentMd5, String blobTagsString, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, + String copySourceAuthorization, String encryptionScope, String copySourceTags, + RequestConditions requestConditions) { + // Generated convenience method for copyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (copySourceTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-tags"), copySourceTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + copyFromUrlWithResponse(copySource, requestOptions).getValue(); + } + + /** + * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response + * until the copy is complete. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void copyFromUrl(String copySource) { + // Generated convenience method for copyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + copyFromUrlWithResponse(copySource, requestOptions).getValue(); + } + + /** + * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with + * zero length and full metadata. + * + * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void abortCopyFromUrl(String copyId, Integer timeout, String leaseId) { + // Generated convenience method for abortCopyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + abortCopyFromUrlWithResponse(copyId, requestOptions).getValue(); + } + + /** + * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with + * zero length and full metadata. + * + * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void abortCopyFromUrl(String copyId) { + // Generated convenience method for abortCopyFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + abortCopyFromUrlWithResponse(copyId, requestOptions).getValue(); + } + + /** + * The Set Tier operation sets the tier on a block blob. The operation is allowed on a page blob or block blob, but + * not on an append blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not + * update the blob's ETag. + * + * @param tier Indicates the tier to be set on the blob. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param rehydratePriority If an object is in rehydrate pending state then this header is returned with priority of + * rehydrate. Valid values are High and Standard. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setTier(AccessTier tier, String snapshot, String versionId, Integer timeout, + RehydratePriority rehydratePriority, String leaseId, String ifTags) { + // Generated convenience method for setTierWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (rehydratePriority != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-rehydrate-priority"), + rehydratePriority.toString()); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + setTierWithResponse(tier.toString(), requestOptions).getValue(); + } + + /** + * The Set Tier operation sets the tier on a block blob. The operation is allowed on a page blob or block blob, but + * not on an append blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not + * update the blob's ETag. + * + * @param tier Indicates the tier to be set on the blob. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setTier(AccessTier tier) { + // Generated convenience method for setTierWithResponse + RequestOptions requestOptions = new RequestOptions(); + setTierWithResponse(tier.toString(), requestOptions).getValue(); + } + + /** + * Returns the sku name and account kind. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getAccountInfo(Integer timeout) { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + getAccountInfoWithResponse(requestOptions).getValue(); + } + + /** + * Returns the sku name and account kind. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getAccountInfo() { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + getAccountInfoWithResponse(requestOptions).getValue(); + } + + /** + * The Get Blob Tags operation enables users to get tags on a blob. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents blob tags. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BlobTags getTags(Integer timeout, String snapshot, String versionId, String leaseId, String ifTags) { + // Generated convenience method for getTagsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + return getTagsWithResponse(requestOptions).getValue().toObject(BlobTags.class); + } + + /** + * The Get Blob Tags operation enables users to get tags on a blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents blob tags. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BlobTags getTags() { + // Generated convenience method for getTagsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getTagsWithResponse(requestOptions).getValue().toObject(BlobTags.class); + } + + /** + * The Set Tags operation enables users to set tags on a blob. + * + * @param tags The blob tags. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version + * of the blob to operate on. It's for service version 2019-10-10 and newer. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setTags(BlobTags tags, Integer timeout, String versionId, String transactionalContentMD5, + String transactionalContentCrc64, String ifTags, String leaseId) { + // Generated convenience method for setTagsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (versionId != null) { + requestOptions.addQueryParam("versionid", versionId, false); + } + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + setTagsWithResponse(BinaryData.fromObject(tags), requestOptions).getValue(); + } + + /** + * The Set Tags operation enables users to set tags on a blob. + * + * @param tags The blob tags. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setTags(BlobTags tags) { + // Generated convenience method for setTagsWithResponse + RequestOptions requestOptions = new RequestOptions(); + setTagsWithResponse(BinaryData.fromObject(tags), requestOptions).getValue(); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerClient.java new file mode 100644 index 000000000000..16088114340d --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ContainerClient.java @@ -0,0 +1,2058 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.serializer.TypeReference; +import com.azure.storage.blob.implementation.ContainersImpl; +import com.azure.storage.blob.models.FilterBlobSegment; +import com.azure.storage.blob.models.FilterBlobsIncludeItem; +import com.azure.storage.blob.models.ListBlobsFlatSegmentResponse; +import com.azure.storage.blob.models.ListBlobsHierarchySegmentResponse; +import com.azure.storage.blob.models.ListBlobsIncludeItem; +import com.azure.storage.blob.models.PublicAccessType; +import com.azure.storage.blob.models.SignedIdentifier; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class ContainerClient { + @Generated + private final ContainersImpl serviceClient; + + /** + * Initializes an instance of ContainerClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ContainerClient(ContainersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new container under the specified account. If the container with the same name already exists, the + * operation fails. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-blob-public-accessStringNoThe public access setting for the container. + * Allowed values: "blob", "container".
x-ms-default-encryption-scopeStringNoOptional. Version 2019-07-07 and later. + * Specifies the default encryption scope to set on the container and use for all future writes.
x-ms-deny-encryption-scope-overrideBooleanNoIf a blob has a lease and the + * lease is of infinite duration then the value of this header is set to true, otherwise it is set to + * false.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse(RequestOptions requestOptions) { + return this.serviceClient.createWithResponse(requestOptions); + } + + /** + * returns all user-defined metadata and system properties for the specified container. The data returned does not + * include the container's list of blobs. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPropertiesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPropertiesWithResponse(requestOptions); + } + + /** + * operation marks the specified container for deletion. The container and any blobs contained within it are later + * deleted during garbage collection. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponse(requestOptions); + } + + /** + * operation sets one or more user-defined name-value pairs for the specified container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-metaMap<String, String>NoThe metadata headers.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setMetadataWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setMetadataWithResponse(requestOptions); + } + + /** + * gets the permissions for the specified container. The permissions indicate whether container data may be accessed + * publicly. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         accessPolicy (Required): {
+     *             start: OffsetDateTime (Required)
+     *             expiry: OffsetDateTime (Required)
+     *             permission: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the permissions for the specified container along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAccessPolicyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAccessPolicyWithResponse(requestOptions); + } + + /** + * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be + * accessed publicly. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-public-accessStringNoThe public access setting for the container. + * Allowed values: "blob", "container".
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         accessPolicy (Required): {
+     *             start: OffsetDateTime (Required)
+     *             expiry: OffsetDateTime (Required)
+     *             permission: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param containerAcl The access control list for the container. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setAccessPolicyWithResponse(BinaryData containerAcl, RequestOptions requestOptions) { + return this.serviceClient.setAccessPolicyWithResponse(containerAcl, requestOptions); + } + + /** + * Restores a previously-deleted container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-deleted-container-nameStringNoOptional. Version 2019-12-12 and later. + * Specifies the name of the deleted container to restore.
x-ms-deleted-container-versionStringNoOptional. Version 2019-12-12 and later. + * Specifies the version of the deleted container to restore.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response restoreWithResponse(RequestOptions requestOptions) { + return this.serviceClient.restoreWithResponse(requestOptions); + } + + /** + * Renames an existing container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-lease-idStringNoA lease ID for the source path. If specified, the + * source path must have an active lease and the lease ID must match.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceContainerName Required. Specifies the name of the container to rename. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response renameWithResponse(String sourceContainerName, RequestOptions requestOptions) { + return this.serviceClient.renameWithResponse(sourceContainerName, requestOptions); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response submitBatchWithResponse(long contentLength, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.submitBatchWithResponse(contentLength, body, requestOptions); + } + + /** + * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search + * expression. Filter blobs searches within the given container. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
whereStringNoFilters the results to return only to return only blobs whose + * tags match the specified expression.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     where: String (Required)
+     *     blobs (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             containerName: String (Required)
+     *             tags (Optional): {
+     *                 blobTagSet (Required): [
+     *                      (Required){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *             versionId: String (Optional)
+     *             isCurrentVersion: Boolean (Optional)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the result of a Filter Blobs API call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response filterBlobsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.filterBlobsWithResponse(requestOptions); + } + + /** + * The Acquire Lease operation requests a new lease on a container. The lease lock duration can be 15 to 60 seconds, + * or can be infinite. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-durationIntegerNoSpecifies the duration of the lease, in seconds, + * or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A + * lease duration cannot be changed using renew or change.
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response acquireLeaseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.acquireLeaseWithResponse(requestOptions); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response releaseLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.releaseLeaseWithResponse(leaseId, requestOptions); + } + + /** + * The Renew Lease operation renews an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response renewLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + return this.serviceClient.renewLeaseWithResponse(leaseId, requestOptions); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
x-ms-lease-break-periodIntegerNoFor a break operation, proposed duration the + * lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is + * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease + * will not be available before the break period has expired, but the lease may be held for longer than the break + * period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining + * lease period elapses, and an infinite lease breaks immediately.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response breakLeaseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.breakLeaseWithResponse(requestOptions); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param proposedLeaseId Required. The proposed lease ID for the container. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response changeLeaseWithResponse(String leaseId, String proposedLeaseId, + RequestOptions requestOptions) { + return this.serviceClient.changeLeaseWithResponse(leaseId, proposedLeaseId, requestOptions); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     containerName: String (Required)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     segment (Required): {
+     *         blobItems (Required): [
+     *              (Required){
+     *                 name (Required): {
+     *                     encoded: boolean (Required)
+     *                     content: String (Required)
+     *                 }
+     *                 deleted: boolean (Required)
+     *                 snapshot: String (Required)
+     *                 versionId: String (Optional)
+     *                 isCurrentVersion: Boolean (Optional)
+     *                 properties (Required): {
+     *                     creationTime: DateTimeRfc1123 (Optional)
+     *                     lastModified: DateTimeRfc1123 (Required)
+     *                     eTag: String (Required)
+     *                     contentLength: Long (Optional)
+     *                     contentType: String (Optional)
+     *                     contentEncoding: String (Optional)
+     *                     contentLanguage: String (Optional)
+     *                     contentMd5: byte[] (Optional)
+     *                     contentDisposition: String (Optional)
+     *                     cacheControl: String (Optional)
+     *                     blobSequenceNumber: Long (Optional)
+     *                     blobType: String(BlockBlob/PageBlob/AppendBlob) (Optional)
+     *                     leaseStatus: String(unlocked/locked) (Optional)
+     *                     leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                     leaseDuration: String(infinite/fixed) (Optional)
+     *                     copyId: String (Optional)
+     *                     copyStatus: String(pending/success/failed/aborted) (Optional)
+     *                     copySource: String (Optional)
+     *                     copyProgress: String (Optional)
+     *                     copyCompletionTime: DateTimeRfc1123 (Optional)
+     *                     copyStatusDescription: String (Optional)
+     *                     serverEncrypted: Boolean (Optional)
+     *                     incrementalCopy: Boolean (Optional)
+     *                     destinationSnapshot: String (Optional)
+     *                     deletedTime: DateTimeRfc1123 (Optional)
+     *                     remainingRetentionDays: Integer (Optional)
+     *                     accessTier: String(P4/P6/P10/P15/P20/P30/P40/P50/P60/P70/P80/Hot/Cool/Archive/Premium/Cold) (Optional)
+     *                     accessTierInferred: Boolean (Optional)
+     *                     archiveStatus: String(rehydrate-pending-to-hot/rehydrate-pending-to-cool/rehydrate-pending-to-cold) (Optional)
+     *                     customerProvidedKeySha256: String (Optional)
+     *                     encryptionScope: String (Optional)
+     *                     accessTierChangeTime: DateTimeRfc1123 (Optional)
+     *                     tagCount: Integer (Optional)
+     *                     expiryTime: DateTimeRfc1123 (Optional)
+     *                     sealed: Boolean (Optional)
+     *                     rehydratePriority: String(High/Standard) (Optional)
+     *                     lastAccessTime: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyUntilDate: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyMode: String(Mutable/Locked/Unlocked) (Optional)
+     *                     legalHold: Boolean (Optional)
+     *                 }
+     *                 metadata (Optional): {
+     *                     encrypted: String (Optional)
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 blobTags (Optional): {
+     *                     blobTagSet (Required): [
+     *                          (Required){
+     *                             key: String (Required)
+     *                             value: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *                 objectReplicationMetadata (Optional): {
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 hasVersionsOnly: Boolean (Optional)
+     *             }
+     *         ]
+     *     }
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an enumeration of blobs along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listBlobFlatSegmentWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listBlobFlatSegmentWithResponse(requestOptions); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. A delimiter can be used to + * traverse a virtual hierarchy of blobs as though it were a file system. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     containerName: String (Required)
+     *     delimiter: String (Optional)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     segment (Required): {
+     *         blobItems (Required): [
+     *              (Required){
+     *                 name (Required): {
+     *                     encoded: boolean (Required)
+     *                     content: String (Required)
+     *                 }
+     *                 deleted: boolean (Required)
+     *                 snapshot: String (Required)
+     *                 versionId: String (Optional)
+     *                 isCurrentVersion: Boolean (Optional)
+     *                 properties (Required): {
+     *                     creationTime: DateTimeRfc1123 (Optional)
+     *                     lastModified: DateTimeRfc1123 (Required)
+     *                     eTag: String (Required)
+     *                     contentLength: Long (Optional)
+     *                     contentType: String (Optional)
+     *                     contentEncoding: String (Optional)
+     *                     contentLanguage: String (Optional)
+     *                     contentMd5: byte[] (Optional)
+     *                     contentDisposition: String (Optional)
+     *                     cacheControl: String (Optional)
+     *                     blobSequenceNumber: Long (Optional)
+     *                     blobType: String(BlockBlob/PageBlob/AppendBlob) (Optional)
+     *                     leaseStatus: String(unlocked/locked) (Optional)
+     *                     leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                     leaseDuration: String(infinite/fixed) (Optional)
+     *                     copyId: String (Optional)
+     *                     copyStatus: String(pending/success/failed/aborted) (Optional)
+     *                     copySource: String (Optional)
+     *                     copyProgress: String (Optional)
+     *                     copyCompletionTime: DateTimeRfc1123 (Optional)
+     *                     copyStatusDescription: String (Optional)
+     *                     serverEncrypted: Boolean (Optional)
+     *                     incrementalCopy: Boolean (Optional)
+     *                     destinationSnapshot: String (Optional)
+     *                     deletedTime: DateTimeRfc1123 (Optional)
+     *                     remainingRetentionDays: Integer (Optional)
+     *                     accessTier: String(P4/P6/P10/P15/P20/P30/P40/P50/P60/P70/P80/Hot/Cool/Archive/Premium/Cold) (Optional)
+     *                     accessTierInferred: Boolean (Optional)
+     *                     archiveStatus: String(rehydrate-pending-to-hot/rehydrate-pending-to-cool/rehydrate-pending-to-cold) (Optional)
+     *                     customerProvidedKeySha256: String (Optional)
+     *                     encryptionScope: String (Optional)
+     *                     accessTierChangeTime: DateTimeRfc1123 (Optional)
+     *                     tagCount: Integer (Optional)
+     *                     expiryTime: DateTimeRfc1123 (Optional)
+     *                     sealed: Boolean (Optional)
+     *                     rehydratePriority: String(High/Standard) (Optional)
+     *                     lastAccessTime: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyUntilDate: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyMode: String(Mutable/Locked/Unlocked) (Optional)
+     *                     legalHold: Boolean (Optional)
+     *                 }
+     *                 metadata (Optional): {
+     *                     encrypted: String (Optional)
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 blobTags (Optional): {
+     *                     blobTagSet (Required): [
+     *                          (Required){
+     *                             key: String (Required)
+     *                             value: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *                 objectReplicationMetadata (Optional): {
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 hasVersionsOnly: Boolean (Optional)
+     *             }
+     *         ]
+     *         blobPrefixes (Optional): [
+     *              (Optional){
+     *                 name (Required): (recursive schema, see name above)
+     *             }
+     *         ]
+     *     }
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the + * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the + * appearance of the delimiter character. The delimiter may be a single character or a string. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an enumeration of blobs along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listBlobHierarchySegmentWithResponse(String delimiter, RequestOptions requestOptions) { + return this.serviceClient.listBlobHierarchySegmentWithResponse(delimiter, requestOptions); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAccountInfoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAccountInfoWithResponse(requestOptions); + } + + /** + * Creates a new container under the specified account. If the container with the same name already exists, the + * operation fails. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param metadata The metadata headers. + * @param access The public access setting for the container. + * @param defaultEncryptionScope Optional. Version 2019-07-07 and later. Specifies the default encryption scope to + * set on the container and use for all future writes. + * @param preventEncryptionScopeOverride If a blob has a lease and the lease is of infinite duration then the value + * of this header is set to true, otherwise it is set to false. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void create(Integer timeout, Map metadata, PublicAccessType access, + String defaultEncryptionScope, Boolean preventEncryptionScopeOverride) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (access != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-public-access"), access.toString()); + } + if (defaultEncryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-default-encryption-scope"), + defaultEncryptionScope); + } + if (preventEncryptionScopeOverride != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-deny-encryption-scope-override"), + String.valueOf(preventEncryptionScopeOverride)); + } + createWithResponse(requestOptions).getValue(); + } + + /** + * Creates a new container under the specified account. If the container with the same name already exists, the + * operation fails. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void create() { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + createWithResponse(requestOptions).getValue(); + } + + /** + * returns all user-defined metadata and system properties for the specified container. The data returned does not + * include the container's list of blobs. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getProperties(Integer timeout, String leaseId) { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + getPropertiesWithResponse(requestOptions).getValue(); + } + + /** + * returns all user-defined metadata and system properties for the specified container. The data returned does not + * include the container's list of blobs. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getProperties() { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + getPropertiesWithResponse(requestOptions).getValue(); + } + + /** + * operation marks the specified container for deletion. The container and any blobs contained within it are later + * deleted during garbage collection. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, + OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + deleteWithResponse(requestOptions).getValue(); + } + + /** + * operation marks the specified container for deletion. The container and any blobs contained within it are later + * deleted during garbage collection. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete() { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteWithResponse(requestOptions).getValue(); + } + + /** + * operation sets one or more user-defined name-value pairs for the specified container. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param metadata The metadata headers. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setMetadata(Integer timeout, String leaseId, Map metadata, + OffsetDateTime ifModifiedSince) { + // Generated convenience method for setMetadataWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + setMetadataWithResponse(requestOptions).getValue(); + } + + /** + * operation sets one or more user-defined name-value pairs for the specified container. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setMetadata() { + // Generated convenience method for setMetadataWithResponse + RequestOptions requestOptions = new RequestOptions(); + setMetadataWithResponse(requestOptions).getValue(); + } + + /** + * gets the permissions for the specified container. The permissions indicate whether container data may be accessed + * publicly. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the permissions for the specified container. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List getAccessPolicy(Integer timeout, String leaseId) { + // Generated convenience method for getAccessPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + return getAccessPolicyWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_SIGNED_IDENTIFIER); + } + + /** + * gets the permissions for the specified container. The permissions indicate whether container data may be accessed + * publicly. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the permissions for the specified container. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List getAccessPolicy() { + // Generated convenience method for getAccessPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAccessPolicyWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_SIGNED_IDENTIFIER); + } + + /** + * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be + * accessed publicly. + * + * @param containerAcl The access control list for the container. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param access The public access setting for the container. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setAccessPolicy(List containerAcl, Integer timeout, String leaseId, + PublicAccessType access, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for setAccessPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (access != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-public-access"), access.toString()); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + setAccessPolicyWithResponse(BinaryData.fromObject(containerAcl), requestOptions).getValue(); + } + + /** + * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be + * accessed publicly. + * + * @param containerAcl The access control list for the container. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setAccessPolicy(List containerAcl) { + // Generated convenience method for setAccessPolicyWithResponse + RequestOptions requestOptions = new RequestOptions(); + setAccessPolicyWithResponse(BinaryData.fromObject(containerAcl), requestOptions).getValue(); + } + + /** + * Restores a previously-deleted container. + * + * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container + * to restore. + * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted + * container to restore. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void restore(String deletedContainerName, String deletedContainerVersion, Integer timeout) { + // Generated convenience method for restoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (deletedContainerName != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-deleted-container-name"), deletedContainerName); + } + if (deletedContainerVersion != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-deleted-container-version"), + deletedContainerVersion); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + restoreWithResponse(requestOptions).getValue(); + } + + /** + * Restores a previously-deleted container. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void restore() { + // Generated convenience method for restoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + restoreWithResponse(requestOptions).getValue(); + } + + /** + * Renames an existing container. + * + * @param sourceContainerName Required. Specifies the name of the container to rename. + * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and + * the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void rename(String sourceContainerName, String sourceLeaseId, Integer timeout) { + // Generated convenience method for renameWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (sourceLeaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-lease-id"), sourceLeaseId); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + renameWithResponse(sourceContainerName, requestOptions).getValue(); + } + + /** + * Renames an existing container. + * + * @param sourceContainerName Required. Specifies the name of the container to rename. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void rename(String sourceContainerName) { + // Generated convenience method for renameWithResponse + RequestOptions requestOptions = new RequestOptions(); + renameWithResponse(sourceContainerName, requestOptions).getValue(); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData submitBatch(long contentLength, BinaryData body, Integer timeout) { + // Generated convenience method for submitBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return submitBatchWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData submitBatch(long contentLength, BinaryData body) { + // Generated convenience method for submitBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return submitBatchWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search + * expression. Filter blobs searches within the given container. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param where Filters the results to return only to return only blobs whose tags match the specified expression. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param include Include this parameter to specify one or more datasets to include in the response. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of a Filter Blobs API call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FilterBlobSegment filterBlobs(Integer timeout, String where, String marker, Integer maxresults, + List include) { + // Generated convenience method for filterBlobsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (where != null) { + requestOptions.addQueryParam("where", where, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return filterBlobsWithResponse(requestOptions).getValue().toObject(FilterBlobSegment.class); + } + + /** + * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search + * expression. Filter blobs searches within the given container. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of a Filter Blobs API call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FilterBlobSegment filterBlobs() { + // Generated convenience method for filterBlobsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return filterBlobsWithResponse(requestOptions).getValue().toObject(FilterBlobSegment.class); + } + + /** + * The Acquire Lease operation requests a new lease on a container. The lease lock duration can be 15 to 60 seconds, + * or can be infinite. + * + * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never + * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or + * change. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param proposedLeaseId Optional. The proposed lease ID for the container. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void acquireLease(Integer duration, Integer timeout, String proposedLeaseId, OffsetDateTime ifModifiedSince, + OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for acquireLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (duration != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-duration"), String.valueOf(duration)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (proposedLeaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-proposed-lease-id"), proposedLeaseId); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + acquireLeaseWithResponse(requestOptions).getValue(); + } + + /** + * The Acquire Lease operation requests a new lease on a container. The lease lock duration can be 15 to 60 seconds, + * or can be infinite. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void acquireLease() { + // Generated convenience method for acquireLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + acquireLeaseWithResponse(requestOptions).getValue(); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the container. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void releaseLease(String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, + OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for releaseLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + releaseLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the container. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void releaseLease(String leaseId) { + // Generated convenience method for releaseLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + releaseLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Renew Lease operation renews an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renewLease(String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, + OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for renewLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + renewLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Renew Lease operation renews an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renewLease(String leaseId) { + // Generated convenience method for renewLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + renewLeaseWithResponse(leaseId, requestOptions).getValue(); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in + * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. + * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has + * expired, but the lease may be held for longer than the break period. If this header does not appear with a break + * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks + * immediately. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void breakLease(Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, + Integer breakPeriod) { + // Generated convenience method for breakLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (breakPeriod != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-break-period"), String.valueOf(breakPeriod)); + } + breakLeaseWithResponse(requestOptions).getValue(); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void breakLease() { + // Generated convenience method for breakLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + breakLeaseWithResponse(requestOptions).getValue(); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param proposedLeaseId Required. The proposed lease ID for the container. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifModifiedSince A date-time value. A request is made under the condition that the resource has been + * modified since the specified date-time. + * @param ifUnmodifiedSince A date-time value. A request is made under the condition that the resource has not been + * modified since the specified date-time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void changeLease(String leaseId, String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, + OffsetDateTime ifUnmodifiedSince) { + // Generated convenience method for changeLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + changeLeaseWithResponse(leaseId, proposedLeaseId, requestOptions).getValue(); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param proposedLeaseId Required. The proposed lease ID for the container. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void changeLease(String leaseId, String proposedLeaseId) { + // Generated convenience method for changeLeaseWithResponse + RequestOptions requestOptions = new RequestOptions(); + changeLeaseWithResponse(leaseId, proposedLeaseId, requestOptions).getValue(); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. + * + * @param prefix Filters the results to return only containers whose name begins with the specified prefix. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param include Include this parameter to specify one or more datasets to include in the response. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an enumeration of blobs. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ListBlobsFlatSegmentResponse listBlobFlatSegment(String prefix, String marker, Integer maxresults, + List include, Integer timeout) { + // Generated convenience method for listBlobFlatSegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (prefix != null) { + requestOptions.addQueryParam("prefix", prefix, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return listBlobFlatSegmentWithResponse(requestOptions).getValue().toObject(ListBlobsFlatSegmentResponse.class); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an enumeration of blobs. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ListBlobsFlatSegmentResponse listBlobFlatSegment() { + // Generated convenience method for listBlobFlatSegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listBlobFlatSegmentWithResponse(requestOptions).getValue().toObject(ListBlobsFlatSegmentResponse.class); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. A delimiter can be used to + * traverse a virtual hierarchy of blobs as though it were a file system. + * + * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the + * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the + * appearance of the delimiter character. The delimiter may be a single character or a string. + * @param prefix Filters the results to return only containers whose name begins with the specified prefix. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param include Include this parameter to specify one or more datasets to include in the response. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an enumeration of blobs. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ListBlobsHierarchySegmentResponse listBlobHierarchySegment(String delimiter, String prefix, String marker, + Integer maxresults, List include, Integer timeout) { + // Generated convenience method for listBlobHierarchySegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (prefix != null) { + requestOptions.addQueryParam("prefix", prefix, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return listBlobHierarchySegmentWithResponse(delimiter, requestOptions).getValue() + .toObject(ListBlobsHierarchySegmentResponse.class); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. A delimiter can be used to + * traverse a virtual hierarchy of blobs as though it were a file system. + * + * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the + * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the + * appearance of the delimiter character. The delimiter may be a single character or a string. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an enumeration of blobs. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ListBlobsHierarchySegmentResponse listBlobHierarchySegment(String delimiter) { + // Generated convenience method for listBlobHierarchySegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listBlobHierarchySegmentWithResponse(delimiter, requestOptions).getValue() + .toObject(ListBlobsHierarchySegmentResponse.class); + } + + /** + * Returns the sku name and account kind. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getAccountInfo(Integer timeout) { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + getAccountInfoWithResponse(requestOptions).getValue(); + } + + /** + * Returns the sku name and account kind. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getAccountInfo() { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + getAccountInfoWithResponse(requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_SIGNED_IDENTIFIER + = new TypeReference>() { + }; +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/HttpGetterInfo.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/HttpGetterInfo.java deleted file mode 100644 index ba677659dba2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/HttpGetterInfo.java +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.Context; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.time.Duration; - -/** - * HttpGetterInfo is a passed to the getter function of a reliable download to specify parameters needed for the GET - * request. - */ -public final class HttpGetterInfo { - private long offset = 0; - private Long count = null; - private String eTag = null; - - /** - * Creates a new instance of {@link HttpGetterInfo}. - */ - public HttpGetterInfo() { - } - - /** - * Gets the start offset that is used when creating the Range header. If unchanged this will default to 0. - * - * @return the start offset used when creating the Range header. Defaults to 0. - */ - public long getOffset() { - return offset; - } - - /** - * Sets the start offset that is used when creating the Range header. If unchanged this will default to 0. - * - * @param offset Start offset - * @return the updated HttpGetterInfo object - */ - public HttpGetterInfo setOffset(long offset) { - this.offset = offset; - return this; - } - - /** - * Gets the count of bytes used to calculate the end offset when creating the Range header. null is the default and - * indicates that the entire rest of the blob should be retrieved. - * - * @return the count of bytes used to calculate the end offset when creating the Range header. null is the default - * and indicates that the entire rest of the blob should be retrieved. - */ - public Long getCount() { - return count; - } - - /** - * Sets the count of bytes used to calculate the end offset when creating the Range header. null is the default and - * indicates that the entire rest of the blob should be retrieved. - * - * @param count Count of bytes - * @return the updated HttpGetterInfo object - */ - public HttpGetterInfo setCount(Long count) { - if (count != null) { - StorageImplUtils.assertInBounds("count", count, 0, Long.MAX_VALUE); - } - this.count = count; - return this; - } - - /** - * Gets the eTag used when creating If-Match header. eTag is returned with any operation that modifies the resource - * and when retrieving - * {@link BlobClient#getPropertiesWithResponse(BlobRequestConditions, Duration, Context) properties}. Defaults to - * null. - * - * @return the eTag used when creating If-Match header. eTag is returned with any operation that modifies the - * resource and when retrieving - * {@link BlobClient#getPropertiesWithResponse(BlobRequestConditions, Duration, Context) properties}. Defaults to - * null. - */ - public String getETag() { - return eTag; - } - - /** - * Sets the eTag used when creating If-Match header. eTag is returned with any operation that modifies the resource - * and when retrieving - * {@link BlobClient#getPropertiesWithResponse(BlobRequestConditions, Duration, Context) properties}. Defaults to - * null. - * - * @param eTag Resource's eTag - * @return the updated HttpGetterInfo object - */ - public HttpGetterInfo setETag(String eTag) { - this.eTag = eTag; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/PageBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/PageBlobAsyncClient.java new file mode 100644 index 000000000000..49d34b735708 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/PageBlobAsyncClient.java @@ -0,0 +1,1781 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.storage.blob.implementation.PageBlobsImpl; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; +import com.azure.storage.blob.models.EncryptionAlgorithmType; +import com.azure.storage.blob.models.PageList; +import com.azure.storage.blob.models.PremiumPageBlobAccessTier; +import com.azure.storage.blob.models.SequenceNumberActionType; +import java.time.OffsetDateTime; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class PageBlobAsyncClient { + @Generated + private final PageBlobsImpl serviceClient; + + /** + * Initializes an instance of PageBlobAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PageBlobAsyncClient(PageBlobsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The Create operation creates a new page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoOptional. Indicates the tier to be set on the page + * blob. Allowed values: "P4", "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80".
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-blob-sequence-numberLongNoOptional. The sequence number is a + * user-controlled property that you can use to track requests. The value of the sequence number must be between 0 + * and 2^63 - 1. The default value is 0.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithResponse(long contentLength, long blobContentLength, + RequestOptions requestOptions) { + return this.serviceClient.createWithResponseAsync(contentLength, blobContentLength, requestOptions); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> uploadPagesWithResponse(long contentLength, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.uploadPagesWithResponseAsync(contentLength, body, requestOptions); + } + + /** + * The Clear Pages operation clears a range of pages from a page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> clearPagesWithResponse(long contentLength, RequestOptions requestOptions) { + return this.serviceClient.clearPagesWithResponseAsync(contentLength, requestOptions); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. The length of this range should match the + * ContentLength header and x-ms-range/Range destination range header. + * @param contentLength The length of the request. + * @param range Bytes of source data in the specified range. The length of this range should match the ContentLength + * header and x-ms-range/Range destination range header. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> uploadPagesFromUrlWithResponse(String sourceUrl, String sourceRange, long contentLength, + String range, RequestOptions requestOptions) { + return this.serviceClient.uploadPagesFromUrlWithResponseAsync(sourceUrl, sourceRange, contentLength, range, + requestOptions); + } + + /** + * The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pageRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     clearRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents a page list along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPageRangesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPageRangesWithResponseAsync(requestOptions); + } + + /** + * The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob or snapshot of a page + * blob. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
prevsnapshotStringNoOptional in version 2015-07-08 and newer. The prevsnapshot + * parameter is a DateTime value that specifies that the response will contain only pages that were changed between + * target blob and previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a + * snapshot, as long as the snapshot specified by prevsnapshot is the older of the two. Note that incremental + * snapshots are currently supported only for blobs created on or after January 1, 2016.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-previous-snapshot-urlStringNoOptional. This header is only supported in + * service versions 2019-04-19 and after and specifies the URL of a previous snapshot of the target blob. The + * response will only contain pages that were changed between the target blob and its previous snapshot.
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pageRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     clearRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents a page list along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPageRangesDiffWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPageRangesDiffWithResponseAsync(requestOptions); + } + + /** + * The Resize operation increases the size of the page blob to the specified size. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> resizeWithResponse(long blobContentLength, RequestOptions requestOptions) { + return this.serviceClient.resizeWithResponseAsync(blobContentLength, requestOptions); + } + + /** + * The Update Sequence Number operation sets the blob's sequence number. The operation will fail if the specified + * sequence number is less than the current sequence number of the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-blob-sequence-numberLongNoSet for page blobs only. The sequence number is + * a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 + * and 2^63 - 1.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This + * property applies to page blobs only. This property indicates how the service should modify the blob's sequence + * number. Allowed values: "increment", "max", "update". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateSequenceNumberWithResponse(String sequenceNumberAction, + RequestOptions requestOptions) { + return this.serviceClient.updateSequenceNumberWithResponseAsync(sequenceNumberAction, requestOptions); + } + + /** + * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot + * is copied such that only the differential changes between the previously copied snapshot are transferred to the + * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as + * usual. This API is supported since REST version 2016-05-31. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> copyIncrementalWithResponse(String copySource, RequestOptions requestOptions) { + return this.serviceClient.copyIncrementalWithResponseAsync(copySource, requestOptions); + } + + /** + * The Create operation creates a new page blob. + * + * @param contentLength The length of the request. + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param metadata The metadata headers. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param tier Optional. Indicates the tier to be set on the page blob. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobSequenceNumber Optional. The sequence number is a user-controlled property that you can use to track + * requests. The value of the sequence number must be between 0 and 2^63 - 1. The default value is 0. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono create(long contentLength, long blobContentLength, Map metadata, Integer timeout, + PremiumPageBlobAccessTier tier, String blobContentType, String blobContentEncoding, String blobContentLanguage, + byte[] blobContentMd5, String blobCacheControl, String leaseId, String blobContentDisposition, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, + String encryptionScope, String ifTags, Long blobSequenceNumber, String blobTagsString, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, + RequestConditions requestConditions) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobSequenceNumber != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-sequence-number"), + String.valueOf(blobSequenceNumber)); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return createWithResponse(contentLength, blobContentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Create operation creates a new page blob. + * + * @param contentLength The length of the request. + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono create(long contentLength, long blobContentLength) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createWithResponse(contentLength, blobContentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence + * number less than or equal to the specified. + * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number + * less than the specified. + * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified + * sequence number. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema + * version and properties. + * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the + * blob/file content inside the message body. Will always be smaller than Content-Length. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono uploadPages(long contentLength, BinaryData body, String transactionalContentMD5, + String transactionalContentCrc64, Integer timeout, String range, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, + Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, + String ifTags, String structuredBodyType, Long structuredContentLength, RequestConditions requestConditions) { + // Generated convenience method for uploadPagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifSequenceNumberLessThanOrEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-le"), + String.valueOf(ifSequenceNumberLessThanOrEqualTo)); + } + if (ifSequenceNumberLessThan != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-lt"), + String.valueOf(ifSequenceNumberLessThan)); + } + if (ifSequenceNumberEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-eq"), + String.valueOf(ifSequenceNumberEqualTo)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (structuredContentLength != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-content-length"), + String.valueOf(structuredContentLength)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return uploadPagesWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono uploadPages(long contentLength, BinaryData body) { + // Generated convenience method for uploadPagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadPagesWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Clear Pages operation clears a range of pages from a page blob. + * + * @param contentLength The length of the request. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence + * number less than or equal to the specified. + * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number + * less than the specified. + * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified + * sequence number. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono clearPages(long contentLength, Integer timeout, String range, String leaseId, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, + String encryptionScope, Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, + Long ifSequenceNumberEqualTo, String ifTags, RequestConditions requestConditions) { + // Generated convenience method for clearPagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifSequenceNumberLessThanOrEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-le"), + String.valueOf(ifSequenceNumberLessThanOrEqualTo)); + } + if (ifSequenceNumberLessThan != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-lt"), + String.valueOf(ifSequenceNumberLessThan)); + } + if (ifSequenceNumberEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-eq"), + String.valueOf(ifSequenceNumberEqualTo)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return clearPagesWithResponse(contentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Clear Pages operation clears a range of pages from a page blob. + * + * @param contentLength The length of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono clearPages(long contentLength) { + // Generated convenience method for clearPagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return clearPagesWithResponse(contentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. + * + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. The length of this range should match the + * ContentLength header and x-ms-range/Range destination range header. + * @param contentLength The length of the request. + * @param range Bytes of source data in the specified range. The length of this range should match the ContentLength + * header and x-ms-range/Range destination range header. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param sourceContentCrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy + * source. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence + * number less than or equal to the specified. + * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number + * less than the specified. + * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified + * sequence number. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono uploadPagesFromUrl(String sourceUrl, String sourceRange, long contentLength, String range, + String sourceContentMd5, byte[] sourceContentCrc64, Integer timeout, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String leaseId, + Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, + String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, + String sourceIfMatch, String sourceIfNoneMatch, String copySourceAuthorization, + RequestConditions requestConditions) { + // Generated convenience method for uploadPagesFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (sourceContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-crc64"), + String.valueOf(sourceContentCrc64)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifSequenceNumberLessThanOrEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-le"), + String.valueOf(ifSequenceNumberLessThanOrEqualTo)); + } + if (ifSequenceNumberLessThan != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-lt"), + String.valueOf(ifSequenceNumberLessThan)); + } + if (ifSequenceNumberEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-eq"), + String.valueOf(ifSequenceNumberEqualTo)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return uploadPagesFromUrlWithResponse(sourceUrl, sourceRange, contentLength, range, requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. + * + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. The length of this range should match the + * ContentLength header and x-ms-range/Range destination range header. + * @param contentLength The length of the request. + * @param range Bytes of source data in the specified range. The length of this range should match the ContentLength + * header and x-ms-range/Range destination range header. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono uploadPagesFromUrl(String sourceUrl, String sourceRange, long contentLength, String range) { + // Generated convenience method for uploadPagesFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadPagesFromUrlWithResponse(sourceUrl, sourceRange, contentLength, range, requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a page list on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPageRanges(String snapshot, Integer timeout, String range, String leaseId, String ifTags, + String marker, Integer maxresults, RequestConditions requestConditions) { + // Generated convenience method for getPageRangesWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return getPageRangesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PageList.class)); + } + + /** + * The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a page list on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPageRanges() { + // Generated convenience method for getPageRangesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPageRangesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PageList.class)); + } + + /** + * The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob or snapshot of a page + * blob. + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that + * specifies that the response will contain only pages that were changed between target blob and previous snapshot. + * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot + * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only + * for blobs created on or after January 1, 2016. + * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and + * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were + * changed between the target blob and its previous snapshot. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a page list on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPageRangesDiff(String snapshot, Integer timeout, String prevsnapshot, + String prevSnapshotUrl, String range, String leaseId, String ifTags, String marker, Integer maxresults, + RequestConditions requestConditions) { + // Generated convenience method for getPageRangesDiffWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (prevsnapshot != null) { + requestOptions.addQueryParam("prevsnapshot", prevsnapshot, false); + } + if (prevSnapshotUrl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-previous-snapshot-url"), prevSnapshotUrl); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return getPageRangesDiffWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PageList.class)); + } + + /** + * The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob or snapshot of a page + * blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a page list on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPageRangesDiff() { + // Generated convenience method for getPageRangesDiffWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPageRangesDiffWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PageList.class)); + } + + /** + * The Resize operation increases the size of the page blob to the specified size. + * + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono resize(long blobContentLength, Integer timeout, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for resizeWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return resizeWithResponse(blobContentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Resize operation increases the size of the page blob to the specified size. + * + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono resize(long blobContentLength) { + // Generated convenience method for resizeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return resizeWithResponse(blobContentLength, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Update Sequence Number operation sets the blob's sequence number. The operation will fail if the specified + * sequence number is less than the current sequence number of the blob. + * + * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This + * property applies to page blobs only. This property indicates how the service should modify the blob's sequence + * number. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can + * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateSequenceNumber(SequenceNumberActionType sequenceNumberAction, Integer timeout, + String leaseId, String ifTags, Long blobSequenceNumber, RequestConditions requestConditions) { + // Generated convenience method for updateSequenceNumberWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobSequenceNumber != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-sequence-number"), + String.valueOf(blobSequenceNumber)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return updateSequenceNumberWithResponse(sequenceNumberAction.toString(), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The Update Sequence Number operation sets the blob's sequence number. The operation will fail if the specified + * sequence number is less than the current sequence number of the blob. + * + * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This + * property applies to page blobs only. This property indicates how the service should modify the blob's sequence + * number. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateSequenceNumber(SequenceNumberActionType sequenceNumberAction) { + // Generated convenience method for updateSequenceNumberWithResponse + RequestOptions requestOptions = new RequestOptions(); + return updateSequenceNumberWithResponse(sequenceNumberAction.toString(), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot + * is copied such that only the differential changes between the previously copied snapshot are transferred to the + * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as + * usual. This API is supported since REST version 2016-05-31. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono copyIncremental(String copySource, Integer timeout, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for copyIncrementalWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return copyIncrementalWithResponse(copySource, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot + * is copied such that only the differential changes between the previously copied snapshot are transferred to the + * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as + * usual. This API is supported since REST version 2016-05-31. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono copyIncremental(String copySource) { + // Generated convenience method for copyIncrementalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return copyIncrementalWithResponse(copySource, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/PageBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/PageBlobClient.java new file mode 100644 index 000000000000..518508c1f6f2 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/PageBlobClient.java @@ -0,0 +1,1755 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.storage.blob.implementation.PageBlobsImpl; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; +import com.azure.storage.blob.models.EncryptionAlgorithmType; +import com.azure.storage.blob.models.PageList; +import com.azure.storage.blob.models.PremiumPageBlobAccessTier; +import com.azure.storage.blob.models.SequenceNumberActionType; +import java.time.OffsetDateTime; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class PageBlobClient { + @Generated + private final PageBlobsImpl serviceClient; + + /** + * Initializes an instance of PageBlobClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PageBlobClient(PageBlobsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The Create operation creates a new page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoOptional. Indicates the tier to be set on the page + * blob. Allowed values: "P4", "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80".
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-blob-sequence-numberLongNoOptional. The sequence number is a + * user-controlled property that you can use to track requests. The value of the sequence number must be between 0 + * and 2^63 - 1. The default value is 0.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse(long contentLength, long blobContentLength, + RequestOptions requestOptions) { + return this.serviceClient.createWithResponse(contentLength, blobContentLength, requestOptions); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response uploadPagesWithResponse(long contentLength, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.uploadPagesWithResponse(contentLength, body, requestOptions); + } + + /** + * The Clear Pages operation clears a range of pages from a page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response clearPagesWithResponse(long contentLength, RequestOptions requestOptions) { + return this.serviceClient.clearPagesWithResponse(contentLength, requestOptions); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. The length of this range should match the + * ContentLength header and x-ms-range/Range destination range header. + * @param contentLength The length of the request. + * @param range Bytes of source data in the specified range. The length of this range should match the ContentLength + * header and x-ms-range/Range destination range header. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response uploadPagesFromUrlWithResponse(String sourceUrl, String sourceRange, long contentLength, + String range, RequestOptions requestOptions) { + return this.serviceClient.uploadPagesFromUrlWithResponse(sourceUrl, sourceRange, contentLength, range, + requestOptions); + } + + /** + * The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pageRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     clearRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents a page list along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPageRangesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPageRangesWithResponse(requestOptions); + } + + /** + * The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob or snapshot of a page + * blob. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
prevsnapshotStringNoOptional in version 2015-07-08 and newer. The prevsnapshot + * parameter is a DateTime value that specifies that the response will contain only pages that were changed between + * target blob and previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a + * snapshot, as long as the snapshot specified by prevsnapshot is the older of the two. Note that incremental + * snapshots are currently supported only for blobs created on or after January 1, 2016.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-previous-snapshot-urlStringNoOptional. This header is only supported in + * service versions 2019-04-19 and after and specifies the URL of a previous snapshot of the target blob. The + * response will only contain pages that were changed between the target blob and its previous snapshot.
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pageRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     clearRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents a page list along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPageRangesDiffWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPageRangesDiffWithResponse(requestOptions); + } + + /** + * The Resize operation increases the size of the page blob to the specified size. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response resizeWithResponse(long blobContentLength, RequestOptions requestOptions) { + return this.serviceClient.resizeWithResponse(blobContentLength, requestOptions); + } + + /** + * The Update Sequence Number operation sets the blob's sequence number. The operation will fail if the specified + * sequence number is less than the current sequence number of the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-blob-sequence-numberLongNoSet for page blobs only. The sequence number is + * a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 + * and 2^63 - 1.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This + * property applies to page blobs only. This property indicates how the service should modify the blob's sequence + * number. Allowed values: "increment", "max", "update". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateSequenceNumberWithResponse(String sequenceNumberAction, RequestOptions requestOptions) { + return this.serviceClient.updateSequenceNumberWithResponse(sequenceNumberAction, requestOptions); + } + + /** + * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot + * is copied such that only the differential changes between the previously copied snapshot are transferred to the + * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as + * usual. This API is supported since REST version 2016-05-31. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response copyIncrementalWithResponse(String copySource, RequestOptions requestOptions) { + return this.serviceClient.copyIncrementalWithResponse(copySource, requestOptions); + } + + /** + * The Create operation creates a new page blob. + * + * @param contentLength The length of the request. + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param metadata The metadata headers. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param tier Optional. Indicates the tier to be set on the page blob. + * @param blobContentType Optional. Sets the blob's content type. If specified, this property is stored with the + * blob and returned with a read request. + * @param blobContentEncoding Optional. Sets the blob's content encoding. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentLanguage Optional. Set the blob's content language. If specified, this property is stored with + * the blob and returned with a read request. + * @param blobContentMd5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the + * hashes for the individual blocks were validated when each was uploaded. + * @param blobCacheControl Optional. Sets the blob's cache control. If specified, this property is stored with the + * blob and returned with a read request. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param blobContentDisposition Optional. Sets the blob's content disposition. If specified, this property is + * stored with the blob and returned with a read request. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobSequenceNumber Optional. The sequence number is a user-controlled property that you can use to track + * requests. The value of the sequence number must be between 0 and 2^63 - 1. The default value is 0. + * @param blobTagsString Optional. Used to set blob tags in various blob operations. + * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. + * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. + * @param legalHold Specified if a legal hold should be set on the blob. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void create(long contentLength, long blobContentLength, Map metadata, Integer timeout, + PremiumPageBlobAccessTier tier, String blobContentType, String blobContentEncoding, String blobContentLanguage, + byte[] blobContentMd5, String blobCacheControl, String leaseId, String blobContentDisposition, + String encryptionKey, String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, + String encryptionScope, String ifTags, Long blobSequenceNumber, String blobTagsString, + OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, + RequestConditions requestConditions) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (metadata != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-meta"), String.valueOf(metadata)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (tier != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-access-tier"), tier.toString()); + } + if (blobContentType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-type"), blobContentType); + } + if (blobContentEncoding != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-encoding"), blobContentEncoding); + } + if (blobContentLanguage != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-language"), blobContentLanguage); + } + if (blobContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-md5"), + String.valueOf(blobContentMd5)); + } + if (blobCacheControl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-cache-control"), blobCacheControl); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (blobContentDisposition != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-content-disposition"), + blobContentDisposition); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobSequenceNumber != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-sequence-number"), + String.valueOf(blobSequenceNumber)); + } + if (blobTagsString != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-tags"), blobTagsString); + } + if (immutabilityPolicyExpiry != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-until-date"), + String.valueOf(new DateTimeRfc1123(immutabilityPolicyExpiry))); + } + if (immutabilityPolicyMode != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-immutability-policy-mode"), + immutabilityPolicyMode.toString()); + } + if (legalHold != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-legal-hold"), String.valueOf(legalHold)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + createWithResponse(contentLength, blobContentLength, requestOptions).getValue(); + } + + /** + * The Create operation creates a new page blob. + * + * @param contentLength The length of the request. + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void create(long contentLength, long blobContentLength) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + createWithResponse(contentLength, blobContentLength, requestOptions).getValue(); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param transactionalContentMD5 Optional. An MD5 hash of the blob content. Note that this hash is not validated, + * as the hashes for the individual blocks were validated when each was uploaded. + * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence + * number less than or equal to the specified. + * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number + * less than the specified. + * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified + * sequence number. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema + * version and properties. + * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the + * blob/file content inside the message body. Will always be smaller than Content-Length. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void uploadPages(long contentLength, BinaryData body, String transactionalContentMD5, + String transactionalContentCrc64, Integer timeout, String range, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, + Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, + String ifTags, String structuredBodyType, Long structuredContentLength, RequestConditions requestConditions) { + // Generated convenience method for uploadPagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (transactionalContentMD5 != null) { + requestOptions.setHeader(HttpHeaderName.CONTENT_MD5, transactionalContentMD5); + } + if (transactionalContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-content-crc64"), transactionalContentCrc64); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifSequenceNumberLessThanOrEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-le"), + String.valueOf(ifSequenceNumberLessThanOrEqualTo)); + } + if (ifSequenceNumberLessThan != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-lt"), + String.valueOf(ifSequenceNumberLessThan)); + } + if (ifSequenceNumberEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-eq"), + String.valueOf(ifSequenceNumberEqualTo)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (structuredBodyType != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-body"), structuredBodyType); + } + if (structuredContentLength != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-structured-content-length"), + String.valueOf(structuredContentLength)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + uploadPagesWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void uploadPages(long contentLength, BinaryData body) { + // Generated convenience method for uploadPagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadPagesWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Clear Pages operation clears a range of pages from a page blob. + * + * @param contentLength The length of the request. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence + * number less than or equal to the specified. + * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number + * less than the specified. + * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified + * sequence number. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void clearPages(long contentLength, Integer timeout, String range, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, + Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, + String ifTags, RequestConditions requestConditions) { + // Generated convenience method for clearPagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifSequenceNumberLessThanOrEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-le"), + String.valueOf(ifSequenceNumberLessThanOrEqualTo)); + } + if (ifSequenceNumberLessThan != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-lt"), + String.valueOf(ifSequenceNumberLessThan)); + } + if (ifSequenceNumberEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-eq"), + String.valueOf(ifSequenceNumberEqualTo)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + clearPagesWithResponse(contentLength, requestOptions).getValue(); + } + + /** + * The Clear Pages operation clears a range of pages from a page blob. + * + * @param contentLength The length of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void clearPages(long contentLength) { + // Generated convenience method for clearPagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + clearPagesWithResponse(contentLength, requestOptions).getValue(); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. + * + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. The length of this range should match the + * ContentLength header and x-ms-range/Range destination range header. + * @param contentLength The length of the request. + * @param range Bytes of source data in the specified range. The length of this range should match the ContentLength + * header and x-ms-range/Range destination range header. + * @param sourceContentMd5 Specify the md5 calculated for the range of bytes that must be read from the copy source. + * @param sourceContentCrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy + * source. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence + * number less than or equal to the specified. + * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number + * less than the specified. + * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified + * sequence number. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since + * the specified date/time. + * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified + * since the specified date/time. + * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. + * @param sourceIfNoneMatch Specify this header value to operate only on a blob if it has been modified since the + * specified date/time. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void uploadPagesFromUrl(String sourceUrl, String sourceRange, long contentLength, String range, + String sourceContentMd5, byte[] sourceContentCrc64, Integer timeout, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String leaseId, + Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, + String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, + String sourceIfMatch, String sourceIfNoneMatch, String copySourceAuthorization, + RequestConditions requestConditions) { + // Generated convenience method for uploadPagesFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (sourceContentMd5 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-md5"), sourceContentMd5); + } + if (sourceContentCrc64 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-content-crc64"), + String.valueOf(sourceContentCrc64)); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifSequenceNumberLessThanOrEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-le"), + String.valueOf(ifSequenceNumberLessThanOrEqualTo)); + } + if (ifSequenceNumberLessThan != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-lt"), + String.valueOf(ifSequenceNumberLessThan)); + } + if (ifSequenceNumberEqualTo != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-sequence-number-eq"), + String.valueOf(ifSequenceNumberEqualTo)); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (sourceIfModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-modified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfModifiedSince))); + } + if (sourceIfUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-unmodified-since"), + String.valueOf(new DateTimeRfc1123(sourceIfUnmodifiedSince))); + } + if (sourceIfMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-match"), sourceIfMatch); + } + if (sourceIfNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-source-if-none-match"), sourceIfNoneMatch); + } + if (copySourceAuthorization != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-copy-source-authorization"), + copySourceAuthorization); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + uploadPagesFromUrlWithResponse(sourceUrl, sourceRange, contentLength, range, requestOptions).getValue(); + } + + /** + * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. + * + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. The length of this range should match the + * ContentLength header and x-ms-range/Range destination range header. + * @param contentLength The length of the request. + * @param range Bytes of source data in the specified range. The length of this range should match the ContentLength + * header and x-ms-range/Range destination range header. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void uploadPagesFromUrl(String sourceUrl, String sourceRange, long contentLength, String range) { + // Generated convenience method for uploadPagesFromUrlWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadPagesFromUrlWithResponse(sourceUrl, sourceRange, contentLength, range, requestOptions).getValue(); + } + + /** + * The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a page list. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PageList getPageRanges(String snapshot, Integer timeout, String range, String leaseId, String ifTags, + String marker, Integer maxresults, RequestConditions requestConditions) { + // Generated convenience method for getPageRangesWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return getPageRangesWithResponse(requestOptions).getValue().toObject(PageList.class); + } + + /** + * The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a page list. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PageList getPageRanges() { + // Generated convenience method for getPageRangesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPageRangesWithResponse(requestOptions).getValue().toObject(PageList.class); + } + + /** + * The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob or snapshot of a page + * blob. + * + * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob + * snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that + * specifies that the response will contain only pages that were changed between target blob and previous snapshot. + * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot + * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only + * for blobs created on or after January 1, 2016. + * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and + * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were + * changed between the target blob and its previous snapshot. + * @param range Return only the bytes of the blob in the specified range. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a page list. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PageList getPageRangesDiff(String snapshot, Integer timeout, String prevsnapshot, String prevSnapshotUrl, + String range, String leaseId, String ifTags, String marker, Integer maxresults, + RequestConditions requestConditions) { + // Generated convenience method for getPageRangesDiffWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (snapshot != null) { + requestOptions.addQueryParam("snapshot", snapshot, false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (prevsnapshot != null) { + requestOptions.addQueryParam("prevsnapshot", prevsnapshot, false); + } + if (prevSnapshotUrl != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-previous-snapshot-url"), prevSnapshotUrl); + } + if (range != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-range"), range); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return getPageRangesDiffWithResponse(requestOptions).getValue().toObject(PageList.class); + } + + /** + * The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob or snapshot of a page + * blob. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a page list. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PageList getPageRangesDiff() { + // Generated convenience method for getPageRangesDiffWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPageRangesDiffWithResponse(requestOptions).getValue().toObject(PageList.class); + } + + /** + * The Resize operation increases the size of the page blob to the specified size. + * + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param encryptionKey Optional. Version 2019-07-07 and later. Specifies the encryption key to use to encrypt the + * data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param encryptionKeySha256 Optional. Version 2019-07-07 and later. Specifies the SHA256 hash of the encryption + * key used to encrypt the data provided in the request. This header is only used for encryption with a + * customer-provided key. If the request is authenticated with a client token, this header should be specified using + * the SHA256 hash of the encryption key. + * @param encryptionAlgorithm Optional. Version 2019-07-07 and later. Specifies the algorithm to use for encryption. + * If not specified, the default is AES256. + * @param encryptionScope Optional. Version 2019-07-07 and later. Specifies the encryption scope to use to encrypt + * the data provided in the request. If not specified, the request will be encrypted with the root account key. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void resize(long blobContentLength, Integer timeout, String leaseId, String encryptionKey, + String encryptionKeySha256, EncryptionAlgorithmType encryptionAlgorithm, String encryptionScope, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for resizeWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (encryptionKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key"), encryptionKey); + } + if (encryptionKeySha256 != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-key-sha256"), encryptionKeySha256); + } + if (encryptionAlgorithm != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-algorithm"), + encryptionAlgorithm.toString()); + } + if (encryptionScope != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-encryption-scope"), encryptionScope); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + resizeWithResponse(blobContentLength, requestOptions).getValue(); + } + + /** + * The Resize operation increases the size of the page blob to the specified size. + * + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void resize(long blobContentLength) { + // Generated convenience method for resizeWithResponse + RequestOptions requestOptions = new RequestOptions(); + resizeWithResponse(blobContentLength, requestOptions).getValue(); + } + + /** + * The Update Sequence Number operation sets the blob's sequence number. The operation will fail if the specified + * sequence number is less than the current sequence number of the blob. + * + * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This + * property applies to page blobs only. This property indicates how the service should modify the blob's sequence + * number. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can + * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void updateSequenceNumber(SequenceNumberActionType sequenceNumberAction, Integer timeout, String leaseId, + String ifTags, Long blobSequenceNumber, RequestConditions requestConditions) { + // Generated convenience method for updateSequenceNumberWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (leaseId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-lease-id"), leaseId); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (blobSequenceNumber != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-blob-sequence-number"), + String.valueOf(blobSequenceNumber)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + updateSequenceNumberWithResponse(sequenceNumberAction.toString(), requestOptions).getValue(); + } + + /** + * The Update Sequence Number operation sets the blob's sequence number. The operation will fail if the specified + * sequence number is less than the current sequence number of the blob. + * + * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This + * property applies to page blobs only. This property indicates how the service should modify the blob's sequence + * number. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void updateSequenceNumber(SequenceNumberActionType sequenceNumberAction) { + // Generated convenience method for updateSequenceNumberWithResponse + RequestOptions requestOptions = new RequestOptions(); + updateSequenceNumberWithResponse(sequenceNumberAction.toString(), requestOptions).getValue(); + } + + /** + * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot + * is copied such that only the differential changes between the previously copied snapshot are transferred to the + * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as + * usual. This API is supported since REST version 2016-05-31. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void copyIncremental(String copySource, Integer timeout, String ifTags, + RequestConditions requestConditions) { + // Generated convenience method for copyIncrementalWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (ifTags != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-if-tags"), ifTags); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + copyIncrementalWithResponse(copySource, requestOptions).getValue(); + } + + /** + * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot + * is copied such that only the differential changes between the previously copied snapshot are transferred to the + * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as + * usual. This API is supported since REST version 2016-05-31. + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void copyIncremental(String copySource) { + // Generated convenience method for copyIncrementalWithResponse + RequestOptions requestOptions = new RequestOptions(); + copyIncrementalWithResponse(copySource, requestOptions).getValue(); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ProgressReceiver.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ProgressReceiver.java deleted file mode 100644 index 0aae6dbb300f..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ProgressReceiver.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.ProgressListener; -import com.azure.storage.blob.models.ParallelTransferOptions; - -import reactor.core.publisher.Flux; - -/** - * A {@code ProgressReceiver} is an object that can be used to report progress on network transfers. When specified on - * transfer operations, the {@code reportProgress} method will be called periodically with the total number of bytes - * transferred. The user may configure this method to report progress in whatever format desired. It is recommended - * that this type be used in conjunction with {@link ProgressReporter#addProgressReporting(Flux, ProgressReceiver)} to - * enable reporting on sequential transfers. Note that any method accepting a {@link ParallelTransferOptions} will use - * the {@code ProgressReceiver} specified there and will handle the logic to coordinate the reporting between parallel - * operations. - * @deprecated Use {@link ProgressListener}. - */ -@Deprecated -public interface ProgressReceiver extends ProgressListener { - - /** - * The callback function invoked as progress is reported. - * - * @param bytesTransferred The total number of bytes transferred during this transaction. - */ - void reportProgress(long bytesTransferred); - - @Override - default void handleProgress(long bytesTransferred) { - reportProgress(bytesTransferred); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ProgressReporter.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ProgressReporter.java deleted file mode 100644 index 7ea4ced7c0eb..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ProgressReporter.java +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.nio.ByteBuffer; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.locks.Lock; - -/** - * {@code ProgressReporter} offers a convenient way to add progress tracking to a given Flux. - * @deprecated Use {@link com.azure.core.util.ProgressReporter} - */ -@Deprecated -public final class ProgressReporter { - - /** - * Creates a new instance of {@link ProgressReporter}. - */ - public ProgressReporter() { - } - - private abstract static class ProgressReporterImpl implements ProgressReceiver { - long blockProgress; - - final ProgressReceiver progressReceiver; - - ProgressReporterImpl(ProgressReceiver progressReceiver) { - this.blockProgress = 0; - this.progressReceiver = progressReceiver; - } - - @Override - public void reportProgress(long bytesTransferred) { - this.blockProgress += bytesTransferred; - } - - void rewindProgress() { - this.blockProgress = 0; - } - - Flux addProgressReporting(Flux data) { - return Mono.just(this).flatMapMany(progressReporter -> { - /* - Each time there is a new subscription, we will rewind the progress. This is desirable specifically - for retries, which resubscribe on each try. The first time this flowable is subscribed to, the - rewind will be a noop as there will have been no progress made. Subsequent rewinds will work as - expected. - */ - progressReporter.rewindProgress(); - - /* - Every time we emit some data, report it to the Tracker, which will pass it on to the end user. - */ - return data.doOnNext(buffer -> progressReporter.reportProgress(buffer.remaining())); - }); - } - } - - /** - * This type is used to keep track of the total amount of data transferred for a single request. This is the type we - * will use when the customer uses the factory to add progress reporting to their Flowable. We need this additional - * type because we can't keep local state directly as lambdas require captured local variables to be effectively - * final. - */ - private static class SequentialProgressReporter extends ProgressReporterImpl { - SequentialProgressReporter(ProgressReceiver progressReceiver) { - super(progressReceiver); - } - - @Override - public void reportProgress(long bytesTransferred) { - super.reportProgress(bytesTransferred); - this.progressReceiver.reportProgress(this.blockProgress); - } - } - - /** - * This type is used to keep track of the total amount of data transferred as a part of a parallel upload in order - * to coordinate progress reporting to the end user. We need this additional type because we can't keep local state - * directly as lambdas require captured local variables to be effectively final. - */ - private static class ParallelProgressReporter extends ProgressReporterImpl { - /* - This lock will be instantiated by the operation initiating the whole transfer to coordinate each - ProgressReporterImpl. - */ - private final Lock transferLock; - - /* - We need an AtomicLong to be able to update the value referenced. Because we are already synchronizing with the - lock, we don't incur any additional performance hit here by the synchronization. - */ - private final AtomicLong totalProgress; - - ParallelProgressReporter(ProgressReceiver progressReceiver, Lock lock, AtomicLong totalProgress) { - super(progressReceiver); - this.transferLock = lock; - this.totalProgress = totalProgress; - } - - @Override - public void reportProgress(long bytesTransferred) { - super.reportProgress(bytesTransferred); - - /* - It is typically a bad idea to lock around customer code (which the progressReceiver is) because they could - never release the lock. However, we have decided that it is sufficiently difficult for them to make their - progressReporting code threadsafe that we will take that burden and the ensuing risks. Although it is the - case that only one thread is allowed to be in onNext at once, however there are multiple independent - requests happening at once to stage/download separate chunks, so we still need to lock either way. - */ - transferLock.lock(); - this.progressReceiver.reportProgress(this.totalProgress.addAndGet(bytesTransferred)); - transferLock.unlock(); - } - - /* - This is used in the case of retries to rewind the amount of progress reported so as not to over-report at the - end. - */ - @Override - public void rewindProgress() { - /* - Blocks do not interfere with each other's block progress and there is no way that, for a single block, one - thread will be trying to add to the progress while the other is trying to zero it. The updates are strictly - sequential. Avoiding using the lock is ideal. - */ - this.totalProgress.addAndGet(-1 * this.blockProgress); - super.rewindProgress(); - } - - } - - /** - * Adds progress reporting functionality to the given {@code Flux}. Each subscription (and therefore each retry) - * will rewind the progress reported so as not to over-report. The data reported will be the total amount of data - * emitted so far, or the "current position" of the Flux. - * - * @param data The data whose transfer progress is to be tracked. - * @param progressReceiver {@link ProgressReceiver} - * @return A {@code Flux} that emits the same data as the source but calls a callback to report the total amount of - * data emitted so far. - * @deprecated Use {@link com.azure.core.util.ProgressReporter} instead. - */ - @Deprecated - public static Flux addProgressReporting(Flux data, ProgressReceiver progressReceiver) { - if (progressReceiver == null) { - return data; - } else { - ProgressReporterImpl tracker = new SequentialProgressReporter(progressReceiver); - return tracker.addProgressReporting(data); - } - } - - /** - * Adds parallel progress reporting functionality to the given {@code Flux}. Each subscription (and therefore each - * retry) will rewind the progress reported so as not to over-report. The data reported will be the total amount - * of data emitted so far, or the "current position" of the Flux in parallel. - * - * @param data The data whose transfer progress is to be tracked. - * @param progressReceiver {@link ProgressReceiver} - * @param lock This lock will be instantiated by the operation initiating the whole transfer to coordinate each - * ProgressReporterImpl. - * @param totalProgress We need an AtomicLong to be able to update the value referenced. Because we are already - * synchronizing with the lock, we don't incur any additional performance hit here by the synchronization. - * @return A {@code Flux} that emits the same data as the source but calls a callback to report the total amount of - * data emitted so far. - * @deprecated Use {@link com.azure.core.util.ProgressReporter} instead. - */ - @Deprecated - public static Flux addParallelProgressReporting(Flux data, - ProgressReceiver progressReceiver, Lock lock, AtomicLong totalProgress) { - if (progressReceiver == null) { - return data; - } else { - ParallelProgressReporter tracker = new ParallelProgressReporter(progressReceiver, lock, totalProgress); - return tracker.addProgressReporting(data); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientAsyncClient.java new file mode 100644 index 000000000000..19b75d91167a --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientAsyncClient.java @@ -0,0 +1,920 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.azure.storage.blob.implementation.ServiceClientClientImpl; +import com.azure.storage.blob.implementation.models.GetUserDelegationKeyRequest; +import com.azure.storage.blob.implementation.models.SetPropertiesRequest; +import com.azure.storage.blob.models.FilterBlobSegment; +import com.azure.storage.blob.models.FilterBlobsIncludeItem; +import com.azure.storage.blob.models.ListContainersIncludeType; +import com.azure.storage.blob.models.ListContainersSegmentResponse; +import com.azure.storage.blob.models.SetPropertiesOptions; +import com.azure.storage.blob.models.StorageServiceProperties; +import com.azure.storage.blob.models.StorageServiceStats; +import com.azure.storage.blob.models.UserDelegationKey; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class ServiceClientAsyncClient { + @Generated + private final ServiceClientClientImpl serviceClient; + + /** + * Initializes an instance of ServiceClientAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ServiceClientAsyncClient(ServiceClientClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and + * CORS (Cross-Origin Resource Sharing) rules. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     logging (Optional): {
+     *         version: String (Required)
+     *         delete: boolean (Required)
+     *         read: boolean (Required)
+     *         write: boolean (Required)
+     *         retentionPolicy (Required): {
+     *             enabled: boolean (Required)
+     *             days: Integer (Optional)
+     *             allowPermanentDelete: Boolean (Optional)
+     *         }
+     *     }
+     *     hourMetrics (Optional): {
+     *         version: String (Optional)
+     *         enabled: boolean (Required)
+     *         includeApis: Boolean (Optional)
+     *         retentionPolicy (Optional): (recursive schema, see retentionPolicy above)
+     *     }
+     *     minuteMetrics (Optional): (recursive schema, see minuteMetrics above)
+     *     cors (Optional): [
+     *          (Optional){
+     *             allowedOrigins: String (Required)
+     *             allowedMethods: String (Required)
+     *             allowedHeaders: String (Required)
+     *             exposedHeaders: String (Required)
+     *             maxAgeInSeconds: int (Required)
+     *         }
+     *     ]
+     *     defaultServiceVersion: String (Optional)
+     *     deleteRetentionPolicy (Optional): (recursive schema, see deleteRetentionPolicy above)
+     *     staticWebsite (Optional): {
+     *         enabled: boolean (Required)
+     *         indexDocument: String (Optional)
+     *         errorDocument404Path: String (Optional)
+     *         defaultIndexDocumentPath: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param setPropertiesRequest The setPropertiesRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setPropertiesWithResponse(BinaryData setPropertiesRequest, + RequestOptions requestOptions) { + return this.serviceClient.setPropertiesWithResponseAsync(setPropertiesRequest, requestOptions); + } + + /** + * Retrieves properties of a storage account's Blob service, including properties for Storage Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     logging (Optional): {
+     *         version: String (Required)
+     *         delete: boolean (Required)
+     *         read: boolean (Required)
+     *         write: boolean (Required)
+     *         retentionPolicy (Required): {
+     *             enabled: boolean (Required)
+     *             days: Integer (Optional)
+     *             allowPermanentDelete: Boolean (Optional)
+     *         }
+     *     }
+     *     hourMetrics (Optional): {
+     *         version: String (Optional)
+     *         enabled: boolean (Required)
+     *         includeApis: Boolean (Optional)
+     *         retentionPolicy (Optional): (recursive schema, see retentionPolicy above)
+     *     }
+     *     minuteMetrics (Optional): (recursive schema, see minuteMetrics above)
+     *     cors (Optional): [
+     *          (Optional){
+     *             allowedOrigins: String (Required)
+     *             allowedMethods: String (Required)
+     *             allowedHeaders: String (Required)
+     *             exposedHeaders: String (Required)
+     *             maxAgeInSeconds: int (Required)
+     *         }
+     *     ]
+     *     defaultServiceVersion: String (Optional)
+     *     deleteRetentionPolicy (Optional): (recursive schema, see deleteRetentionPolicy above)
+     *     staticWebsite (Optional): {
+     *         enabled: boolean (Required)
+     *         indexDocument: String (Optional)
+     *         errorDocument404Path: String (Optional)
+     *         defaultIndexDocumentPath: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the service properties along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPropertiesWithResponseAsync(requestOptions); + } + + /** + * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the storage account. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     geoReplication (Optional): {
+     *         status: String(live/bootstrap/unavailable) (Required)
+     *         lastSyncTime: DateTimeRfc1123 (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return stats for the storage service along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStatisticsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStatisticsWithResponseAsync(requestOptions); + } + + /** + * The List Containers Segment operation returns a list of the containers under the specified account. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
includeList<String>NoInclude this parameter to specify that the + * container's metadata be returned as part of the response body. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     containerItems (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             delete: Boolean (Optional)
+     *             version: String (Optional)
+     *             properties (Required): {
+     *                 lastModified: DateTimeRfc1123 (Required)
+     *                 eTag: String (Required)
+     *                 leaseStatus: String(unlocked/locked) (Optional)
+     *                 leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                 leaseDuration: String(infinite/fixed) (Optional)
+     *                 publicAccess: String(blob/container) (Optional)
+     *                 hasImmutabilityPolicy: Boolean (Optional)
+     *                 hasLegalHold: Boolean (Optional)
+     *                 defaultEncryptionScope: String (Optional)
+     *                 denyEncryptionScopeOverride: Boolean (Optional)
+     *                 deletedTime: DateTimeRfc1123 (Optional)
+     *                 remainingRetentionDays: Integer (Optional)
+     *                 immutableStorageWithVersioningEnabled: Boolean (Optional)
+     *             }
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     NextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the list container segment response along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listContainersSegmentWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listContainersSegmentWithResponseAsync(requestOptions); + } + + /** + * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token + * authentication. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     start: String (Required)
+     *     expiry: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     signedOid: String (Required)
+     *     signedTid: String (Required)
+     *     signedStart: String (Required)
+     *     signedExpiry: String (Required)
+     *     signedService: String (Required)
+     *     signedVersion: String (Required)
+     *     value: String (Required)
+     * }
+     * }
+     * 
+ * + * @param getUserDelegationKeyRequest The getUserDelegationKeyRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a user delegation key along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getUserDelegationKeyWithResponse(BinaryData getUserDelegationKeyRequest, + RequestOptions requestOptions) { + return this.serviceClient.getUserDelegationKeyWithResponseAsync(getUserDelegationKeyRequest, requestOptions); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccountInfoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAccountInfoWithResponseAsync(requestOptions); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> submitBatchWithResponse(long contentLength, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.submitBatchWithResponseAsync(contentLength, body, requestOptions); + } + + /** + * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search + * expression. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
whereStringNoFilters the results to return only to return only blobs whose + * tags match the specified expression.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     where: String (Required)
+     *     blobs (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             containerName: String (Required)
+     *             tags (Optional): {
+     *                 blobTagSet (Required): [
+     *                      (Required){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *             versionId: String (Optional)
+     *             isCurrentVersion: Boolean (Optional)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the result of a Filter Blobs API call along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> filterBlobsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.filterBlobsWithResponseAsync(requestOptions); + } + + /** + * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and + * CORS (Cross-Origin Resource Sharing) rules. + * + * @param options Options for setProperties API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setProperties(SetPropertiesOptions options) { + // Generated convenience method for setPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + Integer timeout = options.getTimeout(); + SetPropertiesRequest setPropertiesRequestObj = new SetPropertiesRequest().setLogging(options.getLogging()) + .setHourMetrics(options.getHourMetrics()) + .setMinuteMetrics(options.getMinuteMetrics()) + .setCors(options.getCors()) + .setDefaultServiceVersion(options.getDefaultServiceVersion()) + .setDeleteRetentionPolicy(options.getDeleteRetentionPolicy()) + .setStaticWebsite(options.getStaticWebsite()); + BinaryData setPropertiesRequest = BinaryData.fromObject(setPropertiesRequestObj); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return setPropertiesWithResponse(setPropertiesRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Retrieves properties of a storage account's Blob service, including properties for Storage Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the service properties on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getProperties(Integer timeout) { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return getPropertiesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StorageServiceProperties.class)); + } + + /** + * Retrieves properties of a storage account's Blob service, including properties for Storage Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the service properties on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getProperties() { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPropertiesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StorageServiceProperties.class)); + } + + /** + * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the storage account. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return stats for the storage service on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getStatistics(Integer timeout) { + // Generated convenience method for getStatisticsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return getStatisticsWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StorageServiceStats.class)); + } + + /** + * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the storage account. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return stats for the storage service on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getStatistics() { + // Generated convenience method for getStatisticsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStatisticsWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StorageServiceStats.class)); + } + + /** + * The List Containers Segment operation returns a list of the containers under the specified account. + * + * @param prefix Filters the results to return only containers whose name begins with the specified prefix. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param include Include this parameter to specify that the container's metadata be returned as part of the + * response body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list container segment response on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listContainersSegment(String prefix, String marker, Integer maxresults, + Integer timeout, List include) { + // Generated convenience method for listContainersSegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (prefix != null) { + requestOptions.addQueryParam("prefix", prefix, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return listContainersSegmentWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ListContainersSegmentResponse.class)); + } + + /** + * The List Containers Segment operation returns a list of the containers under the specified account. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list container segment response on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listContainersSegment() { + // Generated convenience method for listContainersSegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listContainersSegmentWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ListContainersSegmentResponse.class)); + } + + /** + * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token + * authentication. + * + * @param start The date-time the key is active. + * @param expiry The date-time the key expires. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a user delegation key on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getUserDelegationKey(String start, String expiry, Integer timeout) { + // Generated convenience method for getUserDelegationKeyWithResponse + RequestOptions requestOptions = new RequestOptions(); + GetUserDelegationKeyRequest getUserDelegationKeyRequestObj = new GetUserDelegationKeyRequest(start, expiry); + BinaryData getUserDelegationKeyRequest = BinaryData.fromObject(getUserDelegationKeyRequestObj); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return getUserDelegationKeyWithResponse(getUserDelegationKeyRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UserDelegationKey.class)); + } + + /** + * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token + * authentication. + * + * @param start The date-time the key is active. + * @param expiry The date-time the key expires. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a user delegation key on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getUserDelegationKey(String start, String expiry) { + // Generated convenience method for getUserDelegationKeyWithResponse + RequestOptions requestOptions = new RequestOptions(); + GetUserDelegationKeyRequest getUserDelegationKeyRequestObj = new GetUserDelegationKeyRequest(start, expiry); + BinaryData getUserDelegationKeyRequest = BinaryData.fromObject(getUserDelegationKeyRequestObj); + return getUserDelegationKeyWithResponse(getUserDelegationKeyRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UserDelegationKey.class)); + } + + /** + * Returns the sku name and account kind. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAccountInfo(Integer timeout) { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return getAccountInfoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Returns the sku name and account kind. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAccountInfo() { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAccountInfoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono submitBatch(long contentLength, BinaryData body, Integer timeout) { + // Generated convenience method for submitBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return submitBatchWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono submitBatch(long contentLength, BinaryData body) { + // Generated convenience method for submitBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return submitBatchWithResponse(contentLength, body, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search + * expression. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param where Filters the results to return only to return only blobs whose tags match the specified expression. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param include Include this parameter to specify one or more datasets to include in the response. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of a Filter Blobs API call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono filterBlobs(Integer timeout, String where, String marker, Integer maxresults, + List include) { + // Generated convenience method for filterBlobsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (where != null) { + requestOptions.addQueryParam("where", where, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return filterBlobsWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FilterBlobSegment.class)); + } + + /** + * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search + * expression. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of a Filter Blobs API call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono filterBlobs() { + // Generated convenience method for filterBlobsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return filterBlobsWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FilterBlobSegment.class)); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientClient.java new file mode 100644 index 000000000000..67dceabe7458 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientClient.java @@ -0,0 +1,907 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.storage.blob.implementation.ServiceClientClientImpl; +import com.azure.storage.blob.implementation.models.GetUserDelegationKeyRequest; +import com.azure.storage.blob.implementation.models.SetPropertiesRequest; +import com.azure.storage.blob.models.FilterBlobSegment; +import com.azure.storage.blob.models.FilterBlobsIncludeItem; +import com.azure.storage.blob.models.ListContainersIncludeType; +import com.azure.storage.blob.models.ListContainersSegmentResponse; +import com.azure.storage.blob.models.SetPropertiesOptions; +import com.azure.storage.blob.models.StorageServiceProperties; +import com.azure.storage.blob.models.StorageServiceStats; +import com.azure.storage.blob.models.UserDelegationKey; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class ServiceClientClient { + @Generated + private final ServiceClientClientImpl serviceClient; + + /** + * Initializes an instance of ServiceClientClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ServiceClientClient(ServiceClientClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and + * CORS (Cross-Origin Resource Sharing) rules. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     logging (Optional): {
+     *         version: String (Required)
+     *         delete: boolean (Required)
+     *         read: boolean (Required)
+     *         write: boolean (Required)
+     *         retentionPolicy (Required): {
+     *             enabled: boolean (Required)
+     *             days: Integer (Optional)
+     *             allowPermanentDelete: Boolean (Optional)
+     *         }
+     *     }
+     *     hourMetrics (Optional): {
+     *         version: String (Optional)
+     *         enabled: boolean (Required)
+     *         includeApis: Boolean (Optional)
+     *         retentionPolicy (Optional): (recursive schema, see retentionPolicy above)
+     *     }
+     *     minuteMetrics (Optional): (recursive schema, see minuteMetrics above)
+     *     cors (Optional): [
+     *          (Optional){
+     *             allowedOrigins: String (Required)
+     *             allowedMethods: String (Required)
+     *             allowedHeaders: String (Required)
+     *             exposedHeaders: String (Required)
+     *             maxAgeInSeconds: int (Required)
+     *         }
+     *     ]
+     *     defaultServiceVersion: String (Optional)
+     *     deleteRetentionPolicy (Optional): (recursive schema, see deleteRetentionPolicy above)
+     *     staticWebsite (Optional): {
+     *         enabled: boolean (Required)
+     *         indexDocument: String (Optional)
+     *         errorDocument404Path: String (Optional)
+     *         defaultIndexDocumentPath: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param setPropertiesRequest The setPropertiesRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setPropertiesWithResponse(BinaryData setPropertiesRequest, RequestOptions requestOptions) { + return this.serviceClient.setPropertiesWithResponse(setPropertiesRequest, requestOptions); + } + + /** + * Retrieves properties of a storage account's Blob service, including properties for Storage Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     logging (Optional): {
+     *         version: String (Required)
+     *         delete: boolean (Required)
+     *         read: boolean (Required)
+     *         write: boolean (Required)
+     *         retentionPolicy (Required): {
+     *             enabled: boolean (Required)
+     *             days: Integer (Optional)
+     *             allowPermanentDelete: Boolean (Optional)
+     *         }
+     *     }
+     *     hourMetrics (Optional): {
+     *         version: String (Optional)
+     *         enabled: boolean (Required)
+     *         includeApis: Boolean (Optional)
+     *         retentionPolicy (Optional): (recursive schema, see retentionPolicy above)
+     *     }
+     *     minuteMetrics (Optional): (recursive schema, see minuteMetrics above)
+     *     cors (Optional): [
+     *          (Optional){
+     *             allowedOrigins: String (Required)
+     *             allowedMethods: String (Required)
+     *             allowedHeaders: String (Required)
+     *             exposedHeaders: String (Required)
+     *             maxAgeInSeconds: int (Required)
+     *         }
+     *     ]
+     *     defaultServiceVersion: String (Optional)
+     *     deleteRetentionPolicy (Optional): (recursive schema, see deleteRetentionPolicy above)
+     *     staticWebsite (Optional): {
+     *         enabled: boolean (Required)
+     *         indexDocument: String (Optional)
+     *         errorDocument404Path: String (Optional)
+     *         defaultIndexDocumentPath: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the service properties along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPropertiesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPropertiesWithResponse(requestOptions); + } + + /** + * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the storage account. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     geoReplication (Optional): {
+     *         status: String(live/bootstrap/unavailable) (Required)
+     *         lastSyncTime: DateTimeRfc1123 (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return stats for the storage service along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStatisticsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStatisticsWithResponse(requestOptions); + } + + /** + * The List Containers Segment operation returns a list of the containers under the specified account. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
includeList<String>NoInclude this parameter to specify that the + * container's metadata be returned as part of the response body. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     containerItems (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             delete: Boolean (Optional)
+     *             version: String (Optional)
+     *             properties (Required): {
+     *                 lastModified: DateTimeRfc1123 (Required)
+     *                 eTag: String (Required)
+     *                 leaseStatus: String(unlocked/locked) (Optional)
+     *                 leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                 leaseDuration: String(infinite/fixed) (Optional)
+     *                 publicAccess: String(blob/container) (Optional)
+     *                 hasImmutabilityPolicy: Boolean (Optional)
+     *                 hasLegalHold: Boolean (Optional)
+     *                 defaultEncryptionScope: String (Optional)
+     *                 denyEncryptionScopeOverride: Boolean (Optional)
+     *                 deletedTime: DateTimeRfc1123 (Optional)
+     *                 remainingRetentionDays: Integer (Optional)
+     *                 immutableStorageWithVersioningEnabled: Boolean (Optional)
+     *             }
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     NextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the list container segment response along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listContainersSegmentWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listContainersSegmentWithResponse(requestOptions); + } + + /** + * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token + * authentication. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     start: String (Required)
+     *     expiry: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     signedOid: String (Required)
+     *     signedTid: String (Required)
+     *     signedStart: String (Required)
+     *     signedExpiry: String (Required)
+     *     signedService: String (Required)
+     *     signedVersion: String (Required)
+     *     value: String (Required)
+     * }
+     * }
+     * 
+ * + * @param getUserDelegationKeyRequest The getUserDelegationKeyRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a user delegation key along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getUserDelegationKeyWithResponse(BinaryData getUserDelegationKeyRequest, + RequestOptions requestOptions) { + return this.serviceClient.getUserDelegationKeyWithResponse(getUserDelegationKeyRequest, requestOptions); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAccountInfoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAccountInfoWithResponse(requestOptions); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response submitBatchWithResponse(long contentLength, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.submitBatchWithResponse(contentLength, body, requestOptions); + } + + /** + * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search + * expression. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
whereStringNoFilters the results to return only to return only blobs whose + * tags match the specified expression.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     where: String (Required)
+     *     blobs (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             containerName: String (Required)
+     *             tags (Optional): {
+     *                 blobTagSet (Required): [
+     *                      (Required){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *             versionId: String (Optional)
+     *             isCurrentVersion: Boolean (Optional)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the result of a Filter Blobs API call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response filterBlobsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.filterBlobsWithResponse(requestOptions); + } + + /** + * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and + * CORS (Cross-Origin Resource Sharing) rules. + * + * @param options Options for setProperties API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void setProperties(SetPropertiesOptions options) { + // Generated convenience method for setPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + Integer timeout = options.getTimeout(); + SetPropertiesRequest setPropertiesRequestObj = new SetPropertiesRequest().setLogging(options.getLogging()) + .setHourMetrics(options.getHourMetrics()) + .setMinuteMetrics(options.getMinuteMetrics()) + .setCors(options.getCors()) + .setDefaultServiceVersion(options.getDefaultServiceVersion()) + .setDeleteRetentionPolicy(options.getDeleteRetentionPolicy()) + .setStaticWebsite(options.getStaticWebsite()); + BinaryData setPropertiesRequest = BinaryData.fromObject(setPropertiesRequestObj); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + setPropertiesWithResponse(setPropertiesRequest, requestOptions).getValue(); + } + + /** + * Retrieves properties of a storage account's Blob service, including properties for Storage Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the service properties. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StorageServiceProperties getProperties(Integer timeout) { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return getPropertiesWithResponse(requestOptions).getValue().toObject(StorageServiceProperties.class); + } + + /** + * Retrieves properties of a storage account's Blob service, including properties for Storage Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the service properties. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StorageServiceProperties getProperties() { + // Generated convenience method for getPropertiesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPropertiesWithResponse(requestOptions).getValue().toObject(StorageServiceProperties.class); + } + + /** + * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the storage account. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return stats for the storage service. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StorageServiceStats getStatistics(Integer timeout) { + // Generated convenience method for getStatisticsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return getStatisticsWithResponse(requestOptions).getValue().toObject(StorageServiceStats.class); + } + + /** + * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the storage account. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return stats for the storage service. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StorageServiceStats getStatistics() { + // Generated convenience method for getStatisticsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStatisticsWithResponse(requestOptions).getValue().toObject(StorageServiceStats.class); + } + + /** + * The List Containers Segment operation returns a list of the containers under the specified account. + * + * @param prefix Filters the results to return only containers whose name begins with the specified prefix. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param include Include this parameter to specify that the container's metadata be returned as part of the + * response body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list container segment response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ListContainersSegmentResponse listContainersSegment(String prefix, String marker, Integer maxresults, + Integer timeout, List include) { + // Generated convenience method for listContainersSegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (prefix != null) { + requestOptions.addQueryParam("prefix", prefix, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return listContainersSegmentWithResponse(requestOptions).getValue() + .toObject(ListContainersSegmentResponse.class); + } + + /** + * The List Containers Segment operation returns a list of the containers under the specified account. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list container segment response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ListContainersSegmentResponse listContainersSegment() { + // Generated convenience method for listContainersSegmentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listContainersSegmentWithResponse(requestOptions).getValue() + .toObject(ListContainersSegmentResponse.class); + } + + /** + * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token + * authentication. + * + * @param start The date-time the key is active. + * @param expiry The date-time the key expires. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a user delegation key. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UserDelegationKey getUserDelegationKey(String start, String expiry, Integer timeout) { + // Generated convenience method for getUserDelegationKeyWithResponse + RequestOptions requestOptions = new RequestOptions(); + GetUserDelegationKeyRequest getUserDelegationKeyRequestObj = new GetUserDelegationKeyRequest(start, expiry); + BinaryData getUserDelegationKeyRequest = BinaryData.fromObject(getUserDelegationKeyRequestObj); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return getUserDelegationKeyWithResponse(getUserDelegationKeyRequest, requestOptions).getValue() + .toObject(UserDelegationKey.class); + } + + /** + * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token + * authentication. + * + * @param start The date-time the key is active. + * @param expiry The date-time the key expires. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a user delegation key. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UserDelegationKey getUserDelegationKey(String start, String expiry) { + // Generated convenience method for getUserDelegationKeyWithResponse + RequestOptions requestOptions = new RequestOptions(); + GetUserDelegationKeyRequest getUserDelegationKeyRequestObj = new GetUserDelegationKeyRequest(start, expiry); + BinaryData getUserDelegationKeyRequest = BinaryData.fromObject(getUserDelegationKeyRequestObj); + return getUserDelegationKeyWithResponse(getUserDelegationKeyRequest, requestOptions).getValue() + .toObject(UserDelegationKey.class); + } + + /** + * Returns the sku name and account kind. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getAccountInfo(Integer timeout) { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + getAccountInfoWithResponse(requestOptions).getValue(); + } + + /** + * Returns the sku name and account kind. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getAccountInfo() { + // Generated convenience method for getAccountInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + getAccountInfoWithResponse(requestOptions).getValue(); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData submitBatch(long contentLength, BinaryData body, Integer timeout) { + // Generated convenience method for submitBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + return submitBatchWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + * + * @param contentLength The length of the request. + * @param body The body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData submitBatch(long contentLength, BinaryData body) { + // Generated convenience method for submitBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return submitBatchWithResponse(contentLength, body, requestOptions).getValue(); + } + + /** + * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search + * expression. + * + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * @param where Filters the results to return only to return only blobs whose tags match the specified expression. + * @param marker A string value that identifies the portion of the list of containers to be returned with the next + * listing operation. The operation returns the NextMarker value within the response body if the listing operation + * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as + * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value + * is opaque to the client. + * @param maxresults Specifies the maximum number of containers to return. If the request does not specify + * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. + * @param include Include this parameter to specify one or more datasets to include in the response. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of a Filter Blobs API call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FilterBlobSegment filterBlobs(Integer timeout, String where, String marker, Integer maxresults, + List include) { + // Generated convenience method for filterBlobsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (timeout != null) { + requestOptions.addQueryParam("timeout", String.valueOf(timeout), false); + } + if (where != null) { + requestOptions.addQueryParam("where", where, false); + } + if (marker != null) { + requestOptions.addQueryParam("marker", marker, false); + } + if (maxresults != null) { + requestOptions.addQueryParam("maxresults", String.valueOf(maxresults), false); + } + if (include != null) { + requestOptions.addQueryParam("include", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return filterBlobsWithResponse(requestOptions).getValue().toObject(FilterBlobSegment.class); + } + + /** + * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search + * expression. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of a Filter Blobs API call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FilterBlobSegment filterBlobs() { + // Generated convenience method for filterBlobsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return filterBlobsWithResponse(requestOptions).getValue().toObject(FilterBlobSegment.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientClientBuilder.java new file mode 100644 index 000000000000..4aec98148659 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/ServiceClientClientBuilder.java @@ -0,0 +1,508 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.client.traits.KeyCredentialTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.KeyCredential; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.KeyCredentialPolicy; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.storage.blob.implementation.ServiceClientClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ServiceClientClient type. + */ +@ServiceClientBuilder( + serviceClients = { + ServiceClientClient.class, + ContainerClient.class, + ContainerBlobClient.class, + PageBlobClient.class, + AppendBlobClient.class, + BlockBlobClient.class, + ServiceClientAsyncClient.class, + ContainerAsyncClient.class, + ContainerBlobAsyncClient.class, + PageBlobAsyncClient.class, + AppendBlobAsyncClient.class, + BlockBlobAsyncClient.class }) +public final class ServiceClientClientBuilder + implements HttpTrait, ConfigurationTrait, + TokenCredentialTrait, KeyCredentialTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final String[] DEFAULT_SCOPES = new String[] { "https://storage.azure.com/.default" }; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("azure-storage-blob.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ServiceClientClientBuilder. + */ + @Generated + public ServiceClientClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated + private ClientOptions clientOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated + private RetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Generated + private KeyCredential keyCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The host name of the blob storage account, e.g. accountName.blob.core.windows.net + */ + @Generated + private String url; + + /** + * Sets The host name of the blob storage account, e.g. accountName.blob.core.windows.net. + * + * @param url the url value. + * @return the ServiceClientClientBuilder. + */ + @Generated + public ServiceClientClientBuilder url(String url) { + this.url = url; + return this; + } + + /* + * The name of the container. + */ + @Generated + private String containerName; + + /** + * Sets The name of the container. + * + * @param containerName the containerName value. + * @return the ServiceClientClientBuilder. + */ + @Generated + public ServiceClientClientBuilder containerName(String containerName) { + this.containerName = containerName; + return this; + } + + /* + * The name of the blob. + */ + @Generated + private String blob; + + /** + * Sets The name of the blob. + * + * @param blob the blob value. + * @return the ServiceClientClientBuilder. + */ + @Generated + public ServiceClientClientBuilder blob(String blob) { + this.blob = blob; + return this; + } + + /* + * Service version + */ + @Generated + private BlobServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ServiceClientClientBuilder. + */ + @Generated + public ServiceClientClientBuilder serviceVersion(BlobServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated + private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the ServiceClientClientBuilder. + */ + @Generated + public ServiceClientClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ServiceClientClientImpl with the provided parameters. + * + * @return an instance of ServiceClientClientImpl. + */ + @Generated + private ServiceClientClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + BlobServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : BlobServiceVersion.getLatest(); + ServiceClientClientImpl client + = new ServiceClientClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.url, + this.containerName, this.blob, localServiceVersion); + return client; + } + + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(url, "'url' cannot be null."); + Objects.requireNonNull(containerName, "'containerName' cannot be null."); + Objects.requireNonNull(blob, "'blob' cannot be null."); + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("api-key", keyCredential)); + } + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of ServiceClientAsyncClient class. + * + * @return an instance of ServiceClientAsyncClient. + */ + @Generated + public ServiceClientAsyncClient buildAsyncClient() { + return new ServiceClientAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ContainerAsyncClient class. + * + * @return an instance of ContainerAsyncClient. + */ + @Generated + public ContainerAsyncClient buildContainerAsyncClient() { + return new ContainerAsyncClient(buildInnerClient().getContainers()); + } + + /** + * Builds an instance of ContainerBlobAsyncClient class. + * + * @return an instance of ContainerBlobAsyncClient. + */ + @Generated + public ContainerBlobAsyncClient buildContainerBlobAsyncClient() { + return new ContainerBlobAsyncClient(buildInnerClient().getContainerBlobs()); + } + + /** + * Builds an instance of PageBlobAsyncClient class. + * + * @return an instance of PageBlobAsyncClient. + */ + @Generated + public PageBlobAsyncClient buildPageBlobAsyncClient() { + return new PageBlobAsyncClient(buildInnerClient().getPageBlobs()); + } + + /** + * Builds an instance of AppendBlobAsyncClient class. + * + * @return an instance of AppendBlobAsyncClient. + */ + @Generated + public AppendBlobAsyncClient buildAppendBlobAsyncClient() { + return new AppendBlobAsyncClient(buildInnerClient().getAppendBlobs()); + } + + /** + * Builds an instance of BlockBlobAsyncClient class. + * + * @return an instance of BlockBlobAsyncClient. + */ + @Generated + public BlockBlobAsyncClient buildBlockBlobAsyncClient() { + return new BlockBlobAsyncClient(buildInnerClient().getBlockBlobs()); + } + + /** + * Builds an instance of ServiceClientClient class. + * + * @return an instance of ServiceClientClient. + */ + @Generated + public ServiceClientClient buildClient() { + return new ServiceClientClient(buildInnerClient()); + } + + /** + * Builds an instance of ContainerClient class. + * + * @return an instance of ContainerClient. + */ + @Generated + public ContainerClient buildContainerClient() { + return new ContainerClient(buildInnerClient().getContainers()); + } + + /** + * Builds an instance of ContainerBlobClient class. + * + * @return an instance of ContainerBlobClient. + */ + @Generated + public ContainerBlobClient buildContainerBlobClient() { + return new ContainerBlobClient(buildInnerClient().getContainerBlobs()); + } + + /** + * Builds an instance of PageBlobClient class. + * + * @return an instance of PageBlobClient. + */ + @Generated + public PageBlobClient buildPageBlobClient() { + return new PageBlobClient(buildInnerClient().getPageBlobs()); + } + + /** + * Builds an instance of AppendBlobClient class. + * + * @return an instance of AppendBlobClient. + */ + @Generated + public AppendBlobClient buildAppendBlobClient() { + return new AppendBlobClient(buildInnerClient().getAppendBlobs()); + } + + /** + * Builds an instance of BlockBlobClient class. + * + * @return an instance of BlockBlobClient. + */ + @Generated + public BlockBlobClient buildBlockBlobClient() { + return new BlockBlobClient(buildInnerClient().getBlockBlobs()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ServiceClientClientBuilder.class); +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AppendBlobsImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AppendBlobsImpl.java index a2ffe5353144..f9bffbdec2a8 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AppendBlobsImpl.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AppendBlobsImpl.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.storage.blob.implementation; import com.azure.core.annotation.BodyParam; @@ -10,41 +11,27 @@ import com.azure.core.annotation.HostParam; import com.azure.core.annotation.PathParam; import com.azure.core.annotation.Put; -import com.azure.core.annotation.QueryParam; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceInterface; import com.azure.core.annotation.ServiceMethod; import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.Base64Util; import com.azure.core.util.BinaryData; import com.azure.core.util.Context; -import com.azure.core.util.DateTimeRfc1123; import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.implementation.models.AppendBlobsAppendBlockFromUrlHeaders; -import com.azure.storage.blob.implementation.models.AppendBlobsAppendBlockHeaders; -import com.azure.storage.blob.implementation.models.AppendBlobsCreateHeaders; -import com.azure.storage.blob.implementation.models.AppendBlobsSealHeaders; -import com.azure.storage.blob.implementation.models.BlobStorageExceptionInternal; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.EncryptionAlgorithmType; -import java.nio.ByteBuffer; -import java.time.OffsetDateTime; -import java.util.Map; -import reactor.core.publisher.Flux; +import com.azure.storage.blob.BlobServiceVersion; import reactor.core.publisher.Mono; /** * An instance of this class provides access to all the operations defined in AppendBlobs. */ public final class AppendBlobsImpl { - /** * The proxy service used to perform REST calls. */ @@ -53,3323 +40,747 @@ public final class AppendBlobsImpl { /** * The service client containing this operation class. */ - private final AzureBlobStorageImpl client; + private final ServiceClientClientImpl client; /** * Initializes an instance of AppendBlobsImpl. - * + * * @param client the instance of the service client containing this operation class. */ - AppendBlobsImpl(AzureBlobStorageImpl client) { + AppendBlobsImpl(ServiceClientClientImpl client) { this.service = RestProxy.create(AppendBlobsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } /** - * The interface defining all the services for AzureBlobStorageAppendBlobs to be used by the proxy service to + * Gets Service version. + * + * @return the serviceVersion value. + */ + public BlobServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for ServiceClientClientAppendBlobs to be used by the proxy service to * perform REST calls. */ @Host("{url}") - @ServiceInterface(name = "AzureBlobStorageAppe") + @ServiceInterface(name = "ServiceClientClientA") public interface AppendBlobsService { - - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?AppendBlob") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> create(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> createNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> create(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("x-ms-blob-type") String blobType, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?AppendBlob") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase createSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("x-ms-blob-type") String blobType, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=appendblock") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response createNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> appendBlock(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, @BodyParam("application/octet-stream") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=appendblock") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> appendBlock(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") Flux body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response appendBlockSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, @BodyParam("application/octet-stream") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=appendblock&fromUrl") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> appendBlockNoCustomHeaders(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> appendBlockFromUrl(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") Flux body, @HeaderParam("Accept") String accept, - Context context); + @HeaderParam("x-ms-copy-source") String sourceUrl, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=appendblock&fromUrl") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> appendBlock(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response appendBlockFromUrlSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); + @HeaderParam("x-ms-copy-source") String sourceUrl, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> appendBlockNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase appendBlockSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response appendBlockNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> appendBlockFromUrl(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-copy-source") String sourceUrl, - @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> appendBlockFromUrlNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-copy-source") String sourceUrl, - @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase appendBlockFromUrlSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-copy-source") String sourceUrl, - @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response appendBlockFromUrlNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-copy-source") String sourceUrl, - @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-condition-maxsize") Long maxSize, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=seal") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> seal(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, @HeaderParam("Accept") String accept, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> seal(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=seal") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> sealNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, @HeaderParam("Accept") String accept, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sealSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase sealSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response sealNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-blob-condition-appendpos") Long appendPosition, @HeaderParam("Accept") String accept, - Context context); - } - - /** - * The Create Append Blob operation creates a new append blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync(String containerName, String blob, - long contentLength, Integer timeout, Map metadata, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> createWithResponseAsync(containerName, blob, contentLength, timeout, metadata, - leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobTagsString, - immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Create Append Blob operation creates a new append blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync(String containerName, String blob, - long contentLength, Integer timeout, Map metadata, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String blobType = "AppendBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.create(this.client.getUrl(), containerName, blob, blobType, timeout, contentLength, contentType, - contentEncoding, contentLanguage, contentMd5Converted, cacheControl, metadata, leaseId, contentDisposition, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - blobTagsString, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Create Append Blob operation creates a new append blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createAsync(String containerName, String blob, long contentLength, Integer timeout, - Map metadata, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return createWithResponseAsync(containerName, blob, contentLength, timeout, metadata, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, - immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Create Append Blob operation creates a new append blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createAsync(String containerName, String blob, long contentLength, Integer timeout, - Map metadata, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - return createWithResponseAsync(containerName, blob, contentLength, timeout, metadata, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, - immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Create Append Blob operation creates a new append blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Integer timeout, Map metadata, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> createNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, timeout, - metadata, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, - blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); } /** - * The Create Append Blob operation creates a new append blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * The Create operation creates a new append blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Integer timeout, Map metadata, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { + public Mono> createWithResponseAsync(long contentLength, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; final String blobType = "AppendBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .createNoCustomHeaders(this.client.getUrl(), containerName, blob, blobType, timeout, contentLength, - contentType, contentEncoding, contentLanguage, contentMd5Converted, cacheControl, metadata, leaseId, - contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, blobTagsString, immutabilityPolicyExpiryConverted, - immutabilityPolicyMode, legalHold, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Create Append Blob operation creates a new append blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase createWithResponse(String containerName, String blob, - long contentLength, Integer timeout, Map metadata, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String blobType = "AppendBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.createSync(this.client.getUrl(), containerName, blob, blobType, timeout, contentLength, - contentType, contentEncoding, contentLanguage, contentMd5Converted, cacheControl, metadata, leaseId, - contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, blobTagsString, immutabilityPolicyExpiryConverted, - immutabilityPolicyMode, legalHold, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Create Append Blob operation creates a new append blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void create(String containerName, String blob, long contentLength, Integer timeout, - Map metadata, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - createWithResponse(containerName, blob, contentLength, timeout, metadata, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, - immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, encryptionScopeParam, Context.NONE); - } - - /** - * The Create Append Blob operation creates a new append blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.create(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + contentLength, blobType, accept, requestOptions, context)); + } + + /** + * The Create operation creates a new append blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param contentLength The length of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createNoCustomHeadersWithResponse(String containerName, String blob, long contentLength, - Integer timeout, Map metadata, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String blobType = "AppendBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.createNoCustomHeadersSync(this.client.getUrl(), containerName, blob, blobType, timeout, - contentLength, contentType, contentEncoding, contentLanguage, contentMd5Converted, cacheControl, - metadata, leaseId, contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, - encryptionScope, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, blobTagsString, immutabilityPolicyExpiryConverted, - immutabilityPolicyMode, legalHold, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockWithResponseAsync(String containerName, - String blob, long contentLength, Flux body, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> appendBlockWithResponseAsync(containerName, blob, contentLength, body, timeout, - transactionalContentMD5, transactionalContentCrc64, leaseId, maxSize, appendPosition, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockWithResponseAsync(String containerName, - String blob, long contentLength, Flux body, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .appendBlock(this.client.getUrl(), containerName, blob, comp, timeout, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, leaseId, maxSize, appendPosition, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono appendBlockAsync(String containerName, String blob, long contentLength, Flux body, - Integer timeout, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, String leaseId, Long maxSize, - Long appendPosition, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return appendBlockWithResponseAsync(containerName, blob, contentLength, body, timeout, transactionalContentMD5, - transactionalContentCrc64, leaseId, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono appendBlockAsync(String containerName, String blob, long contentLength, Flux body, - Integer timeout, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, String leaseId, Long maxSize, - Long appendPosition, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - return appendBlockWithResponseAsync(containerName, blob, contentLength, body, timeout, transactionalContentMD5, - transactionalContentCrc64, leaseId, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam, - context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Flux body, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> appendBlockNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, - body, timeout, transactionalContentMD5, transactionalContentCrc64, leaseId, maxSize, appendPosition, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, structuredBodyType, - structuredContentLength, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Flux body, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .appendBlockNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, leaseId, maxSize, appendPosition, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockWithResponseAsync(String containerName, - String blob, long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> appendBlockWithResponseAsync(containerName, blob, contentLength, body, timeout, - transactionalContentMD5, transactionalContentCrc64, leaseId, maxSize, appendPosition, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockWithResponseAsync(String containerName, - String blob, long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .appendBlock(this.client.getUrl(), containerName, blob, comp, timeout, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, leaseId, maxSize, appendPosition, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono appendBlockAsync(String containerName, String blob, long contentLength, BinaryData body, - Integer timeout, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, String leaseId, Long maxSize, - Long appendPosition, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return appendBlockWithResponseAsync(containerName, blob, contentLength, body, timeout, transactionalContentMD5, - transactionalContentCrc64, leaseId, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono appendBlockAsync(String containerName, String blob, long contentLength, BinaryData body, - Integer timeout, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, String leaseId, Long maxSize, - Long appendPosition, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - return appendBlockWithResponseAsync(containerName, blob, contentLength, body, timeout, transactionalContentMD5, - transactionalContentCrc64, leaseId, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam, - context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> appendBlockNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, - body, timeout, transactionalContentMD5, transactionalContentCrc64, leaseId, maxSize, appendPosition, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, structuredBodyType, - structuredContentLength, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response createWithResponse(long contentLength, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String blobType = "AppendBlob"; + final String accept = "application/json"; + return service.createSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), contentLength, blobType, accept, requestOptions, + Context.NONE); } /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * The Append Block operation commits a new block of data to the end of an append blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-condition-maxsizeLongNoOptional conditional header. The max length + * in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit + * or if the blob size is already greater than the value specified in this header, the request will fail with + * MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .appendBlockNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, leaseId, maxSize, appendPosition, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase appendBlockWithResponse(String containerName, String blob, - long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.appendBlockSync(this.client.getUrl(), containerName, blob, comp, timeout, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, leaseId, maxSize, appendPosition, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void appendBlock(String containerName, String blob, long contentLength, BinaryData body, Integer timeout, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, String leaseId, Long maxSize, - Long appendPosition, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - appendBlockWithResponse(containerName, blob, contentLength, body, timeout, transactionalContentMD5, - transactionalContentCrc64, leaseId, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam, - Context.NONE); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block - * operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is - * supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + public Mono> appendBlockWithResponseAsync(long contentLength, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.appendBlock(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + contentLength, accept, body, requestOptions, context)); + } + + /** + * The Append Block operation commits a new block of data to the end of an append blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-condition-maxsizeLongNoOptional conditional header. The max length + * in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit + * or if the blob size is already greater than the value specified in this header, the request will fail with + * MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response appendBlockNoCustomHeadersWithResponse(String containerName, String blob, long contentLength, - BinaryData body, Integer timeout, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - String leaseId, Long maxSize, Long appendPosition, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, - Context context) { - try { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.appendBlockNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - contentLength, transactionalContentMD5Converted, transactionalContentCrc64Converted, leaseId, maxSize, - appendPosition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, structuredBodyType, structuredContentLength, body, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob where the contents - * are read from a source url. The Append Block operation is permitted only if the blob was created with - * x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param contentLength The length of the request. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockFromUrlWithResponseAsync( - String containerName, String blob, String sourceUrl, long contentLength, String sourceRange, - byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, byte[] transactionalContentMD5, - String leaseId, Long maxSize, Long appendPosition, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String requestId, String copySourceAuthorization, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> appendBlockFromUrlWithResponseAsync(containerName, blob, sourceUrl, contentLength, - sourceRange, sourceContentMD5, sourceContentcrc64, timeout, transactionalContentMD5, leaseId, maxSize, - appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSince, - sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob where the contents - * are read from a source url. The Append Block operation is permitted only if the blob was created with - * x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param contentLength The length of the request. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockFromUrlWithResponseAsync( - String containerName, String blob, String sourceUrl, long contentLength, String sourceRange, - byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, byte[] transactionalContentMD5, - String leaseId, Long maxSize, Long appendPosition, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String requestId, String copySourceAuthorization, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service.appendBlockFromUrl(this.client.getUrl(), containerName, blob, comp, sourceUrl, sourceRange, - sourceContentMD5Converted, sourceContentcrc64Converted, timeout, contentLength, - transactionalContentMD5Converted, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - leaseId, maxSize, appendPosition, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, - sourceIfNoneMatch, this.client.getVersion(), requestId, copySourceAuthorization, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob where the contents - * are read from a source url. The Append Block operation is permitted only if the blob was created with - * x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param contentLength The length of the request. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono appendBlockFromUrlAsync(String containerName, String blob, String sourceUrl, long contentLength, - String sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, - byte[] transactionalContentMD5, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return appendBlockFromUrlWithResponseAsync(containerName, blob, sourceUrl, contentLength, sourceRange, - sourceContentMD5, sourceContentcrc64, timeout, transactionalContentMD5, leaseId, maxSize, appendPosition, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSince, - sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, - encryptionScopeParam).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob where the contents - * are read from a source url. The Append Block operation is permitted only if the blob was created with - * x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param contentLength The length of the request. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono appendBlockFromUrlAsync(String containerName, String blob, String sourceUrl, long contentLength, - String sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, - byte[] transactionalContentMD5, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - return appendBlockFromUrlWithResponseAsync(containerName, blob, sourceUrl, contentLength, sourceRange, - sourceContentMD5, sourceContentcrc64, timeout, transactionalContentMD5, leaseId, maxSize, appendPosition, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSince, - sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, - encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob where the contents - * are read from a source url. The Append Block operation is permitted only if the blob was created with - * x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param contentLength The length of the request. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockFromUrlNoCustomHeadersWithResponseAsync(String containerName, String blob, - String sourceUrl, long contentLength, String sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, - Integer timeout, byte[] transactionalContentMD5, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> appendBlockFromUrlNoCustomHeadersWithResponseAsync(containerName, blob, sourceUrl, - contentLength, sourceRange, sourceContentMD5, sourceContentcrc64, timeout, transactionalContentMD5, - leaseId, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, - sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestId, - copySourceAuthorization, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response appendBlockWithResponse(long contentLength, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return service.appendBlockSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), contentLength, accept, body, requestOptions, + Context.NONE); } /** - * The Append Block operation commits a new block of data to the end of an existing append blob where the contents - * are read from a source url. The Append Block operation is permitted only if the blob was created with - * x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. + * The Append Block From URL operation creates a new block to be committed as part of an append blob where the + * contents are read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-rangeStringNoBytes of source data in the specified + * range.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-condition-maxsizeLongNoOptional conditional header. The max length + * in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit + * or if the blob size is already greater than the value specified in this header, the request will fail with + * MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * * @param sourceUrl Specify a URL to the copy source. * @param contentLength The length of the request. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockFromUrlNoCustomHeadersWithResponseAsync(String containerName, String blob, - String sourceUrl, long contentLength, String sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, - Integer timeout, byte[] transactionalContentMD5, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service.appendBlockFromUrlNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, sourceUrl, - sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, timeout, contentLength, - transactionalContentMD5Converted, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - leaseId, maxSize, appendPosition, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, - sourceIfNoneMatch, this.client.getVersion(), requestId, copySourceAuthorization, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob where the contents - * are read from a source url. The Append Block operation is permitted only if the blob was created with - * x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param contentLength The length of the request. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase appendBlockFromUrlWithResponse(String containerName, - String blob, String sourceUrl, long contentLength, String sourceRange, byte[] sourceContentMD5, - byte[] sourceContentcrc64, Integer timeout, byte[] transactionalContentMD5, String leaseId, Long maxSize, - Long appendPosition, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service.appendBlockFromUrlSync(this.client.getUrl(), containerName, blob, comp, sourceUrl, - sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, timeout, contentLength, - transactionalContentMD5Converted, encryptionKey, encryptionKeySha256, encryptionAlgorithm, - encryptionScope, leaseId, maxSize, appendPosition, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, - sourceIfMatch, sourceIfNoneMatch, this.client.getVersion(), requestId, copySourceAuthorization, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob where the contents - * are read from a source url. The Append Block operation is permitted only if the blob was created with - * x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. + public Mono> appendBlockFromUrlWithResponseAsync(String sourceUrl, long contentLength, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.appendBlockFromUrl(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + sourceUrl, contentLength, accept, requestOptions, context)); + } + + /** + * The Append Block From URL operation creates a new block to be committed as part of an append blob where the + * contents are read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-rangeStringNoBytes of source data in the specified + * range.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-condition-maxsizeLongNoOptional conditional header. The max length + * in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit + * or if the blob size is already greater than the value specified in this header, the request will fail with + * MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed).
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * * @param sourceUrl Specify a URL to the copy source. * @param contentLength The length of the request. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void appendBlockFromUrl(String containerName, String blob, String sourceUrl, long contentLength, - String sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, - byte[] transactionalContentMD5, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - appendBlockFromUrlWithResponse(containerName, blob, sourceUrl, contentLength, sourceRange, sourceContentMD5, - sourceContentcrc64, timeout, transactionalContentMD5, leaseId, maxSize, appendPosition, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, - sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, encryptionScopeParam, - Context.NONE); - } - - /** - * The Append Block operation commits a new block of data to the end of an existing append blob where the contents - * are read from a source url. The Append Block operation is permitted only if the blob was created with - * x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param contentLength The length of the request. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param maxSize Optional conditional header. The max length in bytes permitted for the append blob. If the Append - * Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value - * specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - - * Precondition Failed). - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response appendBlockFromUrlNoCustomHeadersWithResponse(String containerName, String blob, - String sourceUrl, long contentLength, String sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, - Integer timeout, byte[] transactionalContentMD5, String leaseId, Long maxSize, Long appendPosition, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "appendblock"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service.appendBlockFromUrlNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, - sourceUrl, sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, timeout, contentLength, - transactionalContentMD5Converted, encryptionKey, encryptionKeySha256, encryptionAlgorithm, - encryptionScope, leaseId, maxSize, appendPosition, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, - sourceIfMatch, sourceIfNoneMatch, this.client.getVersion(), requestId, copySourceAuthorization, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Response appendBlockFromUrlWithResponse(String sourceUrl, long contentLength, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.appendBlockFromUrlSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + sourceUrl, contentLength, accept, requestOptions, Context.NONE); } /** * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 * version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> sealWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, Long appendPosition) { - return FluxUtil - .withContext(context -> sealWithResponseAsync(containerName, blob, timeout, requestId, leaseId, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, appendPosition, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 - * version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> sealWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, Long appendPosition, Context context) { - final String comp = "seal"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .seal(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), requestId, - leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, appendPosition, - accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 - * version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono sealAsync(String containerName, String blob, Integer timeout, String requestId, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - Long appendPosition) { - return sealWithResponseAsync(containerName, blob, timeout, requestId, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, appendPosition) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 - * version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono sealAsync(String containerName, String blob, Integer timeout, String requestId, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - Long appendPosition, Context context) { - return sealWithResponseAsync(containerName, blob, timeout, requestId, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, appendPosition, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 - * version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> sealNoCustomHeadersWithResponseAsync(String containerName, String blob, Integer timeout, - String requestId, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, Long appendPosition) { - return FluxUtil - .withContext(context -> sealNoCustomHeadersWithResponseAsync(containerName, blob, timeout, requestId, - leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, appendPosition, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 - * version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> sealNoCustomHeadersWithResponseAsync(String containerName, String blob, Integer timeout, - String requestId, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, Long appendPosition, Context context) { - final String comp = "seal"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .sealNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), - requestId, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, - appendPosition, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Mono> sealWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.seal(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, context)); } /** * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 * version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase sealWithResponse(String containerName, String blob, - Integer timeout, String requestId, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, Long appendPosition, Context context) { - try { - final String comp = "seal"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.sealSync(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), - requestId, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, - appendPosition, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 - * version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void seal(String containerName, String blob, Integer timeout, String requestId, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - Long appendPosition) { - sealWithResponse(containerName, blob, timeout, requestId, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, appendPosition, Context.NONE); - } - - /** - * The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 - * version or later. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param appendPosition Optional conditional header, used only for the Append Block operation. A number indicating - * the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it - * is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition - * Failed). - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-blob-condition-appendposLongNoOptional conditional header, used only for + * the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the + * append position is equal to this number. If it is not, the request will fail with the + * AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response sealNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - String requestId, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, Long appendPosition, Context context) { - try { - final String comp = "seal"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.sealNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - ifMatch, ifNoneMatch, appendPosition, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Response sealWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.sealSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, Context.NONE); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImpl.java deleted file mode 100644 index 86d148d2e191..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImpl.java +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation; - -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.policy.RetryPolicy; -import com.azure.core.http.policy.UserAgentPolicy; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; - -/** - * Initializes a new instance of the AzureBlobStorage type. - */ -public final class AzureBlobStorageImpl { - /** - * The URL of the service account, container, or blob that is the target of the desired operation. - */ - private final String url; - - /** - * Gets The URL of the service account, container, or blob that is the target of the desired operation. - * - * @return the url value. - */ - public String getUrl() { - return this.url; - } - - /** - * Specifies the version of the operation to use for this request. - */ - private final String version; - - /** - * Gets Specifies the version of the operation to use for this request. - * - * @return the version value. - */ - public String getVersion() { - return this.version; - } - - /** - * The HTTP pipeline to send requests through. - */ - private final HttpPipeline httpPipeline; - - /** - * Gets The HTTP pipeline to send requests through. - * - * @return the httpPipeline value. - */ - public HttpPipeline getHttpPipeline() { - return this.httpPipeline; - } - - /** - * The serializer to serialize an object into a string. - */ - private final SerializerAdapter serializerAdapter; - - /** - * Gets The serializer to serialize an object into a string. - * - * @return the serializerAdapter value. - */ - public SerializerAdapter getSerializerAdapter() { - return this.serializerAdapter; - } - - /** - * The ServicesImpl object to access its operations. - */ - private final ServicesImpl services; - - /** - * Gets the ServicesImpl object to access its operations. - * - * @return the ServicesImpl object. - */ - public ServicesImpl getServices() { - return this.services; - } - - /** - * The ContainersImpl object to access its operations. - */ - private final ContainersImpl containers; - - /** - * Gets the ContainersImpl object to access its operations. - * - * @return the ContainersImpl object. - */ - public ContainersImpl getContainers() { - return this.containers; - } - - /** - * The BlobsImpl object to access its operations. - */ - private final BlobsImpl blobs; - - /** - * Gets the BlobsImpl object to access its operations. - * - * @return the BlobsImpl object. - */ - public BlobsImpl getBlobs() { - return this.blobs; - } - - /** - * The PageBlobsImpl object to access its operations. - */ - private final PageBlobsImpl pageBlobs; - - /** - * Gets the PageBlobsImpl object to access its operations. - * - * @return the PageBlobsImpl object. - */ - public PageBlobsImpl getPageBlobs() { - return this.pageBlobs; - } - - /** - * The AppendBlobsImpl object to access its operations. - */ - private final AppendBlobsImpl appendBlobs; - - /** - * Gets the AppendBlobsImpl object to access its operations. - * - * @return the AppendBlobsImpl object. - */ - public AppendBlobsImpl getAppendBlobs() { - return this.appendBlobs; - } - - /** - * The BlockBlobsImpl object to access its operations. - */ - private final BlockBlobsImpl blockBlobs; - - /** - * Gets the BlockBlobsImpl object to access its operations. - * - * @return the BlockBlobsImpl object. - */ - public BlockBlobsImpl getBlockBlobs() { - return this.blockBlobs; - } - - /** - * Initializes an instance of AzureBlobStorage client. - * - * @param url The URL of the service account, container, or blob that is the target of the desired operation. - * @param version Specifies the version of the operation to use for this request. - */ - public AzureBlobStorageImpl(String url, String version) { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), url, version); - } - - /** - * Initializes an instance of AzureBlobStorage client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param url The URL of the service account, container, or blob that is the target of the desired operation. - * @param version Specifies the version of the operation to use for this request. - */ - public AzureBlobStorageImpl(HttpPipeline httpPipeline, String url, String version) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), url, version); - } - - /** - * Initializes an instance of AzureBlobStorage client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param serializerAdapter The serializer to serialize an object into a string. - * @param url The URL of the service account, container, or blob that is the target of the desired operation. - * @param version Specifies the version of the operation to use for this request. - */ - public AzureBlobStorageImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String url, - String version) { - this.httpPipeline = httpPipeline; - this.serializerAdapter = serializerAdapter; - this.url = url; - this.version = version; - this.services = new ServicesImpl(this); - this.containers = new ContainersImpl(this); - this.blobs = new BlobsImpl(this); - this.pageBlobs = new PageBlobsImpl(this); - this.appendBlobs = new AppendBlobsImpl(this); - this.blockBlobs = new BlockBlobsImpl(this); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImplBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImplBuilder.java deleted file mode 100644 index 542c91e74d77..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImplBuilder.java +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.policy.AddDatePolicy; -import com.azure.core.http.policy.AddHeadersFromContextPolicy; -import com.azure.core.http.policy.AddHeadersPolicy; -import com.azure.core.http.policy.CookiePolicy; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.HttpLoggingPolicy; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.policy.HttpPolicyProviders; -import com.azure.core.http.policy.RequestIdPolicy; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.http.policy.RetryPolicy; -import com.azure.core.http.policy.UserAgentPolicy; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.builder.ClientBuilderUtil; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** A builder for creating a new instance of the AzureBlobStorage type. */ -@ServiceClientBuilder(serviceClients = { AzureBlobStorageImpl.class }) -public final class AzureBlobStorageImplBuilder - implements HttpTrait, ConfigurationTrait { - @Generated - private static final String SDK_NAME = "name"; - - @Generated - private static final String SDK_VERSION = "version"; - - @Generated - private static final Map PROPERTIES = new HashMap<>(); - - @Generated - private final List pipelinePolicies; - - /** Create an instance of the AzureBlobStorageImplBuilder. */ - @Generated - public AzureBlobStorageImplBuilder() { - this.pipelinePolicies = new ArrayList<>(); - } - - /* - * The HTTP pipeline to send requests through. - */ - @Generated - private HttpPipeline pipeline; - - /** {@inheritDoc}. */ - @Generated - @Override - public AzureBlobStorageImplBuilder pipeline(HttpPipeline pipeline) { - this.pipeline = pipeline; - return this; - } - - /* - * The HTTP client used to send the request. - */ - @Generated - private HttpClient httpClient; - - /** {@inheritDoc}. */ - @Generated - @Override - public AzureBlobStorageImplBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /* - * The logging configuration for HTTP requests and responses. - */ - @Generated - private HttpLogOptions httpLogOptions; - - /** {@inheritDoc}. */ - @Generated - @Override - public AzureBlobStorageImplBuilder httpLogOptions(HttpLogOptions httpLogOptions) { - this.httpLogOptions = httpLogOptions; - return this; - } - - /* - * The client options such as application ID and custom headers to set on a request. - */ - @Generated - private ClientOptions clientOptions; - - /** {@inheritDoc}. */ - @Generated - @Override - public AzureBlobStorageImplBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - return this; - } - - /* - * The retry options to configure retry policy for failed requests. - */ - @Generated - private RetryOptions retryOptions; - - /** {@inheritDoc}. */ - @Generated - @Override - public AzureBlobStorageImplBuilder retryOptions(RetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** {@inheritDoc}. */ - @Generated - @Override - public AzureBlobStorageImplBuilder addPolicy(HttpPipelinePolicy customPolicy) { - Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); - pipelinePolicies.add(customPolicy); - return this; - } - - /* - * The configuration store that is used during construction of the service client. - */ - @Generated - private Configuration configuration; - - /** {@inheritDoc}. */ - @Generated - @Override - public AzureBlobStorageImplBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /* - * The URL of the service account, container, or blob that is the target of the desired operation. - */ - @Generated - private String url; - - /** - * Sets The URL of the service account, container, or blob that is the target of the desired operation. - * - * @param url the url value. - * @return the AzureBlobStorageImplBuilder. - */ - @Generated - public AzureBlobStorageImplBuilder url(String url) { - this.url = url; - return this; - } - - /* - * Specifies the version of the operation to use for this request. - */ - @Generated - private String version; - - /** - * Sets Specifies the version of the operation to use for this request. - * - * @param version the version value. - * @return the AzureBlobStorageImplBuilder. - */ - @Generated - public AzureBlobStorageImplBuilder version(String version) { - this.version = version; - return this; - } - - /* - * The serializer to serialize an object into a string - */ - @Generated - private SerializerAdapter serializerAdapter; - - /** - * Sets The serializer to serialize an object into a string. - * - * @param serializerAdapter the serializerAdapter value. - * @return the AzureBlobStorageImplBuilder. - */ - @Generated - public AzureBlobStorageImplBuilder serializerAdapter(SerializerAdapter serializerAdapter) { - this.serializerAdapter = serializerAdapter; - return this; - } - - /* - * The retry policy that will attempt to retry failed requests, if applicable. - */ - @Generated - private RetryPolicy retryPolicy; - - /** - * Sets The retry policy that will attempt to retry failed requests, if applicable. - * - * @param retryPolicy the retryPolicy value. - * @return the AzureBlobStorageImplBuilder. - */ - @Generated - public AzureBlobStorageImplBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - return this; - } - - /** - * Builds an instance of AzureBlobStorageImpl with the provided parameters. - * - * @return an instance of AzureBlobStorageImpl. - */ - @Generated - public AzureBlobStorageImpl buildClient() { - HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - String localVersion = (version != null) ? version : "2024-08-04"; - SerializerAdapter localSerializerAdapter - = (serializerAdapter != null) ? serializerAdapter : JacksonAdapter.createDefaultSerializerAdapter(); - AzureBlobStorageImpl client - = new AzureBlobStorageImpl(localPipeline, localSerializerAdapter, url, localVersion); - return client; - } - - @Generated - private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration - = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; - ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; - List policies = new ArrayList<>(); - String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); - policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); - policies.add(new RequestIdPolicy()); - policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = new HttpHeaders(); - localClientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue())); - if (headers.getSize() > 0) { - policies.add(new AddHeadersPolicy(headers)); - } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); - policies.add(new AddDatePolicy()); - policies.add(new CookiePolicy()); - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(httpLogOptions)); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); - return httpPipeline; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlobsImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlobsImpl.java deleted file mode 100644 index bdfaecfdb765..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlobsImpl.java +++ /dev/null @@ -1,11046 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. -package com.azure.storage.blob.implementation; - -import com.azure.core.annotation.BodyParam; -import com.azure.core.annotation.Delete; -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; -import com.azure.core.annotation.Head; -import com.azure.core.annotation.HeaderParam; -import com.azure.core.annotation.Host; -import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.PathParam; -import com.azure.core.annotation.Post; -import com.azure.core.annotation.Put; -import com.azure.core.annotation.QueryParam; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceInterface; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.annotation.UnexpectedResponseExceptionType; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.http.rest.StreamResponse; -import com.azure.core.util.Base64Util; -import com.azure.core.util.Context; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.implementation.models.BlobDeleteType; -import com.azure.storage.blob.implementation.models.BlobExpiryOptions; -import com.azure.storage.blob.implementation.models.BlobStorageExceptionInternal; -import com.azure.storage.blob.implementation.models.BlobTags; -import com.azure.storage.blob.implementation.models.BlobsAbortCopyFromURLHeaders; -import com.azure.storage.blob.implementation.models.BlobsAcquireLeaseHeaders; -import com.azure.storage.blob.implementation.models.BlobsBreakLeaseHeaders; -import com.azure.storage.blob.implementation.models.BlobsChangeLeaseHeaders; -import com.azure.storage.blob.implementation.models.BlobsCopyFromURLHeaders; -import com.azure.storage.blob.implementation.models.BlobsCreateSnapshotHeaders; -import com.azure.storage.blob.implementation.models.BlobsDeleteHeaders; -import com.azure.storage.blob.implementation.models.BlobsDeleteImmutabilityPolicyHeaders; -import com.azure.storage.blob.implementation.models.BlobsDownloadHeaders; -import com.azure.storage.blob.implementation.models.BlobsGetAccountInfoHeaders; -import com.azure.storage.blob.implementation.models.BlobsGetPropertiesHeaders; -import com.azure.storage.blob.implementation.models.BlobsGetTagsHeaders; -import com.azure.storage.blob.implementation.models.BlobsQueryHeaders; -import com.azure.storage.blob.implementation.models.BlobsReleaseLeaseHeaders; -import com.azure.storage.blob.implementation.models.BlobsRenewLeaseHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetExpiryHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetHttpHeadersHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetImmutabilityPolicyHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetLegalHoldHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetMetadataHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetTagsHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetTierHeaders; -import com.azure.storage.blob.implementation.models.BlobsStartCopyFromURLHeaders; -import com.azure.storage.blob.implementation.models.BlobsUndeleteHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.QueryRequest; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobCopySourceTagsMode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.blob.models.EncryptionAlgorithmType; -import com.azure.storage.blob.models.RehydratePriority; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.time.OffsetDateTime; -import java.util.Map; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -/** - * An instance of this class provides access to all the operations defined in Blobs. - */ -public final class BlobsImpl { - - /** - * The proxy service used to perform REST calls. - */ - private final BlobsService service; - - /** - * The service client containing this operation class. - */ - private final AzureBlobStorageImpl client; - - /** - * Initializes an instance of BlobsImpl. - * - * @param client the instance of the service client containing this operation class. - */ - BlobsImpl(AzureBlobStorageImpl client) { - this.service = RestProxy.create(BlobsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); - this.client = client; - } - - /** - * The interface defining all the services for AzureBlobStorageBlobs to be used by the proxy service to perform REST - * calls. - */ - @Host("{url}") - @ServiceInterface(name = "AzureBlobStorageBlob") - public interface BlobsService { - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200, 206 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono>> download(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-range-get-content-md5") Boolean rangeGetContentMD5, - @HeaderParam("x-ms-range-get-content-crc64") Boolean rangeGetContentCRC64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200, 206 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono downloadNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-range-get-content-md5") Boolean rangeGetContentMD5, - @HeaderParam("x-ms-range-get-content-crc64") Boolean rangeGetContentCRC64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200, 206 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase downloadSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-range-get-content-md5") Boolean rangeGetContentMD5, - @HeaderParam("x-ms-range-get-content-crc64") Boolean rangeGetContentCRC64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200, 206 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response downloadNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-range-get-content-md5") Boolean rangeGetContentMD5, - @HeaderParam("x-ms-range-get-content-crc64") Boolean rangeGetContentCRC64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Head("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getProperties(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Head("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getPropertiesNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Head("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getPropertiesSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Head("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getPropertiesNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Delete("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> delete(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-delete-snapshots") DeleteSnapshotsOptionType deleteSnapshots, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("deletetype") BlobDeleteType blobDeleteType, @HeaderParam("Accept") String accept, - Context context); - - @Delete("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> deleteNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-delete-snapshots") DeleteSnapshotsOptionType deleteSnapshots, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("deletetype") BlobDeleteType blobDeleteType, @HeaderParam("Accept") String accept, - Context context); - - @Delete("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase deleteSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-delete-snapshots") DeleteSnapshotsOptionType deleteSnapshots, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("deletetype") BlobDeleteType blobDeleteType, @HeaderParam("Accept") String accept, - Context context); - - @Delete("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response deleteNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-delete-snapshots") DeleteSnapshotsOptionType deleteSnapshots, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("deletetype") BlobDeleteType blobDeleteType, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> undelete(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> undeleteNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase undeleteSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response undeleteNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setExpiry(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-expiry-option") BlobExpiryOptions expiryOptions, - @HeaderParam("x-ms-expiry-time") String expiresOn, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setExpiryNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-expiry-option") BlobExpiryOptions expiryOptions, - @HeaderParam("x-ms-expiry-time") String expiresOn, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setExpirySync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-expiry-option") BlobExpiryOptions expiryOptions, - @HeaderParam("x-ms-expiry-time") String expiresOn, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setExpiryNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-expiry-option") BlobExpiryOptions expiryOptions, - @HeaderParam("x-ms-expiry-time") String expiresOn, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setHttpHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setHttpHeadersNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setHttpHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setHttpHeadersNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setImmutabilityPolicy(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setImmutabilityPolicyNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setImmutabilityPolicySync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setImmutabilityPolicyNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> deleteImmutabilityPolicy( - @HostParam("url") String url, @PathParam("containerName") String containerName, - @PathParam("blob") String blob, @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> deleteImmutabilityPolicyNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase deleteImmutabilityPolicySync( - @HostParam("url") String url, @PathParam("containerName") String containerName, - @PathParam("blob") String blob, @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response deleteImmutabilityPolicyNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setLegalHold(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-legal-hold") boolean legalHold, @QueryParam("snapshot") String snapshot, - @QueryParam("versionid") String versionId, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setLegalHoldNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-legal-hold") boolean legalHold, @QueryParam("snapshot") String snapshot, - @QueryParam("versionid") String versionId, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setLegalHoldSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-legal-hold") boolean legalHold, @QueryParam("snapshot") String snapshot, - @QueryParam("versionid") String versionId, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setLegalHoldNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-legal-hold") boolean legalHold, @QueryParam("snapshot") String snapshot, - @QueryParam("versionid") String versionId, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setMetadata(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setMetadataNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setMetadataSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setMetadataNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> acquireLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-duration") Integer duration, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> acquireLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-duration") Integer duration, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase acquireLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-duration") Integer duration, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response acquireLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-duration") Integer duration, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> releaseLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> releaseLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase releaseLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response releaseLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> renewLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> renewLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase renewLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response renewLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> changeLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> changeLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase changeLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response changeLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> breakLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-break-period") Integer breakPeriod, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> breakLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-break-period") Integer breakPeriod, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase breakLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-break-period") Integer breakPeriod, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response breakLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-break-period") Integer breakPeriod, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> createSnapshot(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> createSnapshotNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase createSnapshotSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response createSnapshotNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> startCopyFromURL(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-rehydrate-priority") RehydratePriority rehydratePriority, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-source-if-tags") String sourceIfTags, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-seal-blob") Boolean sealBlob, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> startCopyFromURLNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-rehydrate-priority") RehydratePriority rehydratePriority, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-source-if-tags") String sourceIfTags, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-seal-blob") Boolean sealBlob, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase startCopyFromURLSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-rehydrate-priority") RehydratePriority rehydratePriority, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-source-if-tags") String sourceIfTags, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-seal-blob") Boolean sealBlob, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response startCopyFromURLNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-rehydrate-priority") RehydratePriority rehydratePriority, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-source-if-tags") String sourceIfTags, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-seal-blob") Boolean sealBlob, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> copyFromURL(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-requires-sync") String xMsRequiresSync, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-copy-source-tag-option") BlobCopySourceTagsMode copySourceTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> copyFromURLNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-requires-sync") String xMsRequiresSync, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-copy-source-tag-option") BlobCopySourceTagsMode copySourceTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase copyFromURLSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-requires-sync") String xMsRequiresSync, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-copy-source-tag-option") BlobCopySourceTagsMode copySourceTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response copyFromURLNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-requires-sync") String xMsRequiresSync, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-copy-source-tag-option") BlobCopySourceTagsMode copySourceTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> abortCopyFromURL(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-copy-action") String copyActionAbortConstant, - @QueryParam("copyid") String copyId, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> abortCopyFromURLNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-copy-action") String copyActionAbortConstant, - @QueryParam("copyid") String copyId, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase abortCopyFromURLSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-copy-action") String copyActionAbortConstant, - @QueryParam("copyid") String copyId, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response abortCopyFromURLNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-copy-action") String copyActionAbortConstant, - @QueryParam("copyid") String copyId, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200, 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setTier(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("versionid") String versionId, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-rehydrate-priority") RehydratePriority rehydratePriority, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200, 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setTierNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("versionid") String versionId, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-rehydrate-priority") RehydratePriority rehydratePriority, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200, 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setTierSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("versionid") String versionId, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-rehydrate-priority") RehydratePriority rehydratePriority, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200, 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setTierNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("versionid") String versionId, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("x-ms-rehydrate-priority") RehydratePriority rehydratePriority, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getAccountInfo(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getAccountInfoNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getAccountInfoSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getAccountInfoNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Post("/{containerName}/{blob}") - @ExpectedResponses({ 200, 206 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono>> query(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") QueryRequest queryRequest, @HeaderParam("Accept") String accept, - Context context); - - @Post("/{containerName}/{blob}") - @ExpectedResponses({ 200, 206 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono queryNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") QueryRequest queryRequest, @HeaderParam("Accept") String accept, - Context context); - - @Post("/{containerName}/{blob}") - @ExpectedResponses({ 200, 206 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase querySync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") QueryRequest queryRequest, @HeaderParam("Accept") String accept, - Context context); - - @Post("/{containerName}/{blob}") - @ExpectedResponses({ 200, 206 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response queryNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") QueryRequest queryRequest, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getTags(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getTagsNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getTagsSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getTagsNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("snapshot") String snapshot, @QueryParam("versionid") String versionId, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setTags(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-version") String version, - @QueryParam("timeout") Integer timeout, @QueryParam("versionid") String versionId, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-lease-id") String leaseId, @BodyParam("application/xml") BlobTags tags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setTagsNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-version") String version, - @QueryParam("timeout") Integer timeout, @QueryParam("versionid") String versionId, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-lease-id") String leaseId, @BodyParam("application/xml") BlobTags tags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setTagsSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-version") String version, - @QueryParam("timeout") Integer timeout, @QueryParam("versionid") String versionId, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-lease-id") String leaseId, @BodyParam("application/xml") BlobTags tags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setTagsNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-version") String version, - @QueryParam("timeout") Integer timeout, @QueryParam("versionid") String versionId, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-lease-id") String leaseId, @BodyParam("application/xml") BlobTags tags, - @HeaderParam("Accept") String accept, Context context); - } - - /** - * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can - * also call Download to read a snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param rangeGetContentMD5 When set to true and specified together with the Range, the service returns the MD5 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param rangeGetContentCRC64 When set to true and specified together with the Range, the service returns the CRC64 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies - * the message schema version and properties. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> downloadWithResponseAsync(String containerName, - String blob, String snapshot, String versionId, Integer timeout, String range, String leaseId, - Boolean rangeGetContentMD5, Boolean rangeGetContentCRC64, String structuredBodyType, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, CpkInfo cpkInfo) { - return FluxUtil - .withContext(context -> downloadWithResponseAsync(containerName, blob, snapshot, versionId, timeout, range, - leaseId, rangeGetContentMD5, rangeGetContentCRC64, structuredBodyType, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can - * also call Download to read a snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param rangeGetContentMD5 When set to true and specified together with the Range, the service returns the MD5 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param rangeGetContentCRC64 When set to true and specified together with the Range, the service returns the CRC64 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies - * the message schema version and properties. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> downloadWithResponseAsync(String containerName, - String blob, String snapshot, String versionId, Integer timeout, String range, String leaseId, - Boolean rangeGetContentMD5, Boolean rangeGetContentCRC64, String structuredBodyType, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, CpkInfo cpkInfo, Context context) { - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .download(this.client.getUrl(), containerName, blob, snapshot, versionId, timeout, range, leaseId, - rangeGetContentMD5, rangeGetContentCRC64, structuredBodyType, encryptionKey, encryptionKeySha256, - encryptionAlgorithm, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can - * also call Download to read a snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param rangeGetContentMD5 When set to true and specified together with the Range, the service returns the MD5 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param rangeGetContentCRC64 When set to true and specified together with the Range, the service returns the CRC64 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies - * the message schema version and properties. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux downloadAsync(String containerName, String blob, String snapshot, String versionId, - Integer timeout, String range, String leaseId, Boolean rangeGetContentMD5, Boolean rangeGetContentCRC64, - String structuredBodyType, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo) { - return downloadWithResponseAsync(containerName, blob, snapshot, versionId, timeout, range, leaseId, - rangeGetContentMD5, rangeGetContentCRC64, structuredBodyType, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, cpkInfo) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can - * also call Download to read a snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param rangeGetContentMD5 When set to true and specified together with the Range, the service returns the MD5 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param rangeGetContentCRC64 When set to true and specified together with the Range, the service returns the CRC64 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies - * the message schema version and properties. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux downloadAsync(String containerName, String blob, String snapshot, String versionId, - Integer timeout, String range, String leaseId, Boolean rangeGetContentMD5, Boolean rangeGetContentCRC64, - String structuredBodyType, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, Context context) { - return downloadWithResponseAsync(containerName, blob, snapshot, versionId, timeout, range, leaseId, - rangeGetContentMD5, rangeGetContentCRC64, structuredBodyType, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, cpkInfo, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can - * also call Download to read a snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param rangeGetContentMD5 When set to true and specified together with the Range, the service returns the MD5 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param rangeGetContentCRC64 When set to true and specified together with the Range, the service returns the CRC64 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies - * the message schema version and properties. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono downloadNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String range, String leaseId, Boolean rangeGetContentMD5, - Boolean rangeGetContentCRC64, String structuredBodyType, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo) { - return FluxUtil - .withContext(context -> downloadNoCustomHeadersWithResponseAsync(containerName, blob, snapshot, versionId, - timeout, range, leaseId, rangeGetContentMD5, rangeGetContentCRC64, structuredBodyType, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can - * also call Download to read a snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param rangeGetContentMD5 When set to true and specified together with the Range, the service returns the MD5 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param rangeGetContentCRC64 When set to true and specified together with the Range, the service returns the CRC64 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies - * the message schema version and properties. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono downloadNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String range, String leaseId, Boolean rangeGetContentMD5, - Boolean rangeGetContentCRC64, String structuredBodyType, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, Context context) { - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .downloadNoCustomHeaders(this.client.getUrl(), containerName, blob, snapshot, versionId, timeout, range, - leaseId, rangeGetContentMD5, rangeGetContentCRC64, structuredBodyType, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can - * also call Download to read a snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param rangeGetContentMD5 When set to true and specified together with the Range, the service returns the MD5 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param rangeGetContentCRC64 When set to true and specified together with the Range, the service returns the CRC64 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies - * the message schema version and properties. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase downloadWithResponse(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String range, String leaseId, Boolean rangeGetContentMD5, - Boolean rangeGetContentCRC64, String structuredBodyType, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, Context context) { - try { - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.downloadSync(this.client.getUrl(), containerName, blob, snapshot, versionId, timeout, range, - leaseId, rangeGetContentMD5, rangeGetContentCRC64, structuredBodyType, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can - * also call Download to read a snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param rangeGetContentMD5 When set to true and specified together with the Range, the service returns the MD5 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param rangeGetContentCRC64 When set to true and specified together with the Range, the service returns the CRC64 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies - * the message schema version and properties. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public InputStream download(String containerName, String blob, String snapshot, String versionId, Integer timeout, - String range, String leaseId, Boolean rangeGetContentMD5, Boolean rangeGetContentCRC64, - String structuredBodyType, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo) { - try { - return downloadWithResponse(containerName, blob, snapshot, versionId, timeout, range, leaseId, - rangeGetContentMD5, rangeGetContentCRC64, structuredBodyType, ifModifiedSince, ifUnmodifiedSince, - ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can - * also call Download to read a snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param rangeGetContentMD5 When set to true and specified together with the Range, the service returns the MD5 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param rangeGetContentCRC64 When set to true and specified together with the Range, the service returns the CRC64 - * hash for the range, as long as the range is less than or equal to 4 MB in size. - * @param structuredBodyType Specifies the response content should be returned as a structured message and specifies - * the message schema version and properties. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response downloadNoCustomHeadersWithResponse(String containerName, String blob, String snapshot, - String versionId, Integer timeout, String range, String leaseId, Boolean rangeGetContentMD5, - Boolean rangeGetContentCRC64, String structuredBodyType, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, Context context) { - try { - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.downloadNoCustomHeadersSync(this.client.getUrl(), containerName, blob, snapshot, versionId, - timeout, range, leaseId, rangeGetContentMD5, rangeGetContentCRC64, structuredBodyType, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties - * for the blob. It does not return the content of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesWithResponseAsync(String containerName, - String blob, String snapshot, String versionId, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo) { - return FluxUtil - .withContext(context -> getPropertiesWithResponseAsync(containerName, blob, snapshot, versionId, timeout, - leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties - * for the blob. It does not return the content of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesWithResponseAsync(String containerName, - String blob, String snapshot, String versionId, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, Context context) { - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .getProperties(this.client.getUrl(), containerName, blob, snapshot, versionId, timeout, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties - * for the blob. It does not return the content of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesAsync(String containerName, String blob, String snapshot, String versionId, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo) { - return getPropertiesWithResponseAsync(containerName, blob, snapshot, versionId, timeout, leaseId, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties - * for the blob. It does not return the content of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesAsync(String containerName, String blob, String snapshot, String versionId, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, Context context) { - return getPropertiesWithResponseAsync(containerName, blob, snapshot, versionId, timeout, leaseId, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties - * for the blob. It does not return the content of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo) { - return FluxUtil - .withContext(context -> getPropertiesNoCustomHeadersWithResponseAsync(containerName, blob, snapshot, - versionId, timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, - requestId, cpkInfo, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties - * for the blob. It does not return the content of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, Context context) { - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .getPropertiesNoCustomHeaders(this.client.getUrl(), containerName, blob, snapshot, versionId, timeout, - leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties - * for the blob. It does not return the content of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getPropertiesWithResponse(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, Context context) { - try { - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.getPropertiesSync(this.client.getUrl(), containerName, blob, snapshot, versionId, timeout, - leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties - * for the blob. It does not return the content of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void getProperties(String containerName, String blob, String snapshot, String versionId, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo) { - getPropertiesWithResponse(containerName, blob, snapshot, versionId, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, Context.NONE); - } - - /** - * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties - * for the blob. It does not return the content of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesNoCustomHeadersWithResponse(String containerName, String blob, String snapshot, - String versionId, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, Context context) { - try { - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.getPropertiesNoCustomHeadersSync(this.client.getUrl(), containerName, blob, snapshot, - versionId, timeout, leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed - * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, - * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or - * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] - * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently - * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until - * it is permanently removed. Use the List Blobs API and specify the "include=deleted" query parameter to discover - * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a - * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP - * status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when - * a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other - * operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access - * automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob - * API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC - * permissions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: - * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob - * itself. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob - * if blob soft delete is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithResponseAsync(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String leaseId, DeleteSnapshotsOptionType deleteSnapshots, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, BlobDeleteType blobDeleteType) { - return FluxUtil - .withContext(context -> deleteWithResponseAsync(containerName, blob, snapshot, versionId, timeout, leaseId, - deleteSnapshots, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, - blobDeleteType, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed - * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, - * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or - * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] - * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently - * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until - * it is permanently removed. Use the List Blobs API and specify the "include=deleted" query parameter to discover - * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a - * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP - * status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when - * a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other - * operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access - * automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob - * API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC - * permissions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: - * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob - * itself. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob - * if blob soft delete is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithResponseAsync(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String leaseId, DeleteSnapshotsOptionType deleteSnapshots, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, BlobDeleteType blobDeleteType, Context context) { - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .delete(this.client.getUrl(), containerName, blob, snapshot, versionId, timeout, leaseId, deleteSnapshots, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, blobDeleteType, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed - * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, - * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or - * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] - * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently - * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until - * it is permanently removed. Use the List Blobs API and specify the "include=deleted" query parameter to discover - * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a - * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP - * status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when - * a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other - * operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access - * automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob - * API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC - * permissions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: - * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob - * itself. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob - * if blob soft delete is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteAsync(String containerName, String blob, String snapshot, String versionId, Integer timeout, - String leaseId, DeleteSnapshotsOptionType deleteSnapshots, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - BlobDeleteType blobDeleteType) { - return deleteWithResponseAsync(containerName, blob, snapshot, versionId, timeout, leaseId, deleteSnapshots, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobDeleteType) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed - * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, - * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or - * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] - * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently - * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until - * it is permanently removed. Use the List Blobs API and specify the "include=deleted" query parameter to discover - * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a - * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP - * status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when - * a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other - * operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access - * automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob - * API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC - * permissions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: - * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob - * itself. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob - * if blob soft delete is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteAsync(String containerName, String blob, String snapshot, String versionId, Integer timeout, - String leaseId, DeleteSnapshotsOptionType deleteSnapshots, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - BlobDeleteType blobDeleteType, Context context) { - return deleteWithResponseAsync(containerName, blob, snapshot, versionId, timeout, leaseId, deleteSnapshots, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobDeleteType, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed - * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, - * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or - * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] - * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently - * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until - * it is permanently removed. Use the List Blobs API and specify the "include=deleted" query parameter to discover - * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a - * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP - * status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when - * a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other - * operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access - * automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob - * API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC - * permissions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: - * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob - * itself. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob - * if blob soft delete is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String leaseId, DeleteSnapshotsOptionType deleteSnapshots, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, BlobDeleteType blobDeleteType) { - return FluxUtil - .withContext(context -> deleteNoCustomHeadersWithResponseAsync(containerName, blob, snapshot, versionId, - timeout, leaseId, deleteSnapshots, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, - requestId, blobDeleteType, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed - * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, - * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or - * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] - * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently - * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until - * it is permanently removed. Use the List Blobs API and specify the "include=deleted" query parameter to discover - * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a - * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP - * status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when - * a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other - * operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access - * automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob - * API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC - * permissions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: - * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob - * itself. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob - * if blob soft delete is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, String versionId, Integer timeout, String leaseId, DeleteSnapshotsOptionType deleteSnapshots, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, BlobDeleteType blobDeleteType, Context context) { - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .deleteNoCustomHeaders(this.client.getUrl(), containerName, blob, snapshot, versionId, timeout, leaseId, - deleteSnapshots, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, blobDeleteType, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed - * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, - * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or - * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] - * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently - * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until - * it is permanently removed. Use the List Blobs API and specify the "include=deleted" query parameter to discover - * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a - * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP - * status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when - * a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other - * operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access - * automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob - * API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC - * permissions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: - * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob - * itself. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob - * if blob soft delete is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase deleteWithResponse(String containerName, String blob, String snapshot, - String versionId, Integer timeout, String leaseId, DeleteSnapshotsOptionType deleteSnapshots, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, BlobDeleteType blobDeleteType, Context context) { - try { - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.deleteSync(this.client.getUrl(), containerName, blob, snapshot, versionId, timeout, leaseId, - deleteSnapshots, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, blobDeleteType, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed - * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, - * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or - * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] - * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently - * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until - * it is permanently removed. Use the List Blobs API and specify the "include=deleted" query parameter to discover - * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a - * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP - * status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when - * a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other - * operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access - * automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob - * API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC - * permissions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: - * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob - * itself. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob - * if blob soft delete is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void delete(String containerName, String blob, String snapshot, String versionId, Integer timeout, - String leaseId, DeleteSnapshotsOptionType deleteSnapshots, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - BlobDeleteType blobDeleteType) { - deleteWithResponse(containerName, blob, snapshot, versionId, timeout, leaseId, deleteSnapshots, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobDeleteType, Context.NONE); - } - - /** - * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed - * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, - * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or - * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] - * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently - * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until - * it is permanently removed. Use the List Blobs API and specify the "include=deleted" query parameter to discover - * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a - * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP - * status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when - * a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other - * operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access - * automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob - * API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC - * permissions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param deleteSnapshots Required if the blob has associated snapshots. Specify one of the following two options: - * include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob - * itself. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobDeleteType Optional. Only possible value is 'permanent', which specifies to permanently delete a blob - * if blob soft delete is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteNoCustomHeadersWithResponse(String containerName, String blob, String snapshot, - String versionId, Integer timeout, String leaseId, DeleteSnapshotsOptionType deleteSnapshots, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, BlobDeleteType blobDeleteType, Context context) { - try { - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.deleteNoCustomHeadersSync(this.client.getUrl(), containerName, blob, snapshot, versionId, - timeout, leaseId, deleteSnapshots, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, this.client.getVersion(), requestId, blobDeleteType, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Undelete a blob that was previously soft deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> undeleteWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> undeleteWithResponseAsync(containerName, blob, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Undelete a blob that was previously soft deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> undeleteWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, Context context) { - final String comp = "undelete"; - final String accept = "application/xml"; - return service - .undelete(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), requestId, - accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Undelete a blob that was previously soft deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono undeleteAsync(String containerName, String blob, Integer timeout, String requestId) { - return undeleteWithResponseAsync(containerName, blob, timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Undelete a blob that was previously soft deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono undeleteAsync(String containerName, String blob, Integer timeout, String requestId, - Context context) { - return undeleteWithResponseAsync(containerName, blob, timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Undelete a blob that was previously soft deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> undeleteNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId) { - return FluxUtil - .withContext( - context -> undeleteNoCustomHeadersWithResponseAsync(containerName, blob, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Undelete a blob that was previously soft deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> undeleteNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, Context context) { - final String comp = "undelete"; - final String accept = "application/xml"; - return service - .undeleteNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Undelete a blob that was previously soft deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase undeleteWithResponse(String containerName, String blob, - Integer timeout, String requestId, Context context) { - try { - final String comp = "undelete"; - final String accept = "application/xml"; - return service.undeleteSync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Undelete a blob that was previously soft deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void undelete(String containerName, String blob, Integer timeout, String requestId) { - undeleteWithResponse(containerName, blob, timeout, requestId, Context.NONE); - } - - /** - * Undelete a blob that was previously soft deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response undeleteNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - String requestId, Context context) { - try { - final String comp = "undelete"; - final String accept = "application/xml"; - return service.undeleteNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Sets the time a blob will expire and be deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param expiryOptions Required. Indicates mode of the expiry time. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param expiresOn The time to set the blob to expiry. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setExpiryWithResponseAsync(String containerName, String blob, - BlobExpiryOptions expiryOptions, Integer timeout, String requestId, String expiresOn) { - return FluxUtil - .withContext(context -> setExpiryWithResponseAsync(containerName, blob, expiryOptions, timeout, requestId, - expiresOn, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Sets the time a blob will expire and be deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param expiryOptions Required. Indicates mode of the expiry time. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param expiresOn The time to set the blob to expiry. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setExpiryWithResponseAsync(String containerName, String blob, - BlobExpiryOptions expiryOptions, Integer timeout, String requestId, String expiresOn, Context context) { - final String comp = "expiry"; - final String accept = "application/xml"; - return service - .setExpiry(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), requestId, - expiryOptions, expiresOn, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Sets the time a blob will expire and be deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param expiryOptions Required. Indicates mode of the expiry time. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param expiresOn The time to set the blob to expiry. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setExpiryAsync(String containerName, String blob, BlobExpiryOptions expiryOptions, - Integer timeout, String requestId, String expiresOn) { - return setExpiryWithResponseAsync(containerName, blob, expiryOptions, timeout, requestId, expiresOn) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Sets the time a blob will expire and be deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param expiryOptions Required. Indicates mode of the expiry time. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param expiresOn The time to set the blob to expiry. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setExpiryAsync(String containerName, String blob, BlobExpiryOptions expiryOptions, - Integer timeout, String requestId, String expiresOn, Context context) { - return setExpiryWithResponseAsync(containerName, blob, expiryOptions, timeout, requestId, expiresOn, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Sets the time a blob will expire and be deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param expiryOptions Required. Indicates mode of the expiry time. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param expiresOn The time to set the blob to expiry. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setExpiryNoCustomHeadersWithResponseAsync(String containerName, String blob, - BlobExpiryOptions expiryOptions, Integer timeout, String requestId, String expiresOn) { - return FluxUtil - .withContext(context -> setExpiryNoCustomHeadersWithResponseAsync(containerName, blob, expiryOptions, - timeout, requestId, expiresOn, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Sets the time a blob will expire and be deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param expiryOptions Required. Indicates mode of the expiry time. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param expiresOn The time to set the blob to expiry. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setExpiryNoCustomHeadersWithResponseAsync(String containerName, String blob, - BlobExpiryOptions expiryOptions, Integer timeout, String requestId, String expiresOn, Context context) { - final String comp = "expiry"; - final String accept = "application/xml"; - return service - .setExpiryNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, expiryOptions, expiresOn, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Sets the time a blob will expire and be deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param expiryOptions Required. Indicates mode of the expiry time. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param expiresOn The time to set the blob to expiry. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setExpiryWithResponse(String containerName, String blob, - BlobExpiryOptions expiryOptions, Integer timeout, String requestId, String expiresOn, Context context) { - try { - final String comp = "expiry"; - final String accept = "application/xml"; - return service.setExpirySync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, expiryOptions, expiresOn, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Sets the time a blob will expire and be deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param expiryOptions Required. Indicates mode of the expiry time. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param expiresOn The time to set the blob to expiry. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setExpiry(String containerName, String blob, BlobExpiryOptions expiryOptions, Integer timeout, - String requestId, String expiresOn) { - setExpiryWithResponse(containerName, blob, expiryOptions, timeout, requestId, expiresOn, Context.NONE); - } - - /** - * Sets the time a blob will expire and be deleted. - * - * @param containerName The container name. - * @param blob The blob name. - * @param expiryOptions Required. Indicates mode of the expiry time. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param expiresOn The time to set the blob to expiry. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setExpiryNoCustomHeadersWithResponse(String containerName, String blob, - BlobExpiryOptions expiryOptions, Integer timeout, String requestId, String expiresOn, Context context) { - try { - final String comp = "expiry"; - final String accept = "application/xml"; - return service.setExpiryNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, expiryOptions, expiresOn, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set HTTP Headers operation sets system properties on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobHttpHeaders Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setHttpHeadersWithResponseAsync(String containerName, - String blob, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, BlobHttpHeaders blobHttpHeaders) { - return FluxUtil - .withContext(context -> setHttpHeadersWithResponseAsync(containerName, blob, timeout, leaseId, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobHttpHeaders, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set HTTP Headers operation sets system properties on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobHttpHeaders Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setHttpHeadersWithResponseAsync(String containerName, - String blob, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, BlobHttpHeaders blobHttpHeaders, - Context context) { - final String comp = "properties"; - final String accept = "application/xml"; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .setHttpHeaders(this.client.getUrl(), containerName, blob, comp, timeout, cacheControl, contentType, - contentMd5Converted, contentEncoding, contentLanguage, leaseId, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, contentDisposition, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set HTTP Headers operation sets system properties on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobHttpHeaders Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setHttpHeadersAsync(String containerName, String blob, Integer timeout, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, BlobHttpHeaders blobHttpHeaders) { - return setHttpHeadersWithResponseAsync(containerName, blob, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobHttpHeaders) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set HTTP Headers operation sets system properties on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobHttpHeaders Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setHttpHeadersAsync(String containerName, String blob, Integer timeout, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, BlobHttpHeaders blobHttpHeaders, Context context) { - return setHttpHeadersWithResponseAsync(containerName, blob, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobHttpHeaders, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set HTTP Headers operation sets system properties on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobHttpHeaders Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setHttpHeadersNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, BlobHttpHeaders blobHttpHeaders) { - return FluxUtil - .withContext(context -> setHttpHeadersNoCustomHeadersWithResponseAsync(containerName, blob, timeout, - leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobHttpHeaders, - context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set HTTP Headers operation sets system properties on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobHttpHeaders Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setHttpHeadersNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, BlobHttpHeaders blobHttpHeaders, - Context context) { - final String comp = "properties"; - final String accept = "application/xml"; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .setHttpHeadersNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, cacheControl, - contentType, contentMd5Converted, contentEncoding, contentLanguage, leaseId, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, contentDisposition, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set HTTP Headers operation sets system properties on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobHttpHeaders Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setHttpHeadersWithResponse(String containerName, String blob, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, BlobHttpHeaders blobHttpHeaders, - Context context) { - try { - final String comp = "properties"; - final String accept = "application/xml"; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.setHttpHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, cacheControl, - contentType, contentMd5Converted, contentEncoding, contentLanguage, leaseId, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, contentDisposition, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set HTTP Headers operation sets system properties on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobHttpHeaders Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setHttpHeaders(String containerName, String blob, Integer timeout, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, BlobHttpHeaders blobHttpHeaders) { - setHttpHeadersWithResponse(containerName, blob, timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, blobHttpHeaders, Context.NONE); - } - - /** - * The Set HTTP Headers operation sets system properties on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobHttpHeaders Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setHttpHeadersNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, BlobHttpHeaders blobHttpHeaders, Context context) { - try { - final String comp = "properties"; - final String accept = "application/xml"; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.setHttpHeadersNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - cacheControl, contentType, contentMd5Converted, contentEncoding, contentLanguage, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, contentDisposition, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Immutability Policy operation sets the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setImmutabilityPolicyWithResponseAsync( - String containerName, String blob, Integer timeout, String requestId, OffsetDateTime ifUnmodifiedSince, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, - String versionId) { - return FluxUtil - .withContext(context -> setImmutabilityPolicyWithResponseAsync(containerName, blob, timeout, requestId, - ifUnmodifiedSince, immutabilityPolicyExpiry, immutabilityPolicyMode, snapshot, versionId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Immutability Policy operation sets the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setImmutabilityPolicyWithResponseAsync( - String containerName, String blob, Integer timeout, String requestId, OffsetDateTime ifUnmodifiedSince, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, - String versionId, Context context) { - final String comp = "immutabilityPolicies"; - final String accept = "application/xml"; - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .setImmutabilityPolicy(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), - requestId, ifUnmodifiedSinceConverted, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, - snapshot, versionId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Immutability Policy operation sets the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setImmutabilityPolicyAsync(String containerName, String blob, Integer timeout, String requestId, - OffsetDateTime ifUnmodifiedSince, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, String versionId) { - return setImmutabilityPolicyWithResponseAsync(containerName, blob, timeout, requestId, ifUnmodifiedSince, - immutabilityPolicyExpiry, immutabilityPolicyMode, snapshot, versionId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Immutability Policy operation sets the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setImmutabilityPolicyAsync(String containerName, String blob, Integer timeout, String requestId, - OffsetDateTime ifUnmodifiedSince, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, String versionId, Context context) { - return setImmutabilityPolicyWithResponseAsync(containerName, blob, timeout, requestId, ifUnmodifiedSince, - immutabilityPolicyExpiry, immutabilityPolicyMode, snapshot, versionId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Immutability Policy operation sets the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setImmutabilityPolicyNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, OffsetDateTime ifUnmodifiedSince, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, String versionId) { - return FluxUtil - .withContext(context -> setImmutabilityPolicyNoCustomHeadersWithResponseAsync(containerName, blob, timeout, - requestId, ifUnmodifiedSince, immutabilityPolicyExpiry, immutabilityPolicyMode, snapshot, versionId, - context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Immutability Policy operation sets the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setImmutabilityPolicyNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, OffsetDateTime ifUnmodifiedSince, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, String versionId, Context context) { - final String comp = "immutabilityPolicies"; - final String accept = "application/xml"; - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .setImmutabilityPolicyNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, ifUnmodifiedSinceConverted, immutabilityPolicyExpiryConverted, - immutabilityPolicyMode, snapshot, versionId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Immutability Policy operation sets the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setImmutabilityPolicyWithResponse(String containerName, - String blob, Integer timeout, String requestId, OffsetDateTime ifUnmodifiedSince, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, - String versionId, Context context) { - try { - final String comp = "immutabilityPolicies"; - final String accept = "application/xml"; - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.setImmutabilityPolicySync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, ifUnmodifiedSinceConverted, immutabilityPolicyExpiryConverted, - immutabilityPolicyMode, snapshot, versionId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Immutability Policy operation sets the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setImmutabilityPolicy(String containerName, String blob, Integer timeout, String requestId, - OffsetDateTime ifUnmodifiedSince, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, String versionId) { - setImmutabilityPolicyWithResponse(containerName, blob, timeout, requestId, ifUnmodifiedSince, - immutabilityPolicyExpiry, immutabilityPolicyMode, snapshot, versionId, Context.NONE); - } - - /** - * The Set Immutability Policy operation sets the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setImmutabilityPolicyNoCustomHeadersWithResponse(String containerName, String blob, - Integer timeout, String requestId, OffsetDateTime ifUnmodifiedSince, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, String snapshot, String versionId, Context context) { - try { - final String comp = "immutabilityPolicies"; - final String accept = "application/xml"; - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.setImmutabilityPolicyNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, - timeout, this.client.getVersion(), requestId, ifUnmodifiedSinceConverted, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, snapshot, versionId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Delete Immutability Policy operation deletes the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteImmutabilityPolicyWithResponseAsync( - String containerName, String blob, Integer timeout, String requestId, String snapshot, String versionId) { - return FluxUtil - .withContext(context -> deleteImmutabilityPolicyWithResponseAsync(containerName, blob, timeout, requestId, - snapshot, versionId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Delete Immutability Policy operation deletes the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteImmutabilityPolicyWithResponseAsync( - String containerName, String blob, Integer timeout, String requestId, String snapshot, String versionId, - Context context) { - final String comp = "immutabilityPolicies"; - final String accept = "application/xml"; - return service - .deleteImmutabilityPolicy(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, snapshot, versionId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Delete Immutability Policy operation deletes the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteImmutabilityPolicyAsync(String containerName, String blob, Integer timeout, - String requestId, String snapshot, String versionId) { - return deleteImmutabilityPolicyWithResponseAsync(containerName, blob, timeout, requestId, snapshot, versionId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Delete Immutability Policy operation deletes the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteImmutabilityPolicyAsync(String containerName, String blob, Integer timeout, - String requestId, String snapshot, String versionId, Context context) { - return deleteImmutabilityPolicyWithResponseAsync(containerName, blob, timeout, requestId, snapshot, versionId, - context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Delete Immutability Policy operation deletes the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteImmutabilityPolicyNoCustomHeadersWithResponseAsync(String containerName, - String blob, Integer timeout, String requestId, String snapshot, String versionId) { - return FluxUtil - .withContext(context -> deleteImmutabilityPolicyNoCustomHeadersWithResponseAsync(containerName, blob, - timeout, requestId, snapshot, versionId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Delete Immutability Policy operation deletes the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteImmutabilityPolicyNoCustomHeadersWithResponseAsync(String containerName, - String blob, Integer timeout, String requestId, String snapshot, String versionId, Context context) { - final String comp = "immutabilityPolicies"; - final String accept = "application/xml"; - return service - .deleteImmutabilityPolicyNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, snapshot, versionId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Delete Immutability Policy operation deletes the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase deleteImmutabilityPolicyWithResponse( - String containerName, String blob, Integer timeout, String requestId, String snapshot, String versionId, - Context context) { - try { - final String comp = "immutabilityPolicies"; - final String accept = "application/xml"; - return service.deleteImmutabilityPolicySync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, snapshot, versionId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Delete Immutability Policy operation deletes the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void deleteImmutabilityPolicy(String containerName, String blob, Integer timeout, String requestId, - String snapshot, String versionId) { - deleteImmutabilityPolicyWithResponse(containerName, blob, timeout, requestId, snapshot, versionId, - Context.NONE); - } - - /** - * The Delete Immutability Policy operation deletes the immutability policy on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteImmutabilityPolicyNoCustomHeadersWithResponse(String containerName, String blob, - Integer timeout, String requestId, String snapshot, String versionId, Context context) { - try { - final String comp = "immutabilityPolicies"; - final String accept = "application/xml"; - return service.deleteImmutabilityPolicyNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, - timeout, this.client.getVersion(), requestId, snapshot, versionId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Legal Hold operation sets a legal hold on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setLegalHoldWithResponseAsync(String containerName, - String blob, boolean legalHold, Integer timeout, String requestId, String snapshot, String versionId) { - return FluxUtil - .withContext(context -> setLegalHoldWithResponseAsync(containerName, blob, legalHold, timeout, requestId, - snapshot, versionId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Legal Hold operation sets a legal hold on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setLegalHoldWithResponseAsync(String containerName, - String blob, boolean legalHold, Integer timeout, String requestId, String snapshot, String versionId, - Context context) { - final String comp = "legalhold"; - final String accept = "application/xml"; - return service - .setLegalHold(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), requestId, - legalHold, snapshot, versionId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Legal Hold operation sets a legal hold on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setLegalHoldAsync(String containerName, String blob, boolean legalHold, Integer timeout, - String requestId, String snapshot, String versionId) { - return setLegalHoldWithResponseAsync(containerName, blob, legalHold, timeout, requestId, snapshot, versionId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Legal Hold operation sets a legal hold on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setLegalHoldAsync(String containerName, String blob, boolean legalHold, Integer timeout, - String requestId, String snapshot, String versionId, Context context) { - return setLegalHoldWithResponseAsync(containerName, blob, legalHold, timeout, requestId, snapshot, versionId, - context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Legal Hold operation sets a legal hold on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setLegalHoldNoCustomHeadersWithResponseAsync(String containerName, String blob, - boolean legalHold, Integer timeout, String requestId, String snapshot, String versionId) { - return FluxUtil - .withContext(context -> setLegalHoldNoCustomHeadersWithResponseAsync(containerName, blob, legalHold, - timeout, requestId, snapshot, versionId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Legal Hold operation sets a legal hold on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setLegalHoldNoCustomHeadersWithResponseAsync(String containerName, String blob, - boolean legalHold, Integer timeout, String requestId, String snapshot, String versionId, Context context) { - final String comp = "legalhold"; - final String accept = "application/xml"; - return service - .setLegalHoldNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, legalHold, snapshot, versionId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Legal Hold operation sets a legal hold on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setLegalHoldWithResponse(String containerName, String blob, - boolean legalHold, Integer timeout, String requestId, String snapshot, String versionId, Context context) { - try { - final String comp = "legalhold"; - final String accept = "application/xml"; - return service.setLegalHoldSync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, legalHold, snapshot, versionId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Legal Hold operation sets a legal hold on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setLegalHold(String containerName, String blob, boolean legalHold, Integer timeout, String requestId, - String snapshot, String versionId) { - setLegalHoldWithResponse(containerName, blob, legalHold, timeout, requestId, snapshot, versionId, Context.NONE); - } - - /** - * The Set Legal Hold operation sets a legal hold on the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setLegalHoldNoCustomHeadersWithResponse(String containerName, String blob, boolean legalHold, - Integer timeout, String requestId, String snapshot, String versionId, Context context) { - try { - final String comp = "legalhold"; - final String accept = "application/xml"; - return service.setLegalHoldNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, legalHold, snapshot, versionId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value - * pairs. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataWithResponseAsync(String containerName, - String blob, Integer timeout, Map metadata, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> setMetadataWithResponseAsync(containerName, blob, timeout, metadata, leaseId, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value - * pairs. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataWithResponseAsync(String containerName, - String blob, Integer timeout, Map metadata, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "metadata"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .setMetadata(this.client.getUrl(), containerName, blob, comp, timeout, metadata, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value - * pairs. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setMetadataAsync(String containerName, String blob, Integer timeout, Map metadata, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return setMetadataWithResponseAsync(containerName, blob, timeout, metadata, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value - * pairs. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setMetadataAsync(String containerName, String blob, Integer timeout, Map metadata, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, - Context context) { - return setMetadataWithResponseAsync(containerName, blob, timeout, metadata, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value - * pairs. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, Map metadata, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> setMetadataNoCustomHeadersWithResponseAsync(containerName, blob, timeout, metadata, - leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value - * pairs. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, Map metadata, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "metadata"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .setMetadataNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, metadata, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value - * pairs. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setMetadataWithResponse(String containerName, String blob, - Integer timeout, Map metadata, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "metadata"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.setMetadataSync(this.client.getUrl(), containerName, blob, comp, timeout, metadata, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value - * pairs. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setMetadata(String containerName, String blob, Integer timeout, Map metadata, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - setMetadataWithResponse(containerName, blob, timeout, metadata, leaseId, ifModifiedSince, ifUnmodifiedSince, - ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, encryptionScopeParam, Context.NONE); - } - - /** - * The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value - * pairs. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setMetadataNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - Map metadata, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "metadata"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.setMetadataNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - metadata, leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseWithResponseAsync(String containerName, - String blob, Integer timeout, Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> acquireLeaseWithResponseAsync(containerName, blob, timeout, duration, - proposedLeaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseWithResponseAsync(String containerName, - String blob, Integer timeout, Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - Context context) { - final String comp = "lease"; - final String action = "acquire"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .acquireLease(this.client.getUrl(), containerName, blob, comp, action, timeout, duration, proposedLeaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono acquireLeaseAsync(String containerName, String blob, Integer timeout, Integer duration, - String proposedLeaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId) { - return acquireLeaseWithResponseAsync(containerName, blob, timeout, duration, proposedLeaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono acquireLeaseAsync(String containerName, String blob, Integer timeout, Integer duration, - String proposedLeaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, Context context) { - return acquireLeaseWithResponseAsync(containerName, blob, timeout, duration, proposedLeaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> acquireLeaseNoCustomHeadersWithResponseAsync(containerName, blob, timeout, duration, - proposedLeaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - Context context) { - final String comp = "lease"; - final String action = "acquire"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .acquireLeaseNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, action, timeout, duration, - proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase acquireLeaseWithResponse(String containerName, String blob, - Integer timeout, Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - Context context) { - try { - final String comp = "lease"; - final String action = "acquire"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.acquireLeaseSync(this.client.getUrl(), containerName, blob, comp, action, timeout, duration, - proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void acquireLease(String containerName, String blob, Integer timeout, Integer duration, - String proposedLeaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId) { - acquireLeaseWithResponse(containerName, blob, timeout, duration, proposedLeaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, Context.NONE); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response acquireLeaseNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - try { - final String comp = "lease"; - final String action = "acquire"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.acquireLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, action, - timeout, duration, proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseWithResponseAsync(String containerName, - String blob, String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> releaseLeaseWithResponseAsync(containerName, blob, leaseId, timeout, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseWithResponseAsync(String containerName, - String blob, String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - final String comp = "lease"; - final String action = "release"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .releaseLease(this.client.getUrl(), containerName, blob, comp, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono releaseLeaseAsync(String containerName, String blob, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId) { - return releaseLeaseWithResponseAsync(containerName, blob, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, - ifMatch, ifNoneMatch, ifTags, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono releaseLeaseAsync(String containerName, String blob, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, Context context) { - return releaseLeaseWithResponseAsync(containerName, blob, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, - ifMatch, ifNoneMatch, ifTags, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> releaseLeaseNoCustomHeadersWithResponseAsync(containerName, blob, leaseId, timeout, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - final String comp = "lease"; - final String action = "release"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .releaseLeaseNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase releaseLeaseWithResponse(String containerName, String blob, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - try { - final String comp = "lease"; - final String action = "release"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.releaseLeaseSync(this.client.getUrl(), containerName, blob, comp, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void releaseLease(String containerName, String blob, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId) { - releaseLeaseWithResponse(containerName, blob, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, Context.NONE); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response releaseLeaseNoCustomHeadersWithResponse(String containerName, String blob, String leaseId, - Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, Context context) { - try { - final String comp = "lease"; - final String action = "release"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.releaseLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, action, - timeout, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseWithResponseAsync(String containerName, - String blob, String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> renewLeaseWithResponseAsync(containerName, blob, leaseId, timeout, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseWithResponseAsync(String containerName, - String blob, String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - final String comp = "lease"; - final String action = "renew"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .renewLease(this.client.getUrl(), containerName, blob, comp, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono renewLeaseAsync(String containerName, String blob, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId) { - return renewLeaseWithResponseAsync(containerName, blob, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, - ifMatch, ifNoneMatch, ifTags, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono renewLeaseAsync(String containerName, String blob, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, Context context) { - return renewLeaseWithResponseAsync(containerName, blob, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, - ifMatch, ifNoneMatch, ifTags, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> renewLeaseNoCustomHeadersWithResponseAsync(containerName, blob, leaseId, timeout, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - final String comp = "lease"; - final String action = "renew"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .renewLeaseNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase renewLeaseWithResponse(String containerName, String blob, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - try { - final String comp = "lease"; - final String action = "renew"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.renewLeaseSync(this.client.getUrl(), containerName, blob, comp, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void renewLease(String containerName, String blob, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId) { - renewLeaseWithResponse(containerName, blob, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, Context.NONE); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response renewLeaseNoCustomHeadersWithResponse(String containerName, String blob, String leaseId, - Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, Context context) { - try { - final String comp = "lease"; - final String action = "renew"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.renewLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, action, - timeout, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseWithResponseAsync(String containerName, - String blob, String leaseId, String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> changeLeaseWithResponseAsync(containerName, blob, leaseId, proposedLeaseId, timeout, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseWithResponseAsync(String containerName, - String blob, String leaseId, String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - Context context) { - final String comp = "lease"; - final String action = "change"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .changeLease(this.client.getUrl(), containerName, blob, comp, action, timeout, leaseId, proposedLeaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono changeLeaseAsync(String containerName, String blob, String leaseId, String proposedLeaseId, - Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId) { - return changeLeaseWithResponseAsync(containerName, blob, leaseId, proposedLeaseId, timeout, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono changeLeaseAsync(String containerName, String blob, String leaseId, String proposedLeaseId, - Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, Context context) { - return changeLeaseWithResponseAsync(containerName, blob, leaseId, proposedLeaseId, timeout, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - String leaseId, String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext( - context -> changeLeaseNoCustomHeadersWithResponseAsync(containerName, blob, leaseId, proposedLeaseId, - timeout, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - String leaseId, String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - Context context) { - final String comp = "lease"; - final String action = "change"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .changeLeaseNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, action, timeout, leaseId, - proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase changeLeaseWithResponse(String containerName, String blob, - String leaseId, String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - Context context) { - try { - final String comp = "lease"; - final String action = "change"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.changeLeaseSync(this.client.getUrl(), containerName, blob, comp, action, timeout, leaseId, - proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void changeLease(String containerName, String blob, String leaseId, String proposedLeaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId) { - changeLeaseWithResponse(containerName, blob, leaseId, proposedLeaseId, timeout, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, Context.NONE); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response changeLeaseNoCustomHeadersWithResponse(String containerName, String blob, String leaseId, - String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - try { - final String comp = "lease"; - final String action = "change"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.changeLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, action, - timeout, leaseId, proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseWithResponseAsync(String containerName, - String blob, Integer timeout, Integer breakPeriod, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> breakLeaseWithResponseAsync(containerName, blob, timeout, breakPeriod, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseWithResponseAsync(String containerName, - String blob, Integer timeout, Integer breakPeriod, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - Context context) { - final String comp = "lease"; - final String action = "break"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .breakLease(this.client.getUrl(), containerName, blob, comp, action, timeout, breakPeriod, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono breakLeaseAsync(String containerName, String blob, Integer timeout, Integer breakPeriod, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId) { - return breakLeaseWithResponseAsync(containerName, blob, timeout, breakPeriod, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono breakLeaseAsync(String containerName, String blob, Integer timeout, Integer breakPeriod, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, Context context) { - return breakLeaseWithResponseAsync(containerName, blob, timeout, breakPeriod, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> breakLeaseNoCustomHeadersWithResponseAsync(containerName, blob, timeout, - breakPeriod, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - final String comp = "lease"; - final String action = "break"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .breakLeaseNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, action, timeout, breakPeriod, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase breakLeaseWithResponse(String containerName, String blob, - Integer timeout, Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - try { - final String comp = "lease"; - final String action = "break"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.breakLeaseSync(this.client.getUrl(), containerName, blob, comp, action, timeout, breakPeriod, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void breakLease(String containerName, String blob, Integer timeout, Integer breakPeriod, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId) { - breakLeaseWithResponse(containerName, blob, timeout, breakPeriod, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, Context.NONE); - } - - /** - * [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response breakLeaseNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, Context context) { - try { - final String comp = "lease"; - final String action = "break"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.breakLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, action, - timeout, breakPeriod, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, - ifTags, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Create Snapshot operation creates a read-only snapshot of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createSnapshotWithResponseAsync(String containerName, - String blob, Integer timeout, Map metadata, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String leaseId, - String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> createSnapshotWithResponseAsync(containerName, blob, timeout, metadata, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Create Snapshot operation creates a read-only snapshot of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createSnapshotWithResponseAsync(String containerName, - String blob, Integer timeout, Map metadata, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String leaseId, - String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "snapshot"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .createSnapshot(this.client.getUrl(), containerName, blob, comp, timeout, metadata, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, leaseId, this.client.getVersion(), requestId, - accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Create Snapshot operation creates a read-only snapshot of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createSnapshotAsync(String containerName, String blob, Integer timeout, - Map metadata, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String leaseId, String requestId, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return createSnapshotWithResponseAsync(containerName, blob, timeout, metadata, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Create Snapshot operation creates a read-only snapshot of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createSnapshotAsync(String containerName, String blob, Integer timeout, - Map metadata, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String leaseId, String requestId, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - return createSnapshotWithResponseAsync(containerName, blob, timeout, metadata, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Create Snapshot operation creates a read-only snapshot of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createSnapshotNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, Map metadata, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String leaseId, String requestId, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> createSnapshotNoCustomHeadersWithResponseAsync(containerName, blob, timeout, - metadata, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Create Snapshot operation creates a read-only snapshot of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createSnapshotNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, Map metadata, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String leaseId, String requestId, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "snapshot"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .createSnapshotNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, metadata, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, leaseId, this.client.getVersion(), requestId, - accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Create Snapshot operation creates a read-only snapshot of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase createSnapshotWithResponse(String containerName, String blob, - Integer timeout, Map metadata, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String leaseId, String requestId, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "snapshot"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.createSnapshotSync(this.client.getUrl(), containerName, blob, comp, timeout, metadata, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, leaseId, this.client.getVersion(), requestId, - accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Create Snapshot operation creates a read-only snapshot of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void createSnapshot(String containerName, String blob, Integer timeout, Map metadata, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - createSnapshotWithResponse(containerName, blob, timeout, metadata, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, leaseId, requestId, cpkInfo, encryptionScopeParam, Context.NONE); - } - - /** - * The Create Snapshot operation creates a read-only snapshot of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createSnapshotNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - Map metadata, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String leaseId, String requestId, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "snapshot"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.createSnapshotNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - metadata, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, leaseId, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Start Copy From URL operation copies a blob or an internet resource to a new blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> startCopyFromURLWithResponseAsync( - String containerName, String blob, String copySource, Integer timeout, Map metadata, - AccessTier tier, RehydratePriority rehydratePriority, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, String blobTagsString, Boolean sealBlob, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold) { - return FluxUtil - .withContext( - context -> startCopyFromURLWithResponseAsync(containerName, blob, copySource, timeout, metadata, tier, - rehydratePriority, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, - sourceIfTags, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, - blobTagsString, sealBlob, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Start Copy From URL operation copies a blob or an internet resource to a new blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> startCopyFromURLWithResponseAsync( - String containerName, String blob, String copySource, Integer timeout, Map metadata, - AccessTier tier, RehydratePriority rehydratePriority, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, String blobTagsString, Boolean sealBlob, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - Context context) { - final String accept = "application/xml"; - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .startCopyFromURL(this.client.getUrl(), containerName, blob, timeout, metadata, tier, rehydratePriority, - sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, - sourceIfTags, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - copySource, leaseId, this.client.getVersion(), requestId, blobTagsString, sealBlob, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Start Copy From URL operation copies a blob or an internet resource to a new blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono startCopyFromURLAsync(String containerName, String blob, String copySource, Integer timeout, - Map metadata, AccessTier tier, RehydratePriority rehydratePriority, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String sourceIfTags, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String leaseId, String requestId, String blobTagsString, - Boolean sealBlob, OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, - Boolean legalHold) { - return startCopyFromURLWithResponseAsync(containerName, blob, copySource, timeout, metadata, tier, - rehydratePriority, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, - sourceIfTags, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, - blobTagsString, sealBlob, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Start Copy From URL operation copies a blob or an internet resource to a new blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono startCopyFromURLAsync(String containerName, String blob, String copySource, Integer timeout, - Map metadata, AccessTier tier, RehydratePriority rehydratePriority, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String sourceIfTags, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String leaseId, String requestId, String blobTagsString, - Boolean sealBlob, OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, - Boolean legalHold, Context context) { - return startCopyFromURLWithResponseAsync(containerName, blob, copySource, timeout, metadata, tier, - rehydratePriority, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, - sourceIfTags, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, - blobTagsString, sealBlob, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Start Copy From URL operation copies a blob or an internet resource to a new blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> startCopyFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String copySource, Integer timeout, Map metadata, AccessTier tier, - RehydratePriority rehydratePriority, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, String blobTagsString, Boolean sealBlob, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold) { - return FluxUtil - .withContext(context -> startCopyFromURLNoCustomHeadersWithResponseAsync(containerName, blob, copySource, - timeout, metadata, tier, rehydratePriority, sourceIfModifiedSince, sourceIfUnmodifiedSince, - sourceIfMatch, sourceIfNoneMatch, sourceIfTags, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, leaseId, requestId, blobTagsString, sealBlob, immutabilityPolicyExpiry, - immutabilityPolicyMode, legalHold, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Start Copy From URL operation copies a blob or an internet resource to a new blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> startCopyFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String copySource, Integer timeout, Map metadata, AccessTier tier, - RehydratePriority rehydratePriority, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, String blobTagsString, Boolean sealBlob, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - Context context) { - final String accept = "application/xml"; - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .startCopyFromURLNoCustomHeaders(this.client.getUrl(), containerName, blob, timeout, metadata, tier, - rehydratePriority, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, - sourceIfNoneMatch, sourceIfTags, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, copySource, leaseId, this.client.getVersion(), requestId, blobTagsString, sealBlob, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Start Copy From URL operation copies a blob or an internet resource to a new blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase startCopyFromURLWithResponse(String containerName, - String blob, String copySource, Integer timeout, Map metadata, AccessTier tier, - RehydratePriority rehydratePriority, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, String blobTagsString, Boolean sealBlob, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - Context context) { - try { - final String accept = "application/xml"; - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.startCopyFromURLSync(this.client.getUrl(), containerName, blob, timeout, metadata, tier, - rehydratePriority, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, - sourceIfNoneMatch, sourceIfTags, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, copySource, leaseId, this.client.getVersion(), requestId, blobTagsString, sealBlob, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Start Copy From URL operation copies a blob or an internet resource to a new blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void startCopyFromURL(String containerName, String blob, String copySource, Integer timeout, - Map metadata, AccessTier tier, RehydratePriority rehydratePriority, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String sourceIfTags, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String leaseId, String requestId, String blobTagsString, - Boolean sealBlob, OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, - Boolean legalHold) { - startCopyFromURLWithResponse(containerName, blob, copySource, timeout, metadata, tier, rehydratePriority, - sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, sourceIfTags, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, blobTagsString, - sealBlob, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, Context.NONE); - } - - /** - * The Start Copy From URL operation copies a blob or an internet resource to a new blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param sealBlob Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response startCopyFromURLNoCustomHeadersWithResponse(String containerName, String blob, - String copySource, Integer timeout, Map metadata, AccessTier tier, - RehydratePriority rehydratePriority, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, String blobTagsString, Boolean sealBlob, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - Context context) { - try { - final String accept = "application/xml"; - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.startCopyFromURLNoCustomHeadersSync(this.client.getUrl(), containerName, blob, timeout, - metadata, tier, rehydratePriority, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, - sourceIfMatch, sourceIfNoneMatch, sourceIfTags, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - ifMatch, ifNoneMatch, ifTags, copySource, leaseId, this.client.getVersion(), requestId, blobTagsString, - sealBlob, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response - * until the copy is complete. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyFromURLWithResponseAsync(String containerName, - String blob, String copySource, Integer timeout, Map metadata, AccessTier tier, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String leaseId, String requestId, byte[] sourceContentMD5, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> copyFromURLWithResponseAsync(containerName, blob, copySource, timeout, metadata, - tier, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, sourceContentMD5, blobTagsString, - immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, copySourceAuthorization, copySourceTags, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response - * until the copy is complete. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyFromURLWithResponseAsync(String containerName, - String blob, String copySource, Integer timeout, Map metadata, AccessTier tier, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String leaseId, String requestId, byte[] sourceContentMD5, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, EncryptionScope encryptionScopeParam, Context context) { - final String xMsRequiresSync = "true"; - final String accept = "application/xml"; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .copyFromURL(this.client.getUrl(), containerName, blob, xMsRequiresSync, timeout, metadata, tier, - sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, copySource, leaseId, - this.client.getVersion(), requestId, sourceContentMD5Converted, blobTagsString, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, copySourceAuthorization, - encryptionScope, copySourceTags, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response - * until the copy is complete. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono copyFromURLAsync(String containerName, String blob, String copySource, Integer timeout, - Map metadata, AccessTier tier, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, byte[] sourceContentMD5, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - String copySourceAuthorization, BlobCopySourceTagsMode copySourceTags, EncryptionScope encryptionScopeParam) { - return copyFromURLWithResponseAsync(containerName, blob, copySource, timeout, metadata, tier, - sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, sourceContentMD5, blobTagsString, - immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, copySourceAuthorization, copySourceTags, - encryptionScopeParam).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response - * until the copy is complete. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono copyFromURLAsync(String containerName, String blob, String copySource, Integer timeout, - Map metadata, AccessTier tier, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, byte[] sourceContentMD5, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - String copySourceAuthorization, BlobCopySourceTagsMode copySourceTags, EncryptionScope encryptionScopeParam, - Context context) { - return copyFromURLWithResponseAsync(containerName, blob, copySource, timeout, metadata, tier, - sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, sourceContentMD5, blobTagsString, - immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, copySourceAuthorization, copySourceTags, - encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response - * until the copy is complete. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String copySource, Integer timeout, Map metadata, AccessTier tier, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String leaseId, String requestId, byte[] sourceContentMD5, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> copyFromURLNoCustomHeadersWithResponseAsync(containerName, blob, copySource, - timeout, metadata, tier, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, - sourceIfNoneMatch, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, leaseId, requestId, - sourceContentMD5, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, - copySourceAuthorization, copySourceTags, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response - * until the copy is complete. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String copySource, Integer timeout, Map metadata, AccessTier tier, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String leaseId, String requestId, byte[] sourceContentMD5, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, EncryptionScope encryptionScopeParam, Context context) { - final String xMsRequiresSync = "true"; - final String accept = "application/xml"; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .copyFromURLNoCustomHeaders(this.client.getUrl(), containerName, blob, xMsRequiresSync, timeout, metadata, - tier, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, - sourceIfNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - copySource, leaseId, this.client.getVersion(), requestId, sourceContentMD5Converted, blobTagsString, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, copySourceAuthorization, - encryptionScope, copySourceTags, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response - * until the copy is complete. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase copyFromURLWithResponse(String containerName, String blob, - String copySource, Integer timeout, Map metadata, AccessTier tier, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String leaseId, String requestId, byte[] sourceContentMD5, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, EncryptionScope encryptionScopeParam, Context context) { - try { - final String xMsRequiresSync = "true"; - final String accept = "application/xml"; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.copyFromURLSync(this.client.getUrl(), containerName, blob, xMsRequiresSync, timeout, - metadata, tier, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, - sourceIfNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - copySource, leaseId, this.client.getVersion(), requestId, sourceContentMD5Converted, blobTagsString, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, copySourceAuthorization, - encryptionScope, copySourceTags, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response - * until the copy is complete. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void copyFromURL(String containerName, String blob, String copySource, Integer timeout, - Map metadata, AccessTier tier, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, byte[] sourceContentMD5, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - String copySourceAuthorization, BlobCopySourceTagsMode copySourceTags, EncryptionScope encryptionScopeParam) { - copyFromURLWithResponse(containerName, blob, copySource, timeout, metadata, tier, sourceIfModifiedSince, - sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, leaseId, requestId, sourceContentMD5, blobTagsString, immutabilityPolicyExpiry, - immutabilityPolicyMode, legalHold, copySourceAuthorization, copySourceTags, encryptionScopeParam, - Context.NONE); - } - - /** - * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response - * until the copy is complete. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response copyFromURLNoCustomHeadersWithResponse(String containerName, String blob, String copySource, - Integer timeout, Map metadata, AccessTier tier, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String leaseId, String requestId, byte[] sourceContentMD5, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - String copySourceAuthorization, BlobCopySourceTagsMode copySourceTags, EncryptionScope encryptionScopeParam, - Context context) { - try { - final String xMsRequiresSync = "true"; - final String accept = "application/xml"; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.copyFromURLNoCustomHeadersSync(this.client.getUrl(), containerName, blob, xMsRequiresSync, - timeout, metadata, tier, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, - sourceIfMatch, sourceIfNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, copySource, leaseId, this.client.getVersion(), requestId, - sourceContentMD5Converted, blobTagsString, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, - legalHold, copySourceAuthorization, encryptionScope, copySourceTags, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with - * zero length and full metadata. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> abortCopyFromURLWithResponseAsync( - String containerName, String blob, String copyId, Integer timeout, String leaseId, String requestId) { - return FluxUtil - .withContext(context -> abortCopyFromURLWithResponseAsync(containerName, blob, copyId, timeout, leaseId, - requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with - * zero length and full metadata. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> abortCopyFromURLWithResponseAsync( - String containerName, String blob, String copyId, Integer timeout, String leaseId, String requestId, - Context context) { - final String comp = "copy"; - final String copyActionAbortConstant = "abort"; - final String accept = "application/xml"; - return service - .abortCopyFromURL(this.client.getUrl(), containerName, blob, comp, copyActionAbortConstant, copyId, timeout, - leaseId, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with - * zero length and full metadata. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono abortCopyFromURLAsync(String containerName, String blob, String copyId, Integer timeout, - String leaseId, String requestId) { - return abortCopyFromURLWithResponseAsync(containerName, blob, copyId, timeout, leaseId, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with - * zero length and full metadata. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono abortCopyFromURLAsync(String containerName, String blob, String copyId, Integer timeout, - String leaseId, String requestId, Context context) { - return abortCopyFromURLWithResponseAsync(containerName, blob, copyId, timeout, leaseId, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with - * zero length and full metadata. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> abortCopyFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String copyId, Integer timeout, String leaseId, String requestId) { - return FluxUtil - .withContext(context -> abortCopyFromURLNoCustomHeadersWithResponseAsync(containerName, blob, copyId, - timeout, leaseId, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with - * zero length and full metadata. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> abortCopyFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String copyId, Integer timeout, String leaseId, String requestId, Context context) { - final String comp = "copy"; - final String copyActionAbortConstant = "abort"; - final String accept = "application/xml"; - return service - .abortCopyFromURLNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, copyActionAbortConstant, - copyId, timeout, leaseId, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with - * zero length and full metadata. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase abortCopyFromURLWithResponse(String containerName, - String blob, String copyId, Integer timeout, String leaseId, String requestId, Context context) { - try { - final String comp = "copy"; - final String copyActionAbortConstant = "abort"; - final String accept = "application/xml"; - return service.abortCopyFromURLSync(this.client.getUrl(), containerName, blob, comp, - copyActionAbortConstant, copyId, timeout, leaseId, this.client.getVersion(), requestId, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with - * zero length and full metadata. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void abortCopyFromURL(String containerName, String blob, String copyId, Integer timeout, String leaseId, - String requestId) { - abortCopyFromURLWithResponse(containerName, blob, copyId, timeout, leaseId, requestId, Context.NONE); - } - - /** - * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with - * zero length and full metadata. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response abortCopyFromURLNoCustomHeadersWithResponse(String containerName, String blob, String copyId, - Integer timeout, String leaseId, String requestId, Context context) { - try { - final String comp = "copy"; - final String copyActionAbortConstant = "abort"; - final String accept = "application/xml"; - return service.abortCopyFromURLNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, - copyActionAbortConstant, copyId, timeout, leaseId, this.client.getVersion(), requestId, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage - * account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's - * tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines - * Hot/Cool/Archive storage type. This operation does not update the blob's ETag. - * - * @param containerName The container name. - * @param blob The blob name. - * @param tier Indicates the tier to be set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setTierWithResponseAsync(String containerName, String blob, - AccessTier tier, String snapshot, String versionId, Integer timeout, RehydratePriority rehydratePriority, - String requestId, String leaseId, String ifTags) { - return FluxUtil - .withContext(context -> setTierWithResponseAsync(containerName, blob, tier, snapshot, versionId, timeout, - rehydratePriority, requestId, leaseId, ifTags, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage - * account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's - * tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines - * Hot/Cool/Archive storage type. This operation does not update the blob's ETag. - * - * @param containerName The container name. - * @param blob The blob name. - * @param tier Indicates the tier to be set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setTierWithResponseAsync(String containerName, String blob, - AccessTier tier, String snapshot, String versionId, Integer timeout, RehydratePriority rehydratePriority, - String requestId, String leaseId, String ifTags, Context context) { - final String comp = "tier"; - final String accept = "application/xml"; - return service - .setTier(this.client.getUrl(), containerName, blob, comp, snapshot, versionId, timeout, tier, - rehydratePriority, this.client.getVersion(), requestId, leaseId, ifTags, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage - * account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's - * tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines - * Hot/Cool/Archive storage type. This operation does not update the blob's ETag. - * - * @param containerName The container name. - * @param blob The blob name. - * @param tier Indicates the tier to be set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setTierAsync(String containerName, String blob, AccessTier tier, String snapshot, - String versionId, Integer timeout, RehydratePriority rehydratePriority, String requestId, String leaseId, - String ifTags) { - return setTierWithResponseAsync(containerName, blob, tier, snapshot, versionId, timeout, rehydratePriority, - requestId, leaseId, ifTags) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage - * account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's - * tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines - * Hot/Cool/Archive storage type. This operation does not update the blob's ETag. - * - * @param containerName The container name. - * @param blob The blob name. - * @param tier Indicates the tier to be set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setTierAsync(String containerName, String blob, AccessTier tier, String snapshot, - String versionId, Integer timeout, RehydratePriority rehydratePriority, String requestId, String leaseId, - String ifTags, Context context) { - return setTierWithResponseAsync(containerName, blob, tier, snapshot, versionId, timeout, rehydratePriority, - requestId, leaseId, ifTags, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage - * account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's - * tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines - * Hot/Cool/Archive storage type. This operation does not update the blob's ETag. - * - * @param containerName The container name. - * @param blob The blob name. - * @param tier Indicates the tier to be set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setTierNoCustomHeadersWithResponseAsync(String containerName, String blob, - AccessTier tier, String snapshot, String versionId, Integer timeout, RehydratePriority rehydratePriority, - String requestId, String leaseId, String ifTags) { - return FluxUtil - .withContext(context -> setTierNoCustomHeadersWithResponseAsync(containerName, blob, tier, snapshot, - versionId, timeout, rehydratePriority, requestId, leaseId, ifTags, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage - * account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's - * tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines - * Hot/Cool/Archive storage type. This operation does not update the blob's ETag. - * - * @param containerName The container name. - * @param blob The blob name. - * @param tier Indicates the tier to be set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setTierNoCustomHeadersWithResponseAsync(String containerName, String blob, - AccessTier tier, String snapshot, String versionId, Integer timeout, RehydratePriority rehydratePriority, - String requestId, String leaseId, String ifTags, Context context) { - final String comp = "tier"; - final String accept = "application/xml"; - return service - .setTierNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, snapshot, versionId, timeout, tier, - rehydratePriority, this.client.getVersion(), requestId, leaseId, ifTags, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage - * account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's - * tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines - * Hot/Cool/Archive storage type. This operation does not update the blob's ETag. - * - * @param containerName The container name. - * @param blob The blob name. - * @param tier Indicates the tier to be set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setTierWithResponse(String containerName, String blob, - AccessTier tier, String snapshot, String versionId, Integer timeout, RehydratePriority rehydratePriority, - String requestId, String leaseId, String ifTags, Context context) { - try { - final String comp = "tier"; - final String accept = "application/xml"; - return service.setTierSync(this.client.getUrl(), containerName, blob, comp, snapshot, versionId, timeout, - tier, rehydratePriority, this.client.getVersion(), requestId, leaseId, ifTags, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage - * account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's - * tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines - * Hot/Cool/Archive storage type. This operation does not update the blob's ETag. - * - * @param containerName The container name. - * @param blob The blob name. - * @param tier Indicates the tier to be set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setTier(String containerName, String blob, AccessTier tier, String snapshot, String versionId, - Integer timeout, RehydratePriority rehydratePriority, String requestId, String leaseId, String ifTags) { - setTierWithResponse(containerName, blob, tier, snapshot, versionId, timeout, rehydratePriority, requestId, - leaseId, ifTags, Context.NONE); - } - - /** - * The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage - * account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's - * tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines - * Hot/Cool/Archive storage type. This operation does not update the blob's ETag. - * - * @param containerName The container name. - * @param blob The blob name. - * @param tier Indicates the tier to be set on the blob. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param rehydratePriority Optional: Indicates the priority with which to rehydrate an archived blob. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setTierNoCustomHeadersWithResponse(String containerName, String blob, AccessTier tier, - String snapshot, String versionId, Integer timeout, RehydratePriority rehydratePriority, String requestId, - String leaseId, String ifTags, Context context) { - try { - final String comp = "tier"; - final String accept = "application/xml"; - return service.setTierNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, snapshot, - versionId, timeout, tier, rehydratePriority, this.client.getVersion(), requestId, leaseId, ifTags, - accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoWithResponseAsync(String containerName, - String blob, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> getAccountInfoWithResponseAsync(containerName, blob, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoWithResponseAsync(String containerName, - String blob, Integer timeout, String requestId, Context context) { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service - .getAccountInfo(this.client.getUrl(), containerName, blob, restype, comp, timeout, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccountInfoAsync(String containerName, String blob, Integer timeout, String requestId) { - return getAccountInfoWithResponseAsync(containerName, blob, timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccountInfoAsync(String containerName, String blob, Integer timeout, String requestId, - Context context) { - return getAccountInfoWithResponseAsync(containerName, blob, timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId) { - return FluxUtil.withContext( - context -> getAccountInfoNoCustomHeadersWithResponseAsync(containerName, blob, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, Context context) { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service - .getAccountInfoNoCustomHeaders(this.client.getUrl(), containerName, blob, restype, comp, timeout, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getAccountInfoWithResponse(String containerName, String blob, - Integer timeout, String requestId, Context context) { - try { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.getAccountInfoSync(this.client.getUrl(), containerName, blob, restype, comp, timeout, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void getAccountInfo(String containerName, String blob, Integer timeout, String requestId) { - getAccountInfoWithResponse(containerName, blob, timeout, requestId, Context.NONE); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getAccountInfoNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - String requestId, Context context) { - try { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.getAccountInfoNoCustomHeadersSync(this.client.getUrl(), containerName, blob, restype, comp, - timeout, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Query operation enables users to select/project on blob data by providing simple query expressions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param queryRequest the query request. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> queryWithResponseAsync(String containerName, - String blob, String snapshot, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - QueryRequest queryRequest, CpkInfo cpkInfo) { - return FluxUtil - .withContext( - context -> queryWithResponseAsync(containerName, blob, snapshot, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, queryRequest, cpkInfo, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Query operation enables users to select/project on blob data by providing simple query expressions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param queryRequest the query request. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> queryWithResponseAsync(String containerName, - String blob, String snapshot, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - QueryRequest queryRequest, CpkInfo cpkInfo, Context context) { - final String comp = "query"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .query(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, this.client.getVersion(), requestId, queryRequest, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Query operation enables users to select/project on blob data by providing simple query expressions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param queryRequest the query request. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux queryAsync(String containerName, String blob, String snapshot, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, QueryRequest queryRequest, CpkInfo cpkInfo) { - return queryWithResponseAsync(containerName, blob, snapshot, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, queryRequest, cpkInfo) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Query operation enables users to select/project on blob data by providing simple query expressions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param queryRequest the query request. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux queryAsync(String containerName, String blob, String snapshot, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, QueryRequest queryRequest, CpkInfo cpkInfo, - Context context) { - return queryWithResponseAsync(containerName, blob, snapshot, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, queryRequest, cpkInfo, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Query operation enables users to select/project on blob data by providing simple query expressions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param queryRequest the query request. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono queryNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - QueryRequest queryRequest, CpkInfo cpkInfo) { - return FluxUtil - .withContext(context -> queryNoCustomHeadersWithResponseAsync(containerName, blob, snapshot, timeout, - leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, queryRequest, - cpkInfo, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Query operation enables users to select/project on blob data by providing simple query expressions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param queryRequest the query request. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono queryNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - QueryRequest queryRequest, CpkInfo cpkInfo, Context context) { - final String comp = "query"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .queryNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - queryRequest, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Query operation enables users to select/project on blob data by providing simple query expressions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param queryRequest the query request. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase queryWithResponse(String containerName, String blob, - String snapshot, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - QueryRequest queryRequest, CpkInfo cpkInfo, Context context) { - try { - final String comp = "query"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.querySync(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - queryRequest, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Query operation enables users to select/project on blob data by providing simple query expressions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param queryRequest the query request. - * @param cpkInfo Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public InputStream query(String containerName, String blob, String snapshot, Integer timeout, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, QueryRequest queryRequest, CpkInfo cpkInfo) { - try { - return queryWithResponse(containerName, blob, snapshot, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, queryRequest, cpkInfo, Context.NONE) - .getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Query operation enables users to select/project on blob data by providing simple query expressions. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param queryRequest the query request. - * @param cpkInfo Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response queryNoCustomHeadersWithResponse(String containerName, String blob, String snapshot, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, QueryRequest queryRequest, CpkInfo cpkInfo, - Context context) { - try { - final String comp = "query"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.queryNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, - leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - queryRequest, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Tags operation enables users to get the tags associated with a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blob tags along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getTagsWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, String snapshot, String versionId, String ifTags, String leaseId) { - return FluxUtil - .withContext(context -> getTagsWithResponseAsync(containerName, blob, timeout, requestId, snapshot, - versionId, ifTags, leaseId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Tags operation enables users to get the tags associated with a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blob tags along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getTagsWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, String snapshot, String versionId, String ifTags, String leaseId, - Context context) { - final String comp = "tags"; - final String accept = "application/xml"; - return service - .getTags(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), requestId, - snapshot, versionId, ifTags, leaseId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Tags operation enables users to get the tags associated with a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blob tags on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getTagsAsync(String containerName, String blob, Integer timeout, String requestId, - String snapshot, String versionId, String ifTags, String leaseId) { - return getTagsWithResponseAsync(containerName, blob, timeout, requestId, snapshot, versionId, ifTags, leaseId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Get Tags operation enables users to get the tags associated with a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blob tags on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getTagsAsync(String containerName, String blob, Integer timeout, String requestId, - String snapshot, String versionId, String ifTags, String leaseId, Context context) { - return getTagsWithResponseAsync(containerName, blob, timeout, requestId, snapshot, versionId, ifTags, leaseId, - context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Get Tags operation enables users to get the tags associated with a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blob tags along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getTagsNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, String snapshot, String versionId, String ifTags, String leaseId) { - return FluxUtil - .withContext(context -> getTagsNoCustomHeadersWithResponseAsync(containerName, blob, timeout, requestId, - snapshot, versionId, ifTags, leaseId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Tags operation enables users to get the tags associated with a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blob tags along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getTagsNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String requestId, String snapshot, String versionId, String ifTags, String leaseId, - Context context) { - final String comp = "tags"; - final String accept = "application/xml"; - return service - .getTagsNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, this.client.getVersion(), - requestId, snapshot, versionId, ifTags, leaseId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Tags operation enables users to get the tags associated with a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blob tags along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getTagsWithResponse(String containerName, String blob, - Integer timeout, String requestId, String snapshot, String versionId, String ifTags, String leaseId, - Context context) { - try { - final String comp = "tags"; - final String accept = "application/xml"; - return service.getTagsSync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, snapshot, versionId, ifTags, leaseId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Tags operation enables users to get the tags associated with a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blob tags. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobTags getTags(String containerName, String blob, Integer timeout, String requestId, String snapshot, - String versionId, String ifTags, String leaseId) { - try { - return getTagsWithResponse(containerName, blob, timeout, requestId, snapshot, versionId, ifTags, leaseId, - Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Tags operation enables users to get the tags associated with a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blob tags along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getTagsNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - String requestId, String snapshot, String versionId, String ifTags, String leaseId, Context context) { - try { - final String comp = "tags"; - final String accept = "application/xml"; - return service.getTagsNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - this.client.getVersion(), requestId, snapshot, versionId, ifTags, leaseId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Tags operation enables users to set tags on a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tags Blob tags. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setTagsWithResponseAsync(String containerName, String blob, - Integer timeout, String versionId, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - String requestId, String ifTags, String leaseId, BlobTags tags) { - return FluxUtil - .withContext(context -> setTagsWithResponseAsync(containerName, blob, timeout, versionId, - transactionalContentMD5, transactionalContentCrc64, requestId, ifTags, leaseId, tags, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Tags operation enables users to set tags on a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tags Blob tags. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setTagsWithResponseAsync(String containerName, String blob, - Integer timeout, String versionId, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - String requestId, String ifTags, String leaseId, BlobTags tags, Context context) { - final String comp = "tags"; - final String accept = "application/xml"; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .setTags(this.client.getUrl(), containerName, blob, comp, this.client.getVersion(), timeout, versionId, - transactionalContentMD5Converted, transactionalContentCrc64Converted, requestId, ifTags, leaseId, tags, - accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Tags operation enables users to set tags on a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tags Blob tags. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setTagsAsync(String containerName, String blob, Integer timeout, String versionId, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, String requestId, String ifTags, - String leaseId, BlobTags tags) { - return setTagsWithResponseAsync(containerName, blob, timeout, versionId, transactionalContentMD5, - transactionalContentCrc64, requestId, ifTags, leaseId, tags) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Tags operation enables users to set tags on a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tags Blob tags. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setTagsAsync(String containerName, String blob, Integer timeout, String versionId, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, String requestId, String ifTags, - String leaseId, BlobTags tags, Context context) { - return setTagsWithResponseAsync(containerName, blob, timeout, versionId, transactionalContentMD5, - transactionalContentCrc64, requestId, ifTags, leaseId, tags, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Set Tags operation enables users to set tags on a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tags Blob tags. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setTagsNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String versionId, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - String requestId, String ifTags, String leaseId, BlobTags tags) { - return FluxUtil - .withContext(context -> setTagsNoCustomHeadersWithResponseAsync(containerName, blob, timeout, versionId, - transactionalContentMD5, transactionalContentCrc64, requestId, ifTags, leaseId, tags, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Tags operation enables users to set tags on a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tags Blob tags. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setTagsNoCustomHeadersWithResponseAsync(String containerName, String blob, - Integer timeout, String versionId, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - String requestId, String ifTags, String leaseId, BlobTags tags, Context context) { - final String comp = "tags"; - final String accept = "application/xml"; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .setTagsNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, this.client.getVersion(), timeout, - versionId, transactionalContentMD5Converted, transactionalContentCrc64Converted, requestId, ifTags, - leaseId, tags, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Set Tags operation enables users to set tags on a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tags Blob tags. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setTagsWithResponse(String containerName, String blob, - Integer timeout, String versionId, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - String requestId, String ifTags, String leaseId, BlobTags tags, Context context) { - try { - final String comp = "tags"; - final String accept = "application/xml"; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service.setTagsSync(this.client.getUrl(), containerName, blob, comp, this.client.getVersion(), - timeout, versionId, transactionalContentMD5Converted, transactionalContentCrc64Converted, requestId, - ifTags, leaseId, tags, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Set Tags operation enables users to set tags on a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tags Blob tags. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setTags(String containerName, String blob, Integer timeout, String versionId, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, String requestId, String ifTags, - String leaseId, BlobTags tags) { - setTagsWithResponse(containerName, blob, timeout, versionId, transactionalContentMD5, transactionalContentCrc64, - requestId, ifTags, leaseId, tags, Context.NONE); - } - - /** - * The Set Tags operation enables users to set tags on a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param versionId The version id parameter is an opaque DateTime value that, when present, specifies the version - * of the blob to operate on. It's for service version 2019-10-10 and newer. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tags Blob tags. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setTagsNoCustomHeadersWithResponse(String containerName, String blob, Integer timeout, - String versionId, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, String requestId, - String ifTags, String leaseId, BlobTags tags, Context context) { - try { - final String comp = "tags"; - final String accept = "application/xml"; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service.setTagsNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, - this.client.getVersion(), timeout, versionId, transactionalContentMD5Converted, - transactionalContentCrc64Converted, requestId, ifTags, leaseId, tags, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlockBlobsImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlockBlobsImpl.java index fa09b463f6bb..2bfa31415cec 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlockBlobsImpl.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlockBlobsImpl.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.storage.blob.implementation; import com.azure.core.annotation.BodyParam; @@ -10,49 +11,30 @@ import com.azure.core.annotation.Host; import com.azure.core.annotation.HostParam; import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; import com.azure.core.annotation.Put; import com.azure.core.annotation.QueryParam; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceInterface; import com.azure.core.annotation.ServiceMethod; import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.Base64Util; import com.azure.core.util.BinaryData; import com.azure.core.util.Context; -import com.azure.core.util.DateTimeRfc1123; import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.implementation.models.BlobStorageExceptionInternal; -import com.azure.storage.blob.implementation.models.BlockBlobsCommitBlockListHeaders; -import com.azure.storage.blob.implementation.models.BlockBlobsGetBlockListHeaders; -import com.azure.storage.blob.implementation.models.BlockBlobsPutBlobFromUrlHeaders; -import com.azure.storage.blob.implementation.models.BlockBlobsStageBlockFromURLHeaders; -import com.azure.storage.blob.implementation.models.BlockBlobsStageBlockHeaders; -import com.azure.storage.blob.implementation.models.BlockBlobsUploadHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobCopySourceTagsMode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.BlockList; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.models.BlockLookupList; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.EncryptionAlgorithmType; -import java.nio.ByteBuffer; -import java.time.OffsetDateTime; -import java.util.Map; -import reactor.core.publisher.Flux; +import com.azure.storage.blob.BlobServiceVersion; import reactor.core.publisher.Mono; /** * An instance of this class provides access to all the operations defined in BlockBlobs. */ public final class BlockBlobsImpl { - /** * The proxy service used to perform REST calls. */ @@ -61,810 +43,203 @@ public final class BlockBlobsImpl { /** * The service client containing this operation class. */ - private final AzureBlobStorageImpl client; + private final ServiceClientClientImpl client; /** * Initializes an instance of BlockBlobsImpl. - * + * * @param client the instance of the service client containing this operation class. */ - BlockBlobsImpl(AzureBlobStorageImpl client) { + BlockBlobsImpl(ServiceClientClientImpl client) { this.service = RestProxy.create(BlockBlobsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } /** - * The interface defining all the services for AzureBlobStorageBlockBlobs to be used by the proxy service to perform - * REST calls. + * Gets Service version. + * + * @return the serviceVersion value. + */ + public BlobServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for ServiceClientClientBlockBlobs to be used by the proxy service to + * perform REST calls. */ @Host("{url}") - @ServiceInterface(name = "AzureBlobStorageBloc") + @ServiceInterface(name = "ServiceClientClientB") public interface BlockBlobsService { - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> upload(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") Flux body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> uploadNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") Flux body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> upload(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> uploadNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase uploadSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response uploadNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> putBlobFromUrl(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-source-if-tags") String sourceIfTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-tags") String blobTagsString, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-copy-source-blob-properties") Boolean copySourceBlobProperties, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("x-ms-copy-source-tag-option") BlobCopySourceTagsMode copySourceTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> putBlobFromUrlNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-source-if-tags") String sourceIfTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-tags") String blobTagsString, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-copy-source-blob-properties") Boolean copySourceBlobProperties, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("x-ms-copy-source-tag-option") BlobCopySourceTagsMode copySourceTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase putBlobFromUrlSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-source-if-tags") String sourceIfTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-tags") String blobTagsString, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-copy-source-blob-properties") Boolean copySourceBlobProperties, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("x-ms-copy-source-tag-option") BlobCopySourceTagsMode copySourceTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response putBlobFromUrlNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-source-if-tags") String sourceIfTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-tags") String blobTagsString, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-copy-source-blob-properties") Boolean copySourceBlobProperties, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("x-ms-copy-source-tag-option") BlobCopySourceTagsMode copySourceTags, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> stageBlock(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") Flux body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> stageBlockNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") Flux body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> stageBlock(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> stageBlockNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?BlockBlob") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase stageBlockSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> upload(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("x-ms-blob-type") String blobType, @HeaderParam("Accept") String accept, + @BodyParam("application/octet-stream") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?BlockBlob") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response stageBlockNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("x-ms-blob-type") String blobType, @HeaderParam("Accept") String accept, + @BodyParam("application/octet-stream") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?BlockBlob&fromUrl") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> stageBlockFromURL(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putBlobFromUrl(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-copy-source") String sourceUrl, - @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-copy-source") String copySource, + @HeaderParam("x-ms-blob-type") String blobType, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?BlockBlob&fromUrl") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> stageBlockFromURLNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-copy-source") String sourceUrl, - @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putBlobFromUrlSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("x-ms-copy-source") String copySource, @HeaderParam("x-ms-blob-type") String blobType, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=block") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase stageBlockFromURLSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-copy-source") String sourceUrl, - @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> stageBlock(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @QueryParam("blockid") String blockId, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, + @BodyParam("application/octet-stream") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=block") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response stageBlockFromURLNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("blockid") String blockId, - @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-copy-source") String sourceUrl, - @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response stageBlockSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @QueryParam("blockid") String blockId, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, + @BodyParam("application/octet-stream") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=block&fromURL") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> commitBlockList(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> stageBlockFromUrl(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @BodyParam("application/xml") BlockLookupList blocks, - @HeaderParam("Accept") String accept, Context context); + @QueryParam("blockid") String blockId, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("x-ms-copy-source") String sourceUrl, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=block&fromURL") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> commitBlockListNoCustomHeaders(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response stageBlockFromUrlSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @BodyParam("application/xml") BlockLookupList blocks, - @HeaderParam("Accept") String accept, Context context); + @QueryParam("blockid") String blockId, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("x-ms-copy-source") String sourceUrl, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=blocklist") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase commitBlockListSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> commitBlockList(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @BodyParam("application/xml") BlockLookupList blocks, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("Accept") String accept, @BodyParam("application/xml") BinaryData blocks, + RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=blocklist") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response commitBlockListNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-access-tier") AccessTier tier, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @BodyParam("application/xml") BlockLookupList blocks, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getBlockList(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("blocklisttype") BlockListType listType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getBlockListNoCustomHeaders(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response commitBlockListSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("blocklisttype") BlockListType listType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("Accept") String accept, @BodyParam("application/xml") BinaryData blocks, + RequestOptions requestOptions, Context context); - @Get("/{containerName}/{blob}") + @Get("/{containerName}/{blob}?comp=blocklist") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getBlockListSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getBlockList(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("blocklisttype") BlockListType listType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); + @QueryParam("blocklisttype") String listType, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); - @Get("/{containerName}/{blob}") + @Get("/{containerName}/{blob}?comp=blocklist") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getBlockListNoCustomHeadersSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getBlockListSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("blocklisttype") BlockListType listType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - } - - /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadWithResponseAsync(String containerName, String blob, - long contentLength, Flux body, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> uploadWithResponseAsync(containerName, blob, contentLength, body, timeout, - transactionalContentMD5, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, - legalHold, transactionalContentCrc64, structuredBodyType, structuredContentLength, blobHttpHeaders, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + @QueryParam("blocklisttype") String listType, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/{containerName}/{blob}?comp=query") + @ExpectedResponses({ 200, 206 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> query(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, + @BodyParam("application/xml") BinaryData queryRequest, RequestOptions requestOptions, Context context); + + @Post("/{containerName}/{blob}?comp=query") + @ExpectedResponses({ 200, 206 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response querySync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, + @BodyParam("application/xml") BinaryData queryRequest, RequestOptions requestOptions, Context context); } /** @@ -872,258 +247,107 @@ public Mono> uploadWithResponseAsync * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadWithResponseAsync(String containerName, String blob, - long contentLength, Flux body, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { + public Mono> uploadWithResponseAsync(long contentLength, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .upload(this.client.getUrl(), containerName, blob, blobType, timeout, transactionalContentMD5Converted, - contentLength, contentType, contentEncoding, contentLanguage, contentMd5Converted, cacheControl, - metadata, leaseId, contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, - encryptionScope, tier, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, - ifTags, this.client.getVersion(), requestId, blobTagsString, immutabilityPolicyExpiryConverted, - immutabilityPolicyMode, legalHold, transactionalContentCrc64Converted, structuredBodyType, - structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadAsync(String containerName, String blob, long contentLength, Flux body, - Integer timeout, byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return uploadWithResponseAsync(containerName, blob, contentLength, body, timeout, transactionalContentMD5, - metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, - blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, transactionalContentCrc64, - structuredBodyType, structuredContentLength, blobHttpHeaders, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadAsync(String containerName, String blob, long contentLength, Flux body, - Integer timeout, byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - return uploadWithResponseAsync(containerName, blob, contentLength, body, timeout, transactionalContentMD5, - metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, - blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, transactionalContentCrc64, - structuredBodyType, structuredContentLength, blobHttpHeaders, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.upload(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + contentLength, blobType, accept, body, requestOptions, context)); } /** @@ -1131,4451 +355,1182 @@ public Mono uploadAsync(String containerName, String blob, long contentLen * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Flux body, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> uploadNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, body, - timeout, transactionalContentMD5, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, - legalHold, transactionalContentCrc64, structuredBodyType, structuredContentLength, blobHttpHeaders, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response uploadWithResponse(long contentLength, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String blobType = "BlockBlob"; + final String accept = "application/json"; + return service.uploadSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), contentLength, blobType, accept, body, + requestOptions, Context.NONE); } /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. + * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given + * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob + * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial + * updates to a block blob’s contents using a source URL, use the Put Block from URL API in conjunction with Put + * Block List. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-source-if-tagsStringNoSpecify a SQL where clause on blob tags to operate + * only on blobs with a matching value.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-copy-source-blob-propertiesBooleanNoOptional, default is true. Indicates + * if properties from the source blob should be copied.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
x-ms-copy-source-tagsStringNoOptional, default 'replace'. Indicates if source + * tags should be copied or replaced with the tags specified by x-ms-tags.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Flux body, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { + public Mono> putBlobFromUrlWithResponseAsync(long contentLength, String copySource, + RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .uploadNoCustomHeaders(this.client.getUrl(), containerName, blob, blobType, timeout, - transactionalContentMD5Converted, contentLength, contentType, contentEncoding, contentLanguage, - contentMd5Converted, cacheControl, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - blobTagsString, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, - transactionalContentCrc64Converted, structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadWithResponseAsync(String containerName, String blob, - long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> uploadWithResponseAsync(containerName, blob, contentLength, body, timeout, - transactionalContentMD5, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, - legalHold, transactionalContentCrc64, structuredBodyType, structuredContentLength, blobHttpHeaders, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.putBlobFromUrl(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + contentLength, copySource, blobType, accept, requestOptions, context)); } /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. + * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given + * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob + * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial + * updates to a block blob’s contents using a source URL, use the Put Block from URL API in conjunction with Put + * Block List. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-source-if-tagsStringNoSpecify a SQL where clause on blob tags to operate + * only on blobs with a matching value.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-copy-source-blob-propertiesBooleanNoOptional, default is true. Indicates + * if properties from the source blob should be copied.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
x-ms-copy-source-tagsStringNoOptional, default 'replace'. Indicates if source + * tags should be copied or replaced with the tags specified by x-ms-tags.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadWithResponseAsync(String containerName, String blob, - long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { + public Response putBlobFromUrlWithResponse(long contentLength, String copySource, + RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .upload(this.client.getUrl(), containerName, blob, blobType, timeout, transactionalContentMD5Converted, - contentLength, contentType, contentEncoding, contentLanguage, contentMd5Converted, cacheControl, - metadata, leaseId, contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, - encryptionScope, tier, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, - ifTags, this.client.getVersion(), requestId, blobTagsString, immutabilityPolicyExpiryConverted, - immutabilityPolicyMode, legalHold, transactionalContentCrc64Converted, structuredBodyType, - structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + final String accept = "application/json"; + return service.putBlobFromUrlSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + contentLength, copySource, blobType, accept, requestOptions, Context.NONE); } /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. + * The Stage Block operation creates a new block to be committed as part of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadAsync(String containerName, String blob, long contentLength, BinaryData body, - Integer timeout, byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return uploadWithResponseAsync(containerName, blob, contentLength, body, timeout, transactionalContentMD5, - metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, - blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, transactionalContentCrc64, - structuredBodyType, structuredContentLength, blobHttpHeaders, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + public Mono> stageBlockWithResponseAsync(String blockId, long contentLength, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.stageBlock(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + blockId, contentLength, accept, body, requestOptions, context)); } /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. + * The Stage Block operation creates a new block to be committed as part of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadAsync(String containerName, String blob, long contentLength, BinaryData body, - Integer timeout, byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - return uploadWithResponseAsync(containerName, blob, contentLength, body, timeout, transactionalContentMD5, - metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, - blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, transactionalContentCrc64, - structuredBodyType, structuredContentLength, blobHttpHeaders, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + public Response stageBlockWithResponse(String blockId, long contentLength, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return service.stageBlockSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), blockId, contentLength, accept, body, requestOptions, + Context.NONE); } /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. + * The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are + * read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-rangeStringNoBytes of source data in the specified + * range.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param sourceUrl Specify a URL to the copy source. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> uploadNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, body, - timeout, transactionalContentMD5, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, - legalHold, transactionalContentCrc64, structuredBodyType, structuredContentLength, blobHttpHeaders, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. + public Mono> stageBlockFromUrlWithResponseAsync(String blockId, long contentLength, String sourceUrl, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.stageBlockFromUrl(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + blockId, contentLength, sourceUrl, accept, requestOptions, context)); + } + + /** + * The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are + * read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-rangeStringNoBytes of source data in the specified + * range.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less + * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter + * must be the same size for each block. * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + * @param sourceUrl Specify a URL to the copy source. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .uploadNoCustomHeaders(this.client.getUrl(), containerName, blob, blobType, timeout, - transactionalContentMD5Converted, contentLength, contentType, contentEncoding, contentLanguage, - contentMd5Converted, cacheControl, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - blobTagsString, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, - transactionalContentCrc64Converted, structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response stageBlockFromUrlWithResponse(String blockId, long contentLength, String sourceUrl, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.stageBlockFromUrlSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + blockId, contentLength, sourceUrl, accept, requestOptions, Context.NONE); } /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. + * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order + * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block + * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then + * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the + * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the + * block, whichever list it may belong to. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     committed (Optional): [
+     *         String (Optional)
+     *     ]
+     *     uncommitted (Optional): [
+     *         String (Optional)
+     *     ]
+     *     latest (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param blocks Blob Blocks. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase uploadWithResponse(String containerName, String blob, - long contentLength, BinaryData body, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - try { - final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service.uploadSync(this.client.getUrl(), containerName, blob, blobType, timeout, - transactionalContentMD5Converted, contentLength, contentType, contentEncoding, contentLanguage, - contentMd5Converted, cacheControl, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - blobTagsString, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, - transactionalContentCrc64Converted, structuredBodyType, structuredContentLength, body, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Mono> commitBlockListWithResponseAsync(BinaryData blocks, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.commitBlockList(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + blocks, requestOptions, context)); } /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order + * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block + * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then + * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the + * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the + * block, whichever list it may belong to. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     committed (Optional): [
+     *         String (Optional)
+     *     ]
+     *     uncommitted (Optional): [
+     *         String (Optional)
+     *     ]
+     *     latest (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param blocks Blob Blocks. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void upload(String containerName, String blob, long contentLength, BinaryData body, Integer timeout, - byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, byte[] transactionalContentCrc64, - String structuredBodyType, Long structuredContentLength, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - uploadWithResponse(containerName, blob, contentLength, body, timeout, transactionalContentMD5, metadata, - leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobTagsString, - immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, transactionalContentCrc64, structuredBodyType, - structuredContentLength, blobHttpHeaders, cpkInfo, encryptionScopeParam, Context.NONE); + public Response commitBlockListWithResponse(BinaryData blocks, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.commitBlockListSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + blocks, requestOptions, Context.NONE); } /** - * The Upload Block Blob operation updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the - * existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a - * block blob, use the Put Block List operation. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadNoCustomHeadersWithResponse(String containerName, String blob, long contentLength, - BinaryData body, Integer timeout, byte[] transactionalContentMD5, Map metadata, String leaseId, - AccessTier tier, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - byte[] transactionalContentCrc64, String structuredBodyType, Long structuredContentLength, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service.uploadNoCustomHeadersSync(this.client.getUrl(), containerName, blob, blobType, timeout, - transactionalContentMD5Converted, contentLength, contentType, contentEncoding, contentLanguage, - contentMd5Converted, cacheControl, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - blobTagsString, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, - transactionalContentCrc64Converted, structuredBodyType, structuredContentLength, body, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     committedBlocks (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             size: long (Required)
+     *         }
+     *     ]
+     *     uncommittedBlocks (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both + * lists together. Allowed values: "committed", "uncommitted", "all". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return contains the committed and uncommitted blocks in a block blob along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getBlockListWithResponseAsync(String listType, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return FluxUtil.withContext(context -> service.getBlockList(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + listType, accept, requestOptions, context)); } /** - * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given - * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob - * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial - * updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put - * Block List. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be - * copied. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     committedBlocks (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             size: long (Required)
+     *         }
+     *     ]
+     *     uncommittedBlocks (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both + * lists together. Allowed values: "committed", "uncommitted", "all". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return contains the committed and uncommitted blocks in a block blob along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> putBlobFromUrlWithResponseAsync( - String containerName, String blob, long contentLength, String copySource, Integer timeout, - byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, String requestId, byte[] sourceContentMD5, - String blobTagsString, Boolean copySourceBlobProperties, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> putBlobFromUrlWithResponseAsync(containerName, blob, contentLength, copySource, - timeout, transactionalContentMD5, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, - sourceIfTags, requestId, sourceContentMD5, blobTagsString, copySourceBlobProperties, - copySourceAuthorization, copySourceTags, blobHttpHeaders, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response getBlockListWithResponse(String listType, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return service.getBlockListSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), listType, accept, requestOptions, Context.NONE); } /** - * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given - * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob - * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial - * updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put - * Block List. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be - * copied. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * The Query operation enables users to select/project on blob data by providing simple query expressions. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     queryType: String(SQL) (Required)
+     *     expression: String (Required)
+     *     inputSerialization (Optional): {
+     *         format (Required): {
+     *             type: String(delimited/json/arrow/parquet) (Required)
+     *             delimitedTextConfiguration (Optional): {
+     *                 columnSeparator: String (Optional)
+     *                 fieldQuote: String (Optional)
+     *                 recordSeparator: String (Optional)
+     *                 escapeChar: String (Optional)
+     *                 headersPresent: Boolean (Optional)
+     *             }
+     *             jsonTextConfiguration (Optional): {
+     *                 recordSeparator: String (Optional)
+     *             }
+     *             arrowConfiguration (Optional): {
+     *                 schema (Required): [
+     *                      (Required){
+     *                         type: String (Required)
+     *                         name: String (Optional)
+     *                         precision: Integer (Optional)
+     *                         scale: Integer (Optional)
+     *                     }
+     *                 ]
+     *             }
+     *             parquetTextConfiguration (Optional): {
+     *                  (Optional): {
+     *                     String: BinaryData (Required)
+     *                 }
+     *             }
+     *         }
+     *     }
+     *     outputSerialization (Optional): (recursive schema, see outputSerialization above)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param queryRequest The query request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> putBlobFromUrlWithResponseAsync( - String containerName, String blob, long contentLength, String copySource, Integer timeout, - byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, String requestId, byte[] sourceContentMD5, - String blobTagsString, Boolean copySourceBlobProperties, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - return service - .putBlobFromUrl(this.client.getUrl(), containerName, blob, blobType, timeout, - transactionalContentMD5Converted, contentLength, contentType, contentEncoding, contentLanguage, - contentMd5Converted, cacheControl, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSinceConverted, - sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, sourceIfTags, - this.client.getVersion(), requestId, sourceContentMD5Converted, blobTagsString, copySource, - copySourceBlobProperties, copySourceAuthorization, copySourceTags, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Mono> queryWithResponseAsync(BinaryData queryRequest, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/octet-stream"; + return FluxUtil.withContext( + context -> service.query(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, queryRequest, requestOptions, context)); } /** - * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given - * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob - * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial - * updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put - * Block List. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be - * copied. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono putBlobFromUrlAsync(String containerName, String blob, long contentLength, String copySource, - Integer timeout, byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, String requestId, byte[] sourceContentMD5, - String blobTagsString, Boolean copySourceBlobProperties, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return putBlobFromUrlWithResponseAsync(containerName, blob, contentLength, copySource, timeout, - transactionalContentMD5, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, sourceIfTags, - requestId, sourceContentMD5, blobTagsString, copySourceBlobProperties, copySourceAuthorization, - copySourceTags, blobHttpHeaders, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given - * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob - * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial - * updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put - * Block List. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be - * copied. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono putBlobFromUrlAsync(String containerName, String blob, long contentLength, String copySource, - Integer timeout, byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, String requestId, byte[] sourceContentMD5, - String blobTagsString, Boolean copySourceBlobProperties, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - return putBlobFromUrlWithResponseAsync(containerName, blob, contentLength, copySource, timeout, - transactionalContentMD5, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, sourceIfTags, - requestId, sourceContentMD5, blobTagsString, copySourceBlobProperties, copySourceAuthorization, - copySourceTags, blobHttpHeaders, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given - * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob - * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial - * updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put - * Block List. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be - * copied. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> putBlobFromUrlNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, String copySource, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String sourceIfTags, String requestId, byte[] sourceContentMD5, String blobTagsString, - Boolean copySourceBlobProperties, String copySourceAuthorization, BlobCopySourceTagsMode copySourceTags, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> putBlobFromUrlNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, - copySource, timeout, transactionalContentMD5, metadata, leaseId, tier, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, - sourceIfMatch, sourceIfNoneMatch, sourceIfTags, requestId, sourceContentMD5, blobTagsString, - copySourceBlobProperties, copySourceAuthorization, copySourceTags, blobHttpHeaders, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given - * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob - * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial - * updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put - * Block List. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be - * copied. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> putBlobFromUrlNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, String copySource, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String sourceIfTags, String requestId, byte[] sourceContentMD5, String blobTagsString, - Boolean copySourceBlobProperties, String copySourceAuthorization, BlobCopySourceTagsMode copySourceTags, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - return service - .putBlobFromUrlNoCustomHeaders(this.client.getUrl(), containerName, blob, blobType, timeout, - transactionalContentMD5Converted, contentLength, contentType, contentEncoding, contentLanguage, - contentMd5Converted, cacheControl, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSinceConverted, - sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, sourceIfTags, - this.client.getVersion(), requestId, sourceContentMD5Converted, blobTagsString, copySource, - copySourceBlobProperties, copySourceAuthorization, copySourceTags, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given - * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob - * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial - * updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put - * Block List. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be - * copied. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase putBlobFromUrlWithResponse(String containerName, - String blob, long contentLength, String copySource, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String sourceIfTags, String requestId, byte[] sourceContentMD5, String blobTagsString, - Boolean copySourceBlobProperties, String copySourceAuthorization, BlobCopySourceTagsMode copySourceTags, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - return service.putBlobFromUrlSync(this.client.getUrl(), containerName, blob, blobType, timeout, - transactionalContentMD5Converted, contentLength, contentType, contentEncoding, contentLanguage, - contentMd5Converted, cacheControl, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSinceConverted, - sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, sourceIfTags, - this.client.getVersion(), requestId, sourceContentMD5Converted, blobTagsString, copySource, - copySourceBlobProperties, copySourceAuthorization, copySourceTags, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given - * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob - * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial - * updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put - * Block List. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be - * copied. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void putBlobFromUrl(String containerName, String blob, long contentLength, String copySource, - Integer timeout, byte[] transactionalContentMD5, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String sourceIfTags, String requestId, byte[] sourceContentMD5, - String blobTagsString, Boolean copySourceBlobProperties, String copySourceAuthorization, - BlobCopySourceTagsMode copySourceTags, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - putBlobFromUrlWithResponse(containerName, blob, contentLength, copySource, timeout, transactionalContentMD5, - metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, - sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, sourceIfTags, requestId, - sourceContentMD5, blobTagsString, copySourceBlobProperties, copySourceAuthorization, copySourceTags, - blobHttpHeaders, cpkInfo, encryptionScopeParam, Context.NONE); - } - - /** - * The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given - * URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob - * from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial - * updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put - * Block List. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param sourceIfTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be - * copied. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param copySourceTags Optional, default 'replace'. Indicates if source tags should be copied or replaced with the - * tags specified by x-ms-tags. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response putBlobFromUrlNoCustomHeadersWithResponse(String containerName, String blob, - long contentLength, String copySource, Integer timeout, byte[] transactionalContentMD5, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String sourceIfTags, String requestId, byte[] sourceContentMD5, String blobTagsString, - Boolean copySourceBlobProperties, String copySourceAuthorization, BlobCopySourceTagsMode copySourceTags, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String blobType = "BlockBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - return service.putBlobFromUrlNoCustomHeadersSync(this.client.getUrl(), containerName, blob, blobType, - timeout, transactionalContentMD5Converted, contentLength, contentType, contentEncoding, contentLanguage, - contentMd5Converted, cacheControl, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSinceConverted, - sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, sourceIfTags, - this.client.getVersion(), requestId, sourceContentMD5Converted, blobTagsString, copySource, - copySourceBlobProperties, copySourceAuthorization, copySourceTags, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockWithResponseAsync(String containerName, - String blob, String blockId, long contentLength, Flux body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String leaseId, String requestId, String structuredBodyType, - Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> stageBlockWithResponseAsync(containerName, blob, blockId, contentLength, body, - transactionalContentMD5, transactionalContentCrc64, timeout, leaseId, requestId, structuredBodyType, - structuredContentLength, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockWithResponseAsync(String containerName, - String blob, String blockId, long contentLength, Flux body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String leaseId, String requestId, String structuredBodyType, - Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .stageBlock(this.client.getUrl(), containerName, blob, comp, blockId, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono stageBlockAsync(String containerName, String blob, String blockId, long contentLength, - Flux body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, - String leaseId, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return stageBlockWithResponseAsync(containerName, blob, blockId, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, leaseId, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono stageBlockAsync(String containerName, String blob, String blockId, long contentLength, - Flux body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, - String leaseId, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - return stageBlockWithResponseAsync(containerName, blob, blockId, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, leaseId, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockNoCustomHeadersWithResponseAsync(String containerName, String blob, - String blockId, long contentLength, Flux body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String leaseId, String requestId, String structuredBodyType, - Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> stageBlockNoCustomHeadersWithResponseAsync(containerName, blob, blockId, - contentLength, body, transactionalContentMD5, transactionalContentCrc64, timeout, leaseId, requestId, - structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockNoCustomHeadersWithResponseAsync(String containerName, String blob, - String blockId, long contentLength, Flux body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String leaseId, String requestId, String structuredBodyType, - Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .stageBlockNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, blockId, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockWithResponseAsync(String containerName, - String blob, String blockId, long contentLength, BinaryData body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String leaseId, String requestId, String structuredBodyType, - Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> stageBlockWithResponseAsync(containerName, blob, blockId, contentLength, body, - transactionalContentMD5, transactionalContentCrc64, timeout, leaseId, requestId, structuredBodyType, - structuredContentLength, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockWithResponseAsync(String containerName, - String blob, String blockId, long contentLength, BinaryData body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String leaseId, String requestId, String structuredBodyType, - Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .stageBlock(this.client.getUrl(), containerName, blob, comp, blockId, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono stageBlockAsync(String containerName, String blob, String blockId, long contentLength, - BinaryData body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, - String leaseId, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return stageBlockWithResponseAsync(containerName, blob, blockId, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, leaseId, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono stageBlockAsync(String containerName, String blob, String blockId, long contentLength, - BinaryData body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, - String leaseId, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - return stageBlockWithResponseAsync(containerName, blob, blockId, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, leaseId, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockNoCustomHeadersWithResponseAsync(String containerName, String blob, - String blockId, long contentLength, BinaryData body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String leaseId, String requestId, String structuredBodyType, - Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> stageBlockNoCustomHeadersWithResponseAsync(containerName, blob, blockId, - contentLength, body, transactionalContentMD5, transactionalContentCrc64, timeout, leaseId, requestId, - structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockNoCustomHeadersWithResponseAsync(String containerName, String blob, - String blockId, long contentLength, BinaryData body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String leaseId, String requestId, String structuredBodyType, - Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service - .stageBlockNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, blockId, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase stageBlockWithResponse(String containerName, String blob, - String blockId, long contentLength, BinaryData body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String leaseId, String requestId, String structuredBodyType, - Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service.stageBlockSync(this.client.getUrl(), containerName, blob, comp, blockId, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, this.client.getVersion(), requestId, - structuredBodyType, structuredContentLength, body, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void stageBlock(String containerName, String blob, String blockId, long contentLength, BinaryData body, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, String leaseId, - String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - stageBlockWithResponse(containerName, blob, blockId, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, leaseId, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam, Context.NONE); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response stageBlockNoCustomHeadersWithResponse(String containerName, String blob, String blockId, - long contentLength, BinaryData body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - Integer timeout, String leaseId, String requestId, String structuredBodyType, Long structuredContentLength, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - return service.stageBlockNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, blockId, - contentLength, transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, this.client.getVersion(), - requestId, structuredBodyType, structuredContentLength, body, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from - * a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockFromURLWithResponseAsync( - String containerName, String blob, String blockId, long contentLength, String sourceUrl, String sourceRange, - byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, String leaseId, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String requestId, String copySourceAuthorization, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> stageBlockFromURLWithResponseAsync(containerName, blob, blockId, contentLength, - sourceUrl, sourceRange, sourceContentMD5, sourceContentcrc64, timeout, leaseId, sourceIfModifiedSince, - sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from - * a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockFromURLWithResponseAsync( - String containerName, String blob, String blockId, long contentLength, String sourceUrl, String sourceRange, - byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, String leaseId, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String requestId, String copySourceAuthorization, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service - .stageBlockFromURL(this.client.getUrl(), containerName, blob, comp, blockId, contentLength, sourceUrl, - sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, timeout, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, leaseId, sourceIfModifiedSinceConverted, - sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, this.client.getVersion(), requestId, - copySourceAuthorization, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from - * a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono stageBlockFromURLAsync(String containerName, String blob, String blockId, long contentLength, - String sourceUrl, String sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, - String leaseId, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return stageBlockFromURLWithResponseAsync(containerName, blob, blockId, contentLength, sourceUrl, sourceRange, - sourceContentMD5, sourceContentcrc64, timeout, leaseId, sourceIfModifiedSince, sourceIfUnmodifiedSince, - sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from - * a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono stageBlockFromURLAsync(String containerName, String blob, String blockId, long contentLength, - String sourceUrl, String sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, - String leaseId, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - return stageBlockFromURLWithResponseAsync(containerName, blob, blockId, contentLength, sourceUrl, sourceRange, - sourceContentMD5, sourceContentcrc64, timeout, leaseId, sourceIfModifiedSince, sourceIfUnmodifiedSince, - sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, encryptionScopeParam, - context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from - * a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String blockId, long contentLength, String sourceUrl, String sourceRange, byte[] sourceContentMD5, - byte[] sourceContentcrc64, Integer timeout, String leaseId, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String requestId, - String copySourceAuthorization, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> stageBlockFromURLNoCustomHeadersWithResponseAsync(containerName, blob, blockId, - contentLength, sourceUrl, sourceRange, sourceContentMD5, sourceContentcrc64, timeout, leaseId, - sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestId, - copySourceAuthorization, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from - * a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String blockId, long contentLength, String sourceUrl, String sourceRange, byte[] sourceContentMD5, - byte[] sourceContentcrc64, Integer timeout, String leaseId, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String requestId, - String copySourceAuthorization, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service - .stageBlockFromURLNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, blockId, contentLength, - sourceUrl, sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, timeout, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, leaseId, sourceIfModifiedSinceConverted, - sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, this.client.getVersion(), requestId, - copySourceAuthorization, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from - * a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase stageBlockFromURLWithResponse(String containerName, - String blob, String blockId, long contentLength, String sourceUrl, String sourceRange, byte[] sourceContentMD5, - byte[] sourceContentcrc64, Integer timeout, String leaseId, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String requestId, - String copySourceAuthorization, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service.stageBlockFromURLSync(this.client.getUrl(), containerName, blob, comp, blockId, - contentLength, sourceUrl, sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, timeout, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, leaseId, - sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, - this.client.getVersion(), requestId, copySourceAuthorization, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from - * a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void stageBlockFromURL(String containerName, String blob, String blockId, long contentLength, - String sourceUrl, String sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, - String leaseId, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - stageBlockFromURLWithResponse(containerName, blob, blockId, contentLength, sourceUrl, sourceRange, - sourceContentMD5, sourceContentcrc64, timeout, leaseId, sourceIfModifiedSince, sourceIfUnmodifiedSince, - sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, encryptionScopeParam, - Context.NONE); - } - - /** - * The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from - * a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less - * than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter - * must be the same size for each block. - * @param contentLength The length of the request. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response stageBlockFromURLNoCustomHeadersWithResponse(String containerName, String blob, - String blockId, long contentLength, String sourceUrl, String sourceRange, byte[] sourceContentMD5, - byte[] sourceContentcrc64, Integer timeout, String leaseId, OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch, String requestId, - String copySourceAuthorization, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "block"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service.stageBlockFromURLNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, - blockId, contentLength, sourceUrl, sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, - timeout, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, leaseId, - sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, - this.client.getVersion(), requestId, copySourceAuthorization, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order - * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block - * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then - * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the - * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the - * block, whichever list it may belong to. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blocks Blob Blocks. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> commitBlockListWithResponseAsync( - String containerName, String blob, BlockLookupList blocks, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> commitBlockListWithResponseAsync(containerName, blob, blocks, timeout, - transactionalContentMD5, transactionalContentCrc64, metadata, leaseId, tier, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, - immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order - * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block - * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then - * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the - * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the - * block, whichever list it may belong to. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blocks Blob Blocks. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> commitBlockListWithResponseAsync( - String containerName, String blob, BlockLookupList blocks, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "blocklist"; - final String accept = "application/xml"; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .commitBlockList(this.client.getUrl(), containerName, blob, comp, timeout, cacheControl, contentType, - contentEncoding, contentLanguage, contentMd5Converted, transactionalContentMD5Converted, - transactionalContentCrc64Converted, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - blobTagsString, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, blocks, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order - * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block - * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then - * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the - * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the - * block, whichever list it may belong to. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blocks Blob Blocks. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono commitBlockListAsync(String containerName, String blob, BlockLookupList blocks, Integer timeout, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Map metadata, String leaseId, - AccessTier tier, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return commitBlockListWithResponseAsync(containerName, blob, blocks, timeout, transactionalContentMD5, - transactionalContentCrc64, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, - blobHttpHeaders, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order - * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block - * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then - * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the - * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the - * block, whichever list it may belong to. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blocks Blob Blocks. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono commitBlockListAsync(String containerName, String blob, BlockLookupList blocks, Integer timeout, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Map metadata, String leaseId, - AccessTier tier, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - return commitBlockListWithResponseAsync(containerName, blob, blocks, timeout, transactionalContentMD5, - transactionalContentCrc64, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, - blobHttpHeaders, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order - * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block - * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then - * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the - * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the - * block, whichever list it may belong to. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blocks Blob Blocks. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> commitBlockListNoCustomHeadersWithResponseAsync(String containerName, String blob, - BlockLookupList blocks, Integer timeout, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> commitBlockListNoCustomHeadersWithResponseAsync(containerName, blob, blocks, - timeout, transactionalContentMD5, transactionalContentCrc64, metadata, leaseId, tier, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, - immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order - * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block - * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then - * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the - * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the - * block, whichever list it may belong to. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blocks Blob Blocks. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> commitBlockListNoCustomHeadersWithResponseAsync(String containerName, String blob, - BlockLookupList blocks, Integer timeout, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "blocklist"; - final String accept = "application/xml"; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .commitBlockListNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, cacheControl, - contentType, contentEncoding, contentLanguage, contentMd5Converted, transactionalContentMD5Converted, - transactionalContentCrc64Converted, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - blobTagsString, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, blocks, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order - * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block - * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then - * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the - * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the - * block, whichever list it may belong to. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blocks Blob Blocks. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase commitBlockListWithResponse(String containerName, - String blob, BlockLookupList blocks, Integer timeout, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Map metadata, String leaseId, AccessTier tier, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "blocklist"; - final String accept = "application/xml"; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.commitBlockListSync(this.client.getUrl(), containerName, blob, comp, timeout, cacheControl, - contentType, contentEncoding, contentLanguage, contentMd5Converted, transactionalContentMD5Converted, - transactionalContentCrc64Converted, metadata, leaseId, contentDisposition, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, - blobTagsString, immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, blocks, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order - * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block - * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then - * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the - * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the - * block, whichever list it may belong to. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blocks Blob Blocks. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void commitBlockList(String containerName, String blob, BlockLookupList blocks, Integer timeout, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Map metadata, String leaseId, - AccessTier tier, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - commitBlockListWithResponse(containerName, blob, blocks, timeout, transactionalContentMD5, - transactionalContentCrc64, metadata, leaseId, tier, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, - blobHttpHeaders, cpkInfo, encryptionScopeParam, Context.NONE); - } - - /** - * The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order - * to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block - * operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then - * committing the new and existing blocks together. You can do this by specifying whether to commit a block from the - * committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the - * block, whichever list it may belong to. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blocks Blob Blocks. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param tier Optional. Indicates the tier to be set on the blob. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response commitBlockListNoCustomHeadersWithResponse(String containerName, String blob, - BlockLookupList blocks, Integer timeout, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - Map metadata, String leaseId, AccessTier tier, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "blocklist"; - final String accept = "application/xml"; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.commitBlockListNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - cacheControl, contentType, contentEncoding, contentLanguage, contentMd5Converted, - transactionalContentMD5Converted, transactionalContentCrc64Converted, metadata, leaseId, - contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, tier, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, blobTagsString, immutabilityPolicyExpiryConverted, - immutabilityPolicyMode, legalHold, blocks, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both - * lists together. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getBlockListWithResponseAsync( - String containerName, String blob, BlockListType listType, String snapshot, Integer timeout, String leaseId, - String ifTags, String requestId) { - return FluxUtil - .withContext(context -> getBlockListWithResponseAsync(containerName, blob, listType, snapshot, timeout, - leaseId, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both - * lists together. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getBlockListWithResponseAsync( - String containerName, String blob, BlockListType listType, String snapshot, Integer timeout, String leaseId, - String ifTags, String requestId, Context context) { - final String comp = "blocklist"; - final String accept = "application/xml"; - return service - .getBlockList(this.client.getUrl(), containerName, blob, comp, snapshot, listType, timeout, leaseId, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both - * lists together. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getBlockListAsync(String containerName, String blob, BlockListType listType, String snapshot, - Integer timeout, String leaseId, String ifTags, String requestId) { - return getBlockListWithResponseAsync(containerName, blob, listType, snapshot, timeout, leaseId, ifTags, - requestId).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both - * lists together. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getBlockListAsync(String containerName, String blob, BlockListType listType, String snapshot, - Integer timeout, String leaseId, String ifTags, String requestId, Context context) { - return getBlockListWithResponseAsync(containerName, blob, listType, snapshot, timeout, leaseId, ifTags, - requestId, context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both - * lists together. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getBlockListNoCustomHeadersWithResponseAsync(String containerName, String blob, - BlockListType listType, String snapshot, Integer timeout, String leaseId, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> getBlockListNoCustomHeadersWithResponseAsync(containerName, blob, listType, - snapshot, timeout, leaseId, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both - * lists together. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getBlockListNoCustomHeadersWithResponseAsync(String containerName, String blob, - BlockListType listType, String snapshot, Integer timeout, String leaseId, String ifTags, String requestId, - Context context) { - final String comp = "blocklist"; - final String accept = "application/xml"; - return service - .getBlockListNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, snapshot, listType, timeout, - leaseId, ifTags, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both - * lists together. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getBlockListWithResponse(String containerName, - String blob, BlockListType listType, String snapshot, Integer timeout, String leaseId, String ifTags, - String requestId, Context context) { - try { - final String comp = "blocklist"; - final String accept = "application/xml"; - return service.getBlockListSync(this.client.getUrl(), containerName, blob, comp, snapshot, listType, - timeout, leaseId, ifTags, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both - * lists together. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockList getBlockList(String containerName, String blob, BlockListType listType, String snapshot, - Integer timeout, String leaseId, String ifTags, String requestId) { - try { - return getBlockListWithResponse(containerName, blob, listType, snapshot, timeout, leaseId, ifTags, - requestId, Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param listType Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both - * lists together. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a + * The Query operation enables users to select/project on blob data by providing simple query expressions. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     queryType: String(SQL) (Required)
+     *     expression: String (Required)
+     *     inputSerialization (Optional): {
+     *         format (Required): {
+     *             type: String(delimited/json/arrow/parquet) (Required)
+     *             delimitedTextConfiguration (Optional): {
+     *                 columnSeparator: String (Optional)
+     *                 fieldQuote: String (Optional)
+     *                 recordSeparator: String (Optional)
+     *                 escapeChar: String (Optional)
+     *                 headersPresent: Boolean (Optional)
+     *             }
+     *             jsonTextConfiguration (Optional): {
+     *                 recordSeparator: String (Optional)
+     *             }
+     *             arrowConfiguration (Optional): {
+     *                 schema (Required): [
+     *                      (Required){
+     *                         type: String (Required)
+     *                         name: String (Optional)
+     *                         precision: Integer (Optional)
+     *                         scale: Integer (Optional)
+     *                     }
+     *                 ]
+     *             }
+     *             parquetTextConfiguration (Optional): {
+     *                  (Optional): {
+     *                     String: BinaryData (Required)
+     *                 }
+     *             }
+     *         }
+     *     }
+     *     outputSerialization (Optional): (recursive schema, see outputSerialization above)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param queryRequest The query request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getBlockListNoCustomHeadersWithResponse(String containerName, String blob, - BlockListType listType, String snapshot, Integer timeout, String leaseId, String ifTags, String requestId, - Context context) { - try { - final String comp = "blocklist"; - final String accept = "application/xml"; - return service.getBlockListNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, snapshot, - listType, timeout, leaseId, ifTags, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Response queryWithResponse(BinaryData queryRequest, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/octet-stream"; + return service.querySync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, queryRequest, requestOptions, Context.NONE); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ContainerBlobsImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ContainerBlobsImpl.java new file mode 100644 index 000000000000..57bf6ac01667 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ContainerBlobsImpl.java @@ -0,0 +1,3030 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.Head; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.storage.blob.BlobServiceVersion; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ContainerBlobs. + */ +public final class ContainerBlobsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ContainerBlobsService service; + + /** + * The service client containing this operation class. + */ + private final ServiceClientClientImpl client; + + /** + * Initializes an instance of ContainerBlobsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ContainerBlobsImpl(ServiceClientClientImpl client) { + this.service + = RestProxy.create(ContainerBlobsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public BlobServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for ServiceClientClientContainerBlobs to be used by the proxy service to + * perform REST calls. + */ + @Host("{url}") + @ServiceInterface(name = "ServiceClientClientC") + public interface ContainerBlobsService { + @Get("/{containerName}/{blob}") + @ExpectedResponses({ 200, 206 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> download(@HostParam("url") String url, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/{containerName}/{blob}") + @ExpectedResponses({ 200, 206 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response downloadSync(@HostParam("url") String url, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Head("/{containerName}/{blob}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getProperties(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Head("/{containerName}/{blob}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getPropertiesSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/{containerName}/{blob}") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> delete(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/{containerName}/{blob}") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=undelete") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> undelete(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=undelete") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response undeleteSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=expiry") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setExpiry(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-expiry-option") String expiryOptions, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=expiry") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setExpirySync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-expiry-option") String expiryOptions, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=properties&SetHTTPHeaders") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setHttpHeaders(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=properties&SetHTTPHeaders") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setHttpHeadersSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=immutabilityPolicies") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setImmutabilityPolicy(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=immutabilityPolicies") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setImmutabilityPolicySync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/{containerName}/{blob}/?comp=immutabilityPolicies") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteImmutabilityPolicy(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/{containerName}/{blob}/?comp=immutabilityPolicies") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteImmutabilityPolicySync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=legalhold") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setLegalHold(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-legal-hold") boolean legalHold, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=legalhold") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setLegalHoldSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-legal-hold") boolean legalHold, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=metadata") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setMetadata(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=metadata") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setMetadataSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=lease&acquire") + @ExpectedResponses({ 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> acquireLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=lease&acquire") + @ExpectedResponses({ 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response acquireLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=lease&release") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> releaseLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=lease&release") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response releaseLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=lease&renew") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renewLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=lease&renew") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renewLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=lease&change") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> changeLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=lease&change") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response changeLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=lease&break") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> breakLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=lease&break") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response breakLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=snapshot") + @ExpectedResponses({ 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createSnapshot(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=snapshot") + @ExpectedResponses({ 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createSnapshotSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=copy") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> startCopyFromUrl(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("x-ms-copy-source") String copySource, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=copy") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response startCopyFromUrlSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("x-ms-copy-source") String copySource, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=copy&sync") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> copyFromUrl(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-copy-source") String copySource, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=copy&sync") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response copyFromUrlSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-copy-source") String copySource, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=copy©id") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> abortCopyFromUrl(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @QueryParam("copyid") String copyId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=copy©id") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response abortCopyFromUrlSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @QueryParam("copyid") String copyId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=tier") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setTier(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-access-tier") String tier, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=tier") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setTierSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-access-tier") String tier, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/{containerName}/{blob}/?restype=account&comp=properties&blob") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAccountInfo(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/{containerName}/{blob}/?restype=account&comp=properties&blob") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAccountInfoSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/{containerName}/{blob}/?comp=tags") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getTags(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @PathParam("blob") String blob, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/{containerName}/{blob}/?comp=tags") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getTagsSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/{containerName}/{blob}/?comp=tags") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setTags(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, + @BodyParam("application/xml") BinaryData tags, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}/?comp=tags") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setTagsSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Accept") String accept, + @BodyParam("application/xml") BinaryData tags, RequestOptions requestOptions, Context context); + } + + /** + * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can + * also call Download to read a snapshot. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-range-get-content-md5BooleanNoWhen set to true and specified together + * with the Range, the service returns the MD5 hash for the range, as long as the range is less than or equal to 4 + * MB in size.
x-ms-range-get-content-crc64BooleanNoOptional. When this header is set to true + * and specified together with the Range header, the service returns the CRC64 hash for the range, as long as the + * range is less than or equal to 4 MB in size.
x-ms-structured-bodyStringNoSpecifies the response content should be returned + * as a structured message and specifies the message schema version and properties.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> downloadWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/octet-stream"; + return FluxUtil + .withContext(context -> service.download(this.client.getUrl(), this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, context)); + } + + /** + * The Download operation reads or downloads a blob from the system, including its metadata and properties. You can + * also call Download to read a snapshot. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-range-get-content-md5BooleanNoWhen set to true and specified together + * with the Range, the service returns the MD5 hash for the range, as long as the range is less than or equal to 4 + * MB in size.
x-ms-range-get-content-crc64BooleanNoOptional. When this header is set to true + * and specified together with the Range header, the service returns the CRC64 hash for the range, as long as the + * range is less than or equal to 4 MB in size.
x-ms-structured-bodyStringNoSpecifies the response content should be returned + * as a structured message and specifies the message schema version and properties.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response downloadWithResponse(RequestOptions requestOptions) { + final String accept = "application/octet-stream"; + return service.downloadSync(this.client.getUrl(), this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, Context.NONE); + } + + /** + * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties + * for the blob. It does not return the content of the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getProperties(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); + } + + /** + * The Get Properties operation returns all user-defined metadata, standard HTTP properties, and system properties + * for the blob. It does not return the content of the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPropertiesWithResponse(RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return service.getPropertiesSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, Context.NONE); + } + + /** + * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed + * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, + * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or + * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] + * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently + * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until + * it is permanently removed. Use the List Blobs API and specify the \"include=deleted\" query parameter to discover + * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a + * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP + * status code of 404 (ResourceNotFound). + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
deletetypeStringNoOptional. Only possible value is 'permanent', which + * specifies to permanently delete a blob if blob soft delete is enabled. Allowed values: "Permanent".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-delete-snapshotsStringNoRequired if the blob has associated snapshots. + * Specify one of the following two options: include: Delete the base blob and all of its snapshots. only: Delete + * only the blob's snapshots and not the blob itself. Allowed values: "only", "include".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.delete(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, context)); + } + + /** + * If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed + * from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, + * it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or + * snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] + * (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently + * removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until + * it is permanently removed. Use the List Blobs API and specify the \"include=deleted\" query parameter to discover + * which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a + * soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP + * status code of 404 (ResourceNotFound). + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
deletetypeStringNoOptional. Only possible value is 'permanent', which + * specifies to permanently delete a blob if blob soft delete is enabled. Allowed values: "Permanent".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-delete-snapshotsStringNoRequired if the blob has associated snapshots. + * Specify one of the following two options: include: Delete the base blob and all of its snapshots. only: Delete + * only the blob's snapshots and not the blob itself. Allowed values: "only", "include".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.deleteSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, Context.NONE); + } + + /** + * Undelete a blob that was previously soft deleted. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> undeleteWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.undelete(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, context)); + } + + /** + * Undelete a blob that was previously soft deleted. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response undeleteWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.undeleteSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, Context.NONE); + } + + /** + * Set the expiration time of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-expiry-timeOffsetDateTimeNoThe time this blob will expire.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param expiryOptions Required. Indicates mode of the expiry time. Allowed values: "NeverExpire", + * "RelativeToCreation", "RelativeToNow", "Absolute". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setExpiryWithResponseAsync(String expiryOptions, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.setExpiry(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + expiryOptions, accept, requestOptions, context)); + } + + /** + * Set the expiration time of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-expiry-timeOffsetDateTimeNoThe time this blob will expire.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param expiryOptions Required. Indicates mode of the expiry time. Allowed values: "NeverExpire", + * "RelativeToCreation", "RelativeToNow", "Absolute". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setExpiryWithResponse(String expiryOptions, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setExpirySync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), expiryOptions, accept, requestOptions, Context.NONE); + } + + /** + * The Set HTTP Headers operation sets system properties on the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setHttpHeadersWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.setHttpHeaders(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); + } + + /** + * The Set HTTP Headers operation sets system properties on the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setHttpHeadersWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setHttpHeadersSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, Context.NONE); + } + + /** + * Set the immutability policy of a blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setImmutabilityPolicyWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.setImmutabilityPolicy(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); + } + + /** + * Set the immutability policy of a blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setImmutabilityPolicyWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setImmutabilityPolicySync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, Context.NONE); + } + + /** + * The Delete Immutability Policy operation deletes the immutability policy on the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteImmutabilityPolicyWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteImmutabilityPolicy(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); + } + + /** + * The Delete Immutability Policy operation deletes the immutability policy on the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteImmutabilityPolicyWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.deleteImmutabilityPolicySync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, Context.NONE); + } + + /** + * The Set Legal Hold operation sets a legal hold on the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param legalHold Required. Specifies the legal hold status to set on the blob. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setLegalHoldWithResponseAsync(boolean legalHold, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.setLegalHold(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + legalHold, accept, requestOptions, context)); + } + + /** + * The Set Legal Hold operation sets a legal hold on the blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param legalHold Required. Specifies the legal hold status to set on the blob. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setLegalHoldWithResponse(boolean legalHold, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setLegalHoldSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), legalHold, accept, requestOptions, Context.NONE); + } + + /** + * The Set Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setMetadataWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.setMetadata(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); + } + + /** + * The Set Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setMetadataWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setMetadataSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, Context.NONE); + } + + /** + * The Acquire Lease operation requests a new lease on a blob. The lease lock duration can be 15 to 60 seconds, or + * can be infinite. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-durationIntegerNoSpecifies the duration of the lease, in seconds, + * or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A + * lease duration cannot be changed using renew or change.
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> acquireLeaseWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.acquireLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); + } + + /** + * The Acquire Lease operation requests a new lease on a blob. The lease lock duration can be 15 to 60 seconds, or + * can be infinite. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-durationIntegerNoSpecifies the duration of the lease, in seconds, + * or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A + * lease duration cannot be changed using renew or change.
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response acquireLeaseWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.acquireLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, Context.NONE); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> releaseLeaseWithResponseAsync(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.releaseLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + leaseId, accept, requestOptions, context)); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response releaseLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.releaseLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), leaseId, accept, requestOptions, Context.NONE); + } + + /** + * The Renew Lease operation renews an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> renewLeaseWithResponseAsync(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.renewLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + leaseId, accept, requestOptions, context)); + } + + /** + * The Renew Lease operation renews an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response renewLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.renewLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), leaseId, accept, requestOptions, Context.NONE); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> changeLeaseWithResponseAsync(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.changeLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + leaseId, accept, requestOptions, context)); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response changeLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.changeLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), leaseId, accept, requestOptions, Context.NONE); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-break-periodIntegerNoFor a break operation, proposed duration the + * lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is + * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease + * will not be available before the break period has expired, but the lease may be held for longer than the break + * period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining + * lease period elapses, and an infinite lease breaks immediately.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> breakLeaseWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.breakLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-break-periodIntegerNoFor a break operation, proposed duration the + * lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is + * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease + * will not be available before the break period has expired, but the lease may be held for longer than the break + * period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining + * lease period elapses, and an infinite lease breaks immediately.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response breakLeaseWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.breakLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, Context.NONE); + } + + /** + * The Create Snapshot operation creates a read-only snapshot of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createSnapshotWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createSnapshot(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); + } + + /** + * The Create Snapshot operation creates a read-only snapshot of a blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createSnapshotWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.createSnapshotSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, Context.NONE); + } + + /** + * The Start Copy From URL operation copies a blob or an internet resource to a new blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
x-ms-rehydrate-priorityStringNoIf an object is in rehydrate pending state then + * this header is returned with priority of rehydrate. Valid values are High and Standard. Allowed values: "High", + * "Standard".
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-source-if-tagsStringNoSpecify a SQL where clause on blob tags to operate + * only on blobs with a matching value.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-seal-blobBooleanNoOverrides the sealed state of the destination blob. + * Service version 2019-12-12 and newer.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> startCopyFromUrlWithResponseAsync(String copySource, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.startCopyFromUrl(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + copySource, accept, requestOptions, context)); + } + + /** + * The Start Copy From URL operation copies a blob or an internet resource to a new blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
x-ms-rehydrate-priorityStringNoIf an object is in rehydrate pending state then + * this header is returned with priority of rehydrate. Valid values are High and Standard. Allowed values: "High", + * "Standard".
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-source-if-tagsStringNoSpecify a SQL where clause on blob tags to operate + * only on blobs with a matching value.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-seal-blobBooleanNoOverrides the sealed state of the destination blob. + * Service version 2019-12-12 and newer.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response startCopyFromUrlWithResponse(String copySource, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.startCopyFromUrlSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + copySource, accept, requestOptions, Context.NONE); + } + + /** + * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response + * until the copy is complete. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-copy-source-tagsStringNoOptional, default 'replace'. Indicates if source + * tags should be copied or replaced with the tags specified by x-ms-tags.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> copyFromUrlWithResponseAsync(String copySource, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.copyFromUrl(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + copySource, accept, requestOptions, context)); + } + + /** + * The Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response + * until the copy is complete. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoThe tier to be set on the blob. Allowed values: "P4", + * "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", + * "Cold".
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-copy-source-tagsStringNoOptional, default 'replace'. Indicates if source + * tags should be copied or replaced with the tags specified by x-ms-tags.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response copyFromUrlWithResponse(String copySource, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.copyFromUrlSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), copySource, accept, requestOptions, Context.NONE); + } + + /** + * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with + * zero length and full metadata. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> abortCopyFromUrlWithResponseAsync(String copyId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.abortCopyFromUrl(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), copyId, + accept, requestOptions, context)); + } + + /** + * The Abort Copy From URL operation aborts a pending Copy From URL operation, and leaves a destination blob with + * zero length and full metadata. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copyId The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response abortCopyFromUrlWithResponse(String copyId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.abortCopyFromUrlSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), copyId, + accept, requestOptions, Context.NONE); + } + + /** + * The Set Tier operation sets the tier on a block blob. The operation is allowed on a page blob or block blob, but + * not on an append blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not + * update the blob's ETag. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rehydrate-priorityStringNoIf an object is in rehydrate pending state then + * this header is returned with priority of rehydrate. Valid values are High and Standard. Allowed values: "High", + * "Standard".
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param tier Indicates the tier to be set on the blob. Allowed values: "P4", "P6", "P10", "P15", "P20", "P30", + * "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", "Cold". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setTierWithResponseAsync(String tier, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.setTier(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), tier, accept, requestOptions, context)); + } + + /** + * The Set Tier operation sets the tier on a block blob. The operation is allowed on a page blob or block blob, but + * not on an append blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not + * update the blob's ETag. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rehydrate-priorityStringNoIf an object is in rehydrate pending state then + * this header is returned with priority of rehydrate. Valid values are High and Standard. Allowed values: "High", + * "Standard".
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param tier Indicates the tier to be set on the blob. Allowed values: "P4", "P6", "P10", "P15", "P20", "P30", + * "P40", "P50", "P60", "P70", "P80", "Hot", "Cool", "Archive", "Premium", "Cold". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setTierWithResponse(String tier, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setTierSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), tier, accept, requestOptions, Context.NONE); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccountInfoWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getAccountInfo(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAccountInfoWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.getAccountInfoSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, Context.NONE); + } + + /** + * The Get Blob Tags operation enables users to get tags on a blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobTagSet (Required): [
+     *          (Required){
+     *             key: String (Required)
+     *             value: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents blob tags along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getTagsWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return FluxUtil.withContext( + context -> service.getTags(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, context)); + } + + /** + * The Get Blob Tags operation enables users to get tags on a blob. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobTagSet (Required): [
+     *          (Required){
+     *             key: String (Required)
+     *             value: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents blob tags along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getTagsWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return service.getTagsSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, requestOptions, Context.NONE); + } + + /** + * The Set Tags operation enables users to set tags on a blob. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobTagSet (Required): [
+     *          (Required){
+     *             key: String (Required)
+     *             value: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param tags The blob tags. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setTagsWithResponseAsync(BinaryData tags, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.setTags(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, tags, requestOptions, context)); + } + + /** + * The Set Tags operation enables users to set tags on a blob. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
versionidStringNoThe version id parameter is an opaque DateTime value that, + * when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and + * newer.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobTagSet (Required): [
+     *          (Required){
+     *             key: String (Required)
+     *             value: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param tags The blob tags. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setTagsWithResponse(BinaryData tags, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setTagsSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), accept, tags, requestOptions, Context.NONE); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ContainersImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ContainersImpl.java index d7e23c414237..11b44ff1f891 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ContainersImpl.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ContainersImpl.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.storage.blob.implementation; import com.azure.core.annotation.BodyParam; @@ -18,58 +19,23 @@ import com.azure.core.annotation.ServiceInterface; import com.azure.core.annotation.ServiceMethod; import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; import com.azure.core.http.rest.RestProxy; -import com.azure.core.http.rest.StreamResponse; import com.azure.core.util.BinaryData; import com.azure.core.util.Context; -import com.azure.core.util.DateTimeRfc1123; import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.implementation.models.BlobSignedIdentifierWrapper; -import com.azure.storage.blob.implementation.models.BlobStorageExceptionInternal; -import com.azure.storage.blob.implementation.models.ContainersAcquireLeaseHeaders; -import com.azure.storage.blob.implementation.models.ContainersBreakLeaseHeaders; -import com.azure.storage.blob.implementation.models.ContainersChangeLeaseHeaders; -import com.azure.storage.blob.implementation.models.ContainersCreateHeaders; -import com.azure.storage.blob.implementation.models.ContainersDeleteHeaders; -import com.azure.storage.blob.implementation.models.ContainersFilterBlobsHeaders; -import com.azure.storage.blob.implementation.models.ContainersGetAccessPolicyHeaders; -import com.azure.storage.blob.implementation.models.ContainersGetAccountInfoHeaders; -import com.azure.storage.blob.implementation.models.ContainersGetPropertiesHeaders; -import com.azure.storage.blob.implementation.models.ContainersListBlobFlatSegmentHeaders; -import com.azure.storage.blob.implementation.models.ContainersListBlobHierarchySegmentHeaders; -import com.azure.storage.blob.implementation.models.ContainersReleaseLeaseHeaders; -import com.azure.storage.blob.implementation.models.ContainersRenameHeaders; -import com.azure.storage.blob.implementation.models.ContainersRenewLeaseHeaders; -import com.azure.storage.blob.implementation.models.ContainersRestoreHeaders; -import com.azure.storage.blob.implementation.models.ContainersSetAccessPolicyHeaders; -import com.azure.storage.blob.implementation.models.ContainersSetMetadataHeaders; -import com.azure.storage.blob.implementation.models.ContainersSubmitBatchHeaders; -import com.azure.storage.blob.implementation.models.FilterBlobSegment; -import com.azure.storage.blob.implementation.models.FilterBlobsIncludeItem; -import com.azure.storage.blob.implementation.models.ListBlobsFlatSegmentResponse; -import com.azure.storage.blob.implementation.models.ListBlobsHierarchySegmentResponse; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobContainerEncryptionScope; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.ListBlobsIncludeItem; -import com.azure.storage.blob.models.PublicAccessType; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.time.OffsetDateTime; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; -import reactor.core.publisher.Flux; +import com.azure.storage.blob.BlobServiceVersion; import reactor.core.publisher.Mono; /** * An instance of this class provides access to all the operations defined in Containers. */ public final class ContainersImpl { - /** * The proxy service used to perform REST calls. */ @@ -78,6589 +44,2389 @@ public final class ContainersImpl { /** * The service client containing this operation class. */ - private final AzureBlobStorageImpl client; + private final ServiceClientClientImpl client; /** * Initializes an instance of ContainersImpl. - * + * * @param client the instance of the service client containing this operation class. */ - ContainersImpl(AzureBlobStorageImpl client) { + ContainersImpl(ServiceClientClientImpl client) { this.service = RestProxy.create(ContainersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } /** - * The interface defining all the services for AzureBlobStorageContainers to be used by the proxy service to perform - * REST calls. + * Gets Service version. + * + * @return the serviceVersion value. + */ + public BlobServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for ServiceClientClientContainers to be used by the proxy service to + * perform REST calls. */ @Host("{url}") - @ServiceInterface(name = "AzureBlobStorageCont") + @ServiceInterface(name = "ServiceClientClientC") public interface ContainersService { - - @Put("/{containerName}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> create(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-blob-public-access") PublicAccessType access, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-default-encryption-scope") String defaultEncryptionScope, - @HeaderParam("x-ms-deny-encryption-scope-override") Boolean encryptionScopeOverridePrevented, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> createNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-blob-public-access") PublicAccessType access, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-default-encryption-scope") String defaultEncryptionScope, - @HeaderParam("x-ms-deny-encryption-scope-override") Boolean encryptionScopeOverridePrevented, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @Put("/{containerName}/?restype=container") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase createSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-blob-public-access") PublicAccessType access, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-default-encryption-scope") String defaultEncryptionScope, - @HeaderParam("x-ms-deny-encryption-scope-override") Boolean encryptionScopeOverridePrevented, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> create(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?restype=container") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response createNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("x-ms-blob-public-access") PublicAccessType access, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-default-encryption-scope") String defaultEncryptionScope, - @HeaderParam("x-ms-deny-encryption-scope-override") Boolean encryptionScopeOverridePrevented, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getProperties(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getPropertiesNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getPropertiesSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getProperties(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getPropertiesNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/{containerName}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> delete(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/{containerName}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> deleteNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getPropertiesSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/{containerName}/?restype=container") @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase deleteSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> delete(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/{containerName}/?restype=container") @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response deleteNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setMetadata(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setMetadataNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setMetadataSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setMetadataNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-meta-") Map metadata, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getAccessPolicy( - @HostParam("url") String url, @PathParam("containerName") String containerName, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getAccessPolicyNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?restype=container&comp=metadata") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getAccessPolicySync( - @HostParam("url") String url, @PathParam("containerName") String containerName, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setMetadata(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?restype=container&comp=metadata") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getAccessPolicyNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setMetadataSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container&comp=acl") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setAccessPolicy(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-public-access") PublicAccessType access, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BlobSignedIdentifierWrapper containerAcl, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAccessPolicy(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container&comp=acl") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setAccessPolicyNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-public-access") PublicAccessType access, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BlobSignedIdentifierWrapper containerAcl, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAccessPolicySync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?restype=container&comp=acl") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setAccessPolicySync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-public-access") PublicAccessType access, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BlobSignedIdentifierWrapper containerAcl, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setAccessPolicy(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + @BodyParam("application/xml") BinaryData containerAcl, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?restype=container&comp=acl") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setAccessPolicyNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-public-access") PublicAccessType access, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BlobSignedIdentifierWrapper containerAcl, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> restore(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-deleted-container-name") String deletedContainerName, - @HeaderParam("x-ms-deleted-container-version") String deletedContainerVersion, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> restoreNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-deleted-container-name") String deletedContainerName, - @HeaderParam("x-ms-deleted-container-version") String deletedContainerVersion, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setAccessPolicySync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + @BodyParam("application/xml") BinaryData containerAcl, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?restype=container&comp=undelete") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase restoreSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-deleted-container-name") String deletedContainerName, - @HeaderParam("x-ms-deleted-container-version") String deletedContainerVersion, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> restore(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?restype=container&comp=undelete") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response restoreNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-deleted-container-name") String deletedContainerName, - @HeaderParam("x-ms-deleted-container-version") String deletedContainerVersion, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> rename(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-container-name") String sourceContainerName, - @HeaderParam("x-ms-source-lease-id") String sourceLeaseId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> renameNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-container-name") String sourceContainerName, - @HeaderParam("x-ms-source-lease-id") String sourceLeaseId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response restoreSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?restype=container&comp=rename") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase renameSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-container-name") String sourceContainerName, - @HeaderParam("x-ms-source-lease-id") String sourceLeaseId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rename(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("x-ms-source-container-name") String sourceContainerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?restype=container&comp=rename") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response renameNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-source-container-name") String sourceContainerName, - @HeaderParam("x-ms-source-lease-id") String sourceLeaseId, @HeaderParam("Accept") String accept, - Context context); - - @Post("/{containerName}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono>> submitBatch(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") Flux body, @HeaderParam("Accept") String accept, Context context); - - @Post("/{containerName}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono submitBatchNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") Flux body, @HeaderParam("Accept") String accept, Context context); - - @Post("/{containerName}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono>> submitBatch(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BinaryData body, @HeaderParam("Accept") String accept, Context context); - - @Post("/{containerName}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono submitBatchNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BinaryData body, @HeaderParam("Accept") String accept, Context context); - - @Post("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renameSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("x-ms-source-container-name") String sourceContainerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/{containerName}/?restype=container&comp=batch") @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase submitBatchSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BinaryData body, @HeaderParam("Accept") String accept, Context context); - - @Post("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> submitBatch(@HostParam("url") String url, + @PathParam("containerName") String containerName, @HeaderParam("Content-Type") String multipartContentType, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, @BodyParam("multipart/mixed") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/{containerName}/?restype=container&comp=batch") @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response submitBatchNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BinaryData body, @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> filterBlobs(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("where") String where, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> filterBlobsNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("where") String where, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response submitBatchSync(@HostParam("url") String url, + @PathParam("containerName") String containerName, @HeaderParam("Content-Type") String multipartContentType, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, @BodyParam("multipart/mixed") BinaryData body, + RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container&comp=blobs") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase filterBlobsSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("where") String where, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> filterBlobs(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container&comp=blobs") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response filterBlobsNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("where") String where, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> acquireLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-duration") Integer duration, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> acquireLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-duration") Integer duration, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response filterBlobsSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&acquire") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase acquireLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-duration") Integer duration, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> acquireLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&acquire") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response acquireLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-duration") Integer duration, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> releaseLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> releaseLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase releaseLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response releaseLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response acquireLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&release") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> renewLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> releaseLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&release") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> renewLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response releaseLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&renew") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase renewLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renewLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&renew") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response renewLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> breakLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-break-period") Integer breakPeriod, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> breakLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-break-period") Integer breakPeriod, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renewLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&break") @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase breakLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-break-period") Integer breakPeriod, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> breakLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&break") @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response breakLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-break-period") Integer breakPeriod, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> changeLease(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> changeLeaseNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase changeLeaseSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response changeLeaseNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("comp") String comp, - @QueryParam("restype") String restype, @HeaderParam("x-ms-lease-action") String action, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> listBlobFlatSegment( - @HostParam("url") String url, @PathParam("containerName") String containerName, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, - @QueryParam("marker") String marker, @QueryParam("maxresults") Integer maxresults, - @QueryParam("include") String include, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> listBlobFlatSegmentNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase listBlobFlatSegmentSync( - @HostParam("url") String url, @PathParam("containerName") String containerName, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, - @QueryParam("marker") String marker, @QueryParam("maxresults") Integer maxresults, - @QueryParam("include") String include, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response listBlobFlatSegmentNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response breakLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&change") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> - listBlobHierarchySegment(@HostParam("url") String url, @PathParam("containerName") String containerName, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("prefix") String prefix, @QueryParam("delimiter") String delimiter, - @QueryParam("marker") String marker, @QueryParam("maxresults") Integer maxresults, - @QueryParam("include") String include, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> changeLease(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/?comp=lease&restype=container&change") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> listBlobHierarchySegmentNoCustomHeaders( - @HostParam("url") String url, @PathParam("containerName") String containerName, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, - @QueryParam("delimiter") String delimiter, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response changeLeaseSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-proposed-lease-id") String proposedLeaseId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container&comp=list&flat") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase - listBlobHierarchySegmentSync(@HostParam("url") String url, @PathParam("containerName") String containerName, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("prefix") String prefix, @QueryParam("delimiter") String delimiter, - @QueryParam("marker") String marker, @QueryParam("maxresults") Integer maxresults, - @QueryParam("include") String include, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listBlobFlatSegment(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container&comp=list&flat") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response listBlobHierarchySegmentNoCustomHeadersSync( - @HostParam("url") String url, @PathParam("containerName") String containerName, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, - @QueryParam("delimiter") String delimiter, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listBlobFlatSegmentSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container&comp=list&hierarchy") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getAccountInfo(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listBlobHierarchySegment(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @QueryParam("delimiter") String delimiter, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=container&comp=list&hierarchy") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getAccountInfoNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listBlobHierarchySegmentSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @QueryParam("delimiter") String delimiter, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=account&comp=properties") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getAccountInfoSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAccountInfo(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/{containerName}/?restype=account&comp=properties") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getAccountInfoNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @QueryParam("restype") String restype, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - } - - /** - * creates a new container under the specified account. If the container with the same name already exists, the - * operation fails. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobContainerEncryptionScope Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync(String containerName, - Integer timeout, Map metadata, PublicAccessType access, String requestId, - BlobContainerEncryptionScope blobContainerEncryptionScope) { - return FluxUtil - .withContext(context -> createWithResponseAsync(containerName, timeout, metadata, access, requestId, - blobContainerEncryptionScope, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAccountInfoSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** - * creates a new container under the specified account. If the container with the same name already exists, the + * Creates a new container under the specified account. If the container with the same name already exists, the * operation fails. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobContainerEncryptionScope Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-blob-public-accessStringNoThe public access setting for the container. + * Allowed values: "blob", "container".
x-ms-default-encryption-scopeStringNoOptional. Version 2019-07-07 and later. + * Specifies the default encryption scope to set on the container and use for all future writes.
x-ms-deny-encryption-scope-overrideBooleanNoIf a blob has a lease and the + * lease is of infinite duration then the value of this header is set to true, otherwise it is set to + * false.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync(String containerName, - Integer timeout, Map metadata, PublicAccessType access, String requestId, - BlobContainerEncryptionScope blobContainerEncryptionScope, Context context) { - final String restype = "container"; - final String accept = "application/xml"; - String defaultEncryptionScopeInternal = null; - if (blobContainerEncryptionScope != null) { - defaultEncryptionScopeInternal = blobContainerEncryptionScope.getDefaultEncryptionScope(); - } - String defaultEncryptionScope = defaultEncryptionScopeInternal; - Boolean encryptionScopeOverridePreventedInternal = null; - if (blobContainerEncryptionScope != null) { - encryptionScopeOverridePreventedInternal - = blobContainerEncryptionScope.isEncryptionScopeOverridePrevented(); - } - Boolean encryptionScopeOverridePrevented = encryptionScopeOverridePreventedInternal; - return service - .create(this.client.getUrl(), containerName, restype, timeout, metadata, access, this.client.getVersion(), - requestId, defaultEncryptionScope, encryptionScopeOverridePrevented, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Mono> createWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.create(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, context)); } /** - * creates a new container under the specified account. If the container with the same name already exists, the + * Creates a new container under the specified account. If the container with the same name already exists, the * operation fails. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobContainerEncryptionScope Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-blob-public-accessStringNoThe public access setting for the container. + * Allowed values: "blob", "container".
x-ms-default-encryption-scopeStringNoOptional. Version 2019-07-07 and later. + * Specifies the default encryption scope to set on the container and use for all future writes.
x-ms-deny-encryption-scope-overrideBooleanNoIf a blob has a lease and the + * lease is of infinite duration then the value of this header is set to true, otherwise it is set to + * false.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createAsync(String containerName, Integer timeout, Map metadata, - PublicAccessType access, String requestId, BlobContainerEncryptionScope blobContainerEncryptionScope) { - return createWithResponseAsync(containerName, timeout, metadata, access, requestId, - blobContainerEncryptionScope) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + public Response createWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.createSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, Context.NONE); } /** - * creates a new container under the specified account. If the container with the same name already exists, the - * operation fails. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobContainerEncryptionScope Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * returns all user-defined metadata and system properties for the specified container. The data returned does not + * include the container's list of blobs. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createAsync(String containerName, Integer timeout, Map metadata, - PublicAccessType access, String requestId, BlobContainerEncryptionScope blobContainerEncryptionScope, - Context context) { - return createWithResponseAsync(containerName, timeout, metadata, access, requestId, - blobContainerEncryptionScope, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + public Mono> getPropertiesWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getProperties(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + context)); } /** - * creates a new container under the specified account. If the container with the same name already exists, the - * operation fails. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobContainerEncryptionScope Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + * returns all user-defined metadata and system properties for the specified container. The data returned does not + * include the container's list of blobs. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - Map metadata, PublicAccessType access, String requestId, - BlobContainerEncryptionScope blobContainerEncryptionScope) { - return FluxUtil - .withContext(context -> createNoCustomHeadersWithResponseAsync(containerName, timeout, metadata, access, - requestId, blobContainerEncryptionScope, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response getPropertiesWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.getPropertiesSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + Context.NONE); } /** - * creates a new container under the specified account. If the container with the same name already exists, the - * operation fails. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobContainerEncryptionScope Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * operation marks the specified container for deletion. The container and any blobs contained within it are later + * deleted during garbage collection. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - Map metadata, PublicAccessType access, String requestId, - BlobContainerEncryptionScope blobContainerEncryptionScope, Context context) { - final String restype = "container"; - final String accept = "application/xml"; - String defaultEncryptionScopeInternal = null; - if (blobContainerEncryptionScope != null) { - defaultEncryptionScopeInternal = blobContainerEncryptionScope.getDefaultEncryptionScope(); - } - String defaultEncryptionScope = defaultEncryptionScopeInternal; - Boolean encryptionScopeOverridePreventedInternal = null; - if (blobContainerEncryptionScope != null) { - encryptionScopeOverridePreventedInternal - = blobContainerEncryptionScope.isEncryptionScopeOverridePrevented(); - } - Boolean encryptionScopeOverridePrevented = encryptionScopeOverridePreventedInternal; - return service - .createNoCustomHeaders(this.client.getUrl(), containerName, restype, timeout, metadata, access, - this.client.getVersion(), requestId, defaultEncryptionScope, encryptionScopeOverridePrevented, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Mono> deleteWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.delete(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, context)); } /** - * creates a new container under the specified account. If the container with the same name already exists, the - * operation fails. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobContainerEncryptionScope Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. + * operation marks the specified container for deletion. The container and any blobs contained within it are later + * deleted during garbage collection. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase createWithResponse(String containerName, Integer timeout, - Map metadata, PublicAccessType access, String requestId, - BlobContainerEncryptionScope blobContainerEncryptionScope, Context context) { - try { - final String restype = "container"; - final String accept = "application/xml"; - String defaultEncryptionScopeInternal = null; - if (blobContainerEncryptionScope != null) { - defaultEncryptionScopeInternal = blobContainerEncryptionScope.getDefaultEncryptionScope(); - } - String defaultEncryptionScope = defaultEncryptionScopeInternal; - Boolean encryptionScopeOverridePreventedInternal = null; - if (blobContainerEncryptionScope != null) { - encryptionScopeOverridePreventedInternal - = blobContainerEncryptionScope.isEncryptionScopeOverridePrevented(); - } - Boolean encryptionScopeOverridePrevented = encryptionScopeOverridePreventedInternal; - return service.createSync(this.client.getUrl(), containerName, restype, timeout, metadata, access, - this.client.getVersion(), requestId, defaultEncryptionScope, encryptionScopeOverridePrevented, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Response deleteWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.deleteSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, Context.NONE); } /** - * creates a new container under the specified account. If the container with the same name already exists, the - * operation fails. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobContainerEncryptionScope Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * operation sets one or more user-defined name-value pairs for the specified container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-metaMap<String, String>NoThe metadata headers.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void create(String containerName, Integer timeout, Map metadata, PublicAccessType access, - String requestId, BlobContainerEncryptionScope blobContainerEncryptionScope) { - createWithResponse(containerName, timeout, metadata, access, requestId, blobContainerEncryptionScope, - Context.NONE); + public Mono> setMetadataWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.setMetadata(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + context)); } /** - * creates a new container under the specified account. If the container with the same name already exists, the - * operation fails. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobContainerEncryptionScope Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * operation sets one or more user-defined name-value pairs for the specified container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-metaMap<String, String>NoThe metadata headers.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createNoCustomHeadersWithResponse(String containerName, Integer timeout, - Map metadata, PublicAccessType access, String requestId, - BlobContainerEncryptionScope blobContainerEncryptionScope, Context context) { - try { - final String restype = "container"; - final String accept = "application/xml"; - String defaultEncryptionScopeInternal = null; - if (blobContainerEncryptionScope != null) { - defaultEncryptionScopeInternal = blobContainerEncryptionScope.getDefaultEncryptionScope(); - } - String defaultEncryptionScope = defaultEncryptionScopeInternal; - Boolean encryptionScopeOverridePreventedInternal = null; - if (blobContainerEncryptionScope != null) { - encryptionScopeOverridePreventedInternal - = blobContainerEncryptionScope.isEncryptionScopeOverridePrevented(); - } - Boolean encryptionScopeOverridePrevented = encryptionScopeOverridePreventedInternal; - return service.createNoCustomHeadersSync(this.client.getUrl(), containerName, restype, timeout, metadata, - access, this.client.getVersion(), requestId, defaultEncryptionScope, encryptionScopeOverridePrevented, - accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Response setMetadataWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setMetadataSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, Context.NONE); } /** - * returns all user-defined metadata and system properties for the specified container. The data returned does not - * include the container's list of blobs. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * gets the permissions for the specified container. The permissions indicate whether container data may be accessed + * publicly. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         accessPolicy (Required): {
+     *             start: OffsetDateTime (Required)
+     *             expiry: OffsetDateTime (Required)
+     *             permission: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the permissions for the specified container along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesWithResponseAsync(String containerName, - Integer timeout, String leaseId, String requestId) { - return FluxUtil - .withContext(context -> getPropertiesWithResponseAsync(containerName, timeout, leaseId, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Mono> getAccessPolicyWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return FluxUtil.withContext(context -> service.getAccessPolicy(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + context)); } /** - * returns all user-defined metadata and system properties for the specified container. The data returned does not - * include the container's list of blobs. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * gets the permissions for the specified container. The permissions indicate whether container data may be accessed + * publicly. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         accessPolicy (Required): {
+     *             start: OffsetDateTime (Required)
+     *             expiry: OffsetDateTime (Required)
+     *             permission: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the permissions for the specified container along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesWithResponseAsync(String containerName, - Integer timeout, String leaseId, String requestId, Context context) { - final String restype = "container"; + public Response getAccessPolicyWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; final String accept = "application/xml"; - return service - .getProperties(this.client.getUrl(), containerName, restype, timeout, leaseId, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + return service.getAccessPolicySync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + Context.NONE); } /** - * returns all user-defined metadata and system properties for the specified container. The data returned does not - * include the container's list of blobs. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be + * accessed publicly. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-public-accessStringNoThe public access setting for the container. + * Allowed values: "blob", "container".
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         accessPolicy (Required): {
+     *             start: OffsetDateTime (Required)
+     *             expiry: OffsetDateTime (Required)
+     *             permission: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param containerAcl The access control list for the container. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesAsync(String containerName, Integer timeout, String leaseId, String requestId) { - return getPropertiesWithResponseAsync(containerName, timeout, leaseId, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + public Mono> setAccessPolicyWithResponseAsync(BinaryData containerAcl, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.setAccessPolicy(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, containerAcl, + requestOptions, context)); } /** - * returns all user-defined metadata and system properties for the specified container. The data returned does not - * include the container's list of blobs. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be + * accessed publicly. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-public-accessStringNoThe public access setting for the container. + * Allowed values: "blob", "container".
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         accessPolicy (Required): {
+     *             start: OffsetDateTime (Required)
+     *             expiry: OffsetDateTime (Required)
+     *             permission: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param containerAcl The access control list for the container. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesAsync(String containerName, Integer timeout, String leaseId, String requestId, - Context context) { - return getPropertiesWithResponseAsync(containerName, timeout, leaseId, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + public Response setAccessPolicyWithResponse(BinaryData containerAcl, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setAccessPolicySync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, containerAcl, + requestOptions, Context.NONE); } /** - * returns all user-defined metadata and system properties for the specified container. The data returned does not - * include the container's list of blobs. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * Restores a previously-deleted container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-deleted-container-nameStringNoOptional. Version 2019-12-12 and later. + * Specifies the name of the deleted container to restore.
x-ms-deleted-container-versionStringNoOptional. Version 2019-12-12 and later. + * Specifies the version of the deleted container to restore.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String leaseId, String requestId) { - return FluxUtil - .withContext(context -> getPropertiesNoCustomHeadersWithResponseAsync(containerName, timeout, leaseId, - requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Mono> restoreWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.restore(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, context)); } /** - * returns all user-defined metadata and system properties for the specified container. The data returned does not - * include the container's list of blobs. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + * Restores a previously-deleted container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-deleted-container-nameStringNoOptional. Version 2019-12-12 and later. + * Specifies the name of the deleted container to restore.
x-ms-deleted-container-versionStringNoOptional. Version 2019-12-12 and later. + * Specifies the version of the deleted container to restore.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String leaseId, String requestId, Context context) { - final String restype = "container"; - final String accept = "application/xml"; - return service - .getPropertiesNoCustomHeaders(this.client.getUrl(), containerName, restype, timeout, leaseId, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response restoreWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.restoreSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, Context.NONE); } /** - * returns all user-defined metadata and system properties for the specified container. The data returned does not - * include the container's list of blobs. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. + * Renames an existing container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-lease-idStringNoA lease ID for the source path. If specified, the + * source path must have an active lease and the lease ID must match.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceContainerName Required. Specifies the name of the container to rename. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getPropertiesWithResponse(String containerName, - Integer timeout, String leaseId, String requestId, Context context) { - try { - final String restype = "container"; - final String accept = "application/xml"; - return service.getPropertiesSync(this.client.getUrl(), containerName, restype, timeout, leaseId, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Mono> renameWithResponseAsync(String sourceContainerName, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.rename(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), sourceContainerName, accept, requestOptions, context)); } /** - * returns all user-defined metadata and system properties for the specified container. The data returned does not - * include the container's list of blobs. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * Renames an existing container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-lease-idStringNoA lease ID for the source path. If specified, the + * source path must have an active lease and the lease ID must match.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceContainerName Required. Specifies the name of the container to rename. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void getProperties(String containerName, Integer timeout, String leaseId, String requestId) { - getPropertiesWithResponse(containerName, timeout, leaseId, requestId, Context.NONE); + public Response renameWithResponse(String sourceContainerName, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.renameSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), sourceContainerName, accept, requestOptions, Context.NONE); } /** - * returns all user-defined metadata and system properties for the specified container. The data returned does not - * include the container's list of blobs. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesNoCustomHeadersWithResponse(String containerName, Integer timeout, - String leaseId, String requestId, Context context) { - try { - final String restype = "container"; - final String accept = "application/xml"; - return service.getPropertiesNoCustomHeadersSync(this.client.getUrl(), containerName, restype, timeout, - leaseId, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Mono> submitBatchWithResponseAsync(long contentLength, BinaryData body, + RequestOptions requestOptions) { + final String multipartContentType = "multipart/mixed"; + final String accept = "multipart/mixed"; + return FluxUtil.withContext( + context -> service.submitBatch(this.client.getUrl(), this.client.getContainerName(), multipartContentType, + contentLength, this.client.getServiceVersion().getVersion(), accept, body, requestOptions, context)); } /** - * operation marks the specified container for deletion. The container and any blobs contained within it are later - * deleted during garbage collection. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithResponseAsync(String containerName, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId) { - return FluxUtil - .withContext(context -> deleteWithResponseAsync(containerName, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response submitBatchWithResponse(long contentLength, BinaryData body, + RequestOptions requestOptions) { + final String multipartContentType = "multipart/mixed"; + final String accept = "multipart/mixed"; + return service.submitBatchSync(this.client.getUrl(), this.client.getContainerName(), multipartContentType, + contentLength, this.client.getServiceVersion().getVersion(), accept, body, requestOptions, Context.NONE); } /** - * operation marks the specified container for deletion. The container and any blobs contained within it are later - * deleted during garbage collection. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search + * expression. Filter blobs searches within the given container. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
whereStringNoFilters the results to return only to return only blobs whose + * tags match the specified expression.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     where: String (Required)
+     *     blobs (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             containerName: String (Required)
+     *             tags (Optional): {
+     *                 blobTagSet (Required): [
+     *                      (Required){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *             versionId: String (Optional)
+     *             isCurrentVersion: Boolean (Optional)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the result of a Filter Blobs API call along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithResponseAsync(String containerName, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, Context context) { - final String restype = "container"; + public Mono> filterBlobsWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .delete(this.client.getUrl(), containerName, restype, timeout, leaseId, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + return FluxUtil.withContext(context -> service.filterBlobs(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + context)); } /** - * operation marks the specified container for deletion. The container and any blobs contained within it are later - * deleted during garbage collection. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search + * expression. Filter blobs searches within the given container. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
whereStringNoFilters the results to return only to return only blobs whose + * tags match the specified expression.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     where: String (Required)
+     *     blobs (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             containerName: String (Required)
+     *             tags (Optional): {
+     *                 blobTagSet (Required): [
+     *                      (Required){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *             versionId: String (Optional)
+     *             isCurrentVersion: Boolean (Optional)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the result of a Filter Blobs API call along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteAsync(String containerName, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId) { - return deleteWithResponseAsync(containerName, timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * operation marks the specified container for deletion. The container and any blobs contained within it are later - * deleted during garbage collection. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + public Response filterBlobsWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return service.filterBlobsSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, Context.NONE); + } + + /** + * The Acquire Lease operation requests a new lease on a container. The lease lock duration can be 15 to 60 seconds, + * or can be infinite. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-durationIntegerNoSpecifies the duration of the lease, in seconds, + * or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A + * lease duration cannot be changed using renew or change.
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteAsync(String containerName, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - return deleteWithResponseAsync(containerName, timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, requestId, - context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * operation marks the specified container for deletion. The container and any blobs contained within it are later - * deleted during garbage collection. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + public Mono> acquireLeaseWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.acquireLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + context)); + } + + /** + * The Acquire Lease operation requests a new lease on a container. The lease lock duration can be 15 to 60 seconds, + * or can be infinite. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-durationIntegerNoSpecifies the duration of the lease, in seconds, + * or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A + * lease duration cannot be changed using renew or change.
x-ms-proposed-lease-idStringNoOptional. The proposed lease ID for the + * container.
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response acquireLeaseWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.acquireLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, Context.NONE); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - return FluxUtil - .withContext(context -> deleteNoCustomHeadersWithResponseAsync(containerName, timeout, leaseId, - ifModifiedSince, ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * operation marks the specified container for deletion. The container and any blobs contained within it are later - * deleted during garbage collection. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - Context context) { - final String restype = "container"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.deleteNoCustomHeaders(this.client.getUrl(), containerName, restype, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * operation marks the specified container for deletion. The container and any blobs contained within it are later - * deleted during garbage collection. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase deleteWithResponse(String containerName, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - Context context) { - try { - final String restype = "container"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.deleteSync(this.client.getUrl(), containerName, restype, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * operation marks the specified container for deletion. The container and any blobs contained within it are later - * deleted during garbage collection. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void delete(String containerName, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId) { - deleteWithResponse(containerName, timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, requestId, - Context.NONE); - } - - /** - * operation marks the specified container for deletion. The container and any blobs contained within it are later - * deleted during garbage collection. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteNoCustomHeadersWithResponse(String containerName, Integer timeout, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - try { - final String restype = "container"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.deleteNoCustomHeadersSync(this.client.getUrl(), containerName, restype, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * operation sets one or more user-defined name-value pairs for the specified container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataWithResponseAsync(String containerName, - Integer timeout, String leaseId, Map metadata, OffsetDateTime ifModifiedSince, - String requestId) { - return FluxUtil - .withContext(context -> setMetadataWithResponseAsync(containerName, timeout, leaseId, metadata, - ifModifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * operation sets one or more user-defined name-value pairs for the specified container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataWithResponseAsync(String containerName, - Integer timeout, String leaseId, Map metadata, OffsetDateTime ifModifiedSince, String requestId, - Context context) { - final String restype = "container"; - final String comp = "metadata"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - return service - .setMetadata(this.client.getUrl(), containerName, restype, comp, timeout, leaseId, metadata, - ifModifiedSinceConverted, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * operation sets one or more user-defined name-value pairs for the specified container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setMetadataAsync(String containerName, Integer timeout, String leaseId, - Map metadata, OffsetDateTime ifModifiedSince, String requestId) { - return setMetadataWithResponseAsync(containerName, timeout, leaseId, metadata, ifModifiedSince, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * operation sets one or more user-defined name-value pairs for the specified container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setMetadataAsync(String containerName, Integer timeout, String leaseId, - Map metadata, OffsetDateTime ifModifiedSince, String requestId, Context context) { - return setMetadataWithResponseAsync(containerName, timeout, leaseId, metadata, ifModifiedSince, requestId, - context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * operation sets one or more user-defined name-value pairs for the specified container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String leaseId, Map metadata, OffsetDateTime ifModifiedSince, String requestId) { - return FluxUtil - .withContext(context -> setMetadataNoCustomHeadersWithResponseAsync(containerName, timeout, leaseId, - metadata, ifModifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * operation sets one or more user-defined name-value pairs for the specified container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String leaseId, Map metadata, OffsetDateTime ifModifiedSince, String requestId, - Context context) { - final String restype = "container"; - final String comp = "metadata"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - return service - .setMetadataNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, timeout, leaseId, metadata, - ifModifiedSinceConverted, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * operation sets one or more user-defined name-value pairs for the specified container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setMetadataWithResponse(String containerName, - Integer timeout, String leaseId, Map metadata, OffsetDateTime ifModifiedSince, String requestId, - Context context) { - try { - final String restype = "container"; - final String comp = "metadata"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - return service.setMetadataSync(this.client.getUrl(), containerName, restype, comp, timeout, leaseId, - metadata, ifModifiedSinceConverted, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * operation sets one or more user-defined name-value pairs for the specified container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setMetadata(String containerName, Integer timeout, String leaseId, Map metadata, - OffsetDateTime ifModifiedSince, String requestId) { - setMetadataWithResponse(containerName, timeout, leaseId, metadata, ifModifiedSince, requestId, Context.NONE); - } - - /** - * operation sets one or more user-defined name-value pairs for the specified container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setMetadataNoCustomHeadersWithResponse(String containerName, Integer timeout, String leaseId, - Map metadata, OffsetDateTime ifModifiedSince, String requestId, Context context) { - try { - final String restype = "container"; - final String comp = "metadata"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - return service.setMetadataNoCustomHeadersSync(this.client.getUrl(), containerName, restype, comp, timeout, - leaseId, metadata, ifModifiedSinceConverted, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * gets the permissions for the specified container. The permissions indicate whether container data may be accessed - * publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the permissions for the specified container along with {@link ResponseBase} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getAccessPolicyWithResponseAsync(String containerName, Integer timeout, String leaseId, String requestId) { - return FluxUtil - .withContext( - context -> getAccessPolicyWithResponseAsync(containerName, timeout, leaseId, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * gets the permissions for the specified container. The permissions indicate whether container data may be accessed - * publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the permissions for the specified container along with {@link ResponseBase} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getAccessPolicyWithResponseAsync(String containerName, Integer timeout, String leaseId, String requestId, - Context context) { - final String restype = "container"; - final String comp = "acl"; - final String accept = "application/xml"; - return service - .getAccessPolicy(this.client.getUrl(), containerName, restype, comp, timeout, leaseId, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * gets the permissions for the specified container. The permissions indicate whether container data may be accessed - * publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the permissions for the specified container on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccessPolicyAsync(String containerName, Integer timeout, String leaseId, - String requestId) { - return getAccessPolicyWithResponseAsync(containerName, timeout, leaseId, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * gets the permissions for the specified container. The permissions indicate whether container data may be accessed - * publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the permissions for the specified container on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccessPolicyAsync(String containerName, Integer timeout, String leaseId, - String requestId, Context context) { - return getAccessPolicyWithResponseAsync(containerName, timeout, leaseId, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * gets the permissions for the specified container. The permissions indicate whether container data may be accessed - * publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the permissions for the specified container along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccessPolicyNoCustomHeadersWithResponseAsync( - String containerName, Integer timeout, String leaseId, String requestId) { - return FluxUtil - .withContext(context -> getAccessPolicyNoCustomHeadersWithResponseAsync(containerName, timeout, leaseId, - requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * gets the permissions for the specified container. The permissions indicate whether container data may be accessed - * publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the permissions for the specified container along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccessPolicyNoCustomHeadersWithResponseAsync( - String containerName, Integer timeout, String leaseId, String requestId, Context context) { - final String restype = "container"; - final String comp = "acl"; - final String accept = "application/xml"; - return service - .getAccessPolicyNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, timeout, leaseId, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * gets the permissions for the specified container. The permissions indicate whether container data may be accessed - * publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the permissions for the specified container along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getAccessPolicyWithResponse( - String containerName, Integer timeout, String leaseId, String requestId, Context context) { - try { - final String restype = "container"; - final String comp = "acl"; - final String accept = "application/xml"; - return service.getAccessPolicySync(this.client.getUrl(), containerName, restype, comp, timeout, leaseId, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * gets the permissions for the specified container. The permissions indicate whether container data may be accessed - * publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the permissions for the specified container. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobSignedIdentifierWrapper getAccessPolicy(String containerName, Integer timeout, String leaseId, - String requestId) { - try { - return getAccessPolicyWithResponse(containerName, timeout, leaseId, requestId, Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * gets the permissions for the specified container. The permissions indicate whether container data may be accessed - * publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the permissions for the specified container along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getAccessPolicyNoCustomHeadersWithResponse(String containerName, - Integer timeout, String leaseId, String requestId, Context context) { - try { - final String restype = "container"; - final String comp = "acl"; - final String accept = "application/xml"; - return service.getAccessPolicyNoCustomHeadersSync(this.client.getUrl(), containerName, restype, comp, - timeout, leaseId, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be - * accessed publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param containerAcl the acls for the container. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setAccessPolicyWithResponseAsync( - String containerName, Integer timeout, String leaseId, PublicAccessType access, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId, List containerAcl) { - return FluxUtil - .withContext(context -> setAccessPolicyWithResponseAsync(containerName, timeout, leaseId, access, - ifModifiedSince, ifUnmodifiedSince, requestId, containerAcl, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be - * accessed publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param containerAcl the acls for the container. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setAccessPolicyWithResponseAsync( - String containerName, Integer timeout, String leaseId, PublicAccessType access, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId, List containerAcl, Context context) { - final String restype = "container"; - final String comp = "acl"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - BlobSignedIdentifierWrapper containerAclConverted = new BlobSignedIdentifierWrapper(containerAcl); - return service - .setAccessPolicy(this.client.getUrl(), containerName, restype, comp, timeout, leaseId, access, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, - containerAclConverted, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be - * accessed publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param containerAcl the acls for the container. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setAccessPolicyAsync(String containerName, Integer timeout, String leaseId, - PublicAccessType access, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - List containerAcl) { - return setAccessPolicyWithResponseAsync(containerName, timeout, leaseId, access, ifModifiedSince, - ifUnmodifiedSince, requestId, containerAcl) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be - * accessed publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param containerAcl the acls for the container. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setAccessPolicyAsync(String containerName, Integer timeout, String leaseId, - PublicAccessType access, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - List containerAcl, Context context) { - return setAccessPolicyWithResponseAsync(containerName, timeout, leaseId, access, ifModifiedSince, - ifUnmodifiedSince, requestId, containerAcl, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be - * accessed publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param containerAcl the acls for the container. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setAccessPolicyNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String leaseId, PublicAccessType access, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, List containerAcl) { - return FluxUtil - .withContext(context -> setAccessPolicyNoCustomHeadersWithResponseAsync(containerName, timeout, leaseId, - access, ifModifiedSince, ifUnmodifiedSince, requestId, containerAcl, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be - * accessed publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param containerAcl the acls for the container. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setAccessPolicyNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String leaseId, PublicAccessType access, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, List containerAcl, Context context) { - final String restype = "container"; - final String comp = "acl"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - BlobSignedIdentifierWrapper containerAclConverted = new BlobSignedIdentifierWrapper(containerAcl); - return service - .setAccessPolicyNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, timeout, leaseId, - access, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, - containerAclConverted, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be - * accessed publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param containerAcl the acls for the container. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setAccessPolicyWithResponse(String containerName, - Integer timeout, String leaseId, PublicAccessType access, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId, List containerAcl, Context context) { - try { - final String restype = "container"; - final String comp = "acl"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - BlobSignedIdentifierWrapper containerAclConverted = new BlobSignedIdentifierWrapper(containerAcl); - return service.setAccessPolicySync(this.client.getUrl(), containerName, restype, comp, timeout, leaseId, - access, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, - containerAclConverted, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be - * accessed publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param containerAcl the acls for the container. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setAccessPolicy(String containerName, Integer timeout, String leaseId, PublicAccessType access, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - List containerAcl) { - setAccessPolicyWithResponse(containerName, timeout, leaseId, access, ifModifiedSince, ifUnmodifiedSince, - requestId, containerAcl, Context.NONE); - } - - /** - * sets the permissions for the specified container. The permissions indicate whether blobs in a container may be - * accessed publicly. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param access Specifies whether data in the container may be accessed publicly and the level of access. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param containerAcl the acls for the container. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setAccessPolicyNoCustomHeadersWithResponse(String containerName, Integer timeout, - String leaseId, PublicAccessType access, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, List containerAcl, Context context) { - try { - final String restype = "container"; - final String comp = "acl"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - BlobSignedIdentifierWrapper containerAclConverted = new BlobSignedIdentifierWrapper(containerAcl); - return service.setAccessPolicyNoCustomHeadersSync(this.client.getUrl(), containerName, restype, comp, - timeout, leaseId, access, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - this.client.getVersion(), requestId, containerAclConverted, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Restores a previously-deleted container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container - * to restore. - * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted - * container to restore. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> restoreWithResponseAsync(String containerName, - Integer timeout, String requestId, String deletedContainerName, String deletedContainerVersion) { - return FluxUtil - .withContext(context -> restoreWithResponseAsync(containerName, timeout, requestId, deletedContainerName, - deletedContainerVersion, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Restores a previously-deleted container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container - * to restore. - * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted - * container to restore. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> restoreWithResponseAsync(String containerName, - Integer timeout, String requestId, String deletedContainerName, String deletedContainerVersion, - Context context) { - final String restype = "container"; - final String comp = "undelete"; - final String accept = "application/xml"; - return service - .restore(this.client.getUrl(), containerName, restype, comp, timeout, this.client.getVersion(), requestId, - deletedContainerName, deletedContainerVersion, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Restores a previously-deleted container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container - * to restore. - * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted - * container to restore. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono restoreAsync(String containerName, Integer timeout, String requestId, String deletedContainerName, - String deletedContainerVersion) { - return restoreWithResponseAsync(containerName, timeout, requestId, deletedContainerName, - deletedContainerVersion) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Restores a previously-deleted container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container - * to restore. - * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted - * container to restore. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono restoreAsync(String containerName, Integer timeout, String requestId, String deletedContainerName, - String deletedContainerVersion, Context context) { - return restoreWithResponseAsync(containerName, timeout, requestId, deletedContainerName, - deletedContainerVersion, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Restores a previously-deleted container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container - * to restore. - * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted - * container to restore. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> restoreNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String requestId, String deletedContainerName, String deletedContainerVersion) { - return FluxUtil - .withContext(context -> restoreNoCustomHeadersWithResponseAsync(containerName, timeout, requestId, - deletedContainerName, deletedContainerVersion, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Restores a previously-deleted container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container - * to restore. - * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted - * container to restore. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> restoreNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String requestId, String deletedContainerName, String deletedContainerVersion, Context context) { - final String restype = "container"; - final String comp = "undelete"; - final String accept = "application/xml"; - return service - .restoreNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, deletedContainerName, deletedContainerVersion, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Restores a previously-deleted container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container - * to restore. - * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted - * container to restore. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase restoreWithResponse(String containerName, Integer timeout, - String requestId, String deletedContainerName, String deletedContainerVersion, Context context) { - try { - final String restype = "container"; - final String comp = "undelete"; - final String accept = "application/xml"; - return service.restoreSync(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, deletedContainerName, deletedContainerVersion, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Restores a previously-deleted container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container - * to restore. - * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted - * container to restore. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void restore(String containerName, Integer timeout, String requestId, String deletedContainerName, - String deletedContainerVersion) { - restoreWithResponse(containerName, timeout, requestId, deletedContainerName, deletedContainerVersion, - Context.NONE); - } - - /** - * Restores a previously-deleted container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param deletedContainerName Optional. Version 2019-12-12 and later. Specifies the name of the deleted container - * to restore. - * @param deletedContainerVersion Optional. Version 2019-12-12 and later. Specifies the version of the deleted - * container to restore. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response restoreNoCustomHeadersWithResponse(String containerName, Integer timeout, String requestId, - String deletedContainerName, String deletedContainerVersion, Context context) { - try { - final String restype = "container"; - final String comp = "undelete"; - final String accept = "application/xml"; - return service.restoreNoCustomHeadersSync(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, deletedContainerName, deletedContainerVersion, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Renames an existing container. - * - * @param containerName The container name. - * @param sourceContainerName Required. Specifies the name of the container to rename. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and - * the lease ID must match. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renameWithResponseAsync(String containerName, - String sourceContainerName, Integer timeout, String requestId, String sourceLeaseId) { - return FluxUtil - .withContext(context -> renameWithResponseAsync(containerName, sourceContainerName, timeout, requestId, - sourceLeaseId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Renames an existing container. - * - * @param containerName The container name. - * @param sourceContainerName Required. Specifies the name of the container to rename. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and - * the lease ID must match. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renameWithResponseAsync(String containerName, - String sourceContainerName, Integer timeout, String requestId, String sourceLeaseId, Context context) { - final String restype = "container"; - final String comp = "rename"; - final String accept = "application/xml"; - return service - .rename(this.client.getUrl(), containerName, restype, comp, timeout, this.client.getVersion(), requestId, - sourceContainerName, sourceLeaseId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Renames an existing container. - * - * @param containerName The container name. - * @param sourceContainerName Required. Specifies the name of the container to rename. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and - * the lease ID must match. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono renameAsync(String containerName, String sourceContainerName, Integer timeout, String requestId, - String sourceLeaseId) { - return renameWithResponseAsync(containerName, sourceContainerName, timeout, requestId, sourceLeaseId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Renames an existing container. - * - * @param containerName The container name. - * @param sourceContainerName Required. Specifies the name of the container to rename. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and - * the lease ID must match. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono renameAsync(String containerName, String sourceContainerName, Integer timeout, String requestId, - String sourceLeaseId, Context context) { - return renameWithResponseAsync(containerName, sourceContainerName, timeout, requestId, sourceLeaseId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Renames an existing container. - * - * @param containerName The container name. - * @param sourceContainerName Required. Specifies the name of the container to rename. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and - * the lease ID must match. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renameNoCustomHeadersWithResponseAsync(String containerName, String sourceContainerName, - Integer timeout, String requestId, String sourceLeaseId) { - return FluxUtil - .withContext(context -> renameNoCustomHeadersWithResponseAsync(containerName, sourceContainerName, timeout, - requestId, sourceLeaseId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Renames an existing container. - * - * @param containerName The container name. - * @param sourceContainerName Required. Specifies the name of the container to rename. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and - * the lease ID must match. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renameNoCustomHeadersWithResponseAsync(String containerName, String sourceContainerName, - Integer timeout, String requestId, String sourceLeaseId, Context context) { - final String restype = "container"; - final String comp = "rename"; - final String accept = "application/xml"; - return service - .renameNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, sourceContainerName, sourceLeaseId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Renames an existing container. - * - * @param containerName The container name. - * @param sourceContainerName Required. Specifies the name of the container to rename. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and - * the lease ID must match. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase renameWithResponse(String containerName, - String sourceContainerName, Integer timeout, String requestId, String sourceLeaseId, Context context) { - try { - final String restype = "container"; - final String comp = "rename"; - final String accept = "application/xml"; - return service.renameSync(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, sourceContainerName, sourceLeaseId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Renames an existing container. - * - * @param containerName The container name. - * @param sourceContainerName Required. Specifies the name of the container to rename. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and - * the lease ID must match. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void rename(String containerName, String sourceContainerName, Integer timeout, String requestId, - String sourceLeaseId) { - renameWithResponse(containerName, sourceContainerName, timeout, requestId, sourceLeaseId, Context.NONE); - } - - /** - * Renames an existing container. - * - * @param containerName The container name. - * @param sourceContainerName Required. Specifies the name of the container to rename. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param sourceLeaseId A lease ID for the source path. If specified, the source path must have an active lease and - * the lease ID must match. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response renameNoCustomHeadersWithResponse(String containerName, String sourceContainerName, - Integer timeout, String requestId, String sourceLeaseId, Context context) { - try { - final String restype = "container"; - final String comp = "rename"; - final String accept = "application/xml"; - return service.renameNoCustomHeadersSync(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, sourceContainerName, sourceLeaseId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> submitBatchWithResponseAsync( - String containerName, long contentLength, String multipartContentType, Flux body, Integer timeout, - String requestId) { - return FluxUtil - .withContext(context -> submitBatchWithResponseAsync(containerName, contentLength, multipartContentType, - body, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> submitBatchWithResponseAsync( - String containerName, long contentLength, String multipartContentType, Flux body, Integer timeout, - String requestId, Context context) { - final String restype = "container"; - final String comp = "batch"; - final String accept = "application/xml"; - return service - .submitBatch(this.client.getUrl(), containerName, restype, comp, contentLength, multipartContentType, - timeout, this.client.getVersion(), requestId, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitBatchAsync(String containerName, long contentLength, String multipartContentType, - Flux body, Integer timeout, String requestId) { - return submitBatchWithResponseAsync(containerName, contentLength, multipartContentType, body, timeout, - requestId).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitBatchAsync(String containerName, long contentLength, String multipartContentType, - Flux body, Integer timeout, String requestId, Context context) { - return submitBatchWithResponseAsync(containerName, contentLength, multipartContentType, body, timeout, - requestId, context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono submitBatchNoCustomHeadersWithResponseAsync(String containerName, long contentLength, - String multipartContentType, Flux body, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> submitBatchNoCustomHeadersWithResponseAsync(containerName, contentLength, - multipartContentType, body, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono submitBatchNoCustomHeadersWithResponseAsync(String containerName, long contentLength, - String multipartContentType, Flux body, Integer timeout, String requestId, Context context) { - final String restype = "container"; - final String comp = "batch"; - final String accept = "application/xml"; - return service - .submitBatchNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, contentLength, - multipartContentType, timeout, this.client.getVersion(), requestId, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> submitBatchWithResponseAsync( - String containerName, long contentLength, String multipartContentType, BinaryData body, Integer timeout, - String requestId) { - return FluxUtil - .withContext(context -> submitBatchWithResponseAsync(containerName, contentLength, multipartContentType, - body, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> submitBatchWithResponseAsync( - String containerName, long contentLength, String multipartContentType, BinaryData body, Integer timeout, - String requestId, Context context) { - final String restype = "container"; - final String comp = "batch"; - final String accept = "application/xml"; - return service - .submitBatch(this.client.getUrl(), containerName, restype, comp, contentLength, multipartContentType, - timeout, this.client.getVersion(), requestId, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitBatchAsync(String containerName, long contentLength, String multipartContentType, - BinaryData body, Integer timeout, String requestId) { - return submitBatchWithResponseAsync(containerName, contentLength, multipartContentType, body, timeout, - requestId).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitBatchAsync(String containerName, long contentLength, String multipartContentType, - BinaryData body, Integer timeout, String requestId, Context context) { - return submitBatchWithResponseAsync(containerName, contentLength, multipartContentType, body, timeout, - requestId, context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono submitBatchNoCustomHeadersWithResponseAsync(String containerName, long contentLength, - String multipartContentType, BinaryData body, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> submitBatchNoCustomHeadersWithResponseAsync(containerName, contentLength, - multipartContentType, body, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono submitBatchNoCustomHeadersWithResponseAsync(String containerName, long contentLength, - String multipartContentType, BinaryData body, Integer timeout, String requestId, Context context) { - final String restype = "container"; - final String comp = "batch"; - final String accept = "application/xml"; - return service - .submitBatchNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, contentLength, - multipartContentType, timeout, this.client.getVersion(), requestId, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase submitBatchWithResponse(String containerName, - long contentLength, String multipartContentType, BinaryData body, Integer timeout, String requestId, - Context context) { - try { - final String restype = "container"; - final String comp = "batch"; - final String accept = "application/xml"; - return service.submitBatchSync(this.client.getUrl(), containerName, restype, comp, contentLength, - multipartContentType, timeout, this.client.getVersion(), requestId, body, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public InputStream submitBatch(String containerName, long contentLength, String multipartContentType, - BinaryData body, Integer timeout, String requestId) { - try { - return submitBatchWithResponse(containerName, contentLength, multipartContentType, body, timeout, requestId, - Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param containerName The container name. - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response submitBatchNoCustomHeadersWithResponse(String containerName, long contentLength, - String multipartContentType, BinaryData body, Integer timeout, String requestId, Context context) { - try { - final String restype = "container"; - final String comp = "batch"; - final String accept = "application/xml"; - return service.submitBatchNoCustomHeadersSync(this.client.getUrl(), containerName, restype, comp, - contentLength, multipartContentType, timeout, this.client.getVersion(), requestId, body, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search - * expression. Filter blobs searches within the given container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link ResponseBase} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> filterBlobsWithResponseAsync( - String containerName, Integer timeout, String requestId, String where, String marker, Integer maxresults, - List include) { - return FluxUtil - .withContext(context -> filterBlobsWithResponseAsync(containerName, timeout, requestId, where, marker, - maxresults, include, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search - * expression. Filter blobs searches within the given container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link ResponseBase} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> filterBlobsWithResponseAsync( - String containerName, Integer timeout, String requestId, String where, String marker, Integer maxresults, - List include, Context context) { - final String restype = "container"; - final String comp = "blobs"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .filterBlobs(this.client.getUrl(), containerName, restype, comp, timeout, this.client.getVersion(), - requestId, where, marker, maxresults, includeConverted, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search - * expression. Filter blobs searches within the given container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono filterBlobsAsync(String containerName, Integer timeout, String requestId, - String where, String marker, Integer maxresults, List include) { - return filterBlobsWithResponseAsync(containerName, timeout, requestId, where, marker, maxresults, include) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search - * expression. Filter blobs searches within the given container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono filterBlobsAsync(String containerName, Integer timeout, String requestId, - String where, String marker, Integer maxresults, List include, Context context) { - return filterBlobsWithResponseAsync(containerName, timeout, requestId, where, marker, maxresults, include, - context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search - * expression. Filter blobs searches within the given container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> filterBlobsNoCustomHeadersWithResponseAsync(String containerName, - Integer timeout, String requestId, String where, String marker, Integer maxresults, - List include) { - return FluxUtil - .withContext(context -> filterBlobsNoCustomHeadersWithResponseAsync(containerName, timeout, requestId, - where, marker, maxresults, include, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search - * expression. Filter blobs searches within the given container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> filterBlobsNoCustomHeadersWithResponseAsync(String containerName, - Integer timeout, String requestId, String where, String marker, Integer maxresults, - List include, Context context) { - final String restype = "container"; - final String comp = "blobs"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .filterBlobsNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, where, marker, maxresults, includeConverted, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search - * expression. Filter blobs searches within the given container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase filterBlobsWithResponse(String containerName, - Integer timeout, String requestId, String where, String marker, Integer maxresults, - List include, Context context) { - try { - final String restype = "container"; - final String comp = "blobs"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service.filterBlobsSync(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, where, marker, maxresults, includeConverted, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search - * expression. Filter blobs searches within the given container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public FilterBlobSegment filterBlobs(String containerName, Integer timeout, String requestId, String where, - String marker, Integer maxresults, List include) { - try { - return filterBlobsWithResponse(containerName, timeout, requestId, where, marker, maxresults, include, - Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Filter Blobs operation enables callers to list blobs in a container whose tags match a given search - * expression. Filter blobs searches within the given container. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response filterBlobsNoCustomHeadersWithResponse(String containerName, Integer timeout, - String requestId, String where, String marker, Integer maxresults, List include, - Context context) { - try { - final String restype = "container"; - final String comp = "blobs"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service.filterBlobsNoCustomHeadersSync(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, where, marker, maxresults, includeConverted, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseWithResponseAsync(String containerName, - Integer timeout, Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId) { - return FluxUtil - .withContext(context -> acquireLeaseWithResponseAsync(containerName, timeout, duration, proposedLeaseId, - ifModifiedSince, ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseWithResponseAsync(String containerName, - Integer timeout, Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "acquire"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .acquireLease(this.client.getUrl(), containerName, comp, restype, action, timeout, duration, - proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono acquireLeaseAsync(String containerName, Integer timeout, Integer duration, String proposedLeaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - return acquireLeaseWithResponseAsync(containerName, timeout, duration, proposedLeaseId, ifModifiedSince, - ifUnmodifiedSince, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono acquireLeaseAsync(String containerName, Integer timeout, Integer duration, String proposedLeaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - return acquireLeaseWithResponseAsync(containerName, timeout, duration, proposedLeaseId, ifModifiedSince, - ifUnmodifiedSince, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId) { - return FluxUtil - .withContext(context -> acquireLeaseNoCustomHeadersWithResponseAsync(containerName, timeout, duration, - proposedLeaseId, ifModifiedSince, ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "acquire"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .acquireLeaseNoCustomHeaders(this.client.getUrl(), containerName, comp, restype, action, timeout, duration, - proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase acquireLeaseWithResponse(String containerName, - Integer timeout, Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "acquire"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.acquireLeaseSync(this.client.getUrl(), containerName, comp, restype, action, timeout, - duration, proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void acquireLease(String containerName, Integer timeout, Integer duration, String proposedLeaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - acquireLeaseWithResponse(containerName, timeout, duration, proposedLeaseId, ifModifiedSince, ifUnmodifiedSince, - requestId, Context.NONE); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param duration Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never - * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or - * change. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response acquireLeaseNoCustomHeadersWithResponse(String containerName, Integer timeout, - Integer duration, String proposedLeaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "acquire"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.acquireLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, comp, restype, action, - timeout, duration, proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseWithResponseAsync(String containerName, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId) { - return FluxUtil - .withContext(context -> releaseLeaseWithResponseAsync(containerName, leaseId, timeout, ifModifiedSince, - ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseWithResponseAsync(String containerName, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "release"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.releaseLease(this.client.getUrl(), containerName, comp, restype, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono releaseLeaseAsync(String containerName, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - return releaseLeaseWithResponseAsync(containerName, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, - requestId).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono releaseLeaseAsync(String containerName, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - return releaseLeaseWithResponseAsync(containerName, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, - requestId, context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseNoCustomHeadersWithResponseAsync(String containerName, String leaseId, - Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - return FluxUtil - .withContext(context -> releaseLeaseNoCustomHeadersWithResponseAsync(containerName, leaseId, timeout, - ifModifiedSince, ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseNoCustomHeadersWithResponseAsync(String containerName, String leaseId, - Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "release"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .releaseLeaseNoCustomHeaders(this.client.getUrl(), containerName, comp, restype, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase releaseLeaseWithResponse(String containerName, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "release"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.releaseLeaseSync(this.client.getUrl(), containerName, comp, restype, action, timeout, - leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, - accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void releaseLease(String containerName, String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId) { - releaseLeaseWithResponse(containerName, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, requestId, - Context.NONE); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response releaseLeaseNoCustomHeadersWithResponse(String containerName, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "release"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.releaseLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, comp, restype, action, - timeout, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseWithResponseAsync(String containerName, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId) { - return FluxUtil - .withContext(context -> renewLeaseWithResponseAsync(containerName, leaseId, timeout, ifModifiedSince, - ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseWithResponseAsync(String containerName, - String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "renew"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.renewLease(this.client.getUrl(), containerName, comp, restype, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono renewLeaseAsync(String containerName, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - return renewLeaseWithResponseAsync(containerName, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, - requestId).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono renewLeaseAsync(String containerName, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - return renewLeaseWithResponseAsync(containerName, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, - requestId, context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseNoCustomHeadersWithResponseAsync(String containerName, String leaseId, - Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - return FluxUtil - .withContext(context -> renewLeaseNoCustomHeadersWithResponseAsync(containerName, leaseId, timeout, - ifModifiedSince, ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseNoCustomHeadersWithResponseAsync(String containerName, String leaseId, - Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "renew"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .renewLeaseNoCustomHeaders(this.client.getUrl(), containerName, comp, restype, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase renewLeaseWithResponse(String containerName, String leaseId, - Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "renew"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.renewLeaseSync(this.client.getUrl(), containerName, comp, restype, action, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void renewLease(String containerName, String leaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId) { - renewLeaseWithResponse(containerName, leaseId, timeout, ifModifiedSince, ifUnmodifiedSince, requestId, - Context.NONE); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response renewLeaseNoCustomHeadersWithResponse(String containerName, String leaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "renew"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.renewLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, comp, restype, action, - timeout, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseWithResponseAsync(String containerName, - Integer timeout, Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId) { - return FluxUtil - .withContext(context -> breakLeaseWithResponseAsync(containerName, timeout, breakPeriod, ifModifiedSince, - ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseWithResponseAsync(String containerName, - Integer timeout, Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "break"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.breakLease(this.client.getUrl(), containerName, comp, restype, action, timeout, breakPeriod, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono breakLeaseAsync(String containerName, Integer timeout, Integer breakPeriod, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - return breakLeaseWithResponseAsync(containerName, timeout, breakPeriod, ifModifiedSince, ifUnmodifiedSince, - requestId).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono breakLeaseAsync(String containerName, Integer timeout, Integer breakPeriod, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - return breakLeaseWithResponseAsync(containerName, timeout, breakPeriod, ifModifiedSince, ifUnmodifiedSince, - requestId, context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + public Mono> releaseLeaseWithResponseAsync(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.releaseLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), leaseId, accept, + requestOptions, context)); + } + + /** + * The Release Lease operation frees the lease if it's no longer needed, so that another client can immediately + * acquire a lease against the container. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - return FluxUtil - .withContext(context -> breakLeaseNoCustomHeadersWithResponseAsync(containerName, timeout, breakPeriod, - ifModifiedSince, ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + public Response releaseLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.releaseLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), leaseId, accept, requestOptions, Context.NONE); + } + + /** + * The Renew Lease operation renews an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "break"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .breakLeaseNoCustomHeaders(this.client.getUrl(), containerName, comp, restype, action, timeout, breakPeriod, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase breakLeaseWithResponse(String containerName, Integer timeout, - Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "break"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.breakLeaseSync(this.client.getUrl(), containerName, comp, restype, action, timeout, - breakPeriod, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, - accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void breakLease(String containerName, Integer timeout, Integer breakPeriod, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId) { - breakLeaseWithResponse(containerName, timeout, breakPeriod, ifModifiedSince, ifUnmodifiedSince, requestId, - Context.NONE); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param breakPeriod For a break operation, proposed duration the lease should continue before it is broken, in - * seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. - * If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - * expired, but the lease may be held for longer than the break period. If this header does not appear with a break - * operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks - * immediately. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + public Mono> renewLeaseWithResponseAsync(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.renewLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), leaseId, accept, + requestOptions, context)); + } + + /** + * The Renew Lease operation renews an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response breakLeaseNoCustomHeadersWithResponse(String containerName, Integer timeout, - Integer breakPeriod, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, - Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "break"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.breakLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, comp, restype, action, - timeout, breakPeriod, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseWithResponseAsync(String containerName, - String leaseId, String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId) { - return FluxUtil - .withContext(context -> changeLeaseWithResponseAsync(containerName, leaseId, proposedLeaseId, timeout, - ifModifiedSince, ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseWithResponseAsync(String containerName, - String leaseId, String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "change"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .changeLease(this.client.getUrl(), containerName, comp, restype, action, timeout, leaseId, proposedLeaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono changeLeaseAsync(String containerName, String leaseId, String proposedLeaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - return changeLeaseWithResponseAsync(containerName, leaseId, proposedLeaseId, timeout, ifModifiedSince, - ifUnmodifiedSince, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono changeLeaseAsync(String containerName, String leaseId, String proposedLeaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - return changeLeaseWithResponseAsync(containerName, leaseId, proposedLeaseId, timeout, ifModifiedSince, - ifUnmodifiedSince, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseNoCustomHeadersWithResponseAsync(String containerName, String leaseId, - String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId) { - return FluxUtil - .withContext(context -> changeLeaseNoCustomHeadersWithResponseAsync(containerName, leaseId, proposedLeaseId, - timeout, ifModifiedSince, ifUnmodifiedSince, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + public Response renewLeaseWithResponse(String leaseId, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.renewLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), leaseId, accept, requestOptions, Context.NONE); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
x-ms-lease-break-periodIntegerNoFor a break operation, proposed duration the + * lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is + * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease + * will not be available before the break period has expired, but the lease may be held for longer than the break + * period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining + * lease period elapses, and an infinite lease breaks immediately.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseNoCustomHeadersWithResponseAsync(String containerName, String leaseId, - String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, Context context) { - final String comp = "lease"; - final String restype = "container"; - final String action = "change"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .changeLeaseNoCustomHeaders(this.client.getUrl(), containerName, comp, restype, action, timeout, leaseId, - proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase changeLeaseWithResponse(String containerName, - String leaseId, String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String requestId, Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "change"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.changeLeaseSync(this.client.getUrl(), containerName, comp, restype, action, timeout, leaseId, - proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void changeLease(String containerName, String leaseId, String proposedLeaseId, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String requestId) { - changeLeaseWithResponse(containerName, leaseId, proposedLeaseId, timeout, ifModifiedSince, ifUnmodifiedSince, - requestId, Context.NONE); - } - - /** - * [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 - * seconds, or can be infinite. - * - * @param containerName The container name. - * @param leaseId Specifies the current lease ID on the resource. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) - * if the proposed lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID - * string formats. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + public Mono> breakLeaseWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.breakLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + context)); + } + + /** + * The Break Lease operation ends a lease and ensures that another client can't acquire a new lease until the + * current lease period has expired. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
x-ms-lease-break-periodIntegerNoFor a break operation, proposed duration the + * lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is + * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease + * will not be available before the break period has expired, but the lease may be held for longer than the break + * period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining + * lease period elapses, and an infinite lease breaks immediately.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response changeLeaseNoCustomHeadersWithResponse(String containerName, String leaseId, - String proposedLeaseId, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String requestId, Context context) { - try { - final String comp = "lease"; - final String restype = "container"; - final String action = "change"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.changeLeaseNoCustomHeadersSync(this.client.getUrl(), containerName, comp, restype, action, - timeout, leaseId, proposedLeaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - listBlobFlatSegmentWithResponseAsync(String containerName, String prefix, String marker, Integer maxresults, - List include, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> listBlobFlatSegmentWithResponseAsync(containerName, prefix, marker, maxresults, - include, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - listBlobFlatSegmentWithResponseAsync(String containerName, String prefix, String marker, Integer maxresults, - List include, Integer timeout, String requestId, Context context) { - final String restype = "container"; - final String comp = "list"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .listBlobFlatSegment(this.client.getUrl(), containerName, restype, comp, prefix, marker, maxresults, - includeConverted, timeout, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listBlobFlatSegmentAsync(String containerName, String prefix, - String marker, Integer maxresults, List include, Integer timeout, String requestId) { - return listBlobFlatSegmentWithResponseAsync(containerName, prefix, marker, maxresults, include, timeout, - requestId).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs on successful completion of {@link Mono}. + public Response breakLeaseWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.breakLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), accept, requestOptions, Context.NONE); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param proposedLeaseId Required. The proposed lease ID for the container. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listBlobFlatSegmentAsync(String containerName, String prefix, - String marker, Integer maxresults, List include, Integer timeout, String requestId, - Context context) { - return listBlobFlatSegmentWithResponseAsync(containerName, prefix, marker, maxresults, include, timeout, - requestId, context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs along with {@link Response} on successful completion of {@link Mono}. + public Mono> changeLeaseWithResponseAsync(String leaseId, String proposedLeaseId, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.changeLease(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), leaseId, proposedLeaseId, + accept, requestOptions, context)); + } + + /** + * The Change Lease operation is used to change the ID of an existing lease. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-Modified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has been modified since the specified date-time.
If-Unmodified-SinceOffsetDateTimeNoA date-time value. A request is made under + * the condition that the resource has not been modified since the specified date-time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param leaseId Required. A lease ID for the source path. If specified, the source path must have an active lease + * and the lease ID must match. + * @param proposedLeaseId Required. The proposed lease ID for the container. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobFlatSegmentNoCustomHeadersWithResponseAsync( - String containerName, String prefix, String marker, Integer maxresults, List include, - Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> listBlobFlatSegmentNoCustomHeadersWithResponseAsync(containerName, prefix, marker, - maxresults, include, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + public Response changeLeaseWithResponse(String leaseId, String proposedLeaseId, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.changeLeaseSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), leaseId, proposedLeaseId, accept, requestOptions, Context.NONE); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     containerName: String (Required)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     segment (Required): {
+     *         blobItems (Required): [
+     *              (Required){
+     *                 name (Required): {
+     *                     encoded: boolean (Required)
+     *                     content: String (Required)
+     *                 }
+     *                 deleted: boolean (Required)
+     *                 snapshot: String (Required)
+     *                 versionId: String (Optional)
+     *                 isCurrentVersion: Boolean (Optional)
+     *                 properties (Required): {
+     *                     creationTime: DateTimeRfc1123 (Optional)
+     *                     lastModified: DateTimeRfc1123 (Required)
+     *                     eTag: String (Required)
+     *                     contentLength: Long (Optional)
+     *                     contentType: String (Optional)
+     *                     contentEncoding: String (Optional)
+     *                     contentLanguage: String (Optional)
+     *                     contentMd5: byte[] (Optional)
+     *                     contentDisposition: String (Optional)
+     *                     cacheControl: String (Optional)
+     *                     blobSequenceNumber: Long (Optional)
+     *                     blobType: String(BlockBlob/PageBlob/AppendBlob) (Optional)
+     *                     leaseStatus: String(unlocked/locked) (Optional)
+     *                     leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                     leaseDuration: String(infinite/fixed) (Optional)
+     *                     copyId: String (Optional)
+     *                     copyStatus: String(pending/success/failed/aborted) (Optional)
+     *                     copySource: String (Optional)
+     *                     copyProgress: String (Optional)
+     *                     copyCompletionTime: DateTimeRfc1123 (Optional)
+     *                     copyStatusDescription: String (Optional)
+     *                     serverEncrypted: Boolean (Optional)
+     *                     incrementalCopy: Boolean (Optional)
+     *                     destinationSnapshot: String (Optional)
+     *                     deletedTime: DateTimeRfc1123 (Optional)
+     *                     remainingRetentionDays: Integer (Optional)
+     *                     accessTier: String(P4/P6/P10/P15/P20/P30/P40/P50/P60/P70/P80/Hot/Cool/Archive/Premium/Cold) (Optional)
+     *                     accessTierInferred: Boolean (Optional)
+     *                     archiveStatus: String(rehydrate-pending-to-hot/rehydrate-pending-to-cool/rehydrate-pending-to-cold) (Optional)
+     *                     customerProvidedKeySha256: String (Optional)
+     *                     encryptionScope: String (Optional)
+     *                     accessTierChangeTime: DateTimeRfc1123 (Optional)
+     *                     tagCount: Integer (Optional)
+     *                     expiryTime: DateTimeRfc1123 (Optional)
+     *                     sealed: Boolean (Optional)
+     *                     rehydratePriority: String(High/Standard) (Optional)
+     *                     lastAccessTime: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyUntilDate: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyMode: String(Mutable/Locked/Unlocked) (Optional)
+     *                     legalHold: Boolean (Optional)
+     *                 }
+     *                 metadata (Optional): {
+     *                     encrypted: String (Optional)
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 blobTags (Optional): {
+     *                     blobTagSet (Required): [
+     *                          (Required){
+     *                             key: String (Required)
+     *                             value: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *                 objectReplicationMetadata (Optional): {
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 hasVersionsOnly: Boolean (Optional)
+     *             }
+     *         ]
+     *     }
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return an enumeration of blobs along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobFlatSegmentNoCustomHeadersWithResponseAsync( - String containerName, String prefix, String marker, Integer maxresults, List include, - Integer timeout, String requestId, Context context) { - final String restype = "container"; - final String comp = "list"; + public Mono> listBlobFlatSegmentWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .listBlobFlatSegmentNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, prefix, marker, - maxresults, includeConverted, timeout, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase - listBlobFlatSegmentWithResponse(String containerName, String prefix, String marker, Integer maxresults, - List include, Integer timeout, String requestId, Context context) { - try { - final String restype = "container"; - final String comp = "list"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service.listBlobFlatSegmentSync(this.client.getUrl(), containerName, restype, comp, prefix, marker, - maxresults, includeConverted, timeout, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ListBlobsFlatSegmentResponse listBlobFlatSegment(String containerName, String prefix, String marker, - Integer maxresults, List include, Integer timeout, String requestId) { - try { - return listBlobFlatSegmentWithResponse(containerName, prefix, marker, maxresults, include, timeout, - requestId, Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + return FluxUtil.withContext(context -> service.listBlobFlatSegment(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + context)); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     containerName: String (Required)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     segment (Required): {
+     *         blobItems (Required): [
+     *              (Required){
+     *                 name (Required): {
+     *                     encoded: boolean (Required)
+     *                     content: String (Required)
+     *                 }
+     *                 deleted: boolean (Required)
+     *                 snapshot: String (Required)
+     *                 versionId: String (Optional)
+     *                 isCurrentVersion: Boolean (Optional)
+     *                 properties (Required): {
+     *                     creationTime: DateTimeRfc1123 (Optional)
+     *                     lastModified: DateTimeRfc1123 (Required)
+     *                     eTag: String (Required)
+     *                     contentLength: Long (Optional)
+     *                     contentType: String (Optional)
+     *                     contentEncoding: String (Optional)
+     *                     contentLanguage: String (Optional)
+     *                     contentMd5: byte[] (Optional)
+     *                     contentDisposition: String (Optional)
+     *                     cacheControl: String (Optional)
+     *                     blobSequenceNumber: Long (Optional)
+     *                     blobType: String(BlockBlob/PageBlob/AppendBlob) (Optional)
+     *                     leaseStatus: String(unlocked/locked) (Optional)
+     *                     leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                     leaseDuration: String(infinite/fixed) (Optional)
+     *                     copyId: String (Optional)
+     *                     copyStatus: String(pending/success/failed/aborted) (Optional)
+     *                     copySource: String (Optional)
+     *                     copyProgress: String (Optional)
+     *                     copyCompletionTime: DateTimeRfc1123 (Optional)
+     *                     copyStatusDescription: String (Optional)
+     *                     serverEncrypted: Boolean (Optional)
+     *                     incrementalCopy: Boolean (Optional)
+     *                     destinationSnapshot: String (Optional)
+     *                     deletedTime: DateTimeRfc1123 (Optional)
+     *                     remainingRetentionDays: Integer (Optional)
+     *                     accessTier: String(P4/P6/P10/P15/P20/P30/P40/P50/P60/P70/P80/Hot/Cool/Archive/Premium/Cold) (Optional)
+     *                     accessTierInferred: Boolean (Optional)
+     *                     archiveStatus: String(rehydrate-pending-to-hot/rehydrate-pending-to-cool/rehydrate-pending-to-cold) (Optional)
+     *                     customerProvidedKeySha256: String (Optional)
+     *                     encryptionScope: String (Optional)
+     *                     accessTierChangeTime: DateTimeRfc1123 (Optional)
+     *                     tagCount: Integer (Optional)
+     *                     expiryTime: DateTimeRfc1123 (Optional)
+     *                     sealed: Boolean (Optional)
+     *                     rehydratePriority: String(High/Standard) (Optional)
+     *                     lastAccessTime: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyUntilDate: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyMode: String(Mutable/Locked/Unlocked) (Optional)
+     *                     legalHold: Boolean (Optional)
+     *                 }
+     *                 metadata (Optional): {
+     *                     encrypted: String (Optional)
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 blobTags (Optional): {
+     *                     blobTagSet (Required): [
+     *                          (Required){
+     *                             key: String (Required)
+     *                             value: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *                 objectReplicationMetadata (Optional): {
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 hasVersionsOnly: Boolean (Optional)
+     *             }
+     *         ]
+     *     }
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return an enumeration of blobs along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response listBlobFlatSegmentNoCustomHeadersWithResponse(String containerName, - String prefix, String marker, Integer maxresults, List include, Integer timeout, - String requestId, Context context) { - try { - final String restype = "container"; - final String comp = "list"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service.listBlobFlatSegmentNoCustomHeadersSync(this.client.getUrl(), containerName, restype, comp, - prefix, marker, maxresults, includeConverted, timeout, this.client.getVersion(), requestId, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the - * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the - * appearance of the delimiter character. The delimiter may be a single character or a string. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - listBlobHierarchySegmentWithResponseAsync(String containerName, String delimiter, String prefix, String marker, - Integer maxresults, List include, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> listBlobHierarchySegmentWithResponseAsync(containerName, delimiter, prefix, marker, - maxresults, include, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the - * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the - * appearance of the delimiter character. The delimiter may be a single character or a string. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - listBlobHierarchySegmentWithResponseAsync(String containerName, String delimiter, String prefix, String marker, - Integer maxresults, List include, Integer timeout, String requestId, - Context context) { - final String restype = "container"; - final String comp = "list"; + public Response listBlobFlatSegmentWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .listBlobHierarchySegment(this.client.getUrl(), containerName, restype, comp, prefix, delimiter, marker, - maxresults, includeConverted, timeout, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the - * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the - * appearance of the delimiter character. The delimiter may be a single character or a string. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listBlobHierarchySegmentAsync(String containerName, String delimiter, - String prefix, String marker, Integer maxresults, List include, Integer timeout, - String requestId) { - return listBlobHierarchySegmentWithResponseAsync(containerName, delimiter, prefix, marker, maxresults, include, - timeout, requestId).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the - * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the - * appearance of the delimiter character. The delimiter may be a single character or a string. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listBlobHierarchySegmentAsync(String containerName, String delimiter, - String prefix, String marker, Integer maxresults, List include, Integer timeout, - String requestId, Context context) { - return listBlobHierarchySegmentWithResponseAsync(containerName, delimiter, prefix, marker, maxresults, include, - timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the - * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the - * appearance of the delimiter character. The delimiter may be a single character or a string. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobHierarchySegmentNoCustomHeadersWithResponseAsync( - String containerName, String delimiter, String prefix, String marker, Integer maxresults, - List include, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> listBlobHierarchySegmentNoCustomHeadersWithResponseAsync(containerName, delimiter, - prefix, marker, maxresults, include, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + return service.listBlobFlatSegmentSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + Context.NONE); } /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. + * The List Blobs operation returns a list of the blobs under the specified container. A delimiter can be used to + * traverse a virtual hierarchy of blobs as though it were a file system. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     containerName: String (Required)
+     *     delimiter: String (Optional)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     segment (Required): {
+     *         blobItems (Required): [
+     *              (Required){
+     *                 name (Required): {
+     *                     encoded: boolean (Required)
+     *                     content: String (Required)
+     *                 }
+     *                 deleted: boolean (Required)
+     *                 snapshot: String (Required)
+     *                 versionId: String (Optional)
+     *                 isCurrentVersion: Boolean (Optional)
+     *                 properties (Required): {
+     *                     creationTime: DateTimeRfc1123 (Optional)
+     *                     lastModified: DateTimeRfc1123 (Required)
+     *                     eTag: String (Required)
+     *                     contentLength: Long (Optional)
+     *                     contentType: String (Optional)
+     *                     contentEncoding: String (Optional)
+     *                     contentLanguage: String (Optional)
+     *                     contentMd5: byte[] (Optional)
+     *                     contentDisposition: String (Optional)
+     *                     cacheControl: String (Optional)
+     *                     blobSequenceNumber: Long (Optional)
+     *                     blobType: String(BlockBlob/PageBlob/AppendBlob) (Optional)
+     *                     leaseStatus: String(unlocked/locked) (Optional)
+     *                     leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                     leaseDuration: String(infinite/fixed) (Optional)
+     *                     copyId: String (Optional)
+     *                     copyStatus: String(pending/success/failed/aborted) (Optional)
+     *                     copySource: String (Optional)
+     *                     copyProgress: String (Optional)
+     *                     copyCompletionTime: DateTimeRfc1123 (Optional)
+     *                     copyStatusDescription: String (Optional)
+     *                     serverEncrypted: Boolean (Optional)
+     *                     incrementalCopy: Boolean (Optional)
+     *                     destinationSnapshot: String (Optional)
+     *                     deletedTime: DateTimeRfc1123 (Optional)
+     *                     remainingRetentionDays: Integer (Optional)
+     *                     accessTier: String(P4/P6/P10/P15/P20/P30/P40/P50/P60/P70/P80/Hot/Cool/Archive/Premium/Cold) (Optional)
+     *                     accessTierInferred: Boolean (Optional)
+     *                     archiveStatus: String(rehydrate-pending-to-hot/rehydrate-pending-to-cool/rehydrate-pending-to-cold) (Optional)
+     *                     customerProvidedKeySha256: String (Optional)
+     *                     encryptionScope: String (Optional)
+     *                     accessTierChangeTime: DateTimeRfc1123 (Optional)
+     *                     tagCount: Integer (Optional)
+     *                     expiryTime: DateTimeRfc1123 (Optional)
+     *                     sealed: Boolean (Optional)
+     *                     rehydratePriority: String(High/Standard) (Optional)
+     *                     lastAccessTime: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyUntilDate: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyMode: String(Mutable/Locked/Unlocked) (Optional)
+     *                     legalHold: Boolean (Optional)
+     *                 }
+     *                 metadata (Optional): {
+     *                     encrypted: String (Optional)
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 blobTags (Optional): {
+     *                     blobTagSet (Required): [
+     *                          (Required){
+     *                             key: String (Required)
+     *                             value: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *                 objectReplicationMetadata (Optional): {
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 hasVersionsOnly: Boolean (Optional)
+     *             }
+     *         ]
+     *         blobPrefixes (Optional): [
+     *              (Optional){
+     *                 name (Required): (recursive schema, see name above)
+     *             }
+     *         ]
+     *     }
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the * appearance of the delimiter character. The delimiter may be a single character or a string. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return an enumeration of blobs along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobHierarchySegmentNoCustomHeadersWithResponseAsync( - String containerName, String delimiter, String prefix, String marker, Integer maxresults, - List include, Integer timeout, String requestId, Context context) { - final String restype = "container"; - final String comp = "list"; + public Mono> listBlobHierarchySegmentWithResponseAsync(String delimiter, + RequestOptions requestOptions) { + final String contentType = "application/xml"; final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .listBlobHierarchySegmentNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, prefix, - delimiter, marker, maxresults, includeConverted, timeout, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the - * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the - * appearance of the delimiter character. The delimiter may be a single character or a string. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase - listBlobHierarchySegmentWithResponse(String containerName, String delimiter, String prefix, String marker, - Integer maxresults, List include, Integer timeout, String requestId, - Context context) { - try { - final String restype = "container"; - final String comp = "list"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service.listBlobHierarchySegmentSync(this.client.getUrl(), containerName, restype, comp, prefix, - delimiter, marker, maxresults, includeConverted, timeout, this.client.getVersion(), requestId, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. + return FluxUtil.withContext(context -> service.listBlobHierarchySegment(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), delimiter, accept, + requestOptions, context)); + } + + /** + * The List Blobs operation returns a list of the blobs under the specified container. A delimiter can be used to + * traverse a virtual hierarchy of blobs as though it were a file system. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     containerName: String (Required)
+     *     delimiter: String (Optional)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     segment (Required): {
+     *         blobItems (Required): [
+     *              (Required){
+     *                 name (Required): {
+     *                     encoded: boolean (Required)
+     *                     content: String (Required)
+     *                 }
+     *                 deleted: boolean (Required)
+     *                 snapshot: String (Required)
+     *                 versionId: String (Optional)
+     *                 isCurrentVersion: Boolean (Optional)
+     *                 properties (Required): {
+     *                     creationTime: DateTimeRfc1123 (Optional)
+     *                     lastModified: DateTimeRfc1123 (Required)
+     *                     eTag: String (Required)
+     *                     contentLength: Long (Optional)
+     *                     contentType: String (Optional)
+     *                     contentEncoding: String (Optional)
+     *                     contentLanguage: String (Optional)
+     *                     contentMd5: byte[] (Optional)
+     *                     contentDisposition: String (Optional)
+     *                     cacheControl: String (Optional)
+     *                     blobSequenceNumber: Long (Optional)
+     *                     blobType: String(BlockBlob/PageBlob/AppendBlob) (Optional)
+     *                     leaseStatus: String(unlocked/locked) (Optional)
+     *                     leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                     leaseDuration: String(infinite/fixed) (Optional)
+     *                     copyId: String (Optional)
+     *                     copyStatus: String(pending/success/failed/aborted) (Optional)
+     *                     copySource: String (Optional)
+     *                     copyProgress: String (Optional)
+     *                     copyCompletionTime: DateTimeRfc1123 (Optional)
+     *                     copyStatusDescription: String (Optional)
+     *                     serverEncrypted: Boolean (Optional)
+     *                     incrementalCopy: Boolean (Optional)
+     *                     destinationSnapshot: String (Optional)
+     *                     deletedTime: DateTimeRfc1123 (Optional)
+     *                     remainingRetentionDays: Integer (Optional)
+     *                     accessTier: String(P4/P6/P10/P15/P20/P30/P40/P50/P60/P70/P80/Hot/Cool/Archive/Premium/Cold) (Optional)
+     *                     accessTierInferred: Boolean (Optional)
+     *                     archiveStatus: String(rehydrate-pending-to-hot/rehydrate-pending-to-cool/rehydrate-pending-to-cold) (Optional)
+     *                     customerProvidedKeySha256: String (Optional)
+     *                     encryptionScope: String (Optional)
+     *                     accessTierChangeTime: DateTimeRfc1123 (Optional)
+     *                     tagCount: Integer (Optional)
+     *                     expiryTime: DateTimeRfc1123 (Optional)
+     *                     sealed: Boolean (Optional)
+     *                     rehydratePriority: String(High/Standard) (Optional)
+     *                     lastAccessTime: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyUntilDate: DateTimeRfc1123 (Optional)
+     *                     immutabilityPolicyMode: String(Mutable/Locked/Unlocked) (Optional)
+     *                     legalHold: Boolean (Optional)
+     *                 }
+     *                 metadata (Optional): {
+     *                     encrypted: String (Optional)
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 blobTags (Optional): {
+     *                     blobTagSet (Required): [
+     *                          (Required){
+     *                             key: String (Required)
+     *                             value: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *                 objectReplicationMetadata (Optional): {
+     *                      (Optional): {
+     *                         String: String (Required)
+     *                     }
+     *                 }
+     *                 hasVersionsOnly: Boolean (Optional)
+     *             }
+     *         ]
+     *         blobPrefixes (Optional): [
+     *              (Optional){
+     *                 name (Required): (recursive schema, see name above)
+     *             }
+     *         ]
+     *     }
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the * appearance of the delimiter character. The delimiter may be a single character or a string. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of blobs. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ListBlobsHierarchySegmentResponse listBlobHierarchySegment(String containerName, String delimiter, - String prefix, String marker, Integer maxresults, List include, Integer timeout, - String requestId) { - try { - return listBlobHierarchySegmentWithResponse(containerName, delimiter, prefix, marker, maxresults, include, - timeout, requestId, Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The List Blobs operation returns a list of the blobs under the specified container. - * - * @param containerName The container name. - * @param delimiter When the request includes this parameter, the operation returns a BlobPrefix element in the - * response body that acts as a placeholder for all blobs whose names begin with the same substring up to the - * appearance of the delimiter character. The delimiter may be a single character or a string. - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return an enumeration of blobs along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response listBlobHierarchySegmentNoCustomHeadersWithResponse( - String containerName, String delimiter, String prefix, String marker, Integer maxresults, - List include, Integer timeout, String requestId, Context context) { - try { - final String restype = "container"; - final String comp = "list"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service.listBlobHierarchySegmentNoCustomHeadersSync(this.client.getUrl(), containerName, restype, - comp, prefix, delimiter, marker, maxresults, includeConverted, timeout, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getAccountInfoWithResponseAsync(String containerName, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> getAccountInfoWithResponseAsync(containerName, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getAccountInfoWithResponseAsync(String containerName, Integer timeout, String requestId, Context context) { - final String restype = "account"; - final String comp = "properties"; + public Response listBlobHierarchySegmentWithResponse(String delimiter, RequestOptions requestOptions) { + final String contentType = "application/xml"; final String accept = "application/xml"; - return service - .getAccountInfo(this.client.getUrl(), containerName, restype, comp, timeout, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccountInfoAsync(String containerName, Integer timeout, String requestId) { - return getAccountInfoWithResponseAsync(containerName, timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccountInfoAsync(String containerName, Integer timeout, String requestId, Context context) { - return getAccountInfoWithResponseAsync(containerName, timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String requestId) { - return FluxUtil - .withContext( - context -> getAccountInfoNoCustomHeadersWithResponseAsync(containerName, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + return service.listBlobHierarchySegmentSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), delimiter, accept, + requestOptions, Context.NONE); } /** * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoNoCustomHeadersWithResponseAsync(String containerName, Integer timeout, - String requestId, Context context) { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service - .getAccountInfoNoCustomHeaders(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getAccountInfoWithResponse(String containerName, - Integer timeout, String requestId, Context context) { - try { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.getAccountInfoSync(this.client.getUrl(), containerName, restype, comp, timeout, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void getAccountInfo(String containerName, Integer timeout, String requestId) { - getAccountInfoWithResponse(containerName, timeout, requestId, Context.NONE); + public Mono> getAccountInfoWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getAccountInfo(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + context)); } /** * Returns the sku name and account kind. - * - * @param containerName The container name. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getAccountInfoNoCustomHeadersWithResponse(String containerName, Integer timeout, - String requestId, Context context) { - try { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.getAccountInfoNoCustomHeadersSync(this.client.getUrl(), containerName, restype, comp, - timeout, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Response getAccountInfoWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.getAccountInfoSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), accept, requestOptions, + Context.NONE); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/PageBlobsImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/PageBlobsImpl.java index b78d5055d942..526ec3ae1c21 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/PageBlobsImpl.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/PageBlobsImpl.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.storage.blob.implementation; import com.azure.core.annotation.BodyParam; @@ -11,49 +12,27 @@ import com.azure.core.annotation.HostParam; import com.azure.core.annotation.PathParam; import com.azure.core.annotation.Put; -import com.azure.core.annotation.QueryParam; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceInterface; import com.azure.core.annotation.ServiceMethod; import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.Base64Util; import com.azure.core.util.BinaryData; import com.azure.core.util.Context; -import com.azure.core.util.DateTimeRfc1123; import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.implementation.models.BlobStorageExceptionInternal; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.PageBlobsClearPagesHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsCopyIncrementalHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsCreateHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesDiffHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsResizeHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsUpdateSequenceNumberHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsUploadPagesFromURLHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsUploadPagesHeaders; -import com.azure.storage.blob.implementation.models.PremiumPageBlobAccessTier; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.EncryptionAlgorithmType; -import com.azure.storage.blob.models.PageList; -import com.azure.storage.blob.models.SequenceNumberActionType; -import java.nio.ByteBuffer; -import java.time.OffsetDateTime; -import java.util.Map; -import reactor.core.publisher.Flux; +import com.azure.storage.blob.BlobServiceVersion; import reactor.core.publisher.Mono; /** * An instance of this class provides access to all the operations defined in PageBlobs. */ public final class PageBlobsImpl { - /** * The proxy service used to perform REST calls. */ @@ -62,6128 +41,1544 @@ public final class PageBlobsImpl { /** * The service client containing this operation class. */ - private final AzureBlobStorageImpl client; + private final ServiceClientClientImpl client; /** * Initializes an instance of PageBlobsImpl. - * + * * @param client the instance of the service client containing this operation class. */ - PageBlobsImpl(AzureBlobStorageImpl client) { + PageBlobsImpl(ServiceClientClientImpl client) { this.service = RestProxy.create(PageBlobsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } /** - * The interface defining all the services for AzureBlobStoragePageBlobs to be used by the proxy service to perform - * REST calls. + * Gets Service version. + * + * @return the serviceVersion value. + */ + public BlobServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for ServiceClientClientPageBlobs to be used by the proxy service to + * perform REST calls. */ @Host("{url}") - @ServiceInterface(name = "AzureBlobStoragePage") + @ServiceInterface(name = "ServiceClientClientP") public interface PageBlobsService { - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> create(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-access-tier") PremiumPageBlobAccessTier tier, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-blob-content-length") long blobContentLength, - @HeaderParam("x-ms-blob-sequence-number") Long blobSequenceNumber, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> createNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-access-tier") PremiumPageBlobAccessTier tier, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-blob-content-length") long blobContentLength, - @HeaderParam("x-ms-blob-sequence-number") Long blobSequenceNumber, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase createSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-access-tier") PremiumPageBlobAccessTier tier, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-blob-content-length") long blobContentLength, - @HeaderParam("x-ms-blob-sequence-number") Long blobSequenceNumber, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response createNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @HeaderParam("x-ms-blob-type") String blobType, @QueryParam("timeout") Integer timeout, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("x-ms-access-tier") PremiumPageBlobAccessTier tier, - @HeaderParam("x-ms-blob-content-type") String contentType, - @HeaderParam("x-ms-blob-content-encoding") String contentEncoding, - @HeaderParam("x-ms-blob-content-language") String contentLanguage, - @HeaderParam("x-ms-blob-content-md5") String contentMd5, - @HeaderParam("x-ms-blob-cache-control") String cacheControl, - @HeaderParam("x-ms-meta-") Map metadata, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-blob-content-disposition") String contentDisposition, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-blob-content-length") long blobContentLength, - @HeaderParam("x-ms-blob-sequence-number") Long blobSequenceNumber, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-tags") String blobTagsString, - @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, - @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, - @HeaderParam("x-ms-legal-hold") Boolean legalHold, @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> uploadPages(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") Flux body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> uploadPagesNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") Flux body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> uploadPages(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> uploadPagesNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase uploadPagesSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response uploadPagesNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-MD5") String transactionalContentMD5, - @HeaderParam("x-ms-content-crc64") String transactionalContentCrc64, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-structured-body") String structuredBodyType, - @HeaderParam("x-ms-structured-content-length") Long structuredContentLength, - @BodyParam("application/octet-stream") BinaryData body, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?PageBlob") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> clearPages(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> create(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("x-ms-blob-content-length") long blobContentLength, + @HeaderParam("x-ms-blob-type") String blobType, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?PageBlob") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> clearPagesNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("x-ms-blob-content-length") long blobContentLength, + @HeaderParam("x-ms-blob-type") String blobType, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=page&update") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase clearPagesSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadPages(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, @BodyParam("application/octet-stream") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=page&update") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response clearPagesNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("Content-Length") long contentLength, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadPagesSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, @BodyParam("application/octet-stream") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=page&clear") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> uploadPagesFromURL(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("x-ms-copy-source") String sourceUrl, @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, - @HeaderParam("Content-Length") long contentLength, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> clearPages(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=page&clear") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> uploadPagesFromURLNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, - @HeaderParam("x-ms-copy-source") String sourceUrl, @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, - @HeaderParam("Content-Length") long contentLength, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response clearPagesSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=page&update&fromUrl") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase uploadPagesFromURLSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadPagesFromUrl(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, @HeaderParam("x-ms-copy-source") String sourceUrl, @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, - @HeaderParam("Content-Length") long contentLength, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-range") String range, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=page&update&fromUrl") @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response uploadPagesFromURLNoCustomHeadersSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadPagesFromUrlSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @HeaderParam("x-ms-page-write") String pageWrite, @HeaderParam("x-ms-copy-source") String sourceUrl, @HeaderParam("x-ms-source-range") String sourceRange, - @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, - @HeaderParam("x-ms-source-content-crc64") String sourceContentcrc64, - @HeaderParam("Content-Length") long contentLength, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-range") String range, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-if-sequence-number-le") Long ifSequenceNumberLessThanOrEqualTo, - @HeaderParam("x-ms-if-sequence-number-lt") Long ifSequenceNumberLessThan, - @HeaderParam("x-ms-if-sequence-number-eq") Long ifSequenceNumberEqualTo, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-source-if-modified-since") DateTimeRfc1123 sourceIfModifiedSince, - @HeaderParam("x-ms-source-if-unmodified-since") DateTimeRfc1123 sourceIfUnmodifiedSince, - @HeaderParam("x-ms-source-if-match") String sourceIfMatch, - @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getPageRanges(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getPageRangesNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getPageRangesSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getPageRangesNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getPageRangesDiff(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @QueryParam("prevsnapshot") String prevsnapshot, - @HeaderParam("x-ms-previous-snapshot-url") String prevSnapshotUrl, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getPageRangesDiffNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @QueryParam("prevsnapshot") String prevsnapshot, - @HeaderParam("x-ms-previous-snapshot-url") String prevSnapshotUrl, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @HeaderParam("Accept") String accept, Context context); - - @Get("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getPageRangesDiffSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @QueryParam("prevsnapshot") String prevsnapshot, - @HeaderParam("x-ms-previous-snapshot-url") String prevSnapshotUrl, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @HeaderParam("Accept") String accept, Context context); + @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-range") String range, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Get("/{containerName}/{blob}") + @Get("/{containerName}/{blob}?comp=pagelist") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getPageRangesDiffNoCustomHeadersSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getPageRanges(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("snapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @QueryParam("prevsnapshot") String prevsnapshot, - @HeaderParam("x-ms-previous-snapshot-url") String prevSnapshotUrl, @HeaderParam("x-ms-range") String range, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @HeaderParam("Accept") String accept, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Get("/{containerName}/{blob}?comp=pagelist") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> resize(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getPageRangesSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-blob-content-length") long blobContentLength, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Get("/{containerName}/{blob}?comp=pagelist&diff") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> resizeNoCustomHeaders(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getPageRangesDiff(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-blob-content-length") long blobContentLength, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Get("/{containerName}/{blob}?comp=pagelist&diff") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase resizeSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getPageRangesDiffSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-blob-content-length") long blobContentLength, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=properties&Resize") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response resizeNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-encryption-key") String encryptionKey, - @HeaderParam("x-ms-encryption-key-sha256") String encryptionKeySha256, - @HeaderParam("x-ms-encryption-algorithm") EncryptionAlgorithmType encryptionAlgorithm, - @HeaderParam("x-ms-encryption-scope") String encryptionScope, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-blob-content-length") long blobContentLength, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> updateSequenceNumber( - @HostParam("url") String url, @PathParam("containerName") String containerName, - @PathParam("blob") String blob, @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-sequence-number-action") SequenceNumberActionType sequenceNumberAction, - @HeaderParam("x-ms-blob-sequence-number") Long blobSequenceNumber, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> resize(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-blob-content-length") long blobContentLength, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=properties&Resize") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> updateSequenceNumberNoCustomHeaders(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-sequence-number-action") SequenceNumberActionType sequenceNumberAction, - @HeaderParam("x-ms-blob-sequence-number") Long blobSequenceNumber, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response resizeSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @HeaderParam("x-ms-blob-content-length") long blobContentLength, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/{containerName}/{blob}?comp=properties&UpdateSequenceNumber") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase updateSequenceNumberSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateSequenceNumber(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-sequence-number-action") SequenceNumberActionType sequenceNumberAction, - @HeaderParam("x-ms-blob-sequence-number") Long blobSequenceNumber, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("x-ms-sequence-number-action") String sequenceNumberAction, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=properties&UpdateSequenceNumber") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response updateSequenceNumberNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, - @HeaderParam("x-ms-sequence-number-action") SequenceNumberActionType sequenceNumberAction, - @HeaderParam("x-ms-blob-sequence-number") Long blobSequenceNumber, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> copyIncremental(@HostParam("url") String url, - @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Put("/{containerName}/{blob}") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> copyIncrementalNoCustomHeaders(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateSequenceNumberSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("x-ms-sequence-number-action") String sequenceNumberAction, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=incrementalcopy") @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase copyIncrementalSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> copyIncremental(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); + @HeaderParam("x-ms-copy-source") String copySource, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); - @Put("/{containerName}/{blob}") + @Put("/{containerName}/{blob}?comp=incrementalcopy") @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response copyIncrementalNoCustomHeadersSync(@HostParam("url") String url, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response copyIncrementalSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, @PathParam("containerName") String containerName, @PathParam("blob") String blob, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("If-Modified-Since") DateTimeRfc1123 ifModifiedSince, - @HeaderParam("If-Unmodified-Since") DateTimeRfc1123 ifUnmodifiedSince, - @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, - @HeaderParam("x-ms-if-tags") String ifTags, @HeaderParam("x-ms-copy-source") String copySource, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - } - - /** - * The Create operation creates a new page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param tier Optional. Indicates the tier to be set on the page blob. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync(String containerName, String blob, - long contentLength, long blobContentLength, Integer timeout, PremiumPageBlobAccessTier tier, - Map metadata, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> createWithResponseAsync(containerName, blob, contentLength, blobContentLength, - timeout, tier, metadata, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, - blobSequenceNumber, requestId, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, - legalHold, blobHttpHeaders, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + @HeaderParam("x-ms-copy-source") String copySource, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); } /** * The Create operation creates a new page blob. - * - * @param containerName The container name. - * @param blob The blob name. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoOptional. Indicates the tier to be set on the page + * blob. Allowed values: "P4", "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80".
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-blob-sequence-numberLongNoOptional. The sequence number is a + * user-controlled property that you can use to track requests. The value of the sequence number must be between 0 + * and 2^63 - 1. The default value is 0.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * * @param contentLength The length of the request. * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param tier Optional. Indicates the tier to be set on the page blob. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync(String containerName, String blob, - long contentLength, long blobContentLength, Integer timeout, PremiumPageBlobAccessTier tier, - Map metadata, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { + public Mono> createWithResponseAsync(long contentLength, long blobContentLength, + RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; final String blobType = "PageBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .create(this.client.getUrl(), containerName, blob, blobType, timeout, contentLength, tier, contentType, - contentEncoding, contentLanguage, contentMd5Converted, cacheControl, metadata, leaseId, - contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, blobContentLength, - blobSequenceNumber, this.client.getVersion(), requestId, blobTagsString, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.create(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + contentLength, blobContentLength, blobType, accept, requestOptions, context)); } /** * The Create operation creates a new page blob. - * - * @param containerName The container name. - * @param blob The blob name. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-metaMap<String, String>NoThe metadata headers.
x-ms-access-tierStringNoOptional. Indicates the tier to be set on the page + * blob. Allowed values: "P4", "P6", "P10", "P15", "P20", "P30", "P40", "P50", "P60", "P70", "P80".
x-ms-blob-content-typeStringNoOptional. Sets the blob's content type. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-encodingStringNoOptional. Sets the blob's content encoding. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-languageStringNoOptional. Set the blob's content language. + * If specified, this property is stored with the blob and returned with a read request.
x-ms-blob-content-md5byte[]NoOptional. An MD5 hash of the blob content. Note + * that this hash is not validated, as the hashes for the individual blocks were validated when each was + * uploaded.
x-ms-blob-cache-controlStringNoOptional. Sets the blob's cache control. If + * specified, this property is stored with the blob and returned with a read request.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-blob-content-dispositionStringNoOptional. Sets the blob's content + * disposition. If specified, this property is stored with the blob and returned with a read request.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-blob-sequence-numberLongNoOptional. The sequence number is a + * user-controlled property that you can use to track requests. The value of the sequence number must be between 0 + * and 2^63 - 1. The default value is 0.
x-ms-tagsStringNoOptional. Used to set blob tags in various blob + * operations.
x-ms-immutability-policy-until-dateOffsetDateTimeNoSpecifies the date time + * when the blobs immutability policy is set to expire.
x-ms-immutability-policy-modeStringNoSpecifies the immutability policy mode to + * set on the blob. Allowed values: "Mutable", "Locked", "Unlocked".
x-ms-legal-holdBooleanNoSpecified if a legal hold should be set on the + * blob.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * * @param contentLength The length of the request. * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param tier Optional. Indicates the tier to be set on the page blob. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createAsync(String containerName, String blob, long contentLength, long blobContentLength, - Integer timeout, PremiumPageBlobAccessTier tier, Map metadata, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, Long blobSequenceNumber, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return createWithResponseAsync(containerName, blob, contentLength, blobContentLength, timeout, tier, metadata, - leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, blobSequenceNumber, requestId, - blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, - encryptionScopeParam).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + public Response createWithResponse(long contentLength, long blobContentLength, + RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String blobType = "PageBlob"; + final String accept = "application/json"; + return service.createSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), contentLength, blobContentLength, blobType, accept, + requestOptions, Context.NONE); } /** - * The Create operation creates a new page blob. - * - * @param containerName The container name. - * @param blob The blob name. + * The Upload Pages operation writes a range of pages to a page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * * @param contentLength The length of the request. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param tier Optional. Indicates the tier to be set on the page blob. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createAsync(String containerName, String blob, long contentLength, long blobContentLength, - Integer timeout, PremiumPageBlobAccessTier tier, Map metadata, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, Long blobSequenceNumber, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - return createWithResponseAsync(containerName, blob, contentLength, blobContentLength, timeout, tier, metadata, - leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, blobSequenceNumber, requestId, - blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, - encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + public Mono> uploadPagesWithResponseAsync(long contentLength, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.uploadPages(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + contentLength, accept, body, requestOptions, context)); } /** - * The Create operation creates a new page blob. - * - * @param containerName The container name. - * @param blob The blob name. + * The Upload Pages operation writes a range of pages to a page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-MD5StringNoOptional. An MD5 hash of the blob content. Note that this + * hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
x-ms-content-crc64StringNoSpecify the transactional crc64 for the body, to be + * validated by the service.
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-structured-bodyStringNoRequired if the request body is a structured + * message. Specifies the message schema version and properties.
x-ms-structured-content-lengthLongNoRequired if the request body is a + * structured message. Specifies the length of the blob/file content inside the message body. Will always be smaller + * than Content-Length.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * * @param contentLength The length of the request. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param tier Optional. Indicates the tier to be set on the page blob. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, long blobContentLength, Integer timeout, PremiumPageBlobAccessTier tier, - Map metadata, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> createNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, - blobContentLength, timeout, tier, metadata, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, blobSequenceNumber, requestId, blobTagsString, immutabilityPolicyExpiry, - immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response uploadPagesWithResponse(long contentLength, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return service.uploadPagesSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), contentLength, accept, body, requestOptions, + Context.NONE); } /** - * The Create operation creates a new page blob. - * - * @param containerName The container name. - * @param blob The blob name. + * The Clear Pages operation clears a range of pages from a page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * * @param contentLength The length of the request. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param tier Optional. Indicates the tier to be set on the page blob. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, long blobContentLength, Integer timeout, PremiumPageBlobAccessTier tier, - Map metadata, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String blobType = "PageBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service - .createNoCustomHeaders(this.client.getUrl(), containerName, blob, blobType, timeout, contentLength, tier, - contentType, contentEncoding, contentLanguage, contentMd5Converted, cacheControl, metadata, leaseId, - contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, blobContentLength, - blobSequenceNumber, this.client.getVersion(), requestId, blobTagsString, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Create operation creates a new page blob. - * - * @param containerName The container name. - * @param blob The blob name. + public Mono> clearPagesWithResponseAsync(long contentLength, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.clearPages(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + contentLength, accept, requestOptions, context)); + } + + /** + * The Clear Pages operation clears a range of pages from a page blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * * @param contentLength The length of the request. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param tier Optional. Indicates the tier to be set on the page blob. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase createWithResponse(String containerName, String blob, - long contentLength, long blobContentLength, Integer timeout, PremiumPageBlobAccessTier tier, - Map metadata, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId, - String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String blobType = "PageBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.createSync(this.client.getUrl(), containerName, blob, blobType, timeout, contentLength, tier, - contentType, contentEncoding, contentLanguage, contentMd5Converted, cacheControl, metadata, leaseId, - contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, blobContentLength, - blobSequenceNumber, this.client.getVersion(), requestId, blobTagsString, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Response clearPagesWithResponse(long contentLength, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return service.clearPagesSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), contentLength, accept, requestOptions, Context.NONE); } /** - * The Create operation creates a new page blob. - * - * @param containerName The container name. - * @param blob The blob name. + * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. The length of this range should match the + * ContentLength header and x-ms-range/Range destination range header. * @param contentLength The length of the request. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param tier Optional. Indicates the tier to be set on the page blob. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param range Bytes of source data in the specified range. The length of this range should match the ContentLength + * header and x-ms-range/Range destination range header. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void create(String containerName, String blob, long contentLength, long blobContentLength, Integer timeout, - PremiumPageBlobAccessTier tier, Map metadata, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, - String requestId, String blobTagsString, OffsetDateTime immutabilityPolicyExpiry, - BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, BlobHttpHeaders blobHttpHeaders, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - createWithResponse(containerName, blob, contentLength, blobContentLength, timeout, tier, metadata, leaseId, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, blobSequenceNumber, requestId, - blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold, blobHttpHeaders, cpkInfo, - encryptionScopeParam, Context.NONE); + public Mono> uploadPagesFromUrlWithResponseAsync(String sourceUrl, String sourceRange, + long contentLength, String range, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.uploadPagesFromUrl(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + sourceUrl, sourceRange, contentLength, range, accept, requestOptions, context)); } /** - * The Create operation creates a new page blob. - * - * @param containerName The container name. - * @param blob The blob name. + * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-source-content-md5StringNoSpecify the md5 calculated for the range of + * bytes that must be read from the copy source.
x-ms-source-content-crc64byte[]NoSpecify the crc64 calculated for the range of + * bytes that must be read from the copy source.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-if-sequence-number-leLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than or equal to the specified.
x-ms-if-sequence-number-ltLongNoSpecify this header value to operate only on a + * blob if it has a sequence number less than the specified.
x-ms-if-sequence-number-eqLongNoSpecify this header value to operate only on a + * blob if it has the specified sequence number.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-source-if-modified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has been modified since the specified date/time.
x-ms-source-if-unmodified-sinceOffsetDateTimeNoSpecify this header value to + * operate only on a blob if it has not been modified since the specified date/time.
x-ms-source-if-matchStringNoSpecify an ETag value to operate only on blobs + * with a matching value.
x-ms-source-if-none-matchStringNoSpecify this header value to operate only on + * a blob if it has been modified since the specified date/time.
x-ms-copy-source-authorizationStringNoOnly Bearer type is supported. + * Credentials should be a valid OAuth access token to copy source.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sourceUrl Specify a URL to the copy source. + * @param sourceRange Bytes of source data in the specified range. The length of this range should match the + * ContentLength header and x-ms-range/Range destination range header. * @param contentLength The length of the request. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param tier Optional. Indicates the tier to be set on the page blob. - * @param metadata Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value - * pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. - * If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and - * metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names - * must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata - * for more information. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param blobTagsString Optional. Used to set blob tags in various blob operations. - * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. - * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. - * @param legalHold Specified if a legal hold should be set on the blob. - * @param blobHttpHeaders Parameter group. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param range Bytes of source data in the specified range. The length of this range should match the ContentLength + * header and x-ms-range/Range destination range header. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createNoCustomHeadersWithResponse(String containerName, String blob, long contentLength, - long blobContentLength, Integer timeout, PremiumPageBlobAccessTier tier, Map metadata, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId, String blobTagsString, - OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, - BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String blobType = "PageBlob"; - final String accept = "application/xml"; - String contentTypeInternal = null; - if (blobHttpHeaders != null) { - contentTypeInternal = blobHttpHeaders.getContentType(); - } - String contentType = contentTypeInternal; - String contentEncodingInternal = null; - if (blobHttpHeaders != null) { - contentEncodingInternal = blobHttpHeaders.getContentEncoding(); - } - String contentEncoding = contentEncodingInternal; - String contentLanguageInternal = null; - if (blobHttpHeaders != null) { - contentLanguageInternal = blobHttpHeaders.getContentLanguage(); - } - String contentLanguage = contentLanguageInternal; - byte[] contentMd5Internal = null; - if (blobHttpHeaders != null) { - contentMd5Internal = blobHttpHeaders.getContentMd5(); - } - byte[] contentMd5 = contentMd5Internal; - String cacheControlInternal = null; - if (blobHttpHeaders != null) { - cacheControlInternal = blobHttpHeaders.getCacheControl(); - } - String cacheControl = cacheControlInternal; - String contentDispositionInternal = null; - if (blobHttpHeaders != null) { - contentDispositionInternal = blobHttpHeaders.getContentDisposition(); - } - String contentDisposition = contentDispositionInternal; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String contentMd5Converted = Base64Util.encodeToString(contentMd5); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 immutabilityPolicyExpiryConverted - = immutabilityPolicyExpiry == null ? null : new DateTimeRfc1123(immutabilityPolicyExpiry); - return service.createNoCustomHeadersSync(this.client.getUrl(), containerName, blob, blobType, timeout, - contentLength, tier, contentType, contentEncoding, contentLanguage, contentMd5Converted, cacheControl, - metadata, leaseId, contentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, - encryptionScope, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - blobContentLength, blobSequenceNumber, this.client.getVersion(), requestId, blobTagsString, - immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesWithResponseAsync(String containerName, - String blob, long contentLength, Flux body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> uploadPagesWithResponseAsync(containerName, blob, contentLength, body, - transactionalContentMD5, transactionalContentCrc64, timeout, range, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response uploadPagesFromUrlWithResponse(String sourceUrl, String sourceRange, long contentLength, + String range, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + final String accept = "application/json"; + return service.uploadPagesFromUrlSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + sourceUrl, sourceRange, contentLength, range, accept, requestOptions, Context.NONE); } /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesWithResponseAsync(String containerName, - String blob, long contentLength, Flux body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "page"; - final String pageWrite = "update"; + * The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pageRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     clearRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents a page list along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPageRangesWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .uploadPages(this.client.getUrl(), containerName, blob, comp, pageWrite, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, range, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadPagesAsync(String containerName, String blob, long contentLength, Flux body, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return uploadPagesWithResponseAsync(containerName, blob, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, range, leaseId, ifSequenceNumberLessThanOrEqualTo, - ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadPagesAsync(String containerName, String blob, long contentLength, Flux body, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - return uploadPagesWithResponseAsync(containerName, blob, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, range, leaseId, ifSequenceNumberLessThanOrEqualTo, - ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Flux body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - Integer timeout, String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> uploadPagesNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, - body, transactionalContentMD5, transactionalContentCrc64, timeout, range, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + return FluxUtil.withContext(context -> service.getPageRanges(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); } /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Flux body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - Integer timeout, String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, - Context context) { - final String comp = "page"; - final String pageWrite = "update"; + * The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot of a page blob. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pageRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     clearRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents a page list along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPageRangesWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .uploadPagesNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, pageWrite, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, range, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesWithResponseAsync(String containerName, - String blob, long contentLength, BinaryData body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> uploadPagesWithResponseAsync(containerName, blob, contentLength, body, - transactionalContentMD5, transactionalContentCrc64, timeout, range, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + return service.getPageRangesSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, Context.NONE); } /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesWithResponseAsync(String containerName, - String blob, long contentLength, BinaryData body, byte[] transactionalContentMD5, - byte[] transactionalContentCrc64, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "page"; - final String pageWrite = "update"; + * The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob or snapshot of a page + * blob. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
prevsnapshotStringNoOptional in version 2015-07-08 and newer. The prevsnapshot + * parameter is a DateTime value that specifies that the response will contain only pages that were changed between + * target blob and previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a + * snapshot, as long as the snapshot specified by prevsnapshot is the older of the two. Note that incremental + * snapshots are currently supported only for blobs created on or after January 1, 2016.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-previous-snapshot-urlStringNoOptional. This header is only supported in + * service versions 2019-04-19 and after and specifies the URL of a previous snapshot of the target blob. The + * response will only contain pages that were changed between the target blob and its previous snapshot.
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pageRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     clearRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents a page list along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPageRangesDiffWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .uploadPages(this.client.getUrl(), containerName, blob, comp, pageWrite, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, range, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + return FluxUtil.withContext(context -> service.getPageRangesDiff(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, context)); } /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob or snapshot of a page + * blob. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
snapshotStringNoThe snapshot parameter is an opaque DateTime value that, when + * present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating + * a Snapshot of a Blob.</a>
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
prevsnapshotStringNoOptional in version 2015-07-08 and newer. The prevsnapshot + * parameter is a DateTime value that specifies that the response will contain only pages that were changed between + * target blob and previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a + * snapshot, as long as the snapshot specified by prevsnapshot is the older of the two. Note that incremental + * snapshots are currently supported only for blobs created on or after January 1, 2016.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-previous-snapshot-urlStringNoOptional. This header is only supported in + * service versions 2019-04-19 and after and specifies the URL of a previous snapshot of the target blob. The + * response will only contain pages that were changed between the target blob and its previous snapshot.
x-ms-rangeStringNoReturn only the bytes of the blob in the specified + * range.
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pageRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     clearRange (Optional): [
+     *          (Optional){
+     *             start: long (Required)
+     *             end: long (Required)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents a page list along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPageRangesDiffWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return service.getPageRangesDiffSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), accept, + requestOptions, Context.NONE); + } + + /** + * The Resize operation increases the size of the page blob to the specified size. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadPagesAsync(String containerName, String blob, long contentLength, BinaryData body, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return uploadPagesWithResponseAsync(containerName, blob, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, range, leaseId, ifSequenceNumberLessThanOrEqualTo, - ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + public Mono> resizeWithResponseAsync(long blobContentLength, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.resize(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + blobContentLength, accept, requestOptions, context)); + } + + /** + * The Resize operation increases the size of the page blob to the specified size. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
x-ms-encryption-keyStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption key to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
x-ms-encryption-key-sha256StringNoOptional. Version 2019-07-07 and later. + * Specifies the SHA256 hash of the encryption key used to encrypt the data provided in the request. This header is + * only used for encryption with a customer-provided key. If the request is authenticated with a client token, this + * header should be specified using the SHA256 hash of the encryption key.
x-ms-encryption-algorithmStringNoOptional. Version 2019-07-07 and later. + * Specifies the algorithm to use for encryption. If not specified, the default is AES256. Allowed values: + * "AES256".
x-ms-encryption-scopeStringNoOptional. Version 2019-07-07 and later. Specifies + * the encryption scope to use to encrypt the data provided in the request. If not specified, the request will be + * encrypted with the root account key.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size + * must be aligned to a 512-byte boundary. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadPagesAsync(String containerName, String blob, long contentLength, BinaryData body, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - return uploadPagesWithResponseAsync(containerName, blob, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, range, leaseId, ifSequenceNumberLessThanOrEqualTo, - ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); + public Response resizeWithResponse(long blobContentLength, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.resizeSync(this.client.getUrl(), contentType, this.client.getServiceVersion().getVersion(), + this.client.getContainerName(), this.client.getBlob(), blobContentLength, accept, requestOptions, + Context.NONE); } /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * The Update Sequence Number operation sets the blob's sequence number. The operation will fail if the specified + * sequence number is less than the current sequence number of the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-blob-sequence-numberLongNoSet for page blobs only. The sequence number is + * a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 + * and 2^63 - 1.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This + * property applies to page blobs only. This property indicates how the service should modify the blob's sequence + * number. Allowed values: "increment", "max", "update". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, BinaryData body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - Integer timeout, String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> uploadPagesNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, - body, transactionalContentMD5, transactionalContentCrc64, timeout, range, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, structuredBodyType, structuredContentLength, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + public Mono> updateSequenceNumberWithResponseAsync(String sequenceNumberAction, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.updateSequenceNumber(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + sequenceNumberAction, accept, requestOptions, context)); + } + + /** + * The Update Sequence Number operation sets the blob's sequence number. The operation will fail if the specified + * sequence number is less than the current sequence number of the blob. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-lease-idStringNoIf specified, the operation only succeeds if the + * resource's lease is active and matches this ID.
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
x-ms-blob-sequence-numberLongNoSet for page blobs only. The sequence number is + * a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 + * and 2^63 - 1.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This + * property applies to page blobs only. This property indicates how the service should modify the blob's sequence + * number. Allowed values: "increment", "max", "update". + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, BinaryData body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - Integer timeout, String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, - Context context) { - final String comp = "page"; - final String pageWrite = "update"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .uploadPagesNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, pageWrite, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, range, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, structuredBodyType, structuredContentLength, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); + public Response updateSequenceNumberWithResponse(String sequenceNumberAction, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.updateSequenceNumberSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + sequenceNumberAction, accept, requestOptions, Context.NONE); } /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. + * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot + * is copied such that only the differential changes between the previously copied snapshot are transferred to the + * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as + * usual. This API is supported since REST version 2016-05-31. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in + * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. + * The source blob must either be public or must be authenticated via a shared access signature. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase uploadPagesWithResponse(String containerName, String blob, - long contentLength, BinaryData body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, - Integer timeout, String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, - Context context) { - try { - final String comp = "page"; - final String pageWrite = "update"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.uploadPagesSync(this.client.getUrl(), containerName, blob, comp, pageWrite, contentLength, - transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, range, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, structuredBodyType, structuredContentLength, body, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void uploadPages(String containerName, String blob, long contentLength, BinaryData body, - byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - uploadPagesWithResponse(containerName, blob, contentLength, body, transactionalContentMD5, - transactionalContentCrc64, timeout, range, leaseId, ifSequenceNumberLessThanOrEqualTo, - ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, requestId, structuredBodyType, structuredContentLength, cpkInfo, encryptionScopeParam, - Context.NONE); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param body Initial data. - * @param transactionalContentMD5 Specify the transactional md5 for the body, to be validated by the service. - * @param transactionalContentCrc64 Specify the transactional crc64 for the body, to be validated by the service. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param structuredBodyType Required if the request body is a structured message. Specifies the message schema - * version and properties. - * @param structuredContentLength Required if the request body is a structured message. Specifies the length of the - * blob/file content inside the message body. Will always be smaller than Content-Length. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadPagesNoCustomHeadersWithResponse(String containerName, String blob, long contentLength, - BinaryData body, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, Integer timeout, - String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, - Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String structuredBodyType, Long structuredContentLength, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "page"; - final String pageWrite = "update"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String transactionalContentMD5Converted = Base64Util.encodeToString(transactionalContentMD5); - String transactionalContentCrc64Converted = Base64Util.encodeToString(transactionalContentCrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.uploadPagesNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, pageWrite, - contentLength, transactionalContentMD5Converted, transactionalContentCrc64Converted, timeout, range, - leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, structuredBodyType, structuredContentLength, body, accept, - context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Clear Pages operation clears a set of pages from a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> clearPagesWithResponseAsync(String containerName, - String blob, long contentLength, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> clearPagesWithResponseAsync(containerName, blob, contentLength, timeout, range, - leaseId, ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Clear Pages operation clears a set of pages from a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> clearPagesWithResponseAsync(String containerName, - String blob, long contentLength, Integer timeout, String range, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "page"; - final String pageWrite = "clear"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .clearPages(this.client.getUrl(), containerName, blob, comp, pageWrite, contentLength, timeout, range, - leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Clear Pages operation clears a set of pages from a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono clearPagesAsync(String containerName, String blob, long contentLength, Integer timeout, - String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, - Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return clearPagesWithResponseAsync(containerName, blob, contentLength, timeout, range, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Clear Pages operation clears a set of pages from a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono clearPagesAsync(String containerName, String blob, long contentLength, Integer timeout, - String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, - Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, - Context context) { - return clearPagesWithResponseAsync(containerName, blob, contentLength, timeout, range, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Clear Pages operation clears a set of pages from a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> clearPagesNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Integer timeout, String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> clearPagesNoCustomHeadersWithResponseAsync(containerName, blob, contentLength, - timeout, range, leaseId, ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, - ifSequenceNumberEqualTo, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, - cpkInfo, encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Clear Pages operation clears a set of pages from a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> clearPagesNoCustomHeadersWithResponseAsync(String containerName, String blob, - long contentLength, Integer timeout, String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "page"; - final String pageWrite = "clear"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .clearPagesNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, pageWrite, contentLength, - timeout, range, leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Clear Pages operation clears a set of pages from a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase clearPagesWithResponse(String containerName, String blob, - long contentLength, Integer timeout, String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "page"; - final String pageWrite = "clear"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.clearPagesSync(this.client.getUrl(), containerName, blob, comp, pageWrite, contentLength, - timeout, range, leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Clear Pages operation clears a set of pages from a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void clearPages(String containerName, String blob, long contentLength, Integer timeout, String range, - String leaseId, Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, - Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - clearPagesWithResponse(containerName, blob, contentLength, timeout, range, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, encryptionScopeParam, Context.NONE); - } - - /** - * The Clear Pages operation clears a set of pages from a page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param contentLength The length of the request. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response clearPagesNoCustomHeadersWithResponse(String containerName, String blob, long contentLength, - Integer timeout, String range, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "page"; - final String pageWrite = "clear"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.clearPagesNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, pageWrite, - contentLength, timeout, range, leaseId, encryptionKey, encryptionKeySha256, encryptionAlgorithm, - encryptionScope, ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. The length of this range should match the - * ContentLength header and x-ms-range/Range destination range header. - * @param contentLength The length of the request. - * @param range The range of bytes to which the source range would be written. The range should be 512 aligned and - * range-end is required. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesFromURLWithResponseAsync( - String containerName, String blob, String sourceUrl, String sourceRange, long contentLength, String range, - byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> uploadPagesFromURLWithResponseAsync(containerName, blob, sourceUrl, sourceRange, - contentLength, range, sourceContentMD5, sourceContentcrc64, timeout, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, - sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, encryptionScopeParam, - context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. The length of this range should match the - * ContentLength header and x-ms-range/Range destination range header. - * @param contentLength The length of the request. - * @param range The range of bytes to which the source range would be written. The range should be 512 aligned and - * range-end is required. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesFromURLWithResponseAsync( - String containerName, String blob, String sourceUrl, String sourceRange, long contentLength, String range, - byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, String leaseId, - Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "page"; - final String pageWrite = "update"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service - .uploadPagesFromURL(this.client.getUrl(), containerName, blob, comp, pageWrite, sourceUrl, sourceRange, - sourceContentMD5Converted, sourceContentcrc64Converted, contentLength, timeout, range, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, leaseId, ifSequenceNumberLessThanOrEqualTo, - ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, - sourceIfMatch, sourceIfNoneMatch, this.client.getVersion(), requestId, copySourceAuthorization, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. The length of this range should match the - * ContentLength header and x-ms-range/Range destination range header. - * @param contentLength The length of the request. - * @param range The range of bytes to which the source range would be written. The range should be 512 aligned and - * range-end is required. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadPagesFromURLAsync(String containerName, String blob, String sourceUrl, String sourceRange, - long contentLength, String range, byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, - String leaseId, Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, - Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return uploadPagesFromURLWithResponseAsync(containerName, blob, sourceUrl, sourceRange, contentLength, range, - sourceContentMD5, sourceContentcrc64, timeout, leaseId, ifSequenceNumberLessThanOrEqualTo, - ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestId, - copySourceAuthorization, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. The length of this range should match the - * ContentLength header and x-ms-range/Range destination range header. - * @param contentLength The length of the request. - * @param range The range of bytes to which the source range would be written. The range should be 512 aligned and - * range-end is required. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadPagesFromURLAsync(String containerName, String blob, String sourceUrl, String sourceRange, - long contentLength, String range, byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, - String leaseId, Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, - Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - return uploadPagesFromURLWithResponseAsync(containerName, blob, sourceUrl, sourceRange, contentLength, range, - sourceContentMD5, sourceContentcrc64, timeout, leaseId, ifSequenceNumberLessThanOrEqualTo, - ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestId, - copySourceAuthorization, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. The length of this range should match the - * ContentLength header and x-ms-range/Range destination range header. - * @param contentLength The length of the request. - * @param range The range of bytes to which the source range would be written. The range should be 512 aligned and - * range-end is required. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String sourceUrl, String sourceRange, long contentLength, String range, byte[] sourceContentMD5, - byte[] sourceContentcrc64, Integer timeout, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String requestId, String copySourceAuthorization, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam) { - return FluxUtil.withContext(context -> uploadPagesFromURLNoCustomHeadersWithResponseAsync(containerName, blob, - sourceUrl, sourceRange, contentLength, range, sourceContentMD5, sourceContentcrc64, timeout, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, - sourceIfMatch, sourceIfNoneMatch, requestId, copySourceAuthorization, cpkInfo, encryptionScopeParam, - context)).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. The length of this range should match the - * ContentLength header and x-ms-range/Range destination range header. - * @param contentLength The length of the request. - * @param range The range of bytes to which the source range would be written. The range should be 512 aligned and - * range-end is required. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesFromURLNoCustomHeadersWithResponseAsync(String containerName, String blob, - String sourceUrl, String sourceRange, long contentLength, String range, byte[] sourceContentMD5, - byte[] sourceContentcrc64, Integer timeout, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String requestId, String copySourceAuthorization, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - final String comp = "page"; - final String pageWrite = "update"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service - .uploadPagesFromURLNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, pageWrite, sourceUrl, - sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, contentLength, timeout, range, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, - this.client.getVersion(), requestId, copySourceAuthorization, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. The length of this range should match the - * ContentLength header and x-ms-range/Range destination range header. - * @param contentLength The length of the request. - * @param range The range of bytes to which the source range would be written. The range should be 512 aligned and - * range-end is required. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase uploadPagesFromURLWithResponse(String containerName, - String blob, String sourceUrl, String sourceRange, long contentLength, String range, byte[] sourceContentMD5, - byte[] sourceContentcrc64, Integer timeout, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String requestId, String copySourceAuthorization, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "page"; - final String pageWrite = "update"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service.uploadPagesFromURLSync(this.client.getUrl(), containerName, blob, comp, pageWrite, sourceUrl, - sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, contentLength, timeout, range, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, leaseId, - ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, - this.client.getVersion(), requestId, copySourceAuthorization, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. The length of this range should match the - * ContentLength header and x-ms-range/Range destination range header. - * @param contentLength The length of the request. - * @param range The range of bytes to which the source range would be written. The range should be 512 aligned and - * range-end is required. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void uploadPagesFromURL(String containerName, String blob, String sourceUrl, String sourceRange, - long contentLength, String range, byte[] sourceContentMD5, byte[] sourceContentcrc64, Integer timeout, - String leaseId, Long ifSequenceNumberLessThanOrEqualTo, Long ifSequenceNumberLessThan, - Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch, String requestId, String copySourceAuthorization, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - uploadPagesFromURLWithResponse(containerName, blob, sourceUrl, sourceRange, contentLength, range, - sourceContentMD5, sourceContentcrc64, timeout, leaseId, ifSequenceNumberLessThanOrEqualTo, - ifSequenceNumberLessThan, ifSequenceNumberEqualTo, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestId, - copySourceAuthorization, cpkInfo, encryptionScopeParam, Context.NONE); - } - - /** - * The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sourceUrl Specify a URL to the copy source. - * @param sourceRange Bytes of source data in the specified range. The length of this range should match the - * ContentLength header and x-ms-range/Range destination range header. - * @param contentLength The length of the request. - * @param range The range of bytes to which the source range would be written. The range should be 512 aligned and - * range-end is required. - * @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source. - * @param sourceContentcrc64 Specify the crc64 calculated for the range of bytes that must be read from the copy - * source. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifSequenceNumberLessThanOrEqualTo Specify this header value to operate only on a blob if it has a sequence - * number less than or equal to the specified. - * @param ifSequenceNumberLessThan Specify this header value to operate only on a blob if it has a sequence number - * less than the specified. - * @param ifSequenceNumberEqualTo Specify this header value to operate only on a blob if it has the specified - * sequence number. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param sourceIfModifiedSince Specify this header value to operate only on a blob if it has been modified since - * the specified date/time. - * @param sourceIfUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified - * since the specified date/time. - * @param sourceIfMatch Specify an ETag value to operate only on blobs with a matching value. - * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to - * copy source. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadPagesFromURLNoCustomHeadersWithResponse(String containerName, String blob, - String sourceUrl, String sourceRange, long contentLength, String range, byte[] sourceContentMD5, - byte[] sourceContentcrc64, Integer timeout, String leaseId, Long ifSequenceNumberLessThanOrEqualTo, - Long ifSequenceNumberLessThan, Long ifSequenceNumberEqualTo, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, - OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, - String sourceIfNoneMatch, String requestId, String copySourceAuthorization, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "page"; - final String pageWrite = "update"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5); - String sourceContentcrc64Converted = Base64Util.encodeToString(sourceContentcrc64); - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - DateTimeRfc1123 sourceIfModifiedSinceConverted - = sourceIfModifiedSince == null ? null : new DateTimeRfc1123(sourceIfModifiedSince); - DateTimeRfc1123 sourceIfUnmodifiedSinceConverted - = sourceIfUnmodifiedSince == null ? null : new DateTimeRfc1123(sourceIfUnmodifiedSince); - return service.uploadPagesFromURLNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, - pageWrite, sourceUrl, sourceRange, sourceContentMD5Converted, sourceContentcrc64Converted, - contentLength, timeout, range, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, - leaseId, ifSequenceNumberLessThanOrEqualTo, ifSequenceNumberLessThan, ifSequenceNumberEqualTo, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - sourceIfModifiedSinceConverted, sourceIfUnmodifiedSinceConverted, sourceIfMatch, sourceIfNoneMatch, - this.client.getVersion(), requestId, copySourceAuthorization, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a - * page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPageRangesWithResponseAsync( - String containerName, String blob, String snapshot, Integer timeout, String range, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String marker, Integer maxresults) { - return FluxUtil - .withContext(context -> getPageRangesWithResponseAsync(containerName, blob, snapshot, timeout, range, - leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, marker, - maxresults, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a - * page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPageRangesWithResponseAsync( - String containerName, String blob, String snapshot, Integer timeout, String range, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String marker, Integer maxresults, Context context) { - final String comp = "pagelist"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .getPageRanges(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, range, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, marker, maxresults, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a - * page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPageRangesAsync(String containerName, String blob, String snapshot, Integer timeout, - String range, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String marker, Integer maxresults) { - return getPageRangesWithResponseAsync(containerName, blob, snapshot, timeout, range, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, marker, maxresults) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a - * page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPageRangesAsync(String containerName, String blob, String snapshot, Integer timeout, - String range, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String marker, Integer maxresults, Context context) { - return getPageRangesWithResponseAsync(containerName, blob, snapshot, timeout, range, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, marker, maxresults, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a - * page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPageRangesNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, Integer timeout, String range, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String marker, Integer maxresults) { - return FluxUtil - .withContext(context -> getPageRangesNoCustomHeadersWithResponseAsync(containerName, blob, snapshot, - timeout, range, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, - marker, maxresults, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a - * page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPageRangesNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, Integer timeout, String range, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String marker, Integer maxresults, Context context) { - final String comp = "pagelist"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .getPageRangesNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, range, - leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, marker, maxresults, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a - * page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getPageRangesWithResponse(String containerName, - String blob, String snapshot, Integer timeout, String range, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String marker, Integer maxresults, Context context) { - try { - final String comp = "pagelist"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.getPageRangesSync(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, range, - leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - this.client.getVersion(), requestId, marker, maxresults, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a - * page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageList getPageRanges(String containerName, String blob, String snapshot, Integer timeout, String range, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String marker, Integer maxresults) { - try { - return getPageRangesWithResponse(containerName, blob, snapshot, timeout, range, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, marker, maxresults, Context.NONE) - .getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a - * page blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPageRangesNoCustomHeadersWithResponse(String containerName, String blob, - String snapshot, Integer timeout, String range, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String marker, Integer maxresults, Context context) { - try { - final String comp = "pagelist"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.getPageRangesNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, snapshot, - timeout, range, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, - ifTags, this.client.getVersion(), requestId, marker, maxresults, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were - * changed between target blob and previous snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that - * specifies that the response will contain only pages that were changed between target blob and previous snapshot. - * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot - * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only - * for blobs created on or after January 1, 2016. - * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and - * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were - * changed between the target blob and its previous snapshot. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPageRangesDiffWithResponseAsync( - String containerName, String blob, String snapshot, Integer timeout, String prevsnapshot, - String prevSnapshotUrl, String range, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String marker, Integer maxresults) { - return FluxUtil - .withContext(context -> getPageRangesDiffWithResponseAsync(containerName, blob, snapshot, timeout, - prevsnapshot, prevSnapshotUrl, range, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, requestId, marker, maxresults, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were - * changed between target blob and previous snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that - * specifies that the response will contain only pages that were changed between target blob and previous snapshot. - * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot - * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only - * for blobs created on or after January 1, 2016. - * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and - * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were - * changed between the target blob and its previous snapshot. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPageRangesDiffWithResponseAsync( - String containerName, String blob, String snapshot, Integer timeout, String prevsnapshot, - String prevSnapshotUrl, String range, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String marker, Integer maxresults, Context context) { - final String comp = "pagelist"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .getPageRangesDiff(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, prevsnapshot, - prevSnapshotUrl, range, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, - ifNoneMatch, ifTags, this.client.getVersion(), requestId, marker, maxresults, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were - * changed between target blob and previous snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that - * specifies that the response will contain only pages that were changed between target blob and previous snapshot. - * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot - * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only - * for blobs created on or after January 1, 2016. - * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and - * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were - * changed between the target blob and its previous snapshot. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPageRangesDiffAsync(String containerName, String blob, String snapshot, Integer timeout, - String prevsnapshot, String prevSnapshotUrl, String range, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String marker, Integer maxresults) { - return getPageRangesDiffWithResponseAsync(containerName, blob, snapshot, timeout, prevsnapshot, prevSnapshotUrl, - range, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, marker, - maxresults).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * [Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were - * changed between target blob and previous snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that - * specifies that the response will contain only pages that were changed between target blob and previous snapshot. - * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot - * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only - * for blobs created on or after January 1, 2016. - * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and - * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were - * changed between the target blob and its previous snapshot. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPageRangesDiffAsync(String containerName, String blob, String snapshot, Integer timeout, - String prevsnapshot, String prevSnapshotUrl, String range, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String marker, Integer maxresults, Context context) { - return getPageRangesDiffWithResponseAsync(containerName, blob, snapshot, timeout, prevsnapshot, prevSnapshotUrl, - range, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, marker, - maxresults, context).onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * [Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were - * changed between target blob and previous snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that - * specifies that the response will contain only pages that were changed between target blob and previous snapshot. - * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot - * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only - * for blobs created on or after January 1, 2016. - * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and - * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were - * changed between the target blob and its previous snapshot. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPageRangesDiffNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, Integer timeout, String prevsnapshot, String prevSnapshotUrl, String range, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String marker, Integer maxresults) { - return FluxUtil - .withContext(context -> getPageRangesDiffNoCustomHeadersWithResponseAsync(containerName, blob, snapshot, - timeout, prevsnapshot, prevSnapshotUrl, range, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, - ifNoneMatch, ifTags, requestId, marker, maxresults, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were - * changed between target blob and previous snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that - * specifies that the response will contain only pages that were changed between target blob and previous snapshot. - * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot - * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only - * for blobs created on or after January 1, 2016. - * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and - * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were - * changed between the target blob and its previous snapshot. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPageRangesDiffNoCustomHeadersWithResponseAsync(String containerName, String blob, - String snapshot, Integer timeout, String prevsnapshot, String prevSnapshotUrl, String range, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String marker, Integer maxresults, Context context) { - final String comp = "pagelist"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .getPageRangesDiffNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, - prevsnapshot, prevSnapshotUrl, range, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, marker, maxresults, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * [Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were - * changed between target blob and previous snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that - * specifies that the response will contain only pages that were changed between target blob and previous snapshot. - * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot - * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only - * for blobs created on or after January 1, 2016. - * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and - * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were - * changed between the target blob and its previous snapshot. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getPageRangesDiffWithResponse(String containerName, - String blob, String snapshot, Integer timeout, String prevsnapshot, String prevSnapshotUrl, String range, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, String marker, Integer maxresults, Context context) { - try { - final String comp = "pagelist"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.getPageRangesDiffSync(this.client.getUrl(), containerName, blob, comp, snapshot, timeout, - prevsnapshot, prevSnapshotUrl, range, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, - ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, marker, maxresults, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were - * changed between target blob and previous snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that - * specifies that the response will contain only pages that were changed between target blob and previous snapshot. - * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot - * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only - * for blobs created on or after January 1, 2016. - * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and - * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were - * changed between the target blob and its previous snapshot. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageList getPageRangesDiff(String containerName, String blob, String snapshot, Integer timeout, - String prevsnapshot, String prevSnapshotUrl, String range, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - String marker, Integer maxresults) { - try { - return getPageRangesDiffWithResponse(containerName, blob, snapshot, timeout, prevsnapshot, prevSnapshotUrl, - range, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, marker, - maxresults, Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * [Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were - * changed between target blob and previous snapshot or version. - * - * @param containerName The container name. - * @param blob The blob name. - * @param snapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the blob - * snapshot to retrieve. For more information on working with blob snapshots, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating - * a Snapshot of a Blob.</a>. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param prevsnapshot Optional in version 2015-07-08 and newer. The prevsnapshot parameter is a DateTime value that - * specifies that the response will contain only pages that were changed between target blob and previous snapshot. - * Changed pages include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot - * specified by prevsnapshot is the older of the two. Note that incremental snapshots are currently supported only - * for blobs created on or after January 1, 2016. - * @param prevSnapshotUrl Optional. This header is only supported in service versions 2019-04-19 and after and - * specifies the URL of a previous snapshot of the target blob. The response will only contain pages that were - * changed between the target blob and its previous snapshot. - * @param range Return only the bytes of the blob in the specified range. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of pages along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPageRangesDiffNoCustomHeadersWithResponse(String containerName, String blob, - String snapshot, Integer timeout, String prevsnapshot, String prevSnapshotUrl, String range, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, String marker, Integer maxresults, Context context) { - try { - final String comp = "pagelist"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.getPageRangesDiffNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, - snapshot, timeout, prevsnapshot, prevSnapshotUrl, range, leaseId, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, this.client.getVersion(), requestId, marker, - maxresults, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Resize the Blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> resizeWithResponseAsync(String containerName, String blob, - long blobContentLength, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> resizeWithResponseAsync(containerName, blob, blobContentLength, timeout, leaseId, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Resize the Blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> resizeWithResponseAsync(String containerName, String blob, - long blobContentLength, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "properties"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .resize(this.client.getUrl(), containerName, blob, comp, timeout, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, blobContentLength, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Resize the Blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono resizeAsync(String containerName, String blob, long blobContentLength, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return resizeWithResponseAsync(containerName, blob, blobContentLength, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, encryptionScopeParam) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Resize the Blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono resizeAsync(String containerName, String blob, long blobContentLength, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, - Context context) { - return resizeWithResponseAsync(containerName, blob, blobContentLength, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, encryptionScopeParam, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Resize the Blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> resizeNoCustomHeadersWithResponseAsync(String containerName, String blob, - long blobContentLength, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - return FluxUtil - .withContext(context -> resizeNoCustomHeadersWithResponseAsync(containerName, blob, blobContentLength, - timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, - encryptionScopeParam, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Resize the Blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> resizeNoCustomHeadersWithResponseAsync(String containerName, String blob, - long blobContentLength, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - final String comp = "properties"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .resizeNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, blobContentLength, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Resize the Blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase resizeWithResponse(String containerName, String blob, - long blobContentLength, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - CpkInfo cpkInfo, EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "properties"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.resizeSync(this.client.getUrl(), containerName, blob, comp, timeout, leaseId, encryptionKey, - encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, blobContentLength, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Resize the Blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void resize(String containerName, String blob, long blobContentLength, Integer timeout, String leaseId, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, CpkInfo cpkInfo, EncryptionScope encryptionScopeParam) { - resizeWithResponse(containerName, blob, blobContentLength, timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, - ifMatch, ifNoneMatch, ifTags, requestId, cpkInfo, encryptionScopeParam, Context.NONE); - } - - /** - * Resize the Blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param blobContentLength This header specifies the maximum size for the page blob, up to 1 TB. The page blob size - * must be aligned to a 512-byte boundary. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param cpkInfo Parameter group. - * @param encryptionScopeParam Parameter group. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response resizeNoCustomHeadersWithResponse(String containerName, String blob, long blobContentLength, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, CpkInfo cpkInfo, - EncryptionScope encryptionScopeParam, Context context) { - try { - final String comp = "properties"; - final String accept = "application/xml"; - String encryptionKeyInternal = null; - if (cpkInfo != null) { - encryptionKeyInternal = cpkInfo.getEncryptionKey(); - } - String encryptionKey = encryptionKeyInternal; - String encryptionKeySha256Internal = null; - if (cpkInfo != null) { - encryptionKeySha256Internal = cpkInfo.getEncryptionKeySha256(); - } - String encryptionKeySha256 = encryptionKeySha256Internal; - EncryptionAlgorithmType encryptionAlgorithmInternal = null; - if (cpkInfo != null) { - encryptionAlgorithmInternal = cpkInfo.getEncryptionAlgorithm(); - } - EncryptionAlgorithmType encryptionAlgorithm = encryptionAlgorithmInternal; - String encryptionScopeInternal = null; - if (encryptionScopeParam != null) { - encryptionScopeInternal = encryptionScopeParam.getEncryptionScope(); - } - String encryptionScope = encryptionScopeInternal; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.resizeNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, leaseId, - encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, blobContentLength, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Update the sequence number of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This - * property applies to page blobs only. This property indicates how the service should modify the blob's sequence - * number. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateSequenceNumberWithResponseAsync( - String containerName, String blob, SequenceNumberActionType sequenceNumberAction, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId) { - return FluxUtil - .withContext(context -> updateSequenceNumberWithResponseAsync(containerName, blob, sequenceNumberAction, - timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, blobSequenceNumber, - requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Update the sequence number of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This - * property applies to page blobs only. This property indicates how the service should modify the blob's sequence - * number. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateSequenceNumberWithResponseAsync( - String containerName, String blob, SequenceNumberActionType sequenceNumberAction, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId, Context context) { - final String comp = "properties"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .updateSequenceNumber(this.client.getUrl(), containerName, blob, comp, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - sequenceNumberAction, blobSequenceNumber, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Update the sequence number of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This - * property applies to page blobs only. This property indicates how the service should modify the blob's sequence - * number. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateSequenceNumberAsync(String containerName, String blob, - SequenceNumberActionType sequenceNumberAction, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, - String requestId) { - return updateSequenceNumberWithResponseAsync(containerName, blob, sequenceNumberAction, timeout, leaseId, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, blobSequenceNumber, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Update the sequence number of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This - * property applies to page blobs only. This property indicates how the service should modify the blob's sequence - * number. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateSequenceNumberAsync(String containerName, String blob, - SequenceNumberActionType sequenceNumberAction, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, - String requestId, Context context) { - return updateSequenceNumberWithResponseAsync(containerName, blob, sequenceNumberAction, timeout, leaseId, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, blobSequenceNumber, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Update the sequence number of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This - * property applies to page blobs only. This property indicates how the service should modify the blob's sequence - * number. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateSequenceNumberNoCustomHeadersWithResponseAsync(String containerName, String blob, - SequenceNumberActionType sequenceNumberAction, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, - String requestId) { - return FluxUtil - .withContext(context -> updateSequenceNumberNoCustomHeadersWithResponseAsync(containerName, blob, - sequenceNumberAction, timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, - ifTags, blobSequenceNumber, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Update the sequence number of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This - * property applies to page blobs only. This property indicates how the service should modify the blob's sequence - * number. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateSequenceNumberNoCustomHeadersWithResponseAsync(String containerName, String blob, - SequenceNumberActionType sequenceNumberAction, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, - String requestId, Context context) { - final String comp = "properties"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .updateSequenceNumberNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - sequenceNumberAction, blobSequenceNumber, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Update the sequence number of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This - * property applies to page blobs only. This property indicates how the service should modify the blob's sequence - * number. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase updateSequenceNumberWithResponse( - String containerName, String blob, SequenceNumberActionType sequenceNumberAction, Integer timeout, - String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, - String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId, Context context) { - try { - final String comp = "properties"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.updateSequenceNumberSync(this.client.getUrl(), containerName, blob, comp, timeout, leaseId, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - sequenceNumberAction, blobSequenceNumber, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Update the sequence number of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This - * property applies to page blobs only. This property indicates how the service should modify the blob's sequence - * number. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void updateSequenceNumber(String containerName, String blob, SequenceNumberActionType sequenceNumberAction, - Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, String requestId) { - updateSequenceNumberWithResponse(containerName, blob, sequenceNumberAction, timeout, leaseId, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, blobSequenceNumber, requestId, Context.NONE); - } - - /** - * Update the sequence number of the blob. - * - * @param containerName The container name. - * @param blob The blob name. - * @param sequenceNumberAction Required if the x-ms-blob-sequence-number header is set for the request. This - * property applies to page blobs only. This property indicates how the service should modify the blob's sequence - * number. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param blobSequenceNumber Set for page blobs only. The sequence number is a user-controlled value that you can - * use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateSequenceNumberNoCustomHeadersWithResponse(String containerName, String blob, - SequenceNumberActionType sequenceNumberAction, Integer timeout, String leaseId, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, Long blobSequenceNumber, - String requestId, Context context) { - try { - final String comp = "properties"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.updateSequenceNumberNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, - timeout, leaseId, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, - sequenceNumberAction, blobSequenceNumber, this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot - * is copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. This API is supported since REST version 2016-05-31. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyIncrementalWithResponseAsync( - String containerName, String blob, String copySource, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> copyIncrementalWithResponseAsync(containerName, blob, copySource, timeout, - ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot - * is copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. This API is supported since REST version 2016-05-31. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyIncrementalWithResponseAsync( - String containerName, String blob, String copySource, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - Context context) { - final String comp = "incrementalcopy"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .copyIncremental(this.client.getUrl(), containerName, blob, comp, timeout, ifModifiedSinceConverted, - ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, copySource, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot - * is copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. This API is supported since REST version 2016-05-31. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono copyIncrementalAsync(String containerName, String blob, String copySource, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId) { - return copyIncrementalWithResponseAsync(containerName, blob, copySource, timeout, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot - * is copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. This API is supported since REST version 2016-05-31. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono copyIncrementalAsync(String containerName, String blob, String copySource, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId, Context context) { - return copyIncrementalWithResponseAsync(containerName, blob, copySource, timeout, ifModifiedSince, - ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot - * is copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. This API is supported since REST version 2016-05-31. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyIncrementalNoCustomHeadersWithResponseAsync(String containerName, String blob, - String copySource, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId) { - return FluxUtil - .withContext(context -> copyIncrementalNoCustomHeadersWithResponseAsync(containerName, blob, copySource, - timeout, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot - * is copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. This API is supported since REST version 2016-05-31. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyIncrementalNoCustomHeadersWithResponseAsync(String containerName, String blob, - String copySource, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - final String comp = "incrementalcopy"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service - .copyIncrementalNoCustomHeaders(this.client.getUrl(), containerName, blob, comp, timeout, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, copySource, - this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot - * is copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. This API is supported since REST version 2016-05-31. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase copyIncrementalWithResponse(String containerName, - String blob, String copySource, Integer timeout, OffsetDateTime ifModifiedSince, - OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, String requestId, - Context context) { - try { - final String comp = "incrementalcopy"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.copyIncrementalSync(this.client.getUrl(), containerName, blob, comp, timeout, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, copySource, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Copy Incremental operation copies a snapshot of the source page blob to a destination page blob. The snapshot - * is copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. This API is supported since REST version 2016-05-31. - * - * @param containerName The container name. - * @param blob The blob name. - * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in - * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. - * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void copyIncremental(String containerName, String blob, String copySource, Integer timeout, - OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, String ifMatch, String ifNoneMatch, - String ifTags, String requestId) { - copyIncrementalWithResponse(containerName, blob, copySource, timeout, ifModifiedSince, ifUnmodifiedSince, - ifMatch, ifNoneMatch, ifTags, requestId, Context.NONE); + public Mono> copyIncrementalWithResponseAsync(String copySource, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.copyIncremental(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + copySource, accept, requestOptions, context)); } /** @@ -6191,46 +1586,49 @@ public void copyIncremental(String containerName, String blob, String copySource * is copied such that only the differential changes between the previously copied snapshot are transferred to the * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as * usual. This API is supported since REST version 2016-05-31. - * - * @param containerName The container name. - * @param blob The blob name. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
x-ms-if-tagsStringNoSpecify a SQL where clause on blob tags to operate only on + * blobs with a matching value.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * * @param copySource Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in * length that specifies a page blob snapshot. The value should be URL-encoded as it would appear in a request URI. * The source blob must either be public or must be authenticated via a shared access signature. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param ifModifiedSince Specify this header value to operate only on a blob if it has been modified since the - * specified date/time. - * @param ifUnmodifiedSince Specify this header value to operate only on a blob if it has not been modified since - * the specified date/time. - * @param ifMatch Specify an ETag value to operate only on blobs with a matching value. - * @param ifNoneMatch Specify an ETag value to operate only on blobs without a matching value. - * @param ifTags Specify a SQL where clause on blob tags to operate only on blobs with a matching value. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response copyIncrementalNoCustomHeadersWithResponse(String containerName, String blob, - String copySource, Integer timeout, OffsetDateTime ifModifiedSince, OffsetDateTime ifUnmodifiedSince, - String ifMatch, String ifNoneMatch, String ifTags, String requestId, Context context) { - try { - final String comp = "incrementalcopy"; - final String accept = "application/xml"; - DateTimeRfc1123 ifModifiedSinceConverted - = ifModifiedSince == null ? null : new DateTimeRfc1123(ifModifiedSince); - DateTimeRfc1123 ifUnmodifiedSinceConverted - = ifUnmodifiedSince == null ? null : new DateTimeRfc1123(ifUnmodifiedSince); - return service.copyIncrementalNoCustomHeadersSync(this.client.getUrl(), containerName, blob, comp, timeout, - ifModifiedSinceConverted, ifUnmodifiedSinceConverted, ifMatch, ifNoneMatch, ifTags, copySource, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } + public Response copyIncrementalWithResponse(String copySource, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.copyIncrementalSync(this.client.getUrl(), contentType, + this.client.getServiceVersion().getVersion(), this.client.getContainerName(), this.client.getBlob(), + copySource, accept, requestOptions, Context.NONE); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ServiceClientClientImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ServiceClientClientImpl.java new file mode 100644 index 000000000000..547749eceb9c --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ServiceClientClientImpl.java @@ -0,0 +1,1356 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.storage.blob.BlobServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ServiceClientClient type. + */ +public final class ServiceClientClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ServiceClientClientService service; + + /** + * The host name of the blob storage account, e.g. accountName.blob.core.windows.net. + */ + private final String url; + + /** + * Gets The host name of the blob storage account, e.g. accountName.blob.core.windows.net. + * + * @return the url value. + */ + public String getUrl() { + return this.url; + } + + /** + * The name of the container. + */ + private final String containerName; + + /** + * Gets The name of the container. + * + * @return the containerName value. + */ + public String getContainerName() { + return this.containerName; + } + + /** + * The name of the blob. + */ + private final String blob; + + /** + * Gets The name of the blob. + * + * @return the blob value. + */ + public String getBlob() { + return this.blob; + } + + /** + * Service version. + */ + private final BlobServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public BlobServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The ContainersImpl object to access its operations. + */ + private final ContainersImpl containers; + + /** + * Gets the ContainersImpl object to access its operations. + * + * @return the ContainersImpl object. + */ + public ContainersImpl getContainers() { + return this.containers; + } + + /** + * The ContainerBlobsImpl object to access its operations. + */ + private final ContainerBlobsImpl containerBlobs; + + /** + * Gets the ContainerBlobsImpl object to access its operations. + * + * @return the ContainerBlobsImpl object. + */ + public ContainerBlobsImpl getContainerBlobs() { + return this.containerBlobs; + } + + /** + * The PageBlobsImpl object to access its operations. + */ + private final PageBlobsImpl pageBlobs; + + /** + * Gets the PageBlobsImpl object to access its operations. + * + * @return the PageBlobsImpl object. + */ + public PageBlobsImpl getPageBlobs() { + return this.pageBlobs; + } + + /** + * The AppendBlobsImpl object to access its operations. + */ + private final AppendBlobsImpl appendBlobs; + + /** + * Gets the AppendBlobsImpl object to access its operations. + * + * @return the AppendBlobsImpl object. + */ + public AppendBlobsImpl getAppendBlobs() { + return this.appendBlobs; + } + + /** + * The BlockBlobsImpl object to access its operations. + */ + private final BlockBlobsImpl blockBlobs; + + /** + * Gets the BlockBlobsImpl object to access its operations. + * + * @return the BlockBlobsImpl object. + */ + public BlockBlobsImpl getBlockBlobs() { + return this.blockBlobs; + } + + /** + * Initializes an instance of ServiceClientClient client. + * + * @param url The host name of the blob storage account, e.g. accountName.blob.core.windows.net. + * @param containerName The name of the container. + * @param blob The name of the blob. + * @param serviceVersion Service version. + */ + public ServiceClientClientImpl(String url, String containerName, String blob, BlobServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), url, containerName, blob, serviceVersion); + } + + /** + * Initializes an instance of ServiceClientClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param url The host name of the blob storage account, e.g. accountName.blob.core.windows.net. + * @param containerName The name of the container. + * @param blob The name of the blob. + * @param serviceVersion Service version. + */ + public ServiceClientClientImpl(HttpPipeline httpPipeline, String url, String containerName, String blob, + BlobServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), url, containerName, blob, serviceVersion); + } + + /** + * Initializes an instance of ServiceClientClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param url The host name of the blob storage account, e.g. accountName.blob.core.windows.net. + * @param containerName The name of the container. + * @param blob The name of the blob. + * @param serviceVersion Service version. + */ + public ServiceClientClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String url, + String containerName, String blob, BlobServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.url = url; + this.containerName = containerName; + this.blob = blob; + this.serviceVersion = serviceVersion; + this.containers = new ContainersImpl(this); + this.containerBlobs = new ContainerBlobsImpl(this); + this.pageBlobs = new PageBlobsImpl(this); + this.appendBlobs = new AppendBlobsImpl(this); + this.blockBlobs = new BlockBlobsImpl(this); + this.service + = RestProxy.create(ServiceClientClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ServiceClientClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{url}") + @ServiceInterface(name = "ServiceClientClient") + public interface ServiceClientClientService { + @Put("/?restype=service&comp=properties") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setProperties(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, @BodyParam("application/xml") BinaryData setPropertiesRequest, + RequestOptions requestOptions, Context context); + + @Put("/?restype=service&comp=properties") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setPropertiesSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @HeaderParam("Accept") String accept, + @BodyParam("application/xml") BinaryData setPropertiesRequest, RequestOptions requestOptions, + Context context); + + @Get("/?restype=service&comp=properties") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getProperties(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/?restype=service&comp=properties") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getPropertiesSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/?restype=service&comp=stats") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStatistics(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/?restype=service&comp=stats") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStatisticsSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/?comp=list") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listContainersSegment(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/?comp=list") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listContainersSegmentSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/?restype=service&comp=userdelegationkey") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getUserDelegationKey(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, @BodyParam("application/xml") BinaryData getUserDelegationKeyRequest, + RequestOptions requestOptions, Context context); + + @Post("/?restype=service&comp=userdelegationkey") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getUserDelegationKeySync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, @BodyParam("application/xml") BinaryData getUserDelegationKeyRequest, + RequestOptions requestOptions, Context context); + + @Get("/?restype=account&comp=properties") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAccountInfo(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/?restype=account&comp=properties") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAccountInfoSync(@HostParam("url") String url, @HeaderParam("Content-Type") String contentType, + @HeaderParam("x-ms-version") String xMsVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/?comp=batch") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> submitBatch(@HostParam("url") String url, + @HeaderParam("Content-Type") String multipartContentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, + @BodyParam("multipart/mixed") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/?comp=batch") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response submitBatchSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String multipartContentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, + @BodyParam("multipart/mixed") BinaryData body, RequestOptions requestOptions, Context context); + + @Get("/?comp=blobs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> filterBlobs(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/?comp=blobs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response filterBlobsSync(@HostParam("url") String url, + @HeaderParam("Content-Type") String contentType, @HeaderParam("x-ms-version") String xMsVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and + * CORS (Cross-Origin Resource Sharing) rules. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     logging (Optional): {
+     *         version: String (Required)
+     *         delete: boolean (Required)
+     *         read: boolean (Required)
+     *         write: boolean (Required)
+     *         retentionPolicy (Required): {
+     *             enabled: boolean (Required)
+     *             days: Integer (Optional)
+     *             allowPermanentDelete: Boolean (Optional)
+     *         }
+     *     }
+     *     hourMetrics (Optional): {
+     *         version: String (Optional)
+     *         enabled: boolean (Required)
+     *         includeApis: Boolean (Optional)
+     *         retentionPolicy (Optional): (recursive schema, see retentionPolicy above)
+     *     }
+     *     minuteMetrics (Optional): (recursive schema, see minuteMetrics above)
+     *     cors (Optional): [
+     *          (Optional){
+     *             allowedOrigins: String (Required)
+     *             allowedMethods: String (Required)
+     *             allowedHeaders: String (Required)
+     *             exposedHeaders: String (Required)
+     *             maxAgeInSeconds: int (Required)
+     *         }
+     *     ]
+     *     defaultServiceVersion: String (Optional)
+     *     deleteRetentionPolicy (Optional): (recursive schema, see deleteRetentionPolicy above)
+     *     staticWebsite (Optional): {
+     *         enabled: boolean (Required)
+     *         indexDocument: String (Optional)
+     *         errorDocument404Path: String (Optional)
+     *         defaultIndexDocumentPath: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param setPropertiesRequest The setPropertiesRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setPropertiesWithResponseAsync(BinaryData setPropertiesRequest, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.setProperties(this.getUrl(), contentType, + this.getServiceVersion().getVersion(), accept, setPropertiesRequest, requestOptions, context)); + } + + /** + * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and + * CORS (Cross-Origin Resource Sharing) rules. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     logging (Optional): {
+     *         version: String (Required)
+     *         delete: boolean (Required)
+     *         read: boolean (Required)
+     *         write: boolean (Required)
+     *         retentionPolicy (Required): {
+     *             enabled: boolean (Required)
+     *             days: Integer (Optional)
+     *             allowPermanentDelete: Boolean (Optional)
+     *         }
+     *     }
+     *     hourMetrics (Optional): {
+     *         version: String (Optional)
+     *         enabled: boolean (Required)
+     *         includeApis: Boolean (Optional)
+     *         retentionPolicy (Optional): (recursive schema, see retentionPolicy above)
+     *     }
+     *     minuteMetrics (Optional): (recursive schema, see minuteMetrics above)
+     *     cors (Optional): [
+     *          (Optional){
+     *             allowedOrigins: String (Required)
+     *             allowedMethods: String (Required)
+     *             allowedHeaders: String (Required)
+     *             exposedHeaders: String (Required)
+     *             maxAgeInSeconds: int (Required)
+     *         }
+     *     ]
+     *     defaultServiceVersion: String (Optional)
+     *     deleteRetentionPolicy (Optional): (recursive schema, see deleteRetentionPolicy above)
+     *     staticWebsite (Optional): {
+     *         enabled: boolean (Required)
+     *         indexDocument: String (Optional)
+     *         errorDocument404Path: String (Optional)
+     *         defaultIndexDocumentPath: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param setPropertiesRequest The setPropertiesRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setPropertiesWithResponse(BinaryData setPropertiesRequest, RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.setPropertiesSync(this.getUrl(), contentType, this.getServiceVersion().getVersion(), accept, + setPropertiesRequest, requestOptions, Context.NONE); + } + + /** + * Retrieves properties of a storage account's Blob service, including properties for Storage Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     logging (Optional): {
+     *         version: String (Required)
+     *         delete: boolean (Required)
+     *         read: boolean (Required)
+     *         write: boolean (Required)
+     *         retentionPolicy (Required): {
+     *             enabled: boolean (Required)
+     *             days: Integer (Optional)
+     *             allowPermanentDelete: Boolean (Optional)
+     *         }
+     *     }
+     *     hourMetrics (Optional): {
+     *         version: String (Optional)
+     *         enabled: boolean (Required)
+     *         includeApis: Boolean (Optional)
+     *         retentionPolicy (Optional): (recursive schema, see retentionPolicy above)
+     *     }
+     *     minuteMetrics (Optional): (recursive schema, see minuteMetrics above)
+     *     cors (Optional): [
+     *          (Optional){
+     *             allowedOrigins: String (Required)
+     *             allowedMethods: String (Required)
+     *             allowedHeaders: String (Required)
+     *             exposedHeaders: String (Required)
+     *             maxAgeInSeconds: int (Required)
+     *         }
+     *     ]
+     *     defaultServiceVersion: String (Optional)
+     *     deleteRetentionPolicy (Optional): (recursive schema, see deleteRetentionPolicy above)
+     *     staticWebsite (Optional): {
+     *         enabled: boolean (Required)
+     *         indexDocument: String (Optional)
+     *         errorDocument404Path: String (Optional)
+     *         defaultIndexDocumentPath: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the service properties along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return FluxUtil.withContext(context -> service.getProperties(this.getUrl(), contentType, + this.getServiceVersion().getVersion(), accept, requestOptions, context)); + } + + /** + * Retrieves properties of a storage account's Blob service, including properties for Storage Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     logging (Optional): {
+     *         version: String (Required)
+     *         delete: boolean (Required)
+     *         read: boolean (Required)
+     *         write: boolean (Required)
+     *         retentionPolicy (Required): {
+     *             enabled: boolean (Required)
+     *             days: Integer (Optional)
+     *             allowPermanentDelete: Boolean (Optional)
+     *         }
+     *     }
+     *     hourMetrics (Optional): {
+     *         version: String (Optional)
+     *         enabled: boolean (Required)
+     *         includeApis: Boolean (Optional)
+     *         retentionPolicy (Optional): (recursive schema, see retentionPolicy above)
+     *     }
+     *     minuteMetrics (Optional): (recursive schema, see minuteMetrics above)
+     *     cors (Optional): [
+     *          (Optional){
+     *             allowedOrigins: String (Required)
+     *             allowedMethods: String (Required)
+     *             allowedHeaders: String (Required)
+     *             exposedHeaders: String (Required)
+     *             maxAgeInSeconds: int (Required)
+     *         }
+     *     ]
+     *     defaultServiceVersion: String (Optional)
+     *     deleteRetentionPolicy (Optional): (recursive schema, see deleteRetentionPolicy above)
+     *     staticWebsite (Optional): {
+     *         enabled: boolean (Required)
+     *         indexDocument: String (Optional)
+     *         errorDocument404Path: String (Optional)
+     *         defaultIndexDocumentPath: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the service properties along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPropertiesWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return service.getPropertiesSync(this.getUrl(), contentType, this.getServiceVersion().getVersion(), accept, + requestOptions, Context.NONE); + } + + /** + * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the storage account. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     geoReplication (Optional): {
+     *         status: String(live/bootstrap/unavailable) (Required)
+     *         lastSyncTime: DateTimeRfc1123 (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return stats for the storage service along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStatisticsWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return FluxUtil.withContext(context -> service.getStatistics(this.getUrl(), contentType, + this.getServiceVersion().getVersion(), accept, requestOptions, context)); + } + + /** + * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the storage account. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     geoReplication (Optional): {
+     *         status: String(live/bootstrap/unavailable) (Required)
+     *         lastSyncTime: DateTimeRfc1123 (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return stats for the storage service along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStatisticsWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return service.getStatisticsSync(this.getUrl(), contentType, this.getServiceVersion().getVersion(), accept, + requestOptions, Context.NONE); + } + + /** + * The List Containers Segment operation returns a list of the containers under the specified account. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
includeList<String>NoInclude this parameter to specify that the + * container's metadata be returned as part of the response body. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     containerItems (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             delete: Boolean (Optional)
+     *             version: String (Optional)
+     *             properties (Required): {
+     *                 lastModified: DateTimeRfc1123 (Required)
+     *                 eTag: String (Required)
+     *                 leaseStatus: String(unlocked/locked) (Optional)
+     *                 leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                 leaseDuration: String(infinite/fixed) (Optional)
+     *                 publicAccess: String(blob/container) (Optional)
+     *                 hasImmutabilityPolicy: Boolean (Optional)
+     *                 hasLegalHold: Boolean (Optional)
+     *                 defaultEncryptionScope: String (Optional)
+     *                 denyEncryptionScopeOverride: Boolean (Optional)
+     *                 deletedTime: DateTimeRfc1123 (Optional)
+     *                 remainingRetentionDays: Integer (Optional)
+     *                 immutableStorageWithVersioningEnabled: Boolean (Optional)
+     *             }
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     NextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the list container segment response along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listContainersSegmentWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return FluxUtil.withContext(context -> service.listContainersSegment(this.getUrl(), contentType, + this.getServiceVersion().getVersion(), accept, requestOptions, context)); + } + + /** + * The List Containers Segment operation returns a list of the containers under the specified account. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
prefixStringNoFilters the results to return only containers whose name begins + * with the specified prefix.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
includeList<String>NoInclude this parameter to specify that the + * container's metadata be returned as part of the response body. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     prefix: String (Optional)
+     *     marker: String (Optional)
+     *     maxResults: Integer (Optional)
+     *     containerItems (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             delete: Boolean (Optional)
+     *             version: String (Optional)
+     *             properties (Required): {
+     *                 lastModified: DateTimeRfc1123 (Required)
+     *                 eTag: String (Required)
+     *                 leaseStatus: String(unlocked/locked) (Optional)
+     *                 leaseState: String(available/leased/expired/breaking/broken) (Optional)
+     *                 leaseDuration: String(infinite/fixed) (Optional)
+     *                 publicAccess: String(blob/container) (Optional)
+     *                 hasImmutabilityPolicy: Boolean (Optional)
+     *                 hasLegalHold: Boolean (Optional)
+     *                 defaultEncryptionScope: String (Optional)
+     *                 denyEncryptionScopeOverride: Boolean (Optional)
+     *                 deletedTime: DateTimeRfc1123 (Optional)
+     *                 remainingRetentionDays: Integer (Optional)
+     *                 immutableStorageWithVersioningEnabled: Boolean (Optional)
+     *             }
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     NextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the list container segment response along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listContainersSegmentWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return service.listContainersSegmentSync(this.getUrl(), contentType, this.getServiceVersion().getVersion(), + accept, requestOptions, Context.NONE); + } + + /** + * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token + * authentication. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     start: String (Required)
+     *     expiry: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     signedOid: String (Required)
+     *     signedTid: String (Required)
+     *     signedStart: String (Required)
+     *     signedExpiry: String (Required)
+     *     signedService: String (Required)
+     *     signedVersion: String (Required)
+     *     value: String (Required)
+     * }
+     * }
+     * 
+ * + * @param getUserDelegationKeyRequest The getUserDelegationKeyRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a user delegation key along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getUserDelegationKeyWithResponseAsync(BinaryData getUserDelegationKeyRequest, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return FluxUtil.withContext(context -> service.getUserDelegationKey(this.getUrl(), contentType, + this.getServiceVersion().getVersion(), accept, getUserDelegationKeyRequest, requestOptions, context)); + } + + /** + * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token + * authentication. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     start: String (Required)
+     *     expiry: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     signedOid: String (Required)
+     *     signedTid: String (Required)
+     *     signedStart: String (Required)
+     *     signedExpiry: String (Required)
+     *     signedService: String (Required)
+     *     signedVersion: String (Required)
+     *     value: String (Required)
+     * }
+     * }
+     * 
+ * + * @param getUserDelegationKeyRequest The getUserDelegationKeyRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a user delegation key along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getUserDelegationKeyWithResponse(BinaryData getUserDelegationKeyRequest, + RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return service.getUserDelegationKeySync(this.getUrl(), contentType, this.getServiceVersion().getVersion(), + accept, getUserDelegationKeyRequest, requestOptions, Context.NONE); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccountInfoWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getAccountInfo(this.getUrl(), contentType, + this.getServiceVersion().getVersion(), accept, requestOptions, context)); + } + + /** + * Returns the sku name and account kind. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAccountInfoWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/json"; + return service.getAccountInfoSync(this.getUrl(), contentType, this.getServiceVersion().getVersion(), accept, + requestOptions, Context.NONE); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> submitBatchWithResponseAsync(long contentLength, BinaryData body, + RequestOptions requestOptions) { + final String multipartContentType = "multipart/mixed"; + final String accept = "multipart/mixed"; + return FluxUtil.withContext(context -> service.submitBatch(this.getUrl(), multipartContentType, + this.getServiceVersion().getVersion(), contentLength, accept, body, requestOptions, context)); + } + + /** + * The Batch operation allows multiple API calls to be embedded into a single HTTP request. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentLength The length of the request. + * @param body The body of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response submitBatchWithResponse(long contentLength, BinaryData body, + RequestOptions requestOptions) { + final String multipartContentType = "multipart/mixed"; + final String accept = "multipart/mixed"; + return service.submitBatchSync(this.getUrl(), multipartContentType, this.getServiceVersion().getVersion(), + contentLength, accept, body, requestOptions, Context.NONE); + } + + /** + * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search + * expression. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
whereStringNoFilters the results to return only to return only blobs whose + * tags match the specified expression.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     where: String (Required)
+     *     blobs (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             containerName: String (Required)
+     *             tags (Optional): {
+     *                 blobTagSet (Required): [
+     *                      (Required){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *             versionId: String (Optional)
+     *             isCurrentVersion: Boolean (Optional)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the result of a Filter Blobs API call along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> filterBlobsWithResponseAsync(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return FluxUtil.withContext(context -> service.filterBlobs(this.getUrl(), contentType, + this.getServiceVersion().getVersion(), accept, requestOptions, context)); + } + + /** + * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search + * expression. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
timeoutIntegerNoThe timeout parameter is expressed in seconds. For more + * information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>
whereStringNoFilters the results to return only to return only blobs whose + * tags match the specified expression.
markerStringNoA string value that identifies the portion of the list of + * containers to be returned with the next listing operation. The operation returns the NextMarker value within the + * response body if the listing operation did not return all containers remaining to be listed with the current + * page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the + * next page of list items. The marker value is opaque to the client.
maxresultsIntegerNoSpecifies the maximum number of containers to return. If + * the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to + * 5000 items.
includeList<String>NoInclude this parameter to specify one or more + * datasets to include in the response. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     serviceEndpoint: String (Required)
+     *     where: String (Required)
+     *     blobs (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             containerName: String (Required)
+     *             tags (Optional): {
+     *                 blobTagSet (Required): [
+     *                      (Required){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *             versionId: String (Optional)
+     *             isCurrentVersion: Boolean (Optional)
+     *         }
+     *     ]
+     *     nextMarker: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the result of a Filter Blobs API call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response filterBlobsWithResponse(RequestOptions requestOptions) { + final String contentType = "application/xml"; + final String accept = "application/xml"; + return service.filterBlobsSync(this.getUrl(), contentType, this.getServiceVersion().getVersion(), accept, + requestOptions, Context.NONE); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ServicesImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ServicesImpl.java deleted file mode 100644 index cb8cb8c401f6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/ServicesImpl.java +++ /dev/null @@ -1,3211 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. -package com.azure.storage.blob.implementation; - -import com.azure.core.annotation.BodyParam; -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; -import com.azure.core.annotation.HeaderParam; -import com.azure.core.annotation.Host; -import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.PathParam; -import com.azure.core.annotation.Post; -import com.azure.core.annotation.Put; -import com.azure.core.annotation.QueryParam; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceInterface; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.annotation.UnexpectedResponseExceptionType; -import com.azure.core.http.rest.PagedFlux; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.PagedResponseBase; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.http.rest.StreamResponse; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.implementation.models.BlobContainersSegment; -import com.azure.storage.blob.implementation.models.BlobStorageExceptionInternal; -import com.azure.storage.blob.implementation.models.FilterBlobSegment; -import com.azure.storage.blob.implementation.models.FilterBlobsIncludeItem; -import com.azure.storage.blob.implementation.models.ServicesFilterBlobsHeaders; -import com.azure.storage.blob.implementation.models.ServicesGetAccountInfoHeaders; -import com.azure.storage.blob.implementation.models.ServicesGetPropertiesHeaders; -import com.azure.storage.blob.implementation.models.ServicesGetStatisticsHeaders; -import com.azure.storage.blob.implementation.models.ServicesGetUserDelegationKeyHeaders; -import com.azure.storage.blob.implementation.models.ServicesListBlobContainersSegmentHeaders; -import com.azure.storage.blob.implementation.models.ServicesListBlobContainersSegmentNextHeaders; -import com.azure.storage.blob.implementation.models.ServicesSetPropertiesHeaders; -import com.azure.storage.blob.implementation.models.ServicesSubmitBatchHeaders; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobContainerItem; -import com.azure.storage.blob.models.BlobServiceProperties; -import com.azure.storage.blob.models.BlobServiceStatistics; -import com.azure.storage.blob.models.KeyInfo; -import com.azure.storage.blob.models.ListBlobContainersIncludeType; -import com.azure.storage.blob.models.UserDelegationKey; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -/** - * An instance of this class provides access to all the operations defined in Services. - */ -public final class ServicesImpl { - - /** - * The proxy service used to perform REST calls. - */ - private final ServicesService service; - - /** - * The service client containing this operation class. - */ - private final AzureBlobStorageImpl client; - - /** - * Initializes an instance of ServicesImpl. - * - * @param client the instance of the service client containing this operation class. - */ - ServicesImpl(AzureBlobStorageImpl client) { - this.service = RestProxy.create(ServicesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); - this.client = client; - } - - /** - * The interface defining all the services for AzureBlobStorageServices to be used by the proxy service to perform - * REST calls. - */ - @Host("{url}") - @ServiceInterface(name = "AzureBlobStorageServ") - public interface ServicesService { - - @Put("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setProperties(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BlobServiceProperties blobServiceProperties, - @HeaderParam("Accept") String accept, Context context); - - @Put("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> setPropertiesNoCustomHeaders(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BlobServiceProperties blobServiceProperties, - @HeaderParam("Accept") String accept, Context context); - - @Put("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase setPropertiesSync(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BlobServiceProperties blobServiceProperties, - @HeaderParam("Accept") String accept, Context context); - - @Put("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response setPropertiesNoCustomHeadersSync(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BlobServiceProperties blobServiceProperties, - @HeaderParam("Accept") String accept, Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getProperties( - @HostParam("url") String url, @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getPropertiesNoCustomHeaders(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getPropertiesSync( - @HostParam("url") String url, @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getPropertiesNoCustomHeadersSync(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getStatistics( - @HostParam("url") String url, @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getStatisticsNoCustomHeaders(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getStatisticsSync( - @HostParam("url") String url, @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getStatisticsNoCustomHeadersSync(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> listBlobContainersSegment( - @HostParam("url") String url, @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, - @QueryParam("marker") String marker, @QueryParam("maxresults") Integer maxresults, - @QueryParam("include") String listBlobContainersIncludeType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> listBlobContainersSegmentNoCustomHeaders(@HostParam("url") String url, - @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String listBlobContainersIncludeType, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase listBlobContainersSegmentSync( - @HostParam("url") String url, @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, - @QueryParam("marker") String marker, @QueryParam("maxresults") Integer maxresults, - @QueryParam("include") String listBlobContainersIncludeType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response listBlobContainersSegmentNoCustomHeadersSync(@HostParam("url") String url, - @QueryParam("comp") String comp, @QueryParam("prefix") String prefix, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String listBlobContainersIncludeType, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Post("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getUserDelegationKey( - @HostParam("url") String url, @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @BodyParam("application/xml") KeyInfo keyInfo, - @HeaderParam("Accept") String accept, Context context); - - @Post("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getUserDelegationKeyNoCustomHeaders(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @BodyParam("application/xml") KeyInfo keyInfo, - @HeaderParam("Accept") String accept, Context context); - - @Post("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getUserDelegationKeySync( - @HostParam("url") String url, @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @BodyParam("application/xml") KeyInfo keyInfo, - @HeaderParam("Accept") String accept, Context context); - - @Post("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getUserDelegationKeyNoCustomHeadersSync(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @BodyParam("application/xml") KeyInfo keyInfo, - @HeaderParam("Accept") String accept, Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getAccountInfo(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> getAccountInfoNoCustomHeaders(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase getAccountInfoSync(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response getAccountInfoNoCustomHeadersSync(@HostParam("url") String url, - @QueryParam("restype") String restype, @QueryParam("comp") String comp, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Post("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono>> submitBatch(@HostParam("url") String url, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") Flux body, @HeaderParam("Accept") String accept, Context context); - - @Post("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono submitBatchNoCustomHeaders(@HostParam("url") String url, @QueryParam("comp") String comp, - @HeaderParam("Content-Length") long contentLength, @HeaderParam("Content-Type") String multipartContentType, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") Flux body, @HeaderParam("Accept") String accept, Context context); - - @Post("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono>> submitBatch(@HostParam("url") String url, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BinaryData body, @HeaderParam("Accept") String accept, Context context); - - @Post("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono submitBatchNoCustomHeaders(@HostParam("url") String url, @QueryParam("comp") String comp, - @HeaderParam("Content-Length") long contentLength, @HeaderParam("Content-Type") String multipartContentType, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @BodyParam("application/xml") BinaryData body, - @HeaderParam("Accept") String accept, Context context); - - @Post("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase submitBatchSync(@HostParam("url") String url, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BinaryData body, @HeaderParam("Accept") String accept, Context context); - - @Post("/") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response submitBatchNoCustomHeadersSync(@HostParam("url") String url, - @QueryParam("comp") String comp, @HeaderParam("Content-Length") long contentLength, - @HeaderParam("Content-Type") String multipartContentType, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @BodyParam("application/xml") BinaryData body, @HeaderParam("Accept") String accept, Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> filterBlobs(@HostParam("url") String url, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("where") String where, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @HeaderParam("Accept") String accept, Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> filterBlobsNoCustomHeaders(@HostParam("url") String url, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("where") String where, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @HeaderParam("Accept") String accept, Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase filterBlobsSync(@HostParam("url") String url, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("where") String where, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @HeaderParam("Accept") String accept, Context context); - - @Get("/") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response filterBlobsNoCustomHeadersSync(@HostParam("url") String url, - @QueryParam("comp") String comp, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @QueryParam("where") String where, @QueryParam("marker") String marker, - @QueryParam("maxresults") Integer maxresults, @QueryParam("include") String include, - @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> - listBlobContainersSegmentNext(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("url") String url, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Mono> listBlobContainersSegmentNextNoCustomHeaders( - @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("url") String url, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - ResponseBase - listBlobContainersSegmentNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("url") String url, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(BlobStorageExceptionInternal.class) - Response listBlobContainersSegmentNextNoCustomHeadersSync( - @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("url") String url, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("Accept") String accept, Context context); - } - - /** - * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and - * CORS (Cross-Origin Resource Sharing) rules. - * - * @param blobServiceProperties The StorageService properties. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - setPropertiesWithResponseAsync(BlobServiceProperties blobServiceProperties, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> setPropertiesWithResponseAsync(blobServiceProperties, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and - * CORS (Cross-Origin Resource Sharing) rules. - * - * @param blobServiceProperties The StorageService properties. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setPropertiesWithResponseAsync( - BlobServiceProperties blobServiceProperties, Integer timeout, String requestId, Context context) { - final String restype = "service"; - final String comp = "properties"; - final String accept = "application/xml"; - return service - .setProperties(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), requestId, - blobServiceProperties, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and - * CORS (Cross-Origin Resource Sharing) rules. - * - * @param blobServiceProperties The StorageService properties. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setPropertiesAsync(BlobServiceProperties blobServiceProperties, Integer timeout, - String requestId) { - return setPropertiesWithResponseAsync(blobServiceProperties, timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and - * CORS (Cross-Origin Resource Sharing) rules. - * - * @param blobServiceProperties The StorageService properties. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setPropertiesAsync(BlobServiceProperties blobServiceProperties, Integer timeout, String requestId, - Context context) { - return setPropertiesWithResponseAsync(blobServiceProperties, timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and - * CORS (Cross-Origin Resource Sharing) rules. - * - * @param blobServiceProperties The StorageService properties. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setPropertiesNoCustomHeadersWithResponseAsync( - BlobServiceProperties blobServiceProperties, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> setPropertiesNoCustomHeadersWithResponseAsync(blobServiceProperties, timeout, - requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and - * CORS (Cross-Origin Resource Sharing) rules. - * - * @param blobServiceProperties The StorageService properties. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setPropertiesNoCustomHeadersWithResponseAsync( - BlobServiceProperties blobServiceProperties, Integer timeout, String requestId, Context context) { - final String restype = "service"; - final String comp = "properties"; - final String accept = "application/xml"; - return service - .setPropertiesNoCustomHeaders(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), - requestId, blobServiceProperties, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and - * CORS (Cross-Origin Resource Sharing) rules. - * - * @param blobServiceProperties The StorageService properties. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase setPropertiesWithResponse( - BlobServiceProperties blobServiceProperties, Integer timeout, String requestId, Context context) { - try { - final String restype = "service"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.setPropertiesSync(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), - requestId, blobServiceProperties, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and - * CORS (Cross-Origin Resource Sharing) rules. - * - * @param blobServiceProperties The StorageService properties. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setProperties(BlobServiceProperties blobServiceProperties, Integer timeout, String requestId) { - setPropertiesWithResponse(blobServiceProperties, timeout, requestId, Context.NONE); - } - - /** - * Sets properties for a storage account's Blob service endpoint, including properties for Storage Analytics and - * CORS (Cross-Origin Resource Sharing) rules. - * - * @param blobServiceProperties The StorageService properties. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setPropertiesNoCustomHeadersWithResponse(BlobServiceProperties blobServiceProperties, - Integer timeout, String requestId, Context context) { - try { - final String restype = "service"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.setPropertiesNoCustomHeadersSync(this.client.getUrl(), restype, comp, timeout, - this.client.getVersion(), requestId, blobServiceProperties, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getPropertiesWithResponseAsync(Integer timeout, String requestId) { - return FluxUtil.withContext(context -> getPropertiesWithResponseAsync(timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getPropertiesWithResponseAsync(Integer timeout, String requestId, Context context) { - final String restype = "service"; - final String comp = "properties"; - final String accept = "application/xml"; - return service - .getProperties(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesAsync(Integer timeout, String requestId) { - return getPropertiesWithResponseAsync(timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesAsync(Integer timeout, String requestId, Context context) { - return getPropertiesWithResponseAsync(timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesNoCustomHeadersWithResponseAsync(Integer timeout, - String requestId) { - return FluxUtil - .withContext(context -> getPropertiesNoCustomHeadersWithResponseAsync(timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesNoCustomHeadersWithResponseAsync(Integer timeout, - String requestId, Context context) { - final String restype = "service"; - final String comp = "properties"; - final String accept = "application/xml"; - return service - .getPropertiesNoCustomHeaders(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getPropertiesWithResponse(Integer timeout, - String requestId, Context context) { - try { - final String restype = "service"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.getPropertiesSync(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobServiceProperties getProperties(Integer timeout, String requestId) { - try { - return getPropertiesWithResponse(timeout, requestId, Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties of a storage account's Blob service, including properties for Storage Analytics and CORS - * (Cross-Origin Resource Sharing) rules along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesNoCustomHeadersWithResponse(Integer timeout, String requestId, - Context context) { - try { - final String restype = "service"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.getPropertiesNoCustomHeadersSync(this.client.getUrl(), restype, comp, timeout, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return stats for the storage service along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getStatisticsWithResponseAsync(Integer timeout, String requestId) { - return FluxUtil.withContext(context -> getStatisticsWithResponseAsync(timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return stats for the storage service along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getStatisticsWithResponseAsync(Integer timeout, String requestId, Context context) { - final String restype = "service"; - final String comp = "stats"; - final String accept = "application/xml"; - return service - .getStatistics(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return stats for the storage service on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getStatisticsAsync(Integer timeout, String requestId) { - return getStatisticsWithResponseAsync(timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return stats for the storage service on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getStatisticsAsync(Integer timeout, String requestId, Context context) { - return getStatisticsWithResponseAsync(timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return stats for the storage service along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getStatisticsNoCustomHeadersWithResponseAsync(Integer timeout, - String requestId) { - return FluxUtil - .withContext(context -> getStatisticsNoCustomHeadersWithResponseAsync(timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return stats for the storage service along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getStatisticsNoCustomHeadersWithResponseAsync(Integer timeout, - String requestId, Context context) { - final String restype = "service"; - final String comp = "stats"; - final String accept = "application/xml"; - return service - .getStatisticsNoCustomHeaders(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return stats for the storage service along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getStatisticsWithResponse(Integer timeout, - String requestId, Context context) { - try { - final String restype = "service"; - final String comp = "stats"; - final String accept = "application/xml"; - return service.getStatisticsSync(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return stats for the storage service. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobServiceStatistics getStatistics(Integer timeout, String requestId) { - try { - return getStatisticsWithResponse(timeout, requestId, Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Retrieves statistics related to replication for the Blob service. It is only available on the secondary location - * endpoint when read-access geo-redundant replication is enabled for the storage account. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return stats for the storage service along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getStatisticsNoCustomHeadersWithResponse(Integer timeout, String requestId, - Context context) { - try { - final String restype = "service"; - final String comp = "stats"; - final String accept = "application/xml"; - return service.getStatisticsNoCustomHeadersSync(this.client.getUrl(), restype, comp, timeout, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobContainersSegmentSinglePageAsync(String prefix, String marker, - Integer maxresults, List listBlobContainersIncludeType, Integer timeout, - String requestId) { - final String comp = "list"; - final String accept = "application/xml"; - String listBlobContainersIncludeTypeConverted = (listBlobContainersIncludeType == null) - ? null - : listBlobContainersIncludeType.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return FluxUtil - .withContext(context -> service.listBlobContainersSegment(this.client.getUrl(), comp, prefix, marker, - maxresults, listBlobContainersIncludeTypeConverted, timeout, this.client.getVersion(), requestId, - accept, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), res.getDeserializedHeaders())); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobContainersSegmentSinglePageAsync(String prefix, String marker, - Integer maxresults, List listBlobContainersIncludeType, Integer timeout, - String requestId, Context context) { - final String comp = "list"; - final String accept = "application/xml"; - String listBlobContainersIncludeTypeConverted = (listBlobContainersIncludeType == null) - ? null - : listBlobContainersIncludeType.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .listBlobContainersSegment(this.client.getUrl(), comp, prefix, marker, maxresults, - listBlobContainersIncludeTypeConverted, timeout, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), res.getDeserializedHeaders())); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobContainersSegmentAsync(String prefix, String marker, Integer maxresults, - List listBlobContainersIncludeType, Integer timeout, String requestId) { - return new PagedFlux<>(() -> listBlobContainersSegmentSinglePageAsync(prefix, marker, maxresults, - listBlobContainersIncludeType, timeout, requestId), - nextLink -> listBlobContainersSegmentNextSinglePageAsync(nextLink, requestId)); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobContainersSegmentAsync(String prefix, String marker, Integer maxresults, - List listBlobContainersIncludeType, Integer timeout, String requestId, - Context context) { - return new PagedFlux<>( - () -> listBlobContainersSegmentSinglePageAsync(prefix, marker, maxresults, listBlobContainersIncludeType, - timeout, requestId, context), - nextLink -> listBlobContainersSegmentNextSinglePageAsync(nextLink, requestId, context)); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobContainersSegmentNoCustomHeadersSinglePageAsync(String prefix, - String marker, Integer maxresults, List listBlobContainersIncludeType, - Integer timeout, String requestId) { - final String comp = "list"; - final String accept = "application/xml"; - String listBlobContainersIncludeTypeConverted = (listBlobContainersIncludeType == null) - ? null - : listBlobContainersIncludeType.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return FluxUtil - .withContext(context -> service.listBlobContainersSegmentNoCustomHeaders(this.client.getUrl(), comp, prefix, - marker, maxresults, listBlobContainersIncludeTypeConverted, timeout, this.client.getVersion(), - requestId, accept, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), null)); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobContainersSegmentNoCustomHeadersSinglePageAsync(String prefix, - String marker, Integer maxresults, List listBlobContainersIncludeType, - Integer timeout, String requestId, Context context) { - final String comp = "list"; - final String accept = "application/xml"; - String listBlobContainersIncludeTypeConverted = (listBlobContainersIncludeType == null) - ? null - : listBlobContainersIncludeType.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .listBlobContainersSegmentNoCustomHeaders(this.client.getUrl(), comp, prefix, marker, maxresults, - listBlobContainersIncludeTypeConverted, timeout, this.client.getVersion(), requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), null)); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobContainersSegmentNoCustomHeadersAsync(String prefix, String marker, - Integer maxresults, List listBlobContainersIncludeType, Integer timeout, - String requestId) { - return new PagedFlux<>( - () -> listBlobContainersSegmentNoCustomHeadersSinglePageAsync(prefix, marker, maxresults, - listBlobContainersIncludeType, timeout, requestId), - nextLink -> listBlobContainersSegmentNextSinglePageAsync(nextLink, requestId)); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listBlobContainersSegmentNoCustomHeadersAsync(String prefix, String marker, - Integer maxresults, List listBlobContainersIncludeType, Integer timeout, - String requestId, Context context) { - return new PagedFlux<>( - () -> listBlobContainersSegmentNoCustomHeadersSinglePageAsync(prefix, marker, maxresults, - listBlobContainersIncludeType, timeout, requestId, context), - nextLink -> listBlobContainersSegmentNextSinglePageAsync(nextLink, requestId, context)); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse listBlobContainersSegmentSinglePage(String prefix, String marker, - Integer maxresults, List listBlobContainersIncludeType, Integer timeout, - String requestId) { - try { - final String comp = "list"; - final String accept = "application/xml"; - String listBlobContainersIncludeTypeConverted = (listBlobContainersIncludeType == null) - ? null - : listBlobContainersIncludeType.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - ResponseBase res - = service.listBlobContainersSegmentSync(this.client.getUrl(), comp, prefix, marker, maxresults, - listBlobContainersIncludeTypeConverted, timeout, this.client.getVersion(), requestId, accept, - Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), res.getDeserializedHeaders()); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse listBlobContainersSegmentSinglePage(String prefix, String marker, - Integer maxresults, List listBlobContainersIncludeType, Integer timeout, - String requestId, Context context) { - try { - final String comp = "list"; - final String accept = "application/xml"; - String listBlobContainersIncludeTypeConverted = (listBlobContainersIncludeType == null) - ? null - : listBlobContainersIncludeType.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - ResponseBase res - = service.listBlobContainersSegmentSync(this.client.getUrl(), comp, prefix, marker, maxresults, - listBlobContainersIncludeTypeConverted, timeout, this.client.getVersion(), requestId, accept, - context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), res.getDeserializedHeaders()); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobContainersSegment(String prefix, String marker, Integer maxresults, - List listBlobContainersIncludeType, Integer timeout, String requestId) { - return new PagedIterable<>( - () -> listBlobContainersSegmentSinglePage(prefix, marker, maxresults, listBlobContainersIncludeType, - timeout, requestId, Context.NONE), - nextLink -> listBlobContainersSegmentNextSinglePage(nextLink, requestId)); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobContainersSegment(String prefix, String marker, Integer maxresults, - List listBlobContainersIncludeType, Integer timeout, String requestId, - Context context) { - return new PagedIterable<>( - () -> listBlobContainersSegmentSinglePage(prefix, marker, maxresults, listBlobContainersIncludeType, - timeout, requestId, context), - nextLink -> listBlobContainersSegmentNextSinglePage(nextLink, requestId, context)); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse listBlobContainersSegmentNoCustomHeadersSinglePage(String prefix, - String marker, Integer maxresults, List listBlobContainersIncludeType, - Integer timeout, String requestId) { - try { - final String comp = "list"; - final String accept = "application/xml"; - String listBlobContainersIncludeTypeConverted = (listBlobContainersIncludeType == null) - ? null - : listBlobContainersIncludeType.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - Response res = service.listBlobContainersSegmentNoCustomHeadersSync( - this.client.getUrl(), comp, prefix, marker, maxresults, listBlobContainersIncludeTypeConverted, timeout, - this.client.getVersion(), requestId, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), null); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse listBlobContainersSegmentNoCustomHeadersSinglePage(String prefix, - String marker, Integer maxresults, List listBlobContainersIncludeType, - Integer timeout, String requestId, Context context) { - try { - final String comp = "list"; - final String accept = "application/xml"; - String listBlobContainersIncludeTypeConverted = (listBlobContainersIncludeType == null) - ? null - : listBlobContainersIncludeType.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - Response res = service.listBlobContainersSegmentNoCustomHeadersSync( - this.client.getUrl(), comp, prefix, marker, maxresults, listBlobContainersIncludeTypeConverted, timeout, - this.client.getVersion(), requestId, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), null); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobContainersSegmentNoCustomHeaders(String prefix, String marker, - Integer maxresults, List listBlobContainersIncludeType, Integer timeout, - String requestId) { - return new PagedIterable<>( - () -> listBlobContainersSegmentNoCustomHeadersSinglePage(prefix, marker, maxresults, - listBlobContainersIncludeType, timeout, requestId, Context.NONE), - nextLink -> listBlobContainersSegmentNextSinglePage(nextLink, requestId)); - } - - /** - * The List Containers Segment operation returns a list of the containers under the specified account. - * - * @param prefix Filters the results to return only containers whose name begins with the specified prefix. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param listBlobContainersIncludeType Include this parameter to specify that the container's metadata be returned - * as part of the response body. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listBlobContainersSegmentNoCustomHeaders(String prefix, String marker, - Integer maxresults, List listBlobContainersIncludeType, Integer timeout, - String requestId, Context context) { - return new PagedIterable<>( - () -> listBlobContainersSegmentNoCustomHeadersSinglePage(prefix, marker, maxresults, - listBlobContainersIncludeType, timeout, requestId, context), - nextLink -> listBlobContainersSegmentNextSinglePage(nextLink, requestId, context)); - } - - /** - * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token - * authentication. - * - * @param keyInfo Key information. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a user delegation key along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getUserDelegationKeyWithResponseAsync(KeyInfo keyInfo, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> getUserDelegationKeyWithResponseAsync(keyInfo, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token - * authentication. - * - * @param keyInfo Key information. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a user delegation key along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - getUserDelegationKeyWithResponseAsync(KeyInfo keyInfo, Integer timeout, String requestId, Context context) { - final String restype = "service"; - final String comp = "userdelegationkey"; - final String accept = "application/xml"; - return service - .getUserDelegationKey(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), requestId, - keyInfo, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token - * authentication. - * - * @param keyInfo Key information. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a user delegation key on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getUserDelegationKeyAsync(KeyInfo keyInfo, Integer timeout, String requestId) { - return getUserDelegationKeyWithResponseAsync(keyInfo, timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token - * authentication. - * - * @param keyInfo Key information. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a user delegation key on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getUserDelegationKeyAsync(KeyInfo keyInfo, Integer timeout, String requestId, - Context context) { - return getUserDelegationKeyWithResponseAsync(keyInfo, timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token - * authentication. - * - * @param keyInfo Key information. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a user delegation key along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getUserDelegationKeyNoCustomHeadersWithResponseAsync(KeyInfo keyInfo, - Integer timeout, String requestId) { - return FluxUtil - .withContext( - context -> getUserDelegationKeyNoCustomHeadersWithResponseAsync(keyInfo, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token - * authentication. - * - * @param keyInfo Key information. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a user delegation key along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getUserDelegationKeyNoCustomHeadersWithResponseAsync(KeyInfo keyInfo, - Integer timeout, String requestId, Context context) { - final String restype = "service"; - final String comp = "userdelegationkey"; - final String accept = "application/xml"; - return service - .getUserDelegationKeyNoCustomHeaders(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), - requestId, keyInfo, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token - * authentication. - * - * @param keyInfo Key information. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a user delegation key along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase - getUserDelegationKeyWithResponse(KeyInfo keyInfo, Integer timeout, String requestId, Context context) { - try { - final String restype = "service"; - final String comp = "userdelegationkey"; - final String accept = "application/xml"; - return service.getUserDelegationKeySync(this.client.getUrl(), restype, comp, timeout, - this.client.getVersion(), requestId, keyInfo, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token - * authentication. - * - * @param keyInfo Key information. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a user delegation key. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public UserDelegationKey getUserDelegationKey(KeyInfo keyInfo, Integer timeout, String requestId) { - try { - return getUserDelegationKeyWithResponse(keyInfo, timeout, requestId, Context.NONE).getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Retrieves a user delegation key for the Blob service. This is only a valid operation when using bearer token - * authentication. - * - * @param keyInfo Key information. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a user delegation key along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getUserDelegationKeyNoCustomHeadersWithResponse(KeyInfo keyInfo, Integer timeout, - String requestId, Context context) { - try { - final String restype = "service"; - final String comp = "userdelegationkey"; - final String accept = "application/xml"; - return service.getUserDelegationKeyNoCustomHeadersSync(this.client.getUrl(), restype, comp, timeout, - this.client.getVersion(), requestId, keyInfo, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Returns the sku name and account kind. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoWithResponseAsync(Integer timeout, - String requestId) { - return FluxUtil.withContext(context -> getAccountInfoWithResponseAsync(timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoWithResponseAsync(Integer timeout, - String requestId, Context context) { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service - .getAccountInfo(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccountInfoAsync(Integer timeout, String requestId) { - return getAccountInfoWithResponseAsync(timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Returns the sku name and account kind. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccountInfoAsync(Integer timeout, String requestId, Context context) { - return getAccountInfoWithResponseAsync(timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Returns the sku name and account kind. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoNoCustomHeadersWithResponseAsync(Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> getAccountInfoNoCustomHeadersWithResponseAsync(timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoNoCustomHeadersWithResponseAsync(Integer timeout, String requestId, - Context context) { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service - .getAccountInfoNoCustomHeaders(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * Returns the sku name and account kind. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getAccountInfoWithResponse(Integer timeout, - String requestId, Context context) { - try { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.getAccountInfoSync(this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), - requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Returns the sku name and account kind. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void getAccountInfo(Integer timeout, String requestId) { - getAccountInfoWithResponse(timeout, requestId, Context.NONE); - } - - /** - * Returns the sku name and account kind. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getAccountInfoNoCustomHeadersWithResponse(Integer timeout, String requestId, - Context context) { - try { - final String restype = "account"; - final String comp = "properties"; - final String accept = "application/xml"; - return service.getAccountInfoNoCustomHeadersSync(this.client.getUrl(), restype, comp, timeout, - this.client.getVersion(), requestId, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> submitBatchWithResponseAsync( - long contentLength, String multipartContentType, Flux body, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> submitBatchWithResponseAsync(contentLength, multipartContentType, body, timeout, - requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> submitBatchWithResponseAsync( - long contentLength, String multipartContentType, Flux body, Integer timeout, String requestId, - Context context) { - final String comp = "batch"; - final String accept = "application/xml"; - return service - .submitBatch(this.client.getUrl(), comp, contentLength, multipartContentType, timeout, - this.client.getVersion(), requestId, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitBatchAsync(long contentLength, String multipartContentType, Flux body, - Integer timeout, String requestId) { - return submitBatchWithResponseAsync(contentLength, multipartContentType, body, timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitBatchAsync(long contentLength, String multipartContentType, Flux body, - Integer timeout, String requestId, Context context) { - return submitBatchWithResponseAsync(contentLength, multipartContentType, body, timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono submitBatchNoCustomHeadersWithResponseAsync(long contentLength, - String multipartContentType, Flux body, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> submitBatchNoCustomHeadersWithResponseAsync(contentLength, multipartContentType, - body, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono submitBatchNoCustomHeadersWithResponseAsync(long contentLength, - String multipartContentType, Flux body, Integer timeout, String requestId, Context context) { - final String comp = "batch"; - final String accept = "application/xml"; - return service - .submitBatchNoCustomHeaders(this.client.getUrl(), comp, contentLength, multipartContentType, timeout, - this.client.getVersion(), requestId, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> submitBatchWithResponseAsync( - long contentLength, String multipartContentType, BinaryData body, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> submitBatchWithResponseAsync(contentLength, multipartContentType, body, timeout, - requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> submitBatchWithResponseAsync( - long contentLength, String multipartContentType, BinaryData body, Integer timeout, String requestId, - Context context) { - final String comp = "batch"; - final String accept = "application/xml"; - return service - .submitBatch(this.client.getUrl(), comp, contentLength, multipartContentType, timeout, - this.client.getVersion(), requestId, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitBatchAsync(long contentLength, String multipartContentType, BinaryData body, - Integer timeout, String requestId) { - return submitBatchWithResponseAsync(contentLength, multipartContentType, body, timeout, requestId) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitBatchAsync(long contentLength, String multipartContentType, BinaryData body, - Integer timeout, String requestId, Context context) { - return submitBatchWithResponseAsync(contentLength, multipartContentType, body, timeout, requestId, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMapMany(fluxByteBufferResponse -> fluxByteBufferResponse.getValue()); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono submitBatchNoCustomHeadersWithResponseAsync(long contentLength, - String multipartContentType, BinaryData body, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> submitBatchNoCustomHeadersWithResponseAsync(contentLength, multipartContentType, - body, timeout, requestId, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono submitBatchNoCustomHeadersWithResponseAsync(long contentLength, - String multipartContentType, BinaryData body, Integer timeout, String requestId, Context context) { - final String comp = "batch"; - final String accept = "application/xml"; - return service - .submitBatchNoCustomHeaders(this.client.getUrl(), comp, contentLength, multipartContentType, timeout, - this.client.getVersion(), requestId, body, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase submitBatchWithResponse(long contentLength, - String multipartContentType, BinaryData body, Integer timeout, String requestId, Context context) { - try { - final String comp = "batch"; - final String accept = "application/xml"; - return service.submitBatchSync(this.client.getUrl(), comp, contentLength, multipartContentType, timeout, - this.client.getVersion(), requestId, body, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public InputStream submitBatch(long contentLength, String multipartContentType, BinaryData body, Integer timeout, - String requestId) { - try { - return submitBatchWithResponse(contentLength, multipartContentType, body, timeout, requestId, Context.NONE) - .getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Batch operation allows multiple API calls to be embedded into a single HTTP request. - * - * @param contentLength The length of the request. - * @param multipartContentType Required. The value of this header must be multipart/mixed with a batch boundary. - * Example header value: multipart/mixed; boundary=batch_<GUID>. - * @param body Initial data. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response submitBatchNoCustomHeadersWithResponse(long contentLength, String multipartContentType, - BinaryData body, Integer timeout, String requestId, Context context) { - try { - final String comp = "batch"; - final String accept = "application/xml"; - return service.submitBatchNoCustomHeadersSync(this.client.getUrl(), comp, contentLength, - multipartContentType, timeout, this.client.getVersion(), requestId, body, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search - * expression. Filter blobs searches across all containers within a storage account but can be scoped within the - * expression to a single container. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link ResponseBase} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> filterBlobsWithResponseAsync( - Integer timeout, String requestId, String where, String marker, Integer maxresults, - List include) { - return FluxUtil.withContext( - context -> filterBlobsWithResponseAsync(timeout, requestId, where, marker, maxresults, include, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search - * expression. Filter blobs searches across all containers within a storage account but can be scoped within the - * expression to a single container. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link ResponseBase} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> filterBlobsWithResponseAsync( - Integer timeout, String requestId, String where, String marker, Integer maxresults, - List include, Context context) { - final String comp = "blobs"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .filterBlobs(this.client.getUrl(), comp, timeout, this.client.getVersion(), requestId, where, marker, - maxresults, includeConverted, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search - * expression. Filter blobs searches across all containers within a storage account but can be scoped within the - * expression to a single container. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono filterBlobsAsync(Integer timeout, String requestId, String where, String marker, - Integer maxresults, List include) { - return filterBlobsWithResponseAsync(timeout, requestId, where, marker, maxresults, include) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search - * expression. Filter blobs searches across all containers within a storage account but can be scoped within the - * expression to a single container. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono filterBlobsAsync(Integer timeout, String requestId, String where, String marker, - Integer maxresults, List include, Context context) { - return filterBlobsWithResponseAsync(timeout, requestId, where, marker, maxresults, include, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search - * expression. Filter blobs searches across all containers within a storage account but can be scoped within the - * expression to a single container. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> filterBlobsNoCustomHeadersWithResponseAsync(Integer timeout, - String requestId, String where, String marker, Integer maxresults, List include) { - return FluxUtil - .withContext(context -> filterBlobsNoCustomHeadersWithResponseAsync(timeout, requestId, where, marker, - maxresults, include, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search - * expression. Filter blobs searches across all containers within a storage account but can be scoped within the - * expression to a single container. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> filterBlobsNoCustomHeadersWithResponseAsync(Integer timeout, - String requestId, String where, String marker, Integer maxresults, List include, - Context context) { - final String comp = "blobs"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service - .filterBlobsNoCustomHeaders(this.client.getUrl(), comp, timeout, this.client.getVersion(), requestId, where, - marker, maxresults, includeConverted, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException); - } - - /** - * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search - * expression. Filter blobs searches across all containers within a storage account but can be scoped within the - * expression to a single container. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase filterBlobsWithResponse(Integer timeout, - String requestId, String where, String marker, Integer maxresults, List include, - Context context) { - try { - final String comp = "blobs"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service.filterBlobsSync(this.client.getUrl(), comp, timeout, this.client.getVersion(), requestId, - where, marker, maxresults, includeConverted, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search - * expression. Filter blobs searches across all containers within a storage account but can be scoped within the - * expression to a single container. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public FilterBlobSegment filterBlobs(Integer timeout, String requestId, String where, String marker, - Integer maxresults, List include) { - try { - return filterBlobsWithResponse(timeout, requestId, where, marker, maxresults, include, Context.NONE) - .getValue(); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search - * expression. Filter blobs searches across all containers within a storage account but can be scoped within the - * expression to a single container. - * - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting - * Timeouts for Blob Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param where Filters the results to return only to return only blobs whose tags match the specified expression. - * @param marker A string value that identifies the portion of the list of containers to be returned with the next - * listing operation. The operation returns the NextMarker value within the response body if the listing operation - * did not return all containers remaining to be listed with the current page. The NextMarker value can be used as - * the value for the marker parameter in a subsequent call to request the next page of list items. The marker value - * is opaque to the client. - * @param maxresults Specifies the maximum number of containers to return. If the request does not specify - * maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the - * listing operation crosses a partition boundary, then the service will return a continuation token for retrieving - * the remainder of the results. For this reason, it is possible that the service will return fewer results than - * specified by maxresults, or than the default of 5000. - * @param include Include this parameter to specify one or more datasets to include in the response. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of a Filter Blobs API call along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response filterBlobsNoCustomHeadersWithResponse(Integer timeout, String requestId, - String where, String marker, Integer maxresults, List include, Context context) { - try { - final String comp = "blobs"; - final String accept = "application/xml"; - String includeConverted = (include == null) - ? null - : include.stream() - .map(paramItemValue -> Objects.toString(paramItemValue, "")) - .collect(Collectors.joining(",")); - return service.filterBlobsNoCustomHeadersSync(this.client.getUrl(), comp, timeout, this.client.getVersion(), - requestId, where, marker, maxresults, includeConverted, accept, context); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobContainersSegmentNextSinglePageAsync(String nextLink, - String requestId) { - final String accept = "application/xml"; - return FluxUtil - .withContext(context -> service.listBlobContainersSegmentNext(nextLink, this.client.getUrl(), - this.client.getVersion(), requestId, accept, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), res.getDeserializedHeaders())); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobContainersSegmentNextSinglePageAsync(String nextLink, - String requestId, Context context) { - final String accept = "application/xml"; - return service - .listBlobContainersSegmentNext(nextLink, this.client.getUrl(), this.client.getVersion(), requestId, accept, - context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), res.getDeserializedHeaders())); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - listBlobContainersSegmentNextNoCustomHeadersSinglePageAsync(String nextLink, String requestId) { - final String accept = "application/xml"; - return FluxUtil - .withContext(context -> service.listBlobContainersSegmentNextNoCustomHeaders(nextLink, this.client.getUrl(), - this.client.getVersion(), requestId, accept, context)) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlobContainersSegmentNextNoCustomHeadersSinglePageAsync( - String nextLink, String requestId, Context context) { - final String accept = "application/xml"; - return service - .listBlobContainersSegmentNextNoCustomHeaders(nextLink, this.client.getUrl(), this.client.getVersion(), - requestId, accept, context) - .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse listBlobContainersSegmentNextSinglePage(String nextLink, String requestId) { - try { - final String accept = "application/xml"; - ResponseBase res - = service.listBlobContainersSegmentNextSync(nextLink, this.client.getUrl(), this.client.getVersion(), - requestId, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), res.getDeserializedHeaders()); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse listBlobContainersSegmentNextSinglePage(String nextLink, String requestId, - Context context) { - try { - final String accept = "application/xml"; - ResponseBase res - = service.listBlobContainersSegmentNextSync(nextLink, this.client.getUrl(), this.client.getVersion(), - requestId, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), res.getDeserializedHeaders()); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse listBlobContainersSegmentNextNoCustomHeadersSinglePage(String nextLink, - String requestId) { - try { - final String accept = "application/xml"; - Response res = service.listBlobContainersSegmentNextNoCustomHeadersSync(nextLink, - this.client.getUrl(), this.client.getVersion(), requestId, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), null); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws BlobStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an enumeration of containers along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse listBlobContainersSegmentNextNoCustomHeadersSinglePage(String nextLink, - String requestId, Context context) { - try { - final String accept = "application/xml"; - Response res = service.listBlobContainersSegmentNextNoCustomHeadersSync(nextLink, - this.client.getUrl(), this.client.getVersion(), requestId, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getBlobContainerItems(), res.getValue().getNextMarker(), null); - } catch (BlobStorageExceptionInternal internalException) { - throw ModelHelper.mapToBlobStorageException(internalException); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobDownloadAsyncResponseConstructorProxy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobDownloadAsyncResponseConstructorProxy.java deleted file mode 100644 index 234ca5e65e77..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobDownloadAsyncResponseConstructorProxy.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.accesshelpers; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.rest.StreamResponse; -import com.azure.storage.blob.models.BlobDownloadAsyncResponse; -import com.azure.storage.blob.models.DownloadRetryOptions; -import reactor.core.publisher.Mono; - -import java.util.function.BiFunction; - -/** - * Helper class to access private values of {@link BlobDownloadAsyncResponse} across package boundaries. - */ -public final class BlobDownloadAsyncResponseConstructorProxy { - private static BlobDownloadAsyncResponseConstructorProxy.BlobDownloadAsyncResponseConstructorAccessor accessor; - - private BlobDownloadAsyncResponseConstructorProxy() { - } - - /** - * Type defining the methods to set the non-public properties of a {@link BlobDownloadAsyncResponseConstructorProxy.BlobDownloadAsyncResponseConstructorAccessor} - * instance. - */ - public interface BlobDownloadAsyncResponseConstructorAccessor { - /** - * Creates a {@link BlobDownloadAsyncResponse}. - * - * @param sourceResponse The initial Stream Response - * @param onErrorResume Function used to resume. - * @param retryOptions Retry options. - */ - BlobDownloadAsyncResponse create(StreamResponse sourceResponse, - BiFunction> onErrorResume, DownloadRetryOptions retryOptions); - } - - /** - * The method called from {@link BlobDownloadAsyncResponse} to set it's accessor. - * - * @param accessor The accessor. - */ - public static void setAccessor( - final BlobDownloadAsyncResponseConstructorProxy.BlobDownloadAsyncResponseConstructorAccessor accessor) { - BlobDownloadAsyncResponseConstructorProxy.accessor = accessor; - } - - /** - * Creates a {@link BlobDownloadAsyncResponse}. - * - * @param sourceResponse The initial Stream Response - * @param onErrorResume Function used to resume. - * @param retryOptions Retry options. - */ - public static BlobDownloadAsyncResponse create(StreamResponse sourceResponse, - BiFunction> onErrorResume, DownloadRetryOptions retryOptions) { - // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the - // application accesses BlobDownloadAsyncResponse which triggers the accessor to be configured. So, if the accessor - // is null this effectively pokes the class to set up the accessor. - if (accessor == null) { - new BlobDownloadAsyncResponse(new HttpRequest(HttpMethod.GET, "http://microsoft.com"), 200, - new HttpHeaders(), null, null); - } - - assert accessor != null; - return accessor.create(sourceResponse, onErrorResume, retryOptions); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobDownloadHeadersConstructorProxy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobDownloadHeadersConstructorProxy.java deleted file mode 100644 index f4c02f3b9afc..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobDownloadHeadersConstructorProxy.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.accesshelpers; - -import com.azure.storage.blob.implementation.models.BlobsDownloadHeaders; -import com.azure.storage.blob.models.BlobDownloadHeaders; - -/** - * Helper class to access private values of {@link BlobDownloadHeaders} across package boundaries. - */ -public final class BlobDownloadHeadersConstructorProxy { - private static BlobDownloadHeadersConstructorAccessor accessor; - - private BlobDownloadHeadersConstructorProxy() { - } - - /** - * Type defining the methods to set the non-public properties of a {@link BlobDownloadHeadersConstructorAccessor} - * instance. - */ - public interface BlobDownloadHeadersConstructorAccessor { - /** - * Creates a new instance of {@link BlobDownloadHeaders} backed by an internal instance of - * {@link BlobsDownloadHeaders}. - * - * @param internalHeaders The internal headers. - * @return A new instance of {@link BlobDownloadHeaders}. - */ - BlobDownloadHeaders create(BlobsDownloadHeaders internalHeaders); - } - - /** - * The method called from {@link BlobDownloadHeaders} to set it's accessor. - * - * @param accessor The accessor. - */ - public static void setAccessor(final BlobDownloadHeadersConstructorAccessor accessor) { - BlobDownloadHeadersConstructorProxy.accessor = accessor; - } - - /** - * Creates a new instance of {@link BlobDownloadHeaders} backed by an internal instance of - * {@link BlobsDownloadHeaders}. - * - * @param internalHeaders The internal headers. - * @return A new instance of {@link BlobDownloadHeaders}. - */ - public static BlobDownloadHeaders create(BlobsDownloadHeaders internalHeaders) { - // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the - // application accesses BlobDownloadHeaders which triggers the accessor to be configured. So, if the accessor - // is null this effectively pokes the class to set up the accessor. - if (accessor == null) { - new BlobDownloadHeaders(); - } - - assert accessor != null; - return accessor.create(internalHeaders); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobItemConstructorProxy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobItemConstructorProxy.java deleted file mode 100644 index fdc8e7d1581b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobItemConstructorProxy.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.accesshelpers; - -import com.azure.storage.blob.implementation.models.BlobItemInternal; -import com.azure.storage.blob.models.BlobItem; - -/** - * Helper class to access private values of {@link BlobItem} across package boundaries. - */ -public final class BlobItemConstructorProxy { - private static BlobItemConstructorAccessor accessor; - - private BlobItemConstructorProxy() { - } - - /** - * Type defining the methods to set the non-public properties of a {@link BlobItem} instance. - */ - public interface BlobItemConstructorAccessor { - /** - * Creates a new instance of {@link BlobItem} backed by an internal instance of - * {@link BlobItem}. - * - * @param blobItemInternal The internal blob item. - * @return A new instance of {@link BlobItem}. - */ - BlobItem create(BlobItemInternal blobItemInternal); - } - - /** - * The method called from {@link BlobItem} to set it's accessor. - * - * @param accessor The accessor. - */ - public static void setAccessor(final BlobItemConstructorAccessor accessor) { - BlobItemConstructorProxy.accessor = accessor; - } - - /** - * Creates a new instance of {@link BlobItem} backed by an internal instance of - * {@link BlobItem}. - * - * @param blobItemInternal The internal blob item. - * @return A new instance of {@link BlobItem}. - */ - public static BlobItem create(BlobItemInternal blobItemInternal) { - // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the - // application accesses BlobDownloadHeaders which triggers the accessor to be configured. So, if the accessor - // is null this effectively pokes the class to set up the accessor. - if (accessor == null) { - new BlobItem(); - } - - assert accessor != null; - return accessor.create(blobItemInternal); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobItemPropertiesConstructorProxy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobItemPropertiesConstructorProxy.java deleted file mode 100644 index 36f664bbdf22..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobItemPropertiesConstructorProxy.java +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.accesshelpers; - -import com.azure.storage.blob.implementation.models.BlobItemPropertiesInternal; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobItemProperties; - -/** - * Helper class to access private values of {@link BlobItemProperties} across package boundaries. - */ -public final class BlobItemPropertiesConstructorProxy { - private static BlobItemPropertiesConstructorAccessor accessor; - - private BlobItemPropertiesConstructorProxy() { - } - - /** - * Type defining the methods to set the non-public properties of a {@link BlobItemProperties} instance. - */ - public interface BlobItemPropertiesConstructorAccessor { - /** - * Creates a new instance of {@link BlobItemProperties} backed by an internal instance of - * {@link BlobItemProperties}. - * - * @param internalProperties The internal properties. - * @return A new instance of {@link BlobItemProperties}. - */ - BlobItemProperties create(BlobItemPropertiesInternal internalProperties); - - /** - * Gets the {@link BlobItemPropertiesInternal} backing the instance of {@link BlobItemProperties}. - * - * @param properties The properties. - * @return The backing {@link BlobItemPropertiesInternal}. - */ - BlobItemPropertiesInternal getInternalProperties(BlobItemProperties properties); - } - - /** - * The method called from {@link BlobItem} to set it's accessor. - * - * @param accessor The accessor. - */ - public static void setAccessor(final BlobItemPropertiesConstructorAccessor accessor) { - BlobItemPropertiesConstructorProxy.accessor = accessor; - } - - /** - * Creates a new instance of {@link BlobItemProperties} backed by an internal instance of - * {@link BlobItemProperties}. - * - * @param internalProperties The internal properties. - * @return A new instance of {@link BlobItemProperties}. - */ - public static BlobItemProperties create(BlobItemPropertiesInternal internalProperties) { - // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the - // application accesses BlobDownloadHeaders which triggers the accessor to be configured. So, if the accessor - // is null this effectively pokes the class to set up the accessor. - if (accessor == null) { - new BlobItemProperties(); - } - - assert accessor != null; - return accessor.create(internalProperties); - } - - /** - * Gets the {@link BlobItemPropertiesInternal} backing the instance of {@link BlobItemProperties}. - * - * @param properties The properties. - * @return The backing {@link BlobItemPropertiesInternal}. - */ - public static BlobItemPropertiesInternal getInternalProperties(BlobItemProperties properties) { - return accessor.getInternalProperties(properties); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobPropertiesConstructorProxy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobPropertiesConstructorProxy.java deleted file mode 100644 index d8dd06e9b6ce..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobPropertiesConstructorProxy.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.accesshelpers; - -import com.azure.storage.blob.implementation.models.BlobPropertiesInternal; -import com.azure.storage.blob.models.BlobProperties; - -/** - * Helper class to access private values of {@link BlobProperties} across package boundaries. - */ -public final class BlobPropertiesConstructorProxy { - private static BlobPropertiesConstructorAccessor accessor; - - private BlobPropertiesConstructorProxy() { - } - - /** - * Interface defining the methods that access non-public APIs of a {@link BlobProperties} instance. - */ - public interface BlobPropertiesConstructorAccessor { - /** - * Creates a new instance of {@link BlobProperties} backed by an internal instance of - * {@link BlobPropertiesInternal}. - * - * @param internalProperties The internal properties. - * @return A new instance of {@link BlobProperties}. - */ - BlobProperties create(BlobPropertiesInternal internalProperties); - } - - /** - * The method called from the static initializer of {@link BlobProperties} to set it's accessor. - * - * @param accessor The {@link BlobProperties} accessor. - */ - public static void setAccessor(final BlobPropertiesConstructorAccessor accessor) { - BlobPropertiesConstructorProxy.accessor = accessor; - } - - /** - * Creates a new instance of {@link BlobProperties} backed by an internal instance of - * {@link BlobPropertiesInternal}. - * - * @param internalProperties The internal properties. - * @return A new instance of {@link BlobProperties}. - */ - public static BlobProperties create(BlobPropertiesInternal internalProperties) { - // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the - // application accesses BlobDownloadHeaders which triggers the accessor to be configured. So, if the accessor - // is null this effectively pokes the class to set up the accessor. - if (accessor == null) { - new BlobProperties(null, null, null, 0, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); - } - - assert accessor != null; - return accessor.create(internalProperties); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobQueryHeadersConstructorProxy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobQueryHeadersConstructorProxy.java deleted file mode 100644 index 4a3d295bd7f4..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/BlobQueryHeadersConstructorProxy.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.accesshelpers; - -import com.azure.storage.blob.implementation.models.BlobsQueryHeaders; -import com.azure.storage.blob.models.BlobQueryHeaders; - -/** - * Helper class to access private values of {@link BlobQueryHeaders} across package boundaries. - */ -public final class BlobQueryHeadersConstructorProxy { - private static BlobQueryHeadersConstructorAccessor accessor; - - private BlobQueryHeadersConstructorProxy() { - } - - /** - * Type defining the methods to set the non-public properties of a {@link BlobQueryHeaders} instance. - */ - public interface BlobQueryHeadersConstructorAccessor { - /** - * Creates a new instance of {@link BlobQueryHeaders} backed by an internal instance of - * {@link BlobsQueryHeaders}. - * - * @param internalHeader The internal headers. - * @return A new instance of {@link BlobQueryHeaders}. - */ - BlobQueryHeaders create(BlobsQueryHeaders internalHeader); - } - - /** - * The method called from {@link BlobQueryHeaders} to set it's accessor. - * - * @param accessor The accessor. - */ - public static void setAccessor(final BlobQueryHeadersConstructorAccessor accessor) { - BlobQueryHeadersConstructorProxy.accessor = accessor; - } - - /** - * Creates a new instance of {@link BlobQueryHeaders} backed by an internal instance of - * {@link BlobsQueryHeaders}. - * - * @param internalHeaders The internal headers. - * @return A new instance of {@link BlobQueryHeaders}. - */ - public static BlobQueryHeaders create(BlobsQueryHeaders internalHeaders) { - // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the - // application accesses BlobQueryHeaders which triggers the accessor to be configured. So, if the accessor - // is null this effectively pokes the class to set up the accessor. - if (accessor == null) { - new BlobQueryHeaders(); - } - - assert accessor != null; - return accessor.create(internalHeaders); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/package-info.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/package-info.java deleted file mode 100644 index 3fbaa48fefcd..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/accesshelpers/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Contains classes that aid access across package boundaries in a package-private manner. - */ -package com.azure.storage.blob.implementation.accesshelpers; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsAppendBlockFromUrlHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsAppendBlockFromUrlHeaders.java deleted file mode 100644 index 097459ec50dc..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsAppendBlockFromUrlHeaders.java +++ /dev/null @@ -1,389 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The AppendBlobsAppendBlockFromUrlHeaders model. - */ -@Fluent -public final class AppendBlobsAppendBlockFromUrlHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The x-ms-blob-committed-block-count property. - */ - private Integer xMsBlobCommittedBlockCount; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-blob-append-offset property. - */ - private String xMsBlobAppendOffset; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_BLOB_COMMITTED_BLOCK_COUNT - = HttpHeaderName.fromString("x-ms-blob-committed-block-count"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_BLOB_APPEND_OFFSET = HttpHeaderName.fromString("x-ms-blob-append-offset"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of AppendBlobsAppendBlockFromUrlHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public AppendBlobsAppendBlockFromUrlHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - String xMsBlobCommittedBlockCount = rawHeaders.getValue(X_MS_BLOB_COMMITTED_BLOCK_COUNT); - if (xMsBlobCommittedBlockCount != null) { - this.xMsBlobCommittedBlockCount = Integer.parseInt(xMsBlobCommittedBlockCount); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsBlobAppendOffset = rawHeaders.getValue(X_MS_BLOB_APPEND_OFFSET); - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @return the xMsBlobCommittedBlockCount value. - */ - public Integer getXMsBlobCommittedBlockCount() { - return this.xMsBlobCommittedBlockCount; - } - - /** - * Set the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @param xMsBlobCommittedBlockCount the xMsBlobCommittedBlockCount value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setXMsBlobCommittedBlockCount(Integer xMsBlobCommittedBlockCount) { - this.xMsBlobCommittedBlockCount = xMsBlobCommittedBlockCount; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsBlobAppendOffset property: The x-ms-blob-append-offset property. - * - * @return the xMsBlobAppendOffset value. - */ - public String getXMsBlobAppendOffset() { - return this.xMsBlobAppendOffset; - } - - /** - * Set the xMsBlobAppendOffset property: The x-ms-blob-append-offset property. - * - * @param xMsBlobAppendOffset the xMsBlobAppendOffset value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setXMsBlobAppendOffset(String xMsBlobAppendOffset) { - this.xMsBlobAppendOffset = xMsBlobAppendOffset; - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the AppendBlobsAppendBlockFromUrlHeaders object itself. - */ - public AppendBlobsAppendBlockFromUrlHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsAppendBlockHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsAppendBlockHeaders.java deleted file mode 100644 index 9e12858def26..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsAppendBlockHeaders.java +++ /dev/null @@ -1,443 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The AppendBlobsAppendBlockHeaders model. - */ -@Fluent -public final class AppendBlobsAppendBlockHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The x-ms-blob-committed-block-count property. - */ - private Integer xMsBlobCommittedBlockCount; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-structured-body property. - */ - private String xMsStructuredBody; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The x-ms-blob-append-offset property. - */ - private String xMsBlobAppendOffset; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_BLOB_COMMITTED_BLOCK_COUNT - = HttpHeaderName.fromString("x-ms-blob-committed-block-count"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_STRUCTURED_BODY = HttpHeaderName.fromString("x-ms-structured-body"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_BLOB_APPEND_OFFSET = HttpHeaderName.fromString("x-ms-blob-append-offset"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of AppendBlobsAppendBlockHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public AppendBlobsAppendBlockHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - String xMsBlobCommittedBlockCount = rawHeaders.getValue(X_MS_BLOB_COMMITTED_BLOCK_COUNT); - if (xMsBlobCommittedBlockCount != null) { - this.xMsBlobCommittedBlockCount = Integer.parseInt(xMsBlobCommittedBlockCount); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsStructuredBody = rawHeaders.getValue(X_MS_STRUCTURED_BODY); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - this.xMsBlobAppendOffset = rawHeaders.getValue(X_MS_BLOB_APPEND_OFFSET); - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @return the xMsBlobCommittedBlockCount value. - */ - public Integer getXMsBlobCommittedBlockCount() { - return this.xMsBlobCommittedBlockCount; - } - - /** - * Set the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @param xMsBlobCommittedBlockCount the xMsBlobCommittedBlockCount value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsBlobCommittedBlockCount(Integer xMsBlobCommittedBlockCount) { - this.xMsBlobCommittedBlockCount = xMsBlobCommittedBlockCount; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsStructuredBody property: The x-ms-structured-body property. - * - * @return the xMsStructuredBody value. - */ - public String getXMsStructuredBody() { - return this.xMsStructuredBody; - } - - /** - * Set the xMsStructuredBody property: The x-ms-structured-body property. - * - * @param xMsStructuredBody the xMsStructuredBody value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsStructuredBody(String xMsStructuredBody) { - this.xMsStructuredBody = xMsStructuredBody; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the xMsBlobAppendOffset property: The x-ms-blob-append-offset property. - * - * @return the xMsBlobAppendOffset value. - */ - public String getXMsBlobAppendOffset() { - return this.xMsBlobAppendOffset; - } - - /** - * Set the xMsBlobAppendOffset property: The x-ms-blob-append-offset property. - * - * @param xMsBlobAppendOffset the xMsBlobAppendOffset value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsBlobAppendOffset(String xMsBlobAppendOffset) { - this.xMsBlobAppendOffset = xMsBlobAppendOffset; - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the AppendBlobsAppendBlockHeaders object itself. - */ - public AppendBlobsAppendBlockHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsCreateHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsCreateHeaders.java deleted file mode 100644 index 9553c9589d1e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsCreateHeaders.java +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The AppendBlobsCreateHeaders model. - */ -@Fluent -public final class AppendBlobsCreateHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of AppendBlobsCreateHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public AppendBlobsCreateHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the AppendBlobsCreateHeaders object itself. - */ - public AppendBlobsCreateHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsSealHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsSealHeaders.java deleted file mode 100644 index ba6caa84b16a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/AppendBlobsSealHeaders.java +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The AppendBlobsSealHeaders model. - */ -@Fluent -public final class AppendBlobsSealHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-blob-sealed property. - */ - private Boolean xMsBlobSealed; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_BLOB_SEALED = HttpHeaderName.fromString("x-ms-blob-sealed"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of AppendBlobsSealHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public AppendBlobsSealHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsBlobSealed = rawHeaders.getValue(X_MS_BLOB_SEALED); - if (xMsBlobSealed != null) { - this.xMsBlobSealed = Boolean.parseBoolean(xMsBlobSealed); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the AppendBlobsSealHeaders object itself. - */ - public AppendBlobsSealHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the AppendBlobsSealHeaders object itself. - */ - public AppendBlobsSealHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsBlobSealed property: The x-ms-blob-sealed property. - * - * @return the xMsBlobSealed value. - */ - public Boolean isXMsBlobSealed() { - return this.xMsBlobSealed; - } - - /** - * Set the xMsBlobSealed property: The x-ms-blob-sealed property. - * - * @param xMsBlobSealed the xMsBlobSealed value to set. - * @return the AppendBlobsSealHeaders object itself. - */ - public AppendBlobsSealHeaders setXMsBlobSealed(Boolean xMsBlobSealed) { - this.xMsBlobSealed = xMsBlobSealed; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the AppendBlobsSealHeaders object itself. - */ - public AppendBlobsSealHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the AppendBlobsSealHeaders object itself. - */ - public AppendBlobsSealHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the AppendBlobsSealHeaders object itself. - */ - public AppendBlobsSealHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the AppendBlobsSealHeaders object itself. - */ - public AppendBlobsSealHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowConfiguration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowConfiguration.java deleted file mode 100644 index 4b9b6569c6ec..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowConfiguration.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; -import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Groups the settings used for formatting the response if the response should be Arrow formatted. - */ -@Fluent -public final class ArrowConfiguration implements XmlSerializable { - /* - * The Schema property. - */ - private List schema; - - /** - * Creates an instance of ArrowConfiguration class. - */ - public ArrowConfiguration() { - } - - /** - * Get the schema property: The Schema property. - * - * @return the schema value. - */ - public List getSchema() { - if (this.schema == null) { - this.schema = new ArrayList<>(); - } - return this.schema; - } - - /** - * Set the schema property: The Schema property. - * - * @param schema the schema value to set. - * @return the ArrowConfiguration object itself. - */ - public ArrowConfiguration setSchema(List schema) { - this.schema = schema; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "ArrowConfiguration" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (this.schema != null) { - xmlWriter.writeStartElement("Schema"); - for (ArrowField element : this.schema) { - xmlWriter.writeXml(element, "Field"); - } - xmlWriter.writeEndElement(); - } - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of ArrowConfiguration from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of ArrowConfiguration if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the ArrowConfiguration. - */ - public static ArrowConfiguration fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of ArrowConfiguration from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of ArrowConfiguration if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the ArrowConfiguration. - */ - public static ArrowConfiguration fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "ArrowConfiguration" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - ArrowConfiguration deserializedArrowConfiguration = new ArrowConfiguration(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Schema".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - elementName = reader.getElementName(); - if ("Field".equals(elementName.getLocalPart())) { - if (deserializedArrowConfiguration.schema == null) { - deserializedArrowConfiguration.schema = new ArrayList<>(); - } - deserializedArrowConfiguration.schema.add(ArrowField.fromXml(reader, "Field")); - } else { - reader.skipElement(); - } - } - } else { - reader.skipElement(); - } - } - - return deserializedArrowConfiguration; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowField.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowField.java deleted file mode 100644 index cf574b934c00..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowField.java +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Groups settings regarding specific field of an arrow schema. - */ -@Fluent -public final class ArrowField implements XmlSerializable { - /* - * The Type property. - */ - private String type; - - /* - * The Name property. - */ - private String name; - - /* - * The Precision property. - */ - private Integer precision; - - /* - * The Scale property. - */ - private Integer scale; - - /** - * Creates an instance of ArrowField class. - */ - public ArrowField() { - } - - /** - * Get the type property: The Type property. - * - * @return the type value. - */ - public String getType() { - return this.type; - } - - /** - * Set the type property: The Type property. - * - * @param type the type value to set. - * @return the ArrowField object itself. - */ - public ArrowField setType(String type) { - this.type = type; - return this; - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - public String getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the ArrowField object itself. - */ - public ArrowField setName(String name) { - this.name = name; - return this; - } - - /** - * Get the precision property: The Precision property. - * - * @return the precision value. - */ - public Integer getPrecision() { - return this.precision; - } - - /** - * Set the precision property: The Precision property. - * - * @param precision the precision value to set. - * @return the ArrowField object itself. - */ - public ArrowField setPrecision(Integer precision) { - this.precision = precision; - return this; - } - - /** - * Get the scale property: The Scale property. - * - * @return the scale value. - */ - public Integer getScale() { - return this.scale; - } - - /** - * Set the scale property: The Scale property. - * - * @param scale the scale value to set. - * @return the ArrowField object itself. - */ - public ArrowField setScale(Integer scale) { - this.scale = scale; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Field" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Type", this.type); - xmlWriter.writeStringElement("Name", this.name); - xmlWriter.writeNumberElement("Precision", this.precision); - xmlWriter.writeNumberElement("Scale", this.scale); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of ArrowField from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of ArrowField if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the ArrowField. - */ - public static ArrowField fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of ArrowField from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of ArrowField if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the ArrowField. - */ - public static ArrowField fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Field" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - ArrowField deserializedArrowField = new ArrowField(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Type".equals(elementName.getLocalPart())) { - deserializedArrowField.type = reader.getStringElement(); - } else if ("Name".equals(elementName.getLocalPart())) { - deserializedArrowField.name = reader.getStringElement(); - } else if ("Precision".equals(elementName.getLocalPart())) { - deserializedArrowField.precision = reader.getNullableElement(Integer::parseInt); - } else if ("Scale".equals(elementName.getLocalPart())) { - deserializedArrowField.scale = reader.getNullableElement(Integer::parseInt); - } else { - reader.skipElement(); - } - } - - return deserializedArrowField; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobContainersSegment.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobContainersSegment.java deleted file mode 100644 index 0fb2ffea592b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobContainersSegment.java +++ /dev/null @@ -1,266 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.BlobContainerItem; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; -import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * An enumeration of containers. - */ -@Fluent -public final class BlobContainersSegment implements XmlSerializable { - /* - * The ServiceEndpoint property. - */ - private String serviceEndpoint; - - /* - * The Prefix property. - */ - private String prefix; - - /* - * The Marker property. - */ - private String marker; - - /* - * The MaxResults property. - */ - private Integer maxResults; - - /* - * The NextMarker property. - */ - private String nextMarker; - - /* - * The BlobContainerItems property. - */ - private List blobContainerItems; - - /** - * Creates an instance of BlobContainersSegment class. - */ - public BlobContainersSegment() { - } - - /** - * Get the serviceEndpoint property: The ServiceEndpoint property. - * - * @return the serviceEndpoint value. - */ - public String getServiceEndpoint() { - return this.serviceEndpoint; - } - - /** - * Set the serviceEndpoint property: The ServiceEndpoint property. - * - * @param serviceEndpoint the serviceEndpoint value to set. - * @return the BlobContainersSegment object itself. - */ - public BlobContainersSegment setServiceEndpoint(String serviceEndpoint) { - this.serviceEndpoint = serviceEndpoint; - return this; - } - - /** - * Get the prefix property: The Prefix property. - * - * @return the prefix value. - */ - public String getPrefix() { - return this.prefix; - } - - /** - * Set the prefix property: The Prefix property. - * - * @param prefix the prefix value to set. - * @return the BlobContainersSegment object itself. - */ - public BlobContainersSegment setPrefix(String prefix) { - this.prefix = prefix; - return this; - } - - /** - * Get the marker property: The Marker property. - * - * @return the marker value. - */ - public String getMarker() { - return this.marker; - } - - /** - * Set the marker property: The Marker property. - * - * @param marker the marker value to set. - * @return the BlobContainersSegment object itself. - */ - public BlobContainersSegment setMarker(String marker) { - this.marker = marker; - return this; - } - - /** - * Get the maxResults property: The MaxResults property. - * - * @return the maxResults value. - */ - public Integer getMaxResults() { - return this.maxResults; - } - - /** - * Set the maxResults property: The MaxResults property. - * - * @param maxResults the maxResults value to set. - * @return the BlobContainersSegment object itself. - */ - public BlobContainersSegment setMaxResults(Integer maxResults) { - this.maxResults = maxResults; - return this; - } - - /** - * Get the nextMarker property: The NextMarker property. - * - * @return the nextMarker value. - */ - public String getNextMarker() { - return this.nextMarker; - } - - /** - * Set the nextMarker property: The NextMarker property. - * - * @param nextMarker the nextMarker value to set. - * @return the BlobContainersSegment object itself. - */ - public BlobContainersSegment setNextMarker(String nextMarker) { - this.nextMarker = nextMarker; - return this; - } - - /** - * Get the blobContainerItems property: The BlobContainerItems property. - * - * @return the blobContainerItems value. - */ - public List getBlobContainerItems() { - if (this.blobContainerItems == null) { - this.blobContainerItems = new ArrayList<>(); - } - return this.blobContainerItems; - } - - /** - * Set the blobContainerItems property: The BlobContainerItems property. - * - * @param blobContainerItems the blobContainerItems value to set. - * @return the BlobContainersSegment object itself. - */ - public BlobContainersSegment setBlobContainerItems(List blobContainerItems) { - this.blobContainerItems = blobContainerItems; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "EnumerationResults" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringAttribute("ServiceEndpoint", this.serviceEndpoint); - xmlWriter.writeStringElement("Prefix", this.prefix); - xmlWriter.writeStringElement("Marker", this.marker); - xmlWriter.writeNumberElement("MaxResults", this.maxResults); - xmlWriter.writeStringElement("NextMarker", this.nextMarker); - if (this.blobContainerItems != null) { - xmlWriter.writeStartElement("Containers"); - for (BlobContainerItem element : this.blobContainerItems) { - xmlWriter.writeXml(element, "Container"); - } - xmlWriter.writeEndElement(); - } - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobContainersSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobContainersSegment if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobContainersSegment. - */ - public static BlobContainersSegment fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobContainersSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobContainersSegment if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobContainersSegment. - */ - public static BlobContainersSegment fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "EnumerationResults" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobContainersSegment deserializedBlobContainersSegment = new BlobContainersSegment(); - deserializedBlobContainersSegment.serviceEndpoint = reader.getStringAttribute(null, "ServiceEndpoint"); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Prefix".equals(elementName.getLocalPart())) { - deserializedBlobContainersSegment.prefix = reader.getStringElement(); - } else if ("Marker".equals(elementName.getLocalPart())) { - deserializedBlobContainersSegment.marker = reader.getStringElement(); - } else if ("MaxResults".equals(elementName.getLocalPart())) { - deserializedBlobContainersSegment.maxResults = reader.getNullableElement(Integer::parseInt); - } else if ("NextMarker".equals(elementName.getLocalPart())) { - deserializedBlobContainersSegment.nextMarker = reader.getStringElement(); - } else if ("Containers".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - elementName = reader.getElementName(); - if ("Container".equals(elementName.getLocalPart())) { - if (deserializedBlobContainersSegment.blobContainerItems == null) { - deserializedBlobContainersSegment.blobContainerItems = new ArrayList<>(); - } - deserializedBlobContainersSegment.blobContainerItems - .add(BlobContainerItem.fromXml(reader, "Container")); - } else { - reader.skipElement(); - } - } - } else { - reader.skipElement(); - } - } - - return deserializedBlobContainersSegment; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobCopySourceTags.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobCopySourceTags.java deleted file mode 100644 index 381e08ff2dff..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobCopySourceTags.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -/** Defines values for BlobCopySourceTags. */ -public enum BlobCopySourceTags { - /** Enum value REPLACE. */ - REPLACE("REPLACE"), - - /** Enum value COPY. */ - COPY("COPY"); - - /** The actual serialized value for a BlobCopySourceTags instance. */ - private final String value; - - BlobCopySourceTags(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a BlobCopySourceTags instance. - * - * @param value the serialized value to parse. - * @return the parsed BlobCopySourceTags object, or null if unable to parse. - */ - public static BlobCopySourceTags fromString(String value) { - BlobCopySourceTags[] items = BlobCopySourceTags.values(); - for (BlobCopySourceTags item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobFlatListSegment.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobFlatListSegment.java deleted file mode 100644 index 61e3c970a95f..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobFlatListSegment.java +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; -import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * The BlobFlatListSegment model. - */ -@Fluent -public final class BlobFlatListSegment implements XmlSerializable { - /* - * The BlobItems property. - */ - private List blobItems = new ArrayList<>(); - - /** - * Creates an instance of BlobFlatListSegment class. - */ - public BlobFlatListSegment() { - } - - /** - * Get the blobItems property: The BlobItems property. - * - * @return the blobItems value. - */ - public List getBlobItems() { - return this.blobItems; - } - - /** - * Set the blobItems property: The BlobItems property. - * - * @param blobItems the blobItems value to set. - * @return the BlobFlatListSegment object itself. - */ - public BlobFlatListSegment setBlobItems(List blobItems) { - this.blobItems = blobItems; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Blobs" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (this.blobItems != null) { - for (BlobItemInternal element : this.blobItems) { - xmlWriter.writeXml(element, "Blob"); - } - } - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobFlatListSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobFlatListSegment if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobFlatListSegment. - */ - public static BlobFlatListSegment fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobFlatListSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobFlatListSegment if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobFlatListSegment. - */ - public static BlobFlatListSegment fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Blobs" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobFlatListSegment deserializedBlobFlatListSegment = new BlobFlatListSegment(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Blob".equals(elementName.getLocalPart())) { - deserializedBlobFlatListSegment.blobItems.add(BlobItemInternal.fromXml(reader, "Blob")); - } else { - reader.skipElement(); - } - } - - return deserializedBlobFlatListSegment; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobHierarchyListSegment.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobHierarchyListSegment.java deleted file mode 100644 index bf9bf05b8dfd..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobHierarchyListSegment.java +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; -import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * The BlobHierarchyListSegment model. - */ -@Fluent -public final class BlobHierarchyListSegment implements XmlSerializable { - /* - * The BlobPrefixes property. - */ - private List blobPrefixes = new ArrayList<>(); - - /* - * The BlobItems property. - */ - private List blobItems = new ArrayList<>(); - - /** - * Creates an instance of BlobHierarchyListSegment class. - */ - public BlobHierarchyListSegment() { - } - - /** - * Get the blobPrefixes property: The BlobPrefixes property. - * - * @return the blobPrefixes value. - */ - public List getBlobPrefixes() { - return this.blobPrefixes; - } - - /** - * Set the blobPrefixes property: The BlobPrefixes property. - * - * @param blobPrefixes the blobPrefixes value to set. - * @return the BlobHierarchyListSegment object itself. - */ - public BlobHierarchyListSegment setBlobPrefixes(List blobPrefixes) { - this.blobPrefixes = blobPrefixes; - return this; - } - - /** - * Get the blobItems property: The BlobItems property. - * - * @return the blobItems value. - */ - public List getBlobItems() { - return this.blobItems; - } - - /** - * Set the blobItems property: The BlobItems property. - * - * @param blobItems the blobItems value to set. - * @return the BlobHierarchyListSegment object itself. - */ - public BlobHierarchyListSegment setBlobItems(List blobItems) { - this.blobItems = blobItems; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Blobs" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (this.blobPrefixes != null) { - for (BlobPrefixInternal element : this.blobPrefixes) { - xmlWriter.writeXml(element, "BlobPrefix"); - } - } - if (this.blobItems != null) { - for (BlobItemInternal element : this.blobItems) { - xmlWriter.writeXml(element, "Blob"); - } - } - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobHierarchyListSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobHierarchyListSegment if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobHierarchyListSegment. - */ - public static BlobHierarchyListSegment fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobHierarchyListSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobHierarchyListSegment if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobHierarchyListSegment. - */ - public static BlobHierarchyListSegment fromXml(XmlReader xmlReader, String rootElementName) - throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Blobs" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobHierarchyListSegment deserializedBlobHierarchyListSegment = new BlobHierarchyListSegment(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("BlobPrefix".equals(elementName.getLocalPart())) { - deserializedBlobHierarchyListSegment.blobPrefixes - .add(BlobPrefixInternal.fromXml(reader, "BlobPrefix")); - } else if ("Blob".equals(elementName.getLocalPart())) { - deserializedBlobHierarchyListSegment.blobItems.add(BlobItemInternal.fromXml(reader, "Blob")); - } else { - reader.skipElement(); - } - } - - return deserializedBlobHierarchyListSegment; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemInternal.java deleted file mode 100644 index 606dff9e5cd3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemInternal.java +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * An Azure Storage blob. - */ -@Fluent -public final class BlobItemInternal implements XmlSerializable { - /* - * The Name property. - */ - private BlobName name; - - /* - * The Deleted property. - */ - private boolean deleted; - - /* - * The Snapshot property. - */ - private String snapshot; - - /* - * The VersionId property. - */ - private String versionId; - - /* - * The IsCurrentVersion property. - */ - private Boolean isCurrentVersion; - - /* - * Properties of a blob - */ - private BlobItemPropertiesInternal properties; - - /* - * Dictionary of - */ - private Map metadata; - - /* - * Blob tags - */ - private BlobTags blobTags; - - /* - * Dictionary of - */ - private Map objectReplicationMetadata; - - /* - * The HasVersionsOnly property. - */ - private Boolean hasVersionsOnly; - - /* - * The IsPrefix property. - */ - private Boolean isPrefix; - - /** - * Creates an instance of BlobItemInternal class. - */ - public BlobItemInternal() { - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - public BlobName getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setName(BlobName name) { - this.name = name; - return this; - } - - /** - * Get the deleted property: The Deleted property. - * - * @return the deleted value. - */ - public boolean isDeleted() { - return this.deleted; - } - - /** - * Set the deleted property: The Deleted property. - * - * @param deleted the deleted value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setDeleted(boolean deleted) { - this.deleted = deleted; - return this; - } - - /** - * Get the snapshot property: The Snapshot property. - * - * @return the snapshot value. - */ - public String getSnapshot() { - return this.snapshot; - } - - /** - * Set the snapshot property: The Snapshot property. - * - * @param snapshot the snapshot value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setSnapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - /** - * Get the versionId property: The VersionId property. - * - * @return the versionId value. - */ - public String getVersionId() { - return this.versionId; - } - - /** - * Set the versionId property: The VersionId property. - * - * @param versionId the versionId value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setVersionId(String versionId) { - this.versionId = versionId; - return this; - } - - /** - * Get the isCurrentVersion property: The IsCurrentVersion property. - * - * @return the isCurrentVersion value. - */ - public Boolean isCurrentVersion() { - return this.isCurrentVersion; - } - - /** - * Set the isCurrentVersion property: The IsCurrentVersion property. - * - * @param isCurrentVersion the isCurrentVersion value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setIsCurrentVersion(Boolean isCurrentVersion) { - this.isCurrentVersion = isCurrentVersion; - return this; - } - - /** - * Get the properties property: Properties of a blob. - * - * @return the properties value. - */ - public BlobItemPropertiesInternal getProperties() { - return this.properties; - } - - /** - * Set the properties property: Properties of a blob. - * - * @param properties the properties value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setProperties(BlobItemPropertiesInternal properties) { - this.properties = properties; - return this; - } - - /** - * Get the metadata property: Dictionary of <string>. - * - * @return the metadata value. - */ - public Map getMetadata() { - return this.metadata; - } - - /** - * Set the metadata property: Dictionary of <string>. - * - * @param metadata the metadata value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Get the blobTags property: Blob tags. - * - * @return the blobTags value. - */ - public BlobTags getBlobTags() { - return this.blobTags; - } - - /** - * Set the blobTags property: Blob tags. - * - * @param blobTags the blobTags value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setBlobTags(BlobTags blobTags) { - this.blobTags = blobTags; - return this; - } - - /** - * Get the objectReplicationMetadata property: Dictionary of <string>. - * - * @return the objectReplicationMetadata value. - */ - public Map getObjectReplicationMetadata() { - return this.objectReplicationMetadata; - } - - /** - * Set the objectReplicationMetadata property: Dictionary of <string>. - * - * @param objectReplicationMetadata the objectReplicationMetadata value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setObjectReplicationMetadata(Map objectReplicationMetadata) { - this.objectReplicationMetadata = objectReplicationMetadata; - return this; - } - - /** - * Get the hasVersionsOnly property: The HasVersionsOnly property. - * - * @return the hasVersionsOnly value. - */ - public Boolean isHasVersionsOnly() { - return this.hasVersionsOnly; - } - - /** - * Set the hasVersionsOnly property: The HasVersionsOnly property. - * - * @param hasVersionsOnly the hasVersionsOnly value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setHasVersionsOnly(Boolean hasVersionsOnly) { - this.hasVersionsOnly = hasVersionsOnly; - return this; - } - - /** - * Get the isPrefix property: The IsPrefix property. - * - * @return the isPrefix value. - */ - public Boolean isPrefix() { - return this.isPrefix; - } - - /** - * Set the isPrefix property: The IsPrefix property. - * - * @param isPrefix the isPrefix value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItemInternal setIsPrefix(Boolean isPrefix) { - this.isPrefix = isPrefix; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Blob" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.name, "Name"); - xmlWriter.writeBooleanElement("Deleted", this.deleted); - xmlWriter.writeStringElement("Snapshot", this.snapshot); - xmlWriter.writeStringElement("VersionId", this.versionId); - xmlWriter.writeBooleanElement("IsCurrentVersion", this.isCurrentVersion); - xmlWriter.writeXml(this.properties, "Properties"); - if (this.metadata != null) { - xmlWriter.writeStartElement("Metadata"); - for (Map.Entry entry : this.metadata.entrySet()) { - xmlWriter.writeStringElement(entry.getKey(), entry.getValue()); - } - xmlWriter.writeEndElement(); - } - xmlWriter.writeXml(this.blobTags, "Tags"); - if (this.objectReplicationMetadata != null) { - xmlWriter.writeStartElement("OrMetadata"); - for (Map.Entry entry : this.objectReplicationMetadata.entrySet()) { - xmlWriter.writeStringElement(entry.getKey(), entry.getValue()); - } - xmlWriter.writeEndElement(); - } - xmlWriter.writeBooleanElement("HasVersionsOnly", this.hasVersionsOnly); - xmlWriter.writeBooleanElement("IsPrefix", this.isPrefix); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobItemInternal from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobItemInternal if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobItemInternal. - */ - public static BlobItemInternal fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobItemInternal from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobItemInternal if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobItemInternal. - */ - public static BlobItemInternal fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Blob" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobItemInternal deserializedBlobItemInternal = new BlobItemInternal(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedBlobItemInternal.name = BlobName.fromXml(reader, "Name"); - } else if ("Deleted".equals(elementName.getLocalPart())) { - deserializedBlobItemInternal.deleted = reader.getBooleanElement(); - } else if ("Snapshot".equals(elementName.getLocalPart())) { - deserializedBlobItemInternal.snapshot = reader.getStringElement(); - } else if ("VersionId".equals(elementName.getLocalPart())) { - deserializedBlobItemInternal.versionId = reader.getStringElement(); - } else if ("IsCurrentVersion".equals(elementName.getLocalPart())) { - deserializedBlobItemInternal.isCurrentVersion = reader.getNullableElement(Boolean::parseBoolean); - } else if ("Properties".equals(elementName.getLocalPart())) { - deserializedBlobItemInternal.properties = BlobItemPropertiesInternal.fromXml(reader, "Properties"); - } else if ("Metadata".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - if (deserializedBlobItemInternal.metadata == null) { - deserializedBlobItemInternal.metadata = new LinkedHashMap<>(); - } - deserializedBlobItemInternal.metadata.put(reader.getElementName().getLocalPart(), - reader.getStringElement()); - } - } else if ("Tags".equals(elementName.getLocalPart())) { - deserializedBlobItemInternal.blobTags = BlobTags.fromXml(reader, "Tags"); - } else if ("OrMetadata".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - if (deserializedBlobItemInternal.objectReplicationMetadata == null) { - deserializedBlobItemInternal.objectReplicationMetadata = new LinkedHashMap<>(); - } - deserializedBlobItemInternal.objectReplicationMetadata - .put(reader.getElementName().getLocalPart(), reader.getStringElement()); - } - } else if ("HasVersionsOnly".equals(elementName.getLocalPart())) { - deserializedBlobItemInternal.hasVersionsOnly = reader.getNullableElement(Boolean::parseBoolean); - } else if ("IsPrefix".equals(elementName.getLocalPart())) { - deserializedBlobItemInternal.isPrefix = reader.getNullableElement(Boolean::parseBoolean); - } else { - reader.skipElement(); - } - } - - return deserializedBlobItemInternal; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java deleted file mode 100644 index 5236d43f00f8..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java +++ /dev/null @@ -1,1293 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.ArchiveStatus; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.time.OffsetDateTime; -import java.util.Objects; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Properties of a blob. - */ -@Fluent -public final class BlobItemPropertiesInternal implements XmlSerializable { - /* - * The Creation-Time property. - */ - private DateTimeRfc1123 creationTime; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The Etag property. - */ - private String eTag; - - /* - * Size in bytes - */ - private Long contentLength; - - /* - * The Content-Type property. - */ - private String contentType; - - /* - * The Content-Encoding property. - */ - private String contentEncoding; - - /* - * The Content-Language property. - */ - private String contentLanguage; - - /* - * The Content-MD5 property. - */ - private byte[] contentMd5; - - /* - * The Content-Disposition property. - */ - private String contentDisposition; - - /* - * The Cache-Control property. - */ - private String cacheControl; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long blobSequenceNumber; - - /* - * The BlobType property. - */ - private BlobType blobType; - - /* - * The LeaseStatus property. - */ - private LeaseStatusType leaseStatus; - - /* - * The LeaseState property. - */ - private LeaseStateType leaseState; - - /* - * The LeaseDuration property. - */ - private LeaseDurationType leaseDuration; - - /* - * The CopyId property. - */ - private String copyId; - - /* - * The CopyStatus property. - */ - private CopyStatusType copyStatus; - - /* - * The CopySource property. - */ - private String copySource; - - /* - * The CopyProgress property. - */ - private String copyProgress; - - /* - * The CopyCompletionTime property. - */ - private DateTimeRfc1123 copyCompletionTime; - - /* - * The CopyStatusDescription property. - */ - private String copyStatusDescription; - - /* - * The ServerEncrypted property. - */ - private Boolean serverEncrypted; - - /* - * The IncrementalCopy property. - */ - private Boolean incrementalCopy; - - /* - * The DestinationSnapshot property. - */ - private String destinationSnapshot; - - /* - * The DeletedTime property. - */ - private DateTimeRfc1123 deletedTime; - - /* - * The RemainingRetentionDays property. - */ - private Integer remainingRetentionDays; - - /* - * The AccessTier property. - */ - private AccessTier accessTier; - - /* - * The AccessTierInferred property. - */ - private Boolean accessTierInferred; - - /* - * The ArchiveStatus property. - */ - private ArchiveStatus archiveStatus; - - /* - * The CustomerProvidedKeySha256 property. - */ - private String customerProvidedKeySha256; - - /* - * The name of the encryption scope under which the blob is encrypted. - */ - private String encryptionScope; - - /* - * The AccessTierChangeTime property. - */ - private DateTimeRfc1123 accessTierChangeTime; - - /* - * The TagCount property. - */ - private Integer tagCount; - - /* - * The Expiry-Time property. - */ - private DateTimeRfc1123 expiresOn; - - /* - * The Sealed property. - */ - private Boolean isSealed; - - /* - * If an object is in rehydrate pending state then this header is returned with priority of rehydrate. Valid values - * are High and Standard. - */ - private RehydratePriority rehydratePriority; - - /* - * The LastAccessTime property. - */ - private DateTimeRfc1123 lastAccessedOn; - - /* - * The ImmutabilityPolicyUntilDate property. - */ - private DateTimeRfc1123 immutabilityPolicyExpiresOn; - - /* - * The ImmutabilityPolicyMode property. - */ - private BlobImmutabilityPolicyMode immutabilityPolicyMode; - - /* - * The LegalHold property. - */ - private Boolean legalHold; - - /** - * Creates an instance of BlobItemPropertiesInternal class. - */ - public BlobItemPropertiesInternal() { - } - - /** - * Get the creationTime property: The Creation-Time property. - * - * @return the creationTime value. - */ - public OffsetDateTime getCreationTime() { - if (this.creationTime == null) { - return null; - } - return this.creationTime.getDateTime(); - } - - /** - * Set the creationTime property: The Creation-Time property. - * - * @param creationTime the creationTime value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setCreationTime(OffsetDateTime creationTime) { - if (creationTime == null) { - this.creationTime = null; - } else { - this.creationTime = new DateTimeRfc1123(creationTime); - } - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the eTag property: The Etag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The Etag property. - * - * @param eTag the eTag value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the contentLength property: Size in bytes. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return this.contentLength; - } - - /** - * Set the contentLength property: Size in bytes. - * - * @param contentLength the contentLength value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setContentLength(Long contentLength) { - this.contentLength = contentLength; - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Get the contentEncoding property: The Content-Encoding property. - * - * @return the contentEncoding value. - */ - public String getContentEncoding() { - return this.contentEncoding; - } - - /** - * Set the contentEncoding property: The Content-Encoding property. - * - * @param contentEncoding the contentEncoding value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - /** - * Get the contentLanguage property: The Content-Language property. - * - * @return the contentLanguage value. - */ - public String getContentLanguage() { - return this.contentLanguage; - } - - /** - * Set the contentLanguage property: The Content-Language property. - * - * @param contentLanguage the contentLanguage value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Get the contentMd5 property: The Content-MD5 property. - * - * @return the contentMd5 value. - */ - public byte[] getContentMd5() { - return CoreUtils.clone(this.contentMd5); - } - - /** - * Set the contentMd5 property: The Content-MD5 property. - * - * @param contentMd5 the contentMd5 value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setContentMd5(byte[] contentMd5) { - this.contentMd5 = CoreUtils.clone(contentMd5); - return this; - } - - /** - * Get the contentDisposition property: The Content-Disposition property. - * - * @return the contentDisposition value. - */ - public String getContentDisposition() { - return this.contentDisposition; - } - - /** - * Set the contentDisposition property: The Content-Disposition property. - * - * @param contentDisposition the contentDisposition value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setContentDisposition(String contentDisposition) { - this.contentDisposition = contentDisposition; - return this; - } - - /** - * Get the cacheControl property: The Cache-Control property. - * - * @return the cacheControl value. - */ - public String getCacheControl() { - return this.cacheControl; - } - - /** - * Set the cacheControl property: The Cache-Control property. - * - * @param cacheControl the cacheControl value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - /** - * Get the blobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the blobSequenceNumber value. - */ - public Long getBlobSequenceNumber() { - return this.blobSequenceNumber; - } - - /** - * Set the blobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param blobSequenceNumber the blobSequenceNumber value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setBlobSequenceNumber(Long blobSequenceNumber) { - this.blobSequenceNumber = blobSequenceNumber; - return this; - } - - /** - * Get the blobType property: The BlobType property. - * - * @return the blobType value. - */ - public BlobType getBlobType() { - return this.blobType; - } - - /** - * Set the blobType property: The BlobType property. - * - * @param blobType the blobType value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setBlobType(BlobType blobType) { - this.blobType = blobType; - return this; - } - - /** - * Get the leaseStatus property: The LeaseStatus property. - * - * @return the leaseStatus value. - */ - public LeaseStatusType getLeaseStatus() { - return this.leaseStatus; - } - - /** - * Set the leaseStatus property: The LeaseStatus property. - * - * @param leaseStatus the leaseStatus value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setLeaseStatus(LeaseStatusType leaseStatus) { - this.leaseStatus = leaseStatus; - return this; - } - - /** - * Get the leaseState property: The LeaseState property. - * - * @return the leaseState value. - */ - public LeaseStateType getLeaseState() { - return this.leaseState; - } - - /** - * Set the leaseState property: The LeaseState property. - * - * @param leaseState the leaseState value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setLeaseState(LeaseStateType leaseState) { - this.leaseState = leaseState; - return this; - } - - /** - * Get the leaseDuration property: The LeaseDuration property. - * - * @return the leaseDuration value. - */ - public LeaseDurationType getLeaseDuration() { - return this.leaseDuration; - } - - /** - * Set the leaseDuration property: The LeaseDuration property. - * - * @param leaseDuration the leaseDuration value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setLeaseDuration(LeaseDurationType leaseDuration) { - this.leaseDuration = leaseDuration; - return this; - } - - /** - * Get the copyId property: The CopyId property. - * - * @return the copyId value. - */ - public String getCopyId() { - return this.copyId; - } - - /** - * Set the copyId property: The CopyId property. - * - * @param copyId the copyId value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setCopyId(String copyId) { - this.copyId = copyId; - return this; - } - - /** - * Get the copyStatus property: The CopyStatus property. - * - * @return the copyStatus value. - */ - public CopyStatusType getCopyStatus() { - return this.copyStatus; - } - - /** - * Set the copyStatus property: The CopyStatus property. - * - * @param copyStatus the copyStatus value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setCopyStatus(CopyStatusType copyStatus) { - this.copyStatus = copyStatus; - return this; - } - - /** - * Get the copySource property: The CopySource property. - * - * @return the copySource value. - */ - public String getCopySource() { - return this.copySource; - } - - /** - * Set the copySource property: The CopySource property. - * - * @param copySource the copySource value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setCopySource(String copySource) { - this.copySource = copySource; - return this; - } - - /** - * Get the copyProgress property: The CopyProgress property. - * - * @return the copyProgress value. - */ - public String getCopyProgress() { - return this.copyProgress; - } - - /** - * Set the copyProgress property: The CopyProgress property. - * - * @param copyProgress the copyProgress value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setCopyProgress(String copyProgress) { - this.copyProgress = copyProgress; - return this; - } - - /** - * Get the copyCompletionTime property: The CopyCompletionTime property. - * - * @return the copyCompletionTime value. - */ - public OffsetDateTime getCopyCompletionTime() { - if (this.copyCompletionTime == null) { - return null; - } - return this.copyCompletionTime.getDateTime(); - } - - /** - * Set the copyCompletionTime property: The CopyCompletionTime property. - * - * @param copyCompletionTime the copyCompletionTime value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setCopyCompletionTime(OffsetDateTime copyCompletionTime) { - if (copyCompletionTime == null) { - this.copyCompletionTime = null; - } else { - this.copyCompletionTime = new DateTimeRfc1123(copyCompletionTime); - } - return this; - } - - /** - * Get the copyStatusDescription property: The CopyStatusDescription property. - * - * @return the copyStatusDescription value. - */ - public String getCopyStatusDescription() { - return this.copyStatusDescription; - } - - /** - * Set the copyStatusDescription property: The CopyStatusDescription property. - * - * @param copyStatusDescription the copyStatusDescription value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setCopyStatusDescription(String copyStatusDescription) { - this.copyStatusDescription = copyStatusDescription; - return this; - } - - /** - * Get the serverEncrypted property: The ServerEncrypted property. - * - * @return the serverEncrypted value. - */ - public Boolean isServerEncrypted() { - return this.serverEncrypted; - } - - /** - * Set the serverEncrypted property: The ServerEncrypted property. - * - * @param serverEncrypted the serverEncrypted value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setServerEncrypted(Boolean serverEncrypted) { - this.serverEncrypted = serverEncrypted; - return this; - } - - /** - * Get the incrementalCopy property: The IncrementalCopy property. - * - * @return the incrementalCopy value. - */ - public Boolean isIncrementalCopy() { - return this.incrementalCopy; - } - - /** - * Set the incrementalCopy property: The IncrementalCopy property. - * - * @param incrementalCopy the incrementalCopy value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setIncrementalCopy(Boolean incrementalCopy) { - this.incrementalCopy = incrementalCopy; - return this; - } - - /** - * Get the destinationSnapshot property: The DestinationSnapshot property. - * - * @return the destinationSnapshot value. - */ - public String getDestinationSnapshot() { - return this.destinationSnapshot; - } - - /** - * Set the destinationSnapshot property: The DestinationSnapshot property. - * - * @param destinationSnapshot the destinationSnapshot value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setDestinationSnapshot(String destinationSnapshot) { - this.destinationSnapshot = destinationSnapshot; - return this; - } - - /** - * Get the deletedTime property: The DeletedTime property. - * - * @return the deletedTime value. - */ - public OffsetDateTime getDeletedTime() { - if (this.deletedTime == null) { - return null; - } - return this.deletedTime.getDateTime(); - } - - /** - * Set the deletedTime property: The DeletedTime property. - * - * @param deletedTime the deletedTime value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setDeletedTime(OffsetDateTime deletedTime) { - if (deletedTime == null) { - this.deletedTime = null; - } else { - this.deletedTime = new DateTimeRfc1123(deletedTime); - } - return this; - } - - /** - * Get the remainingRetentionDays property: The RemainingRetentionDays property. - * - * @return the remainingRetentionDays value. - */ - public Integer getRemainingRetentionDays() { - return this.remainingRetentionDays; - } - - /** - * Set the remainingRetentionDays property: The RemainingRetentionDays property. - * - * @param remainingRetentionDays the remainingRetentionDays value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setRemainingRetentionDays(Integer remainingRetentionDays) { - this.remainingRetentionDays = remainingRetentionDays; - return this; - } - - /** - * Get the accessTier property: The AccessTier property. - * - * @return the accessTier value. - */ - public AccessTier getAccessTier() { - return this.accessTier; - } - - /** - * Set the accessTier property: The AccessTier property. - * - * @param accessTier the accessTier value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setAccessTier(AccessTier accessTier) { - this.accessTier = accessTier; - return this; - } - - /** - * Get the accessTierInferred property: The AccessTierInferred property. - * - * @return the accessTierInferred value. - */ - public Boolean isAccessTierInferred() { - return this.accessTierInferred; - } - - /** - * Set the accessTierInferred property: The AccessTierInferred property. - * - * @param accessTierInferred the accessTierInferred value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setAccessTierInferred(Boolean accessTierInferred) { - this.accessTierInferred = accessTierInferred; - return this; - } - - /** - * Get the archiveStatus property: The ArchiveStatus property. - * - * @return the archiveStatus value. - */ - public ArchiveStatus getArchiveStatus() { - return this.archiveStatus; - } - - /** - * Set the archiveStatus property: The ArchiveStatus property. - * - * @param archiveStatus the archiveStatus value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setArchiveStatus(ArchiveStatus archiveStatus) { - this.archiveStatus = archiveStatus; - return this; - } - - /** - * Get the customerProvidedKeySha256 property: The CustomerProvidedKeySha256 property. - * - * @return the customerProvidedKeySha256 value. - */ - public String getCustomerProvidedKeySha256() { - return this.customerProvidedKeySha256; - } - - /** - * Set the customerProvidedKeySha256 property: The CustomerProvidedKeySha256 property. - * - * @param customerProvidedKeySha256 the customerProvidedKeySha256 value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setCustomerProvidedKeySha256(String customerProvidedKeySha256) { - this.customerProvidedKeySha256 = customerProvidedKeySha256; - return this; - } - - /** - * Get the encryptionScope property: The name of the encryption scope under which the blob is encrypted. - * - * @return the encryptionScope value. - */ - public String getEncryptionScope() { - return this.encryptionScope; - } - - /** - * Set the encryptionScope property: The name of the encryption scope under which the blob is encrypted. - * - * @param encryptionScope the encryptionScope value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setEncryptionScope(String encryptionScope) { - this.encryptionScope = encryptionScope; - return this; - } - - /** - * Get the accessTierChangeTime property: The AccessTierChangeTime property. - * - * @return the accessTierChangeTime value. - */ - public OffsetDateTime getAccessTierChangeTime() { - if (this.accessTierChangeTime == null) { - return null; - } - return this.accessTierChangeTime.getDateTime(); - } - - /** - * Set the accessTierChangeTime property: The AccessTierChangeTime property. - * - * @param accessTierChangeTime the accessTierChangeTime value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setAccessTierChangeTime(OffsetDateTime accessTierChangeTime) { - if (accessTierChangeTime == null) { - this.accessTierChangeTime = null; - } else { - this.accessTierChangeTime = new DateTimeRfc1123(accessTierChangeTime); - } - return this; - } - - /** - * Get the tagCount property: The TagCount property. - * - * @return the tagCount value. - */ - public Integer getTagCount() { - return this.tagCount; - } - - /** - * Set the tagCount property: The TagCount property. - * - * @param tagCount the tagCount value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setTagCount(Integer tagCount) { - this.tagCount = tagCount; - return this; - } - - /** - * Get the expiresOn property: The Expiry-Time property. - * - * @return the expiresOn value. - */ - public OffsetDateTime getExpiresOn() { - if (this.expiresOn == null) { - return null; - } - return this.expiresOn.getDateTime(); - } - - /** - * Set the expiresOn property: The Expiry-Time property. - * - * @param expiresOn the expiresOn value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setExpiresOn(OffsetDateTime expiresOn) { - if (expiresOn == null) { - this.expiresOn = null; - } else { - this.expiresOn = new DateTimeRfc1123(expiresOn); - } - return this; - } - - /** - * Get the isSealed property: The Sealed property. - * - * @return the isSealed value. - */ - public Boolean isSealed() { - return this.isSealed; - } - - /** - * Set the isSealed property: The Sealed property. - * - * @param isSealed the isSealed value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setIsSealed(Boolean isSealed) { - this.isSealed = isSealed; - return this; - } - - /** - * Get the rehydratePriority property: If an object is in rehydrate pending state then this header is returned with - * priority of rehydrate. Valid values are High and Standard. - * - * @return the rehydratePriority value. - */ - public RehydratePriority getRehydratePriority() { - return this.rehydratePriority; - } - - /** - * Set the rehydratePriority property: If an object is in rehydrate pending state then this header is returned with - * priority of rehydrate. Valid values are High and Standard. - * - * @param rehydratePriority the rehydratePriority value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setRehydratePriority(RehydratePriority rehydratePriority) { - this.rehydratePriority = rehydratePriority; - return this; - } - - /** - * Get the lastAccessedOn property: The LastAccessTime property. - * - * @return the lastAccessedOn value. - */ - public OffsetDateTime getLastAccessedOn() { - if (this.lastAccessedOn == null) { - return null; - } - return this.lastAccessedOn.getDateTime(); - } - - /** - * Set the lastAccessedOn property: The LastAccessTime property. - * - * @param lastAccessedOn the lastAccessedOn value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setLastAccessedOn(OffsetDateTime lastAccessedOn) { - if (lastAccessedOn == null) { - this.lastAccessedOn = null; - } else { - this.lastAccessedOn = new DateTimeRfc1123(lastAccessedOn); - } - return this; - } - - /** - * Get the immutabilityPolicyExpiresOn property: The ImmutabilityPolicyUntilDate property. - * - * @return the immutabilityPolicyExpiresOn value. - */ - public OffsetDateTime getImmutabilityPolicyExpiresOn() { - if (this.immutabilityPolicyExpiresOn == null) { - return null; - } - return this.immutabilityPolicyExpiresOn.getDateTime(); - } - - /** - * Set the immutabilityPolicyExpiresOn property: The ImmutabilityPolicyUntilDate property. - * - * @param immutabilityPolicyExpiresOn the immutabilityPolicyExpiresOn value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setImmutabilityPolicyExpiresOn(OffsetDateTime immutabilityPolicyExpiresOn) { - if (immutabilityPolicyExpiresOn == null) { - this.immutabilityPolicyExpiresOn = null; - } else { - this.immutabilityPolicyExpiresOn = new DateTimeRfc1123(immutabilityPolicyExpiresOn); - } - return this; - } - - /** - * Get the immutabilityPolicyMode property: The ImmutabilityPolicyMode property. - * - * @return the immutabilityPolicyMode value. - */ - public BlobImmutabilityPolicyMode getImmutabilityPolicyMode() { - return this.immutabilityPolicyMode; - } - - /** - * Set the immutabilityPolicyMode property: The ImmutabilityPolicyMode property. - * - * @param immutabilityPolicyMode the immutabilityPolicyMode value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setImmutabilityPolicyMode(BlobImmutabilityPolicyMode immutabilityPolicyMode) { - this.immutabilityPolicyMode = immutabilityPolicyMode; - return this; - } - - /** - * Get the legalHold property: The LegalHold property. - * - * @return the legalHold value. - */ - public Boolean isLegalHold() { - return this.legalHold; - } - - /** - * Set the legalHold property: The LegalHold property. - * - * @param legalHold the legalHold value to set. - * @return the BlobItemPropertiesInternal object itself. - */ - public BlobItemPropertiesInternal setLegalHold(Boolean legalHold) { - this.legalHold = legalHold; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Properties" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Creation-Time", Objects.toString(this.creationTime, null)); - xmlWriter.writeStringElement("Last-Modified", Objects.toString(this.lastModified, null)); - xmlWriter.writeStringElement("Etag", this.eTag); - xmlWriter.writeNumberElement("Content-Length", this.contentLength); - xmlWriter.writeStringElement("Content-Type", this.contentType); - xmlWriter.writeStringElement("Content-Encoding", this.contentEncoding); - xmlWriter.writeStringElement("Content-Language", this.contentLanguage); - xmlWriter.writeBinaryElement("Content-MD5", this.contentMd5); - xmlWriter.writeStringElement("Content-Disposition", this.contentDisposition); - xmlWriter.writeStringElement("Cache-Control", this.cacheControl); - xmlWriter.writeNumberElement("x-ms-blob-sequence-number", this.blobSequenceNumber); - xmlWriter.writeStringElement("BlobType", this.blobType == null ? null : this.blobType.toString()); - xmlWriter.writeStringElement("LeaseStatus", this.leaseStatus == null ? null : this.leaseStatus.toString()); - xmlWriter.writeStringElement("LeaseState", this.leaseState == null ? null : this.leaseState.toString()); - xmlWriter.writeStringElement("LeaseDuration", - this.leaseDuration == null ? null : this.leaseDuration.toString()); - xmlWriter.writeStringElement("CopyId", this.copyId); - xmlWriter.writeStringElement("CopyStatus", this.copyStatus == null ? null : this.copyStatus.toString()); - xmlWriter.writeStringElement("CopySource", this.copySource); - xmlWriter.writeStringElement("CopyProgress", this.copyProgress); - xmlWriter.writeStringElement("CopyCompletionTime", Objects.toString(this.copyCompletionTime, null)); - xmlWriter.writeStringElement("CopyStatusDescription", this.copyStatusDescription); - xmlWriter.writeBooleanElement("ServerEncrypted", this.serverEncrypted); - xmlWriter.writeBooleanElement("IncrementalCopy", this.incrementalCopy); - xmlWriter.writeStringElement("DestinationSnapshot", this.destinationSnapshot); - xmlWriter.writeStringElement("DeletedTime", Objects.toString(this.deletedTime, null)); - xmlWriter.writeNumberElement("RemainingRetentionDays", this.remainingRetentionDays); - xmlWriter.writeStringElement("AccessTier", this.accessTier == null ? null : this.accessTier.toString()); - xmlWriter.writeBooleanElement("AccessTierInferred", this.accessTierInferred); - xmlWriter.writeStringElement("ArchiveStatus", - this.archiveStatus == null ? null : this.archiveStatus.toString()); - xmlWriter.writeStringElement("CustomerProvidedKeySha256", this.customerProvidedKeySha256); - xmlWriter.writeStringElement("EncryptionScope", this.encryptionScope); - xmlWriter.writeStringElement("AccessTierChangeTime", Objects.toString(this.accessTierChangeTime, null)); - xmlWriter.writeNumberElement("TagCount", this.tagCount); - xmlWriter.writeStringElement("Expiry-Time", Objects.toString(this.expiresOn, null)); - xmlWriter.writeBooleanElement("Sealed", this.isSealed); - xmlWriter.writeStringElement("RehydratePriority", - this.rehydratePriority == null ? null : this.rehydratePriority.toString()); - xmlWriter.writeStringElement("LastAccessTime", Objects.toString(this.lastAccessedOn, null)); - xmlWriter.writeStringElement("ImmutabilityPolicyUntilDate", - Objects.toString(this.immutabilityPolicyExpiresOn, null)); - xmlWriter.writeStringElement("ImmutabilityPolicyMode", - this.immutabilityPolicyMode == null ? null : this.immutabilityPolicyMode.toString()); - xmlWriter.writeBooleanElement("LegalHold", this.legalHold); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobItemPropertiesInternal from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobItemPropertiesInternal if the XmlReader was pointing to an instance of it, or null if - * it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobItemPropertiesInternal. - */ - public static BlobItemPropertiesInternal fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobItemPropertiesInternal from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobItemPropertiesInternal if the XmlReader was pointing to an instance of it, or null if - * it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobItemPropertiesInternal. - */ - public static BlobItemPropertiesInternal fromXml(XmlReader xmlReader, String rootElementName) - throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Properties" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobItemPropertiesInternal deserializedBlobItemPropertiesInternal = new BlobItemPropertiesInternal(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Creation-Time".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.creationTime - = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("Last-Modified".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.lastModified - = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("Etag".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.eTag = reader.getStringElement(); - } else if ("Content-Length".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.contentLength = reader.getNullableElement(Long::parseLong); - } else if ("Content-Type".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.contentType = reader.getStringElement(); - } else if ("Content-Encoding".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.contentEncoding = reader.getStringElement(); - } else if ("Content-Language".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.contentLanguage = reader.getStringElement(); - } else if ("Content-MD5".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.contentMd5 = reader.getBinaryElement(); - } else if ("Content-Disposition".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.contentDisposition = reader.getStringElement(); - } else if ("Cache-Control".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.cacheControl = reader.getStringElement(); - } else if ("x-ms-blob-sequence-number".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.blobSequenceNumber - = reader.getNullableElement(Long::parseLong); - } else if ("BlobType".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.blobType = BlobType.fromString(reader.getStringElement()); - } else if ("LeaseStatus".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.leaseStatus - = LeaseStatusType.fromString(reader.getStringElement()); - } else if ("LeaseState".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.leaseState - = LeaseStateType.fromString(reader.getStringElement()); - } else if ("LeaseDuration".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.leaseDuration - = LeaseDurationType.fromString(reader.getStringElement()); - } else if ("CopyId".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.copyId = reader.getStringElement(); - } else if ("CopyStatus".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.copyStatus - = CopyStatusType.fromString(reader.getStringElement()); - } else if ("CopySource".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.copySource = reader.getStringElement(); - } else if ("CopyProgress".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.copyProgress = reader.getStringElement(); - } else if ("CopyCompletionTime".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.copyCompletionTime - = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("CopyStatusDescription".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.copyStatusDescription = reader.getStringElement(); - } else if ("ServerEncrypted".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.serverEncrypted - = reader.getNullableElement(Boolean::parseBoolean); - } else if ("IncrementalCopy".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.incrementalCopy - = reader.getNullableElement(Boolean::parseBoolean); - } else if ("DestinationSnapshot".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.destinationSnapshot = reader.getStringElement(); - } else if ("DeletedTime".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.deletedTime - = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("RemainingRetentionDays".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.remainingRetentionDays - = reader.getNullableElement(Integer::parseInt); - } else if ("AccessTier".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.accessTier - = AccessTier.fromString(reader.getStringElement()); - } else if ("AccessTierInferred".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.accessTierInferred - = reader.getNullableElement(Boolean::parseBoolean); - } else if ("ArchiveStatus".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.archiveStatus - = ArchiveStatus.fromString(reader.getStringElement()); - } else if ("CustomerProvidedKeySha256".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.customerProvidedKeySha256 = reader.getStringElement(); - } else if ("EncryptionScope".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.encryptionScope = reader.getStringElement(); - } else if ("AccessTierChangeTime".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.accessTierChangeTime - = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("TagCount".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.tagCount = reader.getNullableElement(Integer::parseInt); - } else if ("Expiry-Time".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.expiresOn = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("Sealed".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.isSealed = reader.getNullableElement(Boolean::parseBoolean); - } else if ("RehydratePriority".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.rehydratePriority - = RehydratePriority.fromString(reader.getStringElement()); - } else if ("LastAccessTime".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.lastAccessedOn - = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("ImmutabilityPolicyUntilDate".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.immutabilityPolicyExpiresOn - = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("ImmutabilityPolicyMode".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.immutabilityPolicyMode - = BlobImmutabilityPolicyMode.fromString(reader.getStringElement()); - } else if ("LegalHold".equals(elementName.getLocalPart())) { - deserializedBlobItemPropertiesInternal.legalHold = reader.getNullableElement(Boolean::parseBoolean); - } else { - reader.skipElement(); - } - } - - return deserializedBlobItemPropertiesInternal; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobName.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobName.java deleted file mode 100644 index 7cba83c20c81..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobName.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlWriter; -import javax.xml.stream.XMLStreamException; - -/** - * The BlobName model. - */ -@Fluent -public final class BlobName implements XmlSerializable { - /* - * Indicates if the blob name is encoded. - */ - private Boolean encoded; - - /* - * The name of the blob. - */ - private String content; - - /** - * Creates an instance of BlobName class. - */ - public BlobName() { - } - - /** - * Get the encoded property: Indicates if the blob name is encoded. - * - * @return the encoded value. - */ - public Boolean isEncoded() { - return this.encoded; - } - - /** - * Set the encoded property: Indicates if the blob name is encoded. - * - * @param encoded the encoded value to set. - * @return the BlobName object itself. - */ - public BlobName setEncoded(Boolean encoded) { - this.encoded = encoded; - return this; - } - - /** - * Get the content property: The name of the blob. - * - * @return the content value. - */ - public String getContent() { - return this.content; - } - - /** - * Set the content property: The name of the blob. - * - * @param content the content value to set. - * @return the BlobName object itself. - */ - public BlobName setContent(String content) { - this.content = content; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobName" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeBooleanAttribute("Encoded", this.encoded); - xmlWriter.writeString(this.content); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobName from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobName if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the BlobName. - */ - public static BlobName fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobName from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobName if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the BlobName. - */ - public static BlobName fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobName" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobName deserializedBlobName = new BlobName(); - deserializedBlobName.encoded = reader.getNullableAttribute(null, "Encoded", Boolean::parseBoolean); - deserializedBlobName.content = reader.getStringElement(); - - return deserializedBlobName; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPrefixInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPrefixInternal.java deleted file mode 100644 index b0bc992b8929..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPrefixInternal.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * The BlobPrefixInternal model. - */ -@Fluent -public final class BlobPrefixInternal implements XmlSerializable { - /* - * The Name property. - */ - private BlobName name; - - /** - * Creates an instance of BlobPrefixInternal class. - */ - public BlobPrefixInternal() { - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - public BlobName getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the BlobPrefixInternal object itself. - */ - public BlobPrefixInternal setName(BlobName name) { - this.name = name; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobPrefix" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.name, "Name"); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobPrefixInternal from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobPrefixInternal if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobPrefixInternal. - */ - public static BlobPrefixInternal fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobPrefixInternal from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobPrefixInternal if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobPrefixInternal. - */ - public static BlobPrefixInternal fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobPrefix" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobPrefixInternal deserializedBlobPrefixInternal = new BlobPrefixInternal(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedBlobPrefixInternal.name = BlobName.fromXml(reader, "Name"); - } else { - reader.skipElement(); - } - } - - return deserializedBlobPrefixInternal; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternal.java deleted file mode 100644 index fc7de467ffc7..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternal.java +++ /dev/null @@ -1,266 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.models; - -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.ArchiveStatus; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import com.azure.storage.blob.models.ObjectReplicationPolicy; -import com.azure.storage.blob.models.RehydratePriority; - -import java.time.OffsetDateTime; -import java.util.List; -import java.util.Map; - -/** - * Internal interface that represents the getter methods for {@link BlobProperties}. - *

- * This interface exists to resolve the problem of the ever-growing constructor argument list as {@link BlobProperties} - * has new properties added to the class. With this each unique API that returns {@link BlobProperties} but with a - * different set of properties will implement this interface and manage which getter APIs it implements based on the - * information available to it. With this interface {@link BlobProperties} should no longer be required to add a new - * constructor every time a new property is added, instead this interface should add a new default getter and each - * implementation of this interface should override it if it contains that property. - */ -public interface BlobPropertiesInternal { - /** - * @return the time when the blob was created - */ - OffsetDateTime getCreationTime(); - - /** - * @return the time when the blob was last modified - */ - OffsetDateTime getLastModified(); - - /** - * @return the eTag of the blob - */ - String getETag(); - - /** - * @return the size of the blob in bytes - */ - long getBlobSize(); - - /** - * @return the content type of the blob - */ - String getContentType(); - - /** - * @return the MD5 of the blob's content - */ - byte[] getContentMd5(); - - /** - * @return the content encoding of the blob - */ - String getContentEncoding(); - - /** - * @return the content disposition of the blob - */ - String getContentDisposition(); - - /** - * @return the content language of the blob - */ - String getContentLanguage(); - - /** - * @return the cache control of the blob - */ - String getCacheControl(); - - /** - * @return the current sequence number of the page blob. This is only returned for page blobs. - */ - Long getBlobSequenceNumber(); - - /** - * @return the type of the blob - */ - BlobType getBlobType(); - - /** - * @return the lease status of the blob - */ - LeaseStatusType getLeaseStatus(); - - /** - * @return the lease state of the blob - */ - LeaseStateType getLeaseState(); - - /** - * @return the lease duration if the blob is leased - */ - LeaseDurationType getLeaseDuration(); - - /** - * @return the identifier of the last copy operation. If this blob hasn't been the target of a copy operation or has - * been modified since this won't be set. - */ - String getCopyId(); - - /** - * @return the status of the last copy operation. If this blob hasn't been the target of a copy operation or has - * been modified since this won't be set. - */ - CopyStatusType getCopyStatus(); - - /** - * @return the source blob URL from the last copy operation. If this blob hasn't been the target of a copy operation - * or has been modified since this won't be set. - */ - String getCopySource(); - - /** - * @return the number of bytes copied and total bytes in the source from the last copy operation (bytes copied/total - * bytes). If this blob hasn't been the target of a copy operation or has been modified since this won't be set. - */ - String getCopyProgress(); - - /** - * @return the completion time of the last copy operation. If this blob hasn't been the target of a copy operation - * or has been modified since this won't be set. - */ - OffsetDateTime getCopyCompletionTime(); - - /** - * @return the description of the last copy failure, this is set when the {@link #getCopyStatus() getCopyStatus} is - * {@link CopyStatusType#FAILED failed} or {@link CopyStatusType#ABORTED aborted}. If this blob hasn't been the - * target of a copy operation or has been modified since this won't be set. - */ - String getCopyStatusDescription(); - - /** - * @return the status of the blob being encrypted on the server - */ - Boolean isServerEncrypted(); - - /** - * @return the status of the blob being an incremental copy blob - */ - Boolean isIncrementalCopy(); - - /** - * @return the snapshot time of the last successful incremental copy snapshot for this blob. If this blob isn't an - * incremental copy blob or incremental copy snapshot or {@link #getCopyStatus() getCopyStatus} isn't {@link - * CopyStatusType#SUCCESS success} this won't be set. - */ - String getCopyDestinationSnapshot(); - - /** - * @return the tier of the blob. This is only set for Page blobs on a premium storage account or for Block blobs on - * blob storage or general purpose V2 account. - */ - AccessTier getAccessTier(); - - /** - * @return the status of the tier being inferred for the blob. This is only set for Page blobs on a premium storage - * account or for Block blobs on blob storage or general purpose V2 account. - */ - Boolean isAccessTierInferred(); - - /** - * @return the archive status of the blob. This is only for blobs on a blob storage and general purpose v2 account. - */ - ArchiveStatus getArchiveStatus(); - - /** - * @return the key used to encrypt the blob - */ - String getEncryptionKeySha256(); - - /** - * @return The name of the encryption scope under which the blob is encrypted. - */ - String getEncryptionScope(); - - /** - * @return the time when the access tier for the blob was last changed - */ - OffsetDateTime getAccessTierChangeTime(); - - /** - * @return the metadata associated with this blob - */ - Map getMetadata(); - - /** - * @return the number of committed blocks in the blob. This is only returned for Append blobs. - */ - Integer getCommittedBlockCount(); - - /** - * @return The number of tags associated with the blob. - */ - Long getTagCount(); - - /** - * @return the version identifier the blob. - */ - String getVersionId(); - - /** - * @return the flag indicating whether version identifier points to current version of the blob. - */ - Boolean isCurrentVersion(); - - /** - * @return a {@link List} that contains information on the object replication policies associated with this blob and - * the status of the replication for each policy. Only available when the blob is the source of object replication. - */ - List getObjectReplicationSourcePolicies(); - - /** - * @return a {@code String} that identifies the Object Replication Policy which made this blob the destination of a - * copy. - */ - String getObjectReplicationDestinationPolicyId(); - - /** - * @return The {@link RehydratePriority} of the blob if it is in RehydratePending state. - */ - RehydratePriority getRehydratePriority(); - - /** - * @return the flag indicating whether this blob has been sealed (marked as read only). This is only returned for - * Append blobs. - */ - Boolean isSealed(); - - /** - * @return The date and time the blob was read or written to. - */ - OffsetDateTime getLastAccessedTime(); - - /** - * @return the time when the blob is going to expire. - */ - OffsetDateTime getExpiresOn(); - - /** - * @return the immutability policy. - */ - BlobImmutabilityPolicy getImmutabilityPolicy(); - - /** - * @return whether the blob has a legal hold. - */ - Boolean hasLegalHold(); - - /** - * @return the x-ms-request-id header value that uniquely identifies the request made against the storage service. - */ - String getRequestId(); -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalConstructorProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalConstructorProperties.java deleted file mode 100644 index 4e00fc508d14..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalConstructorProperties.java +++ /dev/null @@ -1,516 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.ArchiveStatus; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import com.azure.storage.blob.models.ObjectReplicationPolicy; -import com.azure.storage.blob.models.RehydratePriority; - -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Implementation of {@link BlobPropertiesInternal} that represents the last constructor overload of - * {@link BlobProperties}. - */ -public final class BlobPropertiesInternalConstructorProperties implements BlobPropertiesInternal { - private final OffsetDateTime creationTime; - private final OffsetDateTime lastModified; - private final String eTag; - private final long blobSize; - private final String contentType; - private final byte[] contentMd5; - private final String contentEncoding; - private final String contentDisposition; - private final String contentLanguage; - private final String cacheControl; - private final Long blobSequenceNumber; - private final BlobType blobType; - private final LeaseStatusType leaseStatus; - private final LeaseStateType leaseState; - private final LeaseDurationType leaseDuration; - private final String copyId; - private final CopyStatusType copyStatus; - private final String copySource; - private final String copyProgress; - private final OffsetDateTime copyCompletionTime; - private final String copyStatusDescription; - private final Boolean isServerEncrypted; - private final Boolean isIncrementalCopy; - private final String copyDestinationSnapshot; - private final AccessTier accessTier; - private final Boolean isAccessTierInferred; - private final ArchiveStatus archiveStatus; - private final String encryptionKeySha256; - private final String encryptionScope; - private final OffsetDateTime accessTierChangeTime; - private final Map metadata; - private final Integer committedBlockCount; - private final Long tagCount; - private final String versionId; - private final Boolean isCurrentVersion; - private final List objectReplicationSourcePolicies; - private final String objectReplicationDestinationPolicyId; - private final RehydratePriority rehydratePriority; - private final Boolean isSealed; - private final OffsetDateTime lastAccessedTime; - private final OffsetDateTime expiresOn; - private final BlobImmutabilityPolicy immutabilityPolicy; - private final Boolean hasLegalHold; - private final String requestId; - - /** - * Constructs a {@link BlobPropertiesInternalConstructorProperties}. - * - * @param creationTime Creation time of the blob. - * @param lastModified Datetime when the blob was last modified. - * @param eTag ETag of the blob. - * @param blobSize Size of the blob. - * @param contentType Content type specified for the blob. - * @param contentMd5 Content MD5 specified for the blob. - * @param contentEncoding Content encoding specified for the blob. - * @param contentDisposition Content disposition specified for the blob. - * @param contentLanguage Content language specified for the blob. - * @param cacheControl Cache control specified for the blob. - * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob - * pass {@code null}. - * @param blobType Type of the blob. - * @param leaseStatus Status of the lease on the blob. - * @param leaseState State of the lease on the blob. - * @param leaseDuration Type of lease on the blob. - * @param copyId Identifier of the last copy operation performed on the blob. - * @param copyStatus Status of the last copy operation performed on the blob. - * @param copySource Source of the last copy operation performed on the blob. - * @param copyProgress Progress of the last copy operation performed on the blob. - * @param copyCompletionTime Datetime when the last copy operation on the blob completed. - * @param copyStatusDescription Description of the last copy operation on the blob. - * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. - * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. - * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. - * @param accessTier Access tier of the blob. - * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the - * blob. - * @param archiveStatus Archive status of the blob. - * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the server. - * @param encryptionScope The name of the encryption scope under which the blob is encrypted. - * @param accessTierChangeTime Datetime when the access tier of the blob last changed. - * @param metadata Metadata associated with the blob. - * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob - * pass {@code null}. - * @param versionId The version identifier of the blob. - * @param isCurrentVersion Flag indicating if version identifier points to current version of the blob. - * @param tagCount Number of tags associated with the blob. - * @param objectReplicationSourcePolicies The already parsed object replication policies. - * @param objectReplicationDestinationPolicyId The policy id on the destination blob. - * @param rehydratePriority The rehydrate priority - * @param isSealed Whether the blob is sealed. - * @param lastAccessedTime The date and time the blob was read or written to. - * @param expiresOn The time when the blob is going to expire. - * @param immutabilityPolicy the immutability policy of the blob. - * @param hasLegalHold whether the blob has a legal hold. - */ - public BlobPropertiesInternalConstructorProperties(final OffsetDateTime creationTime, - final OffsetDateTime lastModified, final String eTag, final long blobSize, final String contentType, - final byte[] contentMd5, final String contentEncoding, final String contentDisposition, - final String contentLanguage, final String cacheControl, final Long blobSequenceNumber, final BlobType blobType, - final LeaseStatusType leaseStatus, final LeaseStateType leaseState, final LeaseDurationType leaseDuration, - final String copyId, final CopyStatusType copyStatus, final String copySource, final String copyProgress, - final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, - final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, - final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, - final String encryptionScope, final OffsetDateTime accessTierChangeTime, final Map metadata, - final Integer committedBlockCount, final Long tagCount, final String versionId, final Boolean isCurrentVersion, - final List objectReplicationSourcePolicies, - final String objectReplicationDestinationPolicyId, final RehydratePriority rehydratePriority, - final Boolean isSealed, final OffsetDateTime lastAccessedTime, final OffsetDateTime expiresOn, - final BlobImmutabilityPolicy immutabilityPolicy, final Boolean hasLegalHold) { - this.creationTime = creationTime; - this.lastModified = lastModified; - this.eTag = eTag; - this.blobSize = blobSize; - this.contentType = contentType; - this.contentMd5 = CoreUtils.clone(contentMd5); - this.contentEncoding = contentEncoding; - this.contentDisposition = contentDisposition; - this.contentLanguage = contentLanguage; - this.cacheControl = cacheControl; - this.blobSequenceNumber = blobSequenceNumber; - this.blobType = blobType; - this.leaseStatus = leaseStatus; - this.leaseState = leaseState; - this.leaseDuration = leaseDuration; - this.copyId = copyId; - this.copyStatus = copyStatus; - this.copySource = copySource; - this.copyProgress = copyProgress; - this.copyCompletionTime = copyCompletionTime; - this.copyStatusDescription = copyStatusDescription; - this.isServerEncrypted = isServerEncrypted; - this.isIncrementalCopy = isIncrementalCopy; - this.copyDestinationSnapshot = copyDestinationSnapshot; - this.accessTier = accessTier; - this.isAccessTierInferred = isAccessTierInferred; - this.archiveStatus = archiveStatus; - this.encryptionKeySha256 = encryptionKeySha256; - this.encryptionScope = encryptionScope; - this.accessTierChangeTime = accessTierChangeTime; - this.metadata = metadata; - this.committedBlockCount = committedBlockCount; - this.tagCount = tagCount; - this.versionId = versionId; - this.isCurrentVersion = isCurrentVersion; - this.objectReplicationSourcePolicies = objectReplicationSourcePolicies; - this.objectReplicationDestinationPolicyId = objectReplicationDestinationPolicyId; - this.rehydratePriority = rehydratePriority; - this.isSealed = isSealed; - this.lastAccessedTime = lastAccessedTime; - this.expiresOn = expiresOn; - this.immutabilityPolicy = immutabilityPolicy; - this.hasLegalHold = hasLegalHold; - this.requestId = null; - } - - /** - * Constructs a {@link BlobPropertiesInternalConstructorProperties}. - * - * @param creationTime Creation time of the blob. - * @param lastModified Datetime when the blob was last modified. - * @param eTag ETag of the blob. - * @param blobSize Size of the blob. - * @param contentType Content type specified for the blob. - * @param contentMd5 Content MD5 specified for the blob. - * @param contentEncoding Content encoding specified for the blob. - * @param contentDisposition Content disposition specified for the blob. - * @param contentLanguage Content language specified for the blob. - * @param cacheControl Cache control specified for the blob. - * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob - * pass {@code null}. - * @param blobType Type of the blob. - * @param leaseStatus Status of the lease on the blob. - * @param leaseState State of the lease on the blob. - * @param leaseDuration Type of lease on the blob. - * @param copyId Identifier of the last copy operation performed on the blob. - * @param copyStatus Status of the last copy operation performed on the blob. - * @param copySource Source of the last copy operation performed on the blob. - * @param copyProgress Progress of the last copy operation performed on the blob. - * @param copyCompletionTime Datetime when the last copy operation on the blob completed. - * @param copyStatusDescription Description of the last copy operation on the blob. - * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. - * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. - * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. - * @param accessTier Access tier of the blob. - * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the - * blob. - * @param archiveStatus Archive status of the blob. - * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the server. - * @param encryptionScope The name of the encryption scope under which the blob is encrypted. - * @param accessTierChangeTime Datetime when the access tier of the blob last changed. - * @param metadata Metadata associated with the blob. - * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob - * pass {@code null}. - * @param versionId The version identifier of the blob. - * @param isCurrentVersion Flag indicating if version identifier points to current version of the blob. - * @param tagCount Number of tags associated with the blob. - * @param objectReplicationSourcePolicies The already parsed object replication policies. - * @param objectReplicationDestinationPolicyId The policy id on the destination blob. - * @param rehydratePriority The rehydrate priority - * @param isSealed Whether the blob is sealed. - * @param lastAccessedTime The date and time the blob was read or written to. - * @param expiresOn The time when the blob is going to expire. - * @param immutabilityPolicy the immutability policy of the blob. - * @param hasLegalHold whether the blob has a legal hold. - * @param requestId The request id. - */ - public BlobPropertiesInternalConstructorProperties(final OffsetDateTime creationTime, - final OffsetDateTime lastModified, final String eTag, final long blobSize, final String contentType, - final byte[] contentMd5, final String contentEncoding, final String contentDisposition, - final String contentLanguage, final String cacheControl, final Long blobSequenceNumber, final BlobType blobType, - final LeaseStatusType leaseStatus, final LeaseStateType leaseState, final LeaseDurationType leaseDuration, - final String copyId, final CopyStatusType copyStatus, final String copySource, final String copyProgress, - final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, - final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, - final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, - final String encryptionScope, final OffsetDateTime accessTierChangeTime, final Map metadata, - final Integer committedBlockCount, final Long tagCount, final String versionId, final Boolean isCurrentVersion, - final List objectReplicationSourcePolicies, - final String objectReplicationDestinationPolicyId, final RehydratePriority rehydratePriority, - final Boolean isSealed, final OffsetDateTime lastAccessedTime, final OffsetDateTime expiresOn, - final BlobImmutabilityPolicy immutabilityPolicy, final Boolean hasLegalHold, final String requestId) { - this.creationTime = creationTime; - this.lastModified = lastModified; - this.eTag = eTag; - this.blobSize = blobSize; - this.contentType = contentType; - this.contentMd5 = CoreUtils.clone(contentMd5); - this.contentEncoding = contentEncoding; - this.contentDisposition = contentDisposition; - this.contentLanguage = contentLanguage; - this.cacheControl = cacheControl; - this.blobSequenceNumber = blobSequenceNumber; - this.blobType = blobType; - this.leaseStatus = leaseStatus; - this.leaseState = leaseState; - this.leaseDuration = leaseDuration; - this.copyId = copyId; - this.copyStatus = copyStatus; - this.copySource = copySource; - this.copyProgress = copyProgress; - this.copyCompletionTime = copyCompletionTime; - this.copyStatusDescription = copyStatusDescription; - this.isServerEncrypted = isServerEncrypted; - this.isIncrementalCopy = isIncrementalCopy; - this.copyDestinationSnapshot = copyDestinationSnapshot; - this.accessTier = accessTier; - this.isAccessTierInferred = isAccessTierInferred; - this.archiveStatus = archiveStatus; - this.encryptionKeySha256 = encryptionKeySha256; - this.encryptionScope = encryptionScope; - this.accessTierChangeTime = accessTierChangeTime; - this.metadata = metadata; - this.committedBlockCount = committedBlockCount; - this.tagCount = tagCount; - this.versionId = versionId; - this.isCurrentVersion = isCurrentVersion; - this.objectReplicationSourcePolicies = objectReplicationSourcePolicies; - this.objectReplicationDestinationPolicyId = objectReplicationDestinationPolicyId; - this.rehydratePriority = rehydratePriority; - this.isSealed = isSealed; - this.lastAccessedTime = lastAccessedTime; - this.expiresOn = expiresOn; - this.immutabilityPolicy = immutabilityPolicy; - this.hasLegalHold = hasLegalHold; - this.requestId = requestId; - } - - @Override - public OffsetDateTime getCreationTime() { - return creationTime; - } - - @Override - public OffsetDateTime getLastModified() { - return lastModified; - } - - @Override - public String getETag() { - return eTag; - } - - @Override - public long getBlobSize() { - return blobSize; - } - - @Override - public String getContentType() { - return contentType; - } - - @Override - public byte[] getContentMd5() { - return CoreUtils.clone(contentMd5); - } - - @Override - public String getContentEncoding() { - return contentEncoding; - } - - @Override - public String getContentDisposition() { - return contentDisposition; - } - - @Override - public String getContentLanguage() { - return contentLanguage; - } - - @Override - public String getCacheControl() { - return cacheControl; - } - - @Override - public Long getBlobSequenceNumber() { - return blobSequenceNumber; - } - - @Override - public BlobType getBlobType() { - return blobType; - } - - @Override - public LeaseStatusType getLeaseStatus() { - return leaseStatus; - } - - @Override - public LeaseStateType getLeaseState() { - return leaseState; - } - - @Override - public LeaseDurationType getLeaseDuration() { - return leaseDuration; - } - - @Override - public String getCopyId() { - return copyId; - } - - @Override - public CopyStatusType getCopyStatus() { - return copyStatus; - } - - @Override - public String getCopySource() { - return copySource; - } - - @Override - public String getCopyProgress() { - return copyProgress; - } - - @Override - public OffsetDateTime getCopyCompletionTime() { - return copyCompletionTime; - } - - @Override - public String getCopyStatusDescription() { - return copyStatusDescription; - } - - @Override - public Boolean isServerEncrypted() { - return isServerEncrypted; - } - - @Override - public Boolean isIncrementalCopy() { - return isIncrementalCopy; - } - - @Override - public String getCopyDestinationSnapshot() { - return copyDestinationSnapshot; - } - - @Override - public AccessTier getAccessTier() { - return accessTier; - } - - @Override - public Boolean isAccessTierInferred() { - return isAccessTierInferred; - } - - @Override - public ArchiveStatus getArchiveStatus() { - return archiveStatus; - } - - @Override - public String getEncryptionKeySha256() { - return encryptionKeySha256; - } - - @Override - public String getEncryptionScope() { - return encryptionScope; - } - - @Override - public OffsetDateTime getAccessTierChangeTime() { - return accessTierChangeTime; - } - - @Override - public Map getMetadata() { - return metadata; - } - - @Override - public Integer getCommittedBlockCount() { - return committedBlockCount; - } - - @Override - public Long getTagCount() { - return tagCount; - } - - @Override - public String getVersionId() { - return versionId; - } - - @Override - public Boolean isCurrentVersion() { - return isCurrentVersion; - } - - @Override - public List getObjectReplicationSourcePolicies() { - return Collections.unmodifiableList(this.objectReplicationSourcePolicies); - } - - @Override - public String getObjectReplicationDestinationPolicyId() { - return this.objectReplicationDestinationPolicyId; - } - - @Override - public RehydratePriority getRehydratePriority() { - return this.rehydratePriority; - } - - @Override - public Boolean isSealed() { - return isSealed; - } - - @Override - public OffsetDateTime getLastAccessedTime() { - return lastAccessedTime; - } - - @Override - public OffsetDateTime getExpiresOn() { - return expiresOn; - } - - @Override - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return immutabilityPolicy; - } - - @Override - public Boolean hasLegalHold() { - return hasLegalHold; - } - - @Override - public String getRequestId() { - return requestId; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalDownload.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalDownload.java deleted file mode 100644 index ca1a582220ba..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalDownload.java +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.models; - -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.ArchiveStatus; -import com.azure.storage.blob.models.BlobDownloadHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import com.azure.storage.blob.models.ObjectReplicationPolicy; -import com.azure.storage.blob.models.RehydratePriority; - -import java.time.OffsetDateTime; -import java.util.List; -import java.util.Map; - -/** - * Implementation of {@link BlobPropertiesInternal} that represents the download {@link BlobProperties}. - */ -public final class BlobPropertiesInternalDownload implements BlobPropertiesInternal { - private final BlobDownloadHeaders headers; - - /** - * Creates an instance of {@link BlobPropertiesInternalDownload}. - * - * @param headers The download headers. - */ - public BlobPropertiesInternalDownload(BlobDownloadHeaders headers) { - this.headers = headers; - } - - @Override - public OffsetDateTime getCreationTime() { - return headers.getCreationTime(); - } - - @Override - public OffsetDateTime getLastModified() { - return headers.getLastModified(); - } - - @Override - public String getETag() { - return headers.getETag(); - } - - @Override - public long getBlobSize() { - return ModelHelper.getBlobLength(headers); - } - - @Override - public String getContentType() { - return headers.getContentType(); - } - - @Override - public byte[] getContentMd5() { - return headers.getContentMd5(); - } - - @Override - public String getContentEncoding() { - return headers.getContentEncoding(); - } - - @Override - public String getContentDisposition() { - return headers.getContentDisposition(); - } - - @Override - public String getContentLanguage() { - return headers.getContentLanguage(); - } - - @Override - public String getCacheControl() { - return headers.getCacheControl(); - } - - @Override - public Long getBlobSequenceNumber() { - return headers.getBlobSequenceNumber(); - } - - @Override - public BlobType getBlobType() { - return headers.getBlobType(); - } - - @Override - public LeaseStatusType getLeaseStatus() { - return headers.getLeaseStatus(); - } - - @Override - public LeaseStateType getLeaseState() { - return headers.getLeaseState(); - } - - @Override - public LeaseDurationType getLeaseDuration() { - return headers.getLeaseDuration(); - } - - @Override - public String getCopyId() { - return headers.getCopyId(); - } - - @Override - public CopyStatusType getCopyStatus() { - return headers.getCopyStatus(); - } - - @Override - public String getCopySource() { - return headers.getCopySource(); - } - - @Override - public String getCopyProgress() { - return headers.getCopyProgress(); - } - - @Override - public OffsetDateTime getCopyCompletionTime() { - return headers.getCopyCompletionTime(); - } - - @Override - public String getCopyStatusDescription() { - return headers.getCopyStatusDescription(); - } - - @Override - public Boolean isServerEncrypted() { - return headers.isServerEncrypted(); - } - - @Override - public Boolean isIncrementalCopy() { - return null; - } - - @Override - public String getCopyDestinationSnapshot() { - return null; - } - - @Override - public AccessTier getAccessTier() { - return null; - } - - @Override - public Boolean isAccessTierInferred() { - return null; - } - - @Override - public ArchiveStatus getArchiveStatus() { - return null; - } - - @Override - public String getEncryptionKeySha256() { - return headers.getEncryptionKeySha256(); - } - - @Override - public String getEncryptionScope() { - return headers.getEncryptionScope(); - } - - @Override - public OffsetDateTime getAccessTierChangeTime() { - return null; - } - - @Override - public Map getMetadata() { - return headers.getMetadata(); - } - - @Override - public Integer getCommittedBlockCount() { - return headers.getBlobCommittedBlockCount(); - } - - @Override - public Long getTagCount() { - return headers.getTagCount(); - } - - @Override - public String getVersionId() { - return headers.getVersionId(); - } - - @Override - public Boolean isCurrentVersion() { - return headers.isCurrentVersion(); - } - - @Override - public List getObjectReplicationSourcePolicies() { - return headers.getObjectReplicationSourcePolicies(); - } - - @Override - public String getObjectReplicationDestinationPolicyId() { - return headers.getObjectReplicationDestinationPolicyId(); - } - - @Override - public RehydratePriority getRehydratePriority() { - return null; - } - - @Override - public Boolean isSealed() { - return headers.isSealed(); - } - - @Override - public OffsetDateTime getLastAccessedTime() { - return headers.getLastAccessedTime(); - } - - @Override - public OffsetDateTime getExpiresOn() { - return null; - } - - @Override - public BlobImmutabilityPolicy getImmutabilityPolicy() { - // This could be cached but the returned object is mutable. - return headers.getImmutabilityPolicy(); - } - - @Override - public Boolean hasLegalHold() { - return headers.hasLegalHold(); - } - - @Override - public String getRequestId() { - return headers.getRequestId(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalGetProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalGetProperties.java deleted file mode 100644 index f4de3908d17d..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobPropertiesInternalGetProperties.java +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.models; - -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.ArchiveStatus; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import com.azure.storage.blob.models.ObjectReplicationPolicy; -import com.azure.storage.blob.models.RehydratePriority; - -import java.time.OffsetDateTime; -import java.util.List; -import java.util.Map; - -/** - * Implementation of {@link BlobPropertiesInternal} that represents the get properties {@link BlobProperties}. - */ -public final class BlobPropertiesInternalGetProperties implements BlobPropertiesInternal { - private final BlobsGetPropertiesHeaders headers; - - /** - * Creates an instance of {@link BlobPropertiesInternalGetProperties}. - * - * @param headers The get properties headers. - */ - public BlobPropertiesInternalGetProperties(BlobsGetPropertiesHeaders headers) { - this.headers = headers; - } - - @Override - public OffsetDateTime getCreationTime() { - return headers.getXMsCreationTime(); - } - - @Override - public OffsetDateTime getLastModified() { - return headers.getLastModified(); - } - - @Override - public String getETag() { - return headers.getETag(); - } - - @Override - public long getBlobSize() { - return headers.getContentLength() == null ? 0 : headers.getContentLength(); - } - - @Override - public String getContentType() { - return headers.getContentType(); - } - - @Override - public byte[] getContentMd5() { - return headers.getContentMD5(); - } - - @Override - public String getContentEncoding() { - return headers.getContentEncoding(); - } - - @Override - public String getContentDisposition() { - return headers.getContentDisposition(); - } - - @Override - public String getContentLanguage() { - return headers.getContentLanguage(); - } - - @Override - public String getCacheControl() { - return headers.getCacheControl(); - } - - @Override - public Long getBlobSequenceNumber() { - return headers.getXMsBlobSequenceNumber(); - } - - @Override - public BlobType getBlobType() { - return headers.getXMsBlobType(); - } - - @Override - public LeaseStatusType getLeaseStatus() { - return headers.getXMsLeaseStatus(); - } - - @Override - public LeaseStateType getLeaseState() { - return headers.getXMsLeaseState(); - } - - @Override - public LeaseDurationType getLeaseDuration() { - return headers.getXMsLeaseDuration(); - } - - @Override - public String getCopyId() { - return headers.getXMsCopyId(); - } - - @Override - public CopyStatusType getCopyStatus() { - return headers.getXMsCopyStatus(); - } - - @Override - public String getCopySource() { - return headers.getXMsCopySource(); - } - - @Override - public String getCopyProgress() { - return headers.getXMsCopyProgress(); - } - - @Override - public OffsetDateTime getCopyCompletionTime() { - return headers.getXMsCopyCompletionTime(); - } - - @Override - public String getCopyStatusDescription() { - return headers.getXMsCopyStatusDescription(); - } - - @Override - public Boolean isServerEncrypted() { - return headers.isXMsServerEncrypted(); - } - - @Override - public Boolean isIncrementalCopy() { - return headers.isXMsIncrementalCopy(); - } - - @Override - public String getCopyDestinationSnapshot() { - return headers.getXMsCopyDestinationSnapshot(); - } - - @Override - public AccessTier getAccessTier() { - return AccessTier.fromString(headers.getXMsAccessTier()); - } - - @Override - public Boolean isAccessTierInferred() { - return headers.isXMsAccessTierInferred(); - } - - @Override - public ArchiveStatus getArchiveStatus() { - return ArchiveStatus.fromString(headers.getXMsArchiveStatus()); - } - - @Override - public String getEncryptionKeySha256() { - return headers.getXMsEncryptionKeySha256(); - } - - @Override - public String getEncryptionScope() { - return headers.getXMsEncryptionScope(); - } - - @Override - public OffsetDateTime getAccessTierChangeTime() { - return headers.getXMsAccessTierChangeTime(); - } - - @Override - public Map getMetadata() { - return headers.getXMsMeta(); - } - - @Override - public Integer getCommittedBlockCount() { - return headers.getXMsBlobCommittedBlockCount(); - } - - @Override - public Long getTagCount() { - return headers.getXMsTagCount(); - } - - @Override - public String getVersionId() { - return headers.getXMsVersionId(); - } - - @Override - public Boolean isCurrentVersion() { - return headers.isXMsIsCurrentVersion(); - } - - @Override - public List getObjectReplicationSourcePolicies() { - return ModelHelper.getObjectReplicationSourcePolicies(headers.getXMsOr()); - } - - @Override - public String getObjectReplicationDestinationPolicyId() { - return ModelHelper.getObjectReplicationDestinationPolicyId(headers.getXMsOr()); - } - - @Override - public RehydratePriority getRehydratePriority() { - return RehydratePriority.fromString(headers.getXMsRehydratePriority()); - } - - @Override - public Boolean isSealed() { - return headers.isXMsBlobSealed(); - } - - @Override - public OffsetDateTime getLastAccessedTime() { - return headers.getXMsLastAccessTime(); - } - - @Override - public OffsetDateTime getExpiresOn() { - return headers.getXMsExpiryTime(); - } - - @Override - public BlobImmutabilityPolicy getImmutabilityPolicy() { - // This could be cached but the returned object is mutable. - return new BlobImmutabilityPolicy().setExpiryTime(headers.getXMsImmutabilityPolicyUntilDate()) - .setPolicyMode(headers.getXMsImmutabilityPolicyMode()); - } - - @Override - public Boolean hasLegalHold() { - return headers.isXMsLegalHold(); - } - - @Override - public String getRequestId() { - return headers.getXMsRequestId(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobSignedIdentifierWrapper.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobSignedIdentifierWrapper.java deleted file mode 100644 index eb3913b0715b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobSignedIdentifierWrapper.java +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; -import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * A wrapper around List<BlobSignedIdentifier> which provides top-level metadata for serialization. - */ -public final class BlobSignedIdentifierWrapper implements XmlSerializable { - private final List signedIdentifiers; - - /** - * Creates an instance of BlobSignedIdentifierWrapper. - * - * @param signedIdentifiers the list. - */ - public BlobSignedIdentifierWrapper(List signedIdentifiers) { - this.signedIdentifiers = signedIdentifiers; - } - - /** - * Get the List<BlobSignedIdentifier> contained in this wrapper. - * - * @return the List<BlobSignedIdentifier>. - */ - public List items() { - return signedIdentifiers; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "SignedIdentifiers" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (signedIdentifiers != null) { - for (BlobSignedIdentifier element : signedIdentifiers) { - xmlWriter.writeXml(element, "SignedIdentifier"); - } - } - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobSignedIdentifierWrapper from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobSignedIdentifierWrapper if the XmlReader was pointing to an instance of it, or null if - * it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobSignedIdentifierWrapper. - */ - public static BlobSignedIdentifierWrapper fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobSignedIdentifierWrapper from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobSignedIdentifierWrapper if the XmlReader was pointing to an instance of it, or null if - * it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobSignedIdentifierWrapper. - */ - public static BlobSignedIdentifierWrapper fromXml(XmlReader xmlReader, String rootElementName) - throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "SignedIdentifiers" : rootElementName; - return xmlReader.readObject(rootElementName, reader -> { - List items = null; - - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("SignedIdentifier".equals(elementName.getLocalPart())) { - if (items == null) { - items = new ArrayList<>(); - } - - items.add(BlobSignedIdentifier.fromXml(reader)); - } else { - reader.nextElement(); - } - } - return new BlobSignedIdentifierWrapper(items); - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobStorageError.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobStorageError.java deleted file mode 100644 index 9ae705adf845..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobStorageError.java +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.implementation.models; - -import com.azure.core.util.CoreUtils; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import java.io.IOException; - -/** - * Represents an error response returned by the Azure Storage Blob service. - */ -public final class BlobStorageError implements JsonSerializable, XmlSerializable { - private String code; - private String message; - private String queryParameterName; - private String queryParameterValue; - private String reason; - private String extendedErrorDetail; - - private BlobStorageError() { - } - - /** - * Gets the error code returned by the Azure Storage Blob service. - * - * @return The error code. - */ - public String getCode() { - return code; - } - - /** - * Gets the error message returned by the Azure Storage Blob service. - * - * @return The error message. - */ - public String getMessage() { - return message; - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return jsonWriter.writeStartObject("Error") - .writeStringField("Code", code) - .writeStringField("Message", this.message) - .writeStringField("QueryParameterName", this.queryParameterName) - .writeStringField("QueryParameterValue", this.queryParameterValue) - .writeStringField("Reason", this.reason) - .writeStringField("ExtendedErrorDetail", this.extendedErrorDetail) - .writeEndObject(); - } - - /** - * Reads an instance of BlobStorageError from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of BlobStorageError if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the BlobStorageError. - */ - public static BlobStorageError fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - // Buffer the next JSON object as BlobStorageError can take two forms: - // - // - A BlobStorageError object - // - A BlobStorageError object wrapped in an "error" node. - JsonReader bufferedReader = reader.bufferObject(); - bufferedReader.nextToken(); // Get to the START_OBJECT token. - while (bufferedReader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = bufferedReader.getFieldName(); - bufferedReader.nextToken(); - - if ("error".equals(fieldName)) { - // If the BlobStorageError was wrapped in the "error" node begin reading it now. - return readBlobError(bufferedReader); - } else { - bufferedReader.skipChildren(); - } - } - - // Otherwise reset the JsonReader and read the whole JSON object. - return readBlobError(bufferedReader.reset()); - }); - } - - private static BlobStorageError readBlobError(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - BlobStorageError deserializedStorageError = new BlobStorageError(); - - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("code".equals(fieldName)) { - deserializedStorageError.code = reader.getString(); - } else if ("message".equals(fieldName)) { - deserializedStorageError.message = reader.getString(); - } else if ("queryParameterName".equals(fieldName)) { - deserializedStorageError.queryParameterName = reader.getString(); - } else if ("queryParameterValue".equals(fieldName)) { - deserializedStorageError.queryParameterValue = reader.getString(); - } else if ("reason".equals(fieldName)) { - deserializedStorageError.reason = reader.getString(); - } else if ("extendedErrorDetail".equals(fieldName)) { - deserializedStorageError.extendedErrorDetail = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedStorageError; - }); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Error" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Code", code); - xmlWriter.writeStringElement("Message", this.message); - xmlWriter.writeStringElement("QueryParameterName", this.queryParameterName); - xmlWriter.writeStringElement("QueryParameterValue", this.queryParameterValue); - xmlWriter.writeStringElement("Reason", this.reason); - xmlWriter.writeStringElement("ExtendedErrorDetail", this.extendedErrorDetail); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobStorageError from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobStorageError if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobStorageError. - */ - public static BlobStorageError fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobStorageError from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobStorageError if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobStorageError. - */ - public static BlobStorageError fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Error" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobStorageError deserializedStorageError = new BlobStorageError(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Code".equals(elementName.getLocalPart())) { - deserializedStorageError.code = reader.getStringElement(); - } else if ("Message".equals(elementName.getLocalPart())) { - deserializedStorageError.message = reader.getStringElement(); - } else if ("QueryParameterName".equals(elementName.getLocalPart())) { - deserializedStorageError.queryParameterName = reader.getStringElement(); - } else if ("QueryParameterValue".equals(elementName.getLocalPart())) { - deserializedStorageError.queryParameterValue = reader.getStringElement(); - } else if ("Reason".equals(elementName.getLocalPart())) { - deserializedStorageError.reason = reader.getStringElement(); - } else if ("ExtendedErrorDetail".equals(elementName.getLocalPart())) { - deserializedStorageError.extendedErrorDetail = reader.getStringElement(); - } - } - - return deserializedStorageError; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobStorageExceptionInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobStorageExceptionInternal.java deleted file mode 100644 index 2b9f9081930b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobStorageExceptionInternal.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.implementation.models; - -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpResponse; -import com.azure.storage.common.implementation.StorageImplUtils; - -/** - * A {@code BlobStorageException} is thrown whenever Azure Storage successfully returns an error code that is not - * 200-level. Users can inspect the status code and error code to determine the cause of the error response. The - * exception message may also contain more detailed information depending on the type of error. The user may also - * inspect the raw HTTP response or call toString to get the full payload of the error response if present. Note that - * even some expected "errors" will be thrown as a {@code BlobStorageException}. For example, some users may perform a - * getProperties request on an entity to determine whether it exists or not. If it does not exists, an exception will be - * thrown even though this may be considered an expected indication of absence in this case. - * - *

Sample Code

- *

For more samples, please see the sample - * file

- */ -public final class BlobStorageExceptionInternal extends HttpResponseException { - /** - * Constructs a {@code BlobStorageException}. - * - * @param message the exception message or the response content if a message is not available. - * @param response the HTTP response. - * @param value the deserialized error response. - */ - public BlobStorageExceptionInternal(String message, HttpResponse response, BlobStorageError value) { - super(StorageImplUtils.convertStorageExceptionMessage(message, response), response, value); - } - - @Override - public BlobStorageError getValue() { - return (BlobStorageError) super.getValue(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobTag.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobTag.java deleted file mode 100644 index 766957f6bf55..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobTag.java +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * The BlobTag model. - */ -@Fluent -public final class BlobTag implements XmlSerializable { - /* - * The Key property. - */ - private String key; - - /* - * The Value property. - */ - private String value; - - /** - * Creates an instance of BlobTag class. - */ - public BlobTag() { - } - - /** - * Get the key property: The Key property. - * - * @return the key value. - */ - public String getKey() { - return this.key; - } - - /** - * Set the key property: The Key property. - * - * @param key the key value to set. - * @return the BlobTag object itself. - */ - public BlobTag setKey(String key) { - this.key = key; - return this; - } - - /** - * Get the value property: The Value property. - * - * @return the value value. - */ - public String getValue() { - return this.value; - } - - /** - * Set the value property: The Value property. - * - * @param value the value value to set. - * @return the BlobTag object itself. - */ - public BlobTag setValue(String value) { - this.value = value; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Tag" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Key", this.key); - xmlWriter.writeStringElement("Value", this.value); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobTag from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobTag if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the BlobTag. - */ - public static BlobTag fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobTag from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobTag if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the BlobTag. - */ - public static BlobTag fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Tag" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobTag deserializedBlobTag = new BlobTag(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Key".equals(elementName.getLocalPart())) { - deserializedBlobTag.key = reader.getStringElement(); - } else if ("Value".equals(elementName.getLocalPart())) { - deserializedBlobTag.value = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedBlobTag; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobTags.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobTags.java deleted file mode 100644 index c76b6ad7577c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobTags.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; -import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Blob tags. - */ -@Fluent -public final class BlobTags implements XmlSerializable { - /* - * The BlobTagSet property. - */ - private List blobTagSet; - - /** - * Creates an instance of BlobTags class. - */ - public BlobTags() { - } - - /** - * Get the blobTagSet property: The BlobTagSet property. - * - * @return the blobTagSet value. - */ - public List getBlobTagSet() { - if (this.blobTagSet == null) { - this.blobTagSet = new ArrayList<>(); - } - return this.blobTagSet; - } - - /** - * Set the blobTagSet property: The BlobTagSet property. - * - * @param blobTagSet the blobTagSet value to set. - * @return the BlobTags object itself. - */ - public BlobTags setBlobTagSet(List blobTagSet) { - this.blobTagSet = blobTagSet; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Tags" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (this.blobTagSet != null) { - xmlWriter.writeStartElement("TagSet"); - for (BlobTag element : this.blobTagSet) { - xmlWriter.writeXml(element, "Tag"); - } - xmlWriter.writeEndElement(); - } - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobTags from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobTags if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the BlobTags. - */ - public static BlobTags fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobTags from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobTags if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the BlobTags. - */ - public static BlobTags fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Tags" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobTags deserializedBlobTags = new BlobTags(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("TagSet".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - elementName = reader.getElementName(); - if ("Tag".equals(elementName.getLocalPart())) { - if (deserializedBlobTags.blobTagSet == null) { - deserializedBlobTags.blobTagSet = new ArrayList<>(); - } - deserializedBlobTags.blobTagSet.add(BlobTag.fromXml(reader, "Tag")); - } else { - reader.skipElement(); - } - } - } else { - reader.skipElement(); - } - } - - return deserializedBlobTags; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsAbortCopyFromURLHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsAbortCopyFromURLHeaders.java deleted file mode 100644 index e8cf0fef635e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsAbortCopyFromURLHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsAbortCopyFromURLHeaders model. - */ -@Fluent -public final class BlobsAbortCopyFromURLHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsAbortCopyFromURLHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsAbortCopyFromURLHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsAbortCopyFromURLHeaders object itself. - */ - public BlobsAbortCopyFromURLHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsAbortCopyFromURLHeaders object itself. - */ - public BlobsAbortCopyFromURLHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsAbortCopyFromURLHeaders object itself. - */ - public BlobsAbortCopyFromURLHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsAbortCopyFromURLHeaders object itself. - */ - public BlobsAbortCopyFromURLHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsAcquireLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsAcquireLeaseHeaders.java deleted file mode 100644 index 0f1959c9b572..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsAcquireLeaseHeaders.java +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsAcquireLeaseHeaders model. - */ -@Fluent -public final class BlobsAcquireLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-lease-id property. - */ - private String xMsLeaseId; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_LEASE_ID = HttpHeaderName.fromString("x-ms-lease-id"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsAcquireLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsAcquireLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.xMsLeaseId = rawHeaders.getValue(X_MS_LEASE_ID); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsAcquireLeaseHeaders object itself. - */ - public BlobsAcquireLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsAcquireLeaseHeaders object itself. - */ - public BlobsAcquireLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsLeaseId property: The x-ms-lease-id property. - * - * @return the xMsLeaseId value. - */ - public String getXMsLeaseId() { - return this.xMsLeaseId; - } - - /** - * Set the xMsLeaseId property: The x-ms-lease-id property. - * - * @param xMsLeaseId the xMsLeaseId value to set. - * @return the BlobsAcquireLeaseHeaders object itself. - */ - public BlobsAcquireLeaseHeaders setXMsLeaseId(String xMsLeaseId) { - this.xMsLeaseId = xMsLeaseId; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsAcquireLeaseHeaders object itself. - */ - public BlobsAcquireLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsAcquireLeaseHeaders object itself. - */ - public BlobsAcquireLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsAcquireLeaseHeaders object itself. - */ - public BlobsAcquireLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsAcquireLeaseHeaders object itself. - */ - public BlobsAcquireLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsBreakLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsBreakLeaseHeaders.java deleted file mode 100644 index 3fe87c9ac0aa..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsBreakLeaseHeaders.java +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsBreakLeaseHeaders model. - */ -@Fluent -public final class BlobsBreakLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-lease-time property. - */ - private Integer xMsLeaseTime; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_LEASE_TIME = HttpHeaderName.fromString("x-ms-lease-time"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsBreakLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsBreakLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsLeaseTime = rawHeaders.getValue(X_MS_LEASE_TIME); - if (xMsLeaseTime != null) { - this.xMsLeaseTime = Integer.parseInt(xMsLeaseTime); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsBreakLeaseHeaders object itself. - */ - public BlobsBreakLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsBreakLeaseHeaders object itself. - */ - public BlobsBreakLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsLeaseTime property: The x-ms-lease-time property. - * - * @return the xMsLeaseTime value. - */ - public Integer getXMsLeaseTime() { - return this.xMsLeaseTime; - } - - /** - * Set the xMsLeaseTime property: The x-ms-lease-time property. - * - * @param xMsLeaseTime the xMsLeaseTime value to set. - * @return the BlobsBreakLeaseHeaders object itself. - */ - public BlobsBreakLeaseHeaders setXMsLeaseTime(Integer xMsLeaseTime) { - this.xMsLeaseTime = xMsLeaseTime; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsBreakLeaseHeaders object itself. - */ - public BlobsBreakLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsBreakLeaseHeaders object itself. - */ - public BlobsBreakLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsBreakLeaseHeaders object itself. - */ - public BlobsBreakLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsBreakLeaseHeaders object itself. - */ - public BlobsBreakLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsChangeLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsChangeLeaseHeaders.java deleted file mode 100644 index 4ffc02052757..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsChangeLeaseHeaders.java +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsChangeLeaseHeaders model. - */ -@Fluent -public final class BlobsChangeLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-lease-id property. - */ - private String xMsLeaseId; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_LEASE_ID = HttpHeaderName.fromString("x-ms-lease-id"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsChangeLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsChangeLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.xMsLeaseId = rawHeaders.getValue(X_MS_LEASE_ID); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsChangeLeaseHeaders object itself. - */ - public BlobsChangeLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsChangeLeaseHeaders object itself. - */ - public BlobsChangeLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsLeaseId property: The x-ms-lease-id property. - * - * @return the xMsLeaseId value. - */ - public String getXMsLeaseId() { - return this.xMsLeaseId; - } - - /** - * Set the xMsLeaseId property: The x-ms-lease-id property. - * - * @param xMsLeaseId the xMsLeaseId value to set. - * @return the BlobsChangeLeaseHeaders object itself. - */ - public BlobsChangeLeaseHeaders setXMsLeaseId(String xMsLeaseId) { - this.xMsLeaseId = xMsLeaseId; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsChangeLeaseHeaders object itself. - */ - public BlobsChangeLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsChangeLeaseHeaders object itself. - */ - public BlobsChangeLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsChangeLeaseHeaders object itself. - */ - public BlobsChangeLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsChangeLeaseHeaders object itself. - */ - public BlobsChangeLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsCopyFromURLHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsCopyFromURLHeaders.java deleted file mode 100644 index 822a4004a755..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsCopyFromURLHeaders.java +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The BlobsCopyFromURLHeaders model. - */ -@Fluent -public final class BlobsCopyFromURLHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-copy-id property. - */ - private String xMsCopyId; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-copy-status property. - */ - private String xMsCopyStatus = "success"; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsCopyFromURLHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsCopyFromURLHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsCopyId = rawHeaders.getValue(X_MS_COPY_ID); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsCopyStatus = rawHeaders.getValue(X_MS_COPY_STATUS); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsCopyId property: The x-ms-copy-id property. - * - * @return the xMsCopyId value. - */ - public String getXMsCopyId() { - return this.xMsCopyId; - } - - /** - * Set the xMsCopyId property: The x-ms-copy-id property. - * - * @param xMsCopyId the xMsCopyId value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setXMsCopyId(String xMsCopyId) { - this.xMsCopyId = xMsCopyId; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsCopyStatus property: The x-ms-copy-status property. - * - * @return the xMsCopyStatus value. - */ - public String getXMsCopyStatus() { - return this.xMsCopyStatus; - } - - /** - * Set the xMsCopyStatus property: The x-ms-copy-status property. - * - * @param xMsCopyStatus the xMsCopyStatus value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setXMsCopyStatus(String xMsCopyStatus) { - this.xMsCopyStatus = xMsCopyStatus; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlobsCopyFromURLHeaders object itself. - */ - public BlobsCopyFromURLHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsCreateSnapshotHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsCreateSnapshotHeaders.java deleted file mode 100644 index 8292c86cb40c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsCreateSnapshotHeaders.java +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsCreateSnapshotHeaders model. - */ -@Fluent -public final class BlobsCreateSnapshotHeaders { - /* - * The x-ms-snapshot property. - */ - private String xMsSnapshot; - - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_SNAPSHOT = HttpHeaderName.fromString("x-ms-snapshot"); - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsCreateSnapshotHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsCreateSnapshotHeaders(HttpHeaders rawHeaders) { - this.xMsSnapshot = rawHeaders.getValue(X_MS_SNAPSHOT); - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsSnapshot property: The x-ms-snapshot property. - * - * @return the xMsSnapshot value. - */ - public String getXMsSnapshot() { - return this.xMsSnapshot; - } - - /** - * Set the xMsSnapshot property: The x-ms-snapshot property. - * - * @param xMsSnapshot the xMsSnapshot value to set. - * @return the BlobsCreateSnapshotHeaders object itself. - */ - public BlobsCreateSnapshotHeaders setXMsSnapshot(String xMsSnapshot) { - this.xMsSnapshot = xMsSnapshot; - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsCreateSnapshotHeaders object itself. - */ - public BlobsCreateSnapshotHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsCreateSnapshotHeaders object itself. - */ - public BlobsCreateSnapshotHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsCreateSnapshotHeaders object itself. - */ - public BlobsCreateSnapshotHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the BlobsCreateSnapshotHeaders object itself. - */ - public BlobsCreateSnapshotHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsCreateSnapshotHeaders object itself. - */ - public BlobsCreateSnapshotHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the BlobsCreateSnapshotHeaders object itself. - */ - public BlobsCreateSnapshotHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsCreateSnapshotHeaders object itself. - */ - public BlobsCreateSnapshotHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsCreateSnapshotHeaders object itself. - */ - public BlobsCreateSnapshotHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDeleteHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDeleteHeaders.java deleted file mode 100644 index 87bc9f477bb0..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDeleteHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsDeleteHeaders model. - */ -@Fluent -public final class BlobsDeleteHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsDeleteHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsDeleteHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsDeleteHeaders object itself. - */ - public BlobsDeleteHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsDeleteHeaders object itself. - */ - public BlobsDeleteHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsDeleteHeaders object itself. - */ - public BlobsDeleteHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsDeleteHeaders object itself. - */ - public BlobsDeleteHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDeleteImmutabilityPolicyHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDeleteImmutabilityPolicyHeaders.java deleted file mode 100644 index 9a88ef2453e5..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDeleteImmutabilityPolicyHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsDeleteImmutabilityPolicyHeaders model. - */ -@Fluent -public final class BlobsDeleteImmutabilityPolicyHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsDeleteImmutabilityPolicyHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsDeleteImmutabilityPolicyHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsDeleteImmutabilityPolicyHeaders object itself. - */ - public BlobsDeleteImmutabilityPolicyHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsDeleteImmutabilityPolicyHeaders object itself. - */ - public BlobsDeleteImmutabilityPolicyHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsDeleteImmutabilityPolicyHeaders object itself. - */ - public BlobsDeleteImmutabilityPolicyHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsDeleteImmutabilityPolicyHeaders object itself. - */ - public BlobsDeleteImmutabilityPolicyHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDownloadHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDownloadHeaders.java deleted file mode 100644 index 62a866f505bf..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDownloadHeaders.java +++ /dev/null @@ -1,1425 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeader; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import java.time.OffsetDateTime; -import java.util.Base64; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * The BlobsDownloadHeaders model. - */ -@Fluent -public final class BlobsDownloadHeaders { - /* - * The x-ms-is-current-version property. - */ - private Boolean xMsIsCurrentVersion; - - /* - * The x-ms-lease-status property. - */ - private LeaseStatusType xMsLeaseStatus; - - /* - * The x-ms-tag-count property. - */ - private Long xMsTagCount; - - /* - * The Content-Range property. - */ - private String contentRange; - - /* - * The x-ms-lease-state property. - */ - private LeaseStateType xMsLeaseState; - - /* - * The x-ms-blob-sealed property. - */ - private Boolean xMsBlobSealed; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-structured-body property. - */ - private String xMsStructuredBody; - - /* - * The x-ms-blob-type property. - */ - private BlobType xMsBlobType; - - /* - * The x-ms-immutability-policy-mode property. - */ - private String xMsImmutabilityPolicyMode; - - /* - * The x-ms-structured-content-length property. - */ - private Long xMsStructuredContentLength; - - /* - * The Content-Encoding property. - */ - private String contentEncoding; - - /* - * The x-ms-copy-status-description property. - */ - private String xMsCopyStatusDescription; - - /* - * The x-ms-creation-time property. - */ - private DateTimeRfc1123 xMsCreationTime; - - /* - * The x-ms-lease-duration property. - */ - private LeaseDurationType xMsLeaseDuration; - - /* - * The Content-Length property. - */ - private Long contentLength; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The Content-Type property. - */ - private String contentType; - - /* - * The x-ms-last-access-time property. - */ - private DateTimeRfc1123 xMsLastAccessTime; - - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-copy-id property. - */ - private String xMsCopyId; - - /* - * The x-ms-copy-source property. - */ - private String xMsCopySource; - - /* - * The x-ms-immutability-policy-until-date property. - */ - private DateTimeRfc1123 xMsImmutabilityPolicyUntilDate; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long xMsBlobSequenceNumber; - - /* - * The x-ms-copy-progress property. - */ - private String xMsCopyProgress; - - /* - * The x-ms-blob-committed-block-count property. - */ - private Integer xMsBlobCommittedBlockCount; - - /* - * The x-ms-blob-content-md5 property. - */ - private byte[] xMsBlobContentMd5; - - /* - * The x-ms-meta- property. - */ - private Map xMsMeta; - - /* - * The x-ms-legal-hold property. - */ - private Boolean xMsLegalHold; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-copy-completion-time property. - */ - private DateTimeRfc1123 xMsCopyCompletionTime; - - /* - * The Accept-Ranges property. - */ - private String acceptRanges; - - /* - * The x-ms-server-encrypted property. - */ - private Boolean xMsServerEncrypted; - - /* - * The x-ms-or-policy-id property. - */ - private String xMsOrPolicyId; - - /* - * The Cache-Control property. - */ - private String cacheControl; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Content-Disposition property. - */ - private String contentDisposition; - - /* - * The x-ms-copy-status property. - */ - private CopyStatusType xMsCopyStatus; - - /* - * The Content-Language property. - */ - private String contentLanguage; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The x-ms-or- property. - */ - private Map xMsOr; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_IS_CURRENT_VERSION = HttpHeaderName.fromString("x-ms-is-current-version"); - - private static final HttpHeaderName X_MS_LEASE_STATUS = HttpHeaderName.fromString("x-ms-lease-status"); - - private static final HttpHeaderName X_MS_TAG_COUNT = HttpHeaderName.fromString("x-ms-tag-count"); - - private static final HttpHeaderName X_MS_LEASE_STATE = HttpHeaderName.fromString("x-ms-lease-state"); - - private static final HttpHeaderName X_MS_BLOB_SEALED = HttpHeaderName.fromString("x-ms-blob-sealed"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_STRUCTURED_BODY = HttpHeaderName.fromString("x-ms-structured-body"); - - private static final HttpHeaderName X_MS_BLOB_TYPE = HttpHeaderName.fromString("x-ms-blob-type"); - - private static final HttpHeaderName X_MS_IMMUTABILITY_POLICY_MODE - = HttpHeaderName.fromString("x-ms-immutability-policy-mode"); - - private static final HttpHeaderName X_MS_STRUCTURED_CONTENT_LENGTH - = HttpHeaderName.fromString("x-ms-structured-content-length"); - - private static final HttpHeaderName X_MS_COPY_STATUS_DESCRIPTION - = HttpHeaderName.fromString("x-ms-copy-status-description"); - - private static final HttpHeaderName X_MS_CREATION_TIME = HttpHeaderName.fromString("x-ms-creation-time"); - - private static final HttpHeaderName X_MS_LEASE_DURATION = HttpHeaderName.fromString("x-ms-lease-duration"); - - private static final HttpHeaderName X_MS_LAST_ACCESS_TIME = HttpHeaderName.fromString("x-ms-last-access-time"); - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); - - private static final HttpHeaderName X_MS_COPY_SOURCE = HttpHeaderName.fromString("x-ms-copy-source"); - - private static final HttpHeaderName X_MS_IMMUTABILITY_POLICY_UNTIL_DATE - = HttpHeaderName.fromString("x-ms-immutability-policy-until-date"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_BLOB_SEQUENCE_NUMBER - = HttpHeaderName.fromString("x-ms-blob-sequence-number"); - - private static final HttpHeaderName X_MS_COPY_PROGRESS = HttpHeaderName.fromString("x-ms-copy-progress"); - - private static final HttpHeaderName X_MS_BLOB_COMMITTED_BLOCK_COUNT - = HttpHeaderName.fromString("x-ms-blob-committed-block-count"); - - private static final HttpHeaderName X_MS_BLOB_CONTENT_MD5 = HttpHeaderName.fromString("x-ms-blob-content-md5"); - - private static final HttpHeaderName X_MS_LEGAL_HOLD = HttpHeaderName.fromString("x-ms-legal-hold"); - - private static final HttpHeaderName X_MS_COPY_COMPLETION_TIME - = HttpHeaderName.fromString("x-ms-copy-completion-time"); - - private static final HttpHeaderName X_MS_SERVER_ENCRYPTED = HttpHeaderName.fromString("x-ms-server-encrypted"); - - private static final HttpHeaderName X_MS_OR_POLICY_ID = HttpHeaderName.fromString("x-ms-or-policy-id"); - - private static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsDownloadHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsDownloadHeaders(HttpHeaders rawHeaders) { - String xMsIsCurrentVersion = rawHeaders.getValue(X_MS_IS_CURRENT_VERSION); - if (xMsIsCurrentVersion != null) { - this.xMsIsCurrentVersion = Boolean.parseBoolean(xMsIsCurrentVersion); - } - String xMsLeaseStatus = rawHeaders.getValue(X_MS_LEASE_STATUS); - if (xMsLeaseStatus != null) { - this.xMsLeaseStatus = LeaseStatusType.fromString(xMsLeaseStatus); - } - String xMsTagCount = rawHeaders.getValue(X_MS_TAG_COUNT); - if (xMsTagCount != null) { - this.xMsTagCount = Long.parseLong(xMsTagCount); - } - this.contentRange = rawHeaders.getValue(HttpHeaderName.CONTENT_RANGE); - String xMsLeaseState = rawHeaders.getValue(X_MS_LEASE_STATE); - if (xMsLeaseState != null) { - this.xMsLeaseState = LeaseStateType.fromString(xMsLeaseState); - } - String xMsBlobSealed = rawHeaders.getValue(X_MS_BLOB_SEALED); - if (xMsBlobSealed != null) { - this.xMsBlobSealed = Boolean.parseBoolean(xMsBlobSealed); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsStructuredBody = rawHeaders.getValue(X_MS_STRUCTURED_BODY); - String xMsBlobType = rawHeaders.getValue(X_MS_BLOB_TYPE); - if (xMsBlobType != null) { - this.xMsBlobType = BlobType.fromString(xMsBlobType); - } - this.xMsImmutabilityPolicyMode = rawHeaders.getValue(X_MS_IMMUTABILITY_POLICY_MODE); - String xMsStructuredContentLength = rawHeaders.getValue(X_MS_STRUCTURED_CONTENT_LENGTH); - if (xMsStructuredContentLength != null) { - this.xMsStructuredContentLength = Long.parseLong(xMsStructuredContentLength); - } - this.contentEncoding = rawHeaders.getValue(HttpHeaderName.CONTENT_ENCODING); - this.xMsCopyStatusDescription = rawHeaders.getValue(X_MS_COPY_STATUS_DESCRIPTION); - String xMsCreationTime = rawHeaders.getValue(X_MS_CREATION_TIME); - if (xMsCreationTime != null) { - this.xMsCreationTime = new DateTimeRfc1123(xMsCreationTime); - } - String xMsLeaseDuration = rawHeaders.getValue(X_MS_LEASE_DURATION); - if (xMsLeaseDuration != null) { - this.xMsLeaseDuration = LeaseDurationType.fromString(xMsLeaseDuration); - } - String contentLength = rawHeaders.getValue(HttpHeaderName.CONTENT_LENGTH); - if (contentLength != null) { - this.contentLength = Long.parseLong(contentLength); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); - String xMsLastAccessTime = rawHeaders.getValue(X_MS_LAST_ACCESS_TIME); - if (xMsLastAccessTime != null) { - this.xMsLastAccessTime = new DateTimeRfc1123(xMsLastAccessTime); - } - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsCopyId = rawHeaders.getValue(X_MS_COPY_ID); - this.xMsCopySource = rawHeaders.getValue(X_MS_COPY_SOURCE); - String xMsImmutabilityPolicyUntilDate = rawHeaders.getValue(X_MS_IMMUTABILITY_POLICY_UNTIL_DATE); - if (xMsImmutabilityPolicyUntilDate != null) { - this.xMsImmutabilityPolicyUntilDate = new DateTimeRfc1123(xMsImmutabilityPolicyUntilDate); - } - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - String xMsBlobSequenceNumber = rawHeaders.getValue(X_MS_BLOB_SEQUENCE_NUMBER); - if (xMsBlobSequenceNumber != null) { - this.xMsBlobSequenceNumber = Long.parseLong(xMsBlobSequenceNumber); - } - this.xMsCopyProgress = rawHeaders.getValue(X_MS_COPY_PROGRESS); - String xMsBlobCommittedBlockCount = rawHeaders.getValue(X_MS_BLOB_COMMITTED_BLOCK_COUNT); - if (xMsBlobCommittedBlockCount != null) { - this.xMsBlobCommittedBlockCount = Integer.parseInt(xMsBlobCommittedBlockCount); - } - String xMsBlobContentMd5 = rawHeaders.getValue(X_MS_BLOB_CONTENT_MD5); - if (xMsBlobContentMd5 != null) { - this.xMsBlobContentMd5 = Base64.getDecoder().decode(xMsBlobContentMd5); - } - String xMsLegalHold = rawHeaders.getValue(X_MS_LEGAL_HOLD); - if (xMsLegalHold != null) { - this.xMsLegalHold = Boolean.parseBoolean(xMsLegalHold); - } - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - String xMsCopyCompletionTime = rawHeaders.getValue(X_MS_COPY_COMPLETION_TIME); - if (xMsCopyCompletionTime != null) { - this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); - } - this.acceptRanges = rawHeaders.getValue(HttpHeaderName.ACCEPT_RANGES); - String xMsServerEncrypted = rawHeaders.getValue(X_MS_SERVER_ENCRYPTED); - if (xMsServerEncrypted != null) { - this.xMsServerEncrypted = Boolean.parseBoolean(xMsServerEncrypted); - } - this.xMsOrPolicyId = rawHeaders.getValue(X_MS_OR_POLICY_ID); - this.cacheControl = rawHeaders.getValue(HttpHeaderName.CACHE_CONTROL); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.contentDisposition = rawHeaders.getValue(HttpHeaderName.CONTENT_DISPOSITION); - String xMsCopyStatus = rawHeaders.getValue(X_MS_COPY_STATUS); - if (xMsCopyStatus != null) { - this.xMsCopyStatus = CopyStatusType.fromString(xMsCopyStatus); - } - this.contentLanguage = rawHeaders.getValue(HttpHeaderName.CONTENT_LANGUAGE); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - Map xMsMetaHeaderCollection = new LinkedHashMap<>(); - Map xMsOrHeaderCollection = new LinkedHashMap<>(); - - for (HttpHeader header : rawHeaders) { - String headerName = header.getName(); - if (headerName.startsWith("x-ms-meta-")) { - xMsMetaHeaderCollection.put(headerName.substring(10), header.getValue()); - continue; - } - if (headerName.startsWith("x-ms-or-")) { - xMsOrHeaderCollection.put(headerName.substring(8), header.getValue()); - } - } - - this.xMsMeta = xMsMetaHeaderCollection; - this.xMsOr = xMsOrHeaderCollection; - } - - /** - * Get the xMsIsCurrentVersion property: The x-ms-is-current-version property. - * - * @return the xMsIsCurrentVersion value. - */ - public Boolean isXMsIsCurrentVersion() { - return this.xMsIsCurrentVersion; - } - - /** - * Set the xMsIsCurrentVersion property: The x-ms-is-current-version property. - * - * @param xMsIsCurrentVersion the xMsIsCurrentVersion value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsIsCurrentVersion(Boolean xMsIsCurrentVersion) { - this.xMsIsCurrentVersion = xMsIsCurrentVersion; - return this; - } - - /** - * Get the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @return the xMsLeaseStatus value. - */ - public LeaseStatusType getXMsLeaseStatus() { - return this.xMsLeaseStatus; - } - - /** - * Set the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @param xMsLeaseStatus the xMsLeaseStatus value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsLeaseStatus(LeaseStatusType xMsLeaseStatus) { - this.xMsLeaseStatus = xMsLeaseStatus; - return this; - } - - /** - * Get the xMsTagCount property: The x-ms-tag-count property. - * - * @return the xMsTagCount value. - */ - public Long getXMsTagCount() { - return this.xMsTagCount; - } - - /** - * Set the xMsTagCount property: The x-ms-tag-count property. - * - * @param xMsTagCount the xMsTagCount value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsTagCount(Long xMsTagCount) { - this.xMsTagCount = xMsTagCount; - return this; - } - - /** - * Get the contentRange property: The Content-Range property. - * - * @return the contentRange value. - */ - public String getContentRange() { - return this.contentRange; - } - - /** - * Set the contentRange property: The Content-Range property. - * - * @param contentRange the contentRange value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setContentRange(String contentRange) { - this.contentRange = contentRange; - return this; - } - - /** - * Get the xMsLeaseState property: The x-ms-lease-state property. - * - * @return the xMsLeaseState value. - */ - public LeaseStateType getXMsLeaseState() { - return this.xMsLeaseState; - } - - /** - * Set the xMsLeaseState property: The x-ms-lease-state property. - * - * @param xMsLeaseState the xMsLeaseState value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsLeaseState(LeaseStateType xMsLeaseState) { - this.xMsLeaseState = xMsLeaseState; - return this; - } - - /** - * Get the xMsBlobSealed property: The x-ms-blob-sealed property. - * - * @return the xMsBlobSealed value. - */ - public Boolean isXMsBlobSealed() { - return this.xMsBlobSealed; - } - - /** - * Set the xMsBlobSealed property: The x-ms-blob-sealed property. - * - * @param xMsBlobSealed the xMsBlobSealed value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsBlobSealed(Boolean xMsBlobSealed) { - this.xMsBlobSealed = xMsBlobSealed; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsStructuredBody property: The x-ms-structured-body property. - * - * @return the xMsStructuredBody value. - */ - public String getXMsStructuredBody() { - return this.xMsStructuredBody; - } - - /** - * Set the xMsStructuredBody property: The x-ms-structured-body property. - * - * @param xMsStructuredBody the xMsStructuredBody value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsStructuredBody(String xMsStructuredBody) { - this.xMsStructuredBody = xMsStructuredBody; - return this; - } - - /** - * Get the xMsBlobType property: The x-ms-blob-type property. - * - * @return the xMsBlobType value. - */ - public BlobType getXMsBlobType() { - return this.xMsBlobType; - } - - /** - * Set the xMsBlobType property: The x-ms-blob-type property. - * - * @param xMsBlobType the xMsBlobType value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsBlobType(BlobType xMsBlobType) { - this.xMsBlobType = xMsBlobType; - return this; - } - - /** - * Get the xMsImmutabilityPolicyMode property: The x-ms-immutability-policy-mode property. - * - * @return the xMsImmutabilityPolicyMode value. - */ - public String getXMsImmutabilityPolicyMode() { - return this.xMsImmutabilityPolicyMode; - } - - /** - * Set the xMsImmutabilityPolicyMode property: The x-ms-immutability-policy-mode property. - * - * @param xMsImmutabilityPolicyMode the xMsImmutabilityPolicyMode value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsImmutabilityPolicyMode(String xMsImmutabilityPolicyMode) { - this.xMsImmutabilityPolicyMode = xMsImmutabilityPolicyMode; - return this; - } - - /** - * Get the xMsStructuredContentLength property: The x-ms-structured-content-length property. - * - * @return the xMsStructuredContentLength value. - */ - public Long getXMsStructuredContentLength() { - return this.xMsStructuredContentLength; - } - - /** - * Set the xMsStructuredContentLength property: The x-ms-structured-content-length property. - * - * @param xMsStructuredContentLength the xMsStructuredContentLength value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsStructuredContentLength(Long xMsStructuredContentLength) { - this.xMsStructuredContentLength = xMsStructuredContentLength; - return this; - } - - /** - * Get the contentEncoding property: The Content-Encoding property. - * - * @return the contentEncoding value. - */ - public String getContentEncoding() { - return this.contentEncoding; - } - - /** - * Set the contentEncoding property: The Content-Encoding property. - * - * @param contentEncoding the contentEncoding value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - /** - * Get the xMsCopyStatusDescription property: The x-ms-copy-status-description property. - * - * @return the xMsCopyStatusDescription value. - */ - public String getXMsCopyStatusDescription() { - return this.xMsCopyStatusDescription; - } - - /** - * Set the xMsCopyStatusDescription property: The x-ms-copy-status-description property. - * - * @param xMsCopyStatusDescription the xMsCopyStatusDescription value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsCopyStatusDescription(String xMsCopyStatusDescription) { - this.xMsCopyStatusDescription = xMsCopyStatusDescription; - return this; - } - - /** - * Get the xMsCreationTime property: The x-ms-creation-time property. - * - * @return the xMsCreationTime value. - */ - public OffsetDateTime getXMsCreationTime() { - if (this.xMsCreationTime == null) { - return null; - } - return this.xMsCreationTime.getDateTime(); - } - - /** - * Set the xMsCreationTime property: The x-ms-creation-time property. - * - * @param xMsCreationTime the xMsCreationTime value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsCreationTime(OffsetDateTime xMsCreationTime) { - if (xMsCreationTime == null) { - this.xMsCreationTime = null; - } else { - this.xMsCreationTime = new DateTimeRfc1123(xMsCreationTime); - } - return this; - } - - /** - * Get the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @return the xMsLeaseDuration value. - */ - public LeaseDurationType getXMsLeaseDuration() { - return this.xMsLeaseDuration; - } - - /** - * Set the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @param xMsLeaseDuration the xMsLeaseDuration value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsLeaseDuration(LeaseDurationType xMsLeaseDuration) { - this.xMsLeaseDuration = xMsLeaseDuration; - return this; - } - - /** - * Get the contentLength property: The Content-Length property. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return this.contentLength; - } - - /** - * Set the contentLength property: The Content-Length property. - * - * @param contentLength the contentLength value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setContentLength(Long contentLength) { - this.contentLength = contentLength; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Get the xMsLastAccessTime property: The x-ms-last-access-time property. - * - * @return the xMsLastAccessTime value. - */ - public OffsetDateTime getXMsLastAccessTime() { - if (this.xMsLastAccessTime == null) { - return null; - } - return this.xMsLastAccessTime.getDateTime(); - } - - /** - * Set the xMsLastAccessTime property: The x-ms-last-access-time property. - * - * @param xMsLastAccessTime the xMsLastAccessTime value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsLastAccessTime(OffsetDateTime xMsLastAccessTime) { - if (xMsLastAccessTime == null) { - this.xMsLastAccessTime = null; - } else { - this.xMsLastAccessTime = new DateTimeRfc1123(xMsLastAccessTime); - } - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsCopyId property: The x-ms-copy-id property. - * - * @return the xMsCopyId value. - */ - public String getXMsCopyId() { - return this.xMsCopyId; - } - - /** - * Set the xMsCopyId property: The x-ms-copy-id property. - * - * @param xMsCopyId the xMsCopyId value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsCopyId(String xMsCopyId) { - this.xMsCopyId = xMsCopyId; - return this; - } - - /** - * Get the xMsCopySource property: The x-ms-copy-source property. - * - * @return the xMsCopySource value. - */ - public String getXMsCopySource() { - return this.xMsCopySource; - } - - /** - * Set the xMsCopySource property: The x-ms-copy-source property. - * - * @param xMsCopySource the xMsCopySource value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsCopySource(String xMsCopySource) { - this.xMsCopySource = xMsCopySource; - return this; - } - - /** - * Get the xMsImmutabilityPolicyUntilDate property: The x-ms-immutability-policy-until-date property. - * - * @return the xMsImmutabilityPolicyUntilDate value. - */ - public OffsetDateTime getXMsImmutabilityPolicyUntilDate() { - if (this.xMsImmutabilityPolicyUntilDate == null) { - return null; - } - return this.xMsImmutabilityPolicyUntilDate.getDateTime(); - } - - /** - * Set the xMsImmutabilityPolicyUntilDate property: The x-ms-immutability-policy-until-date property. - * - * @param xMsImmutabilityPolicyUntilDate the xMsImmutabilityPolicyUntilDate value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsImmutabilityPolicyUntilDate(OffsetDateTime xMsImmutabilityPolicyUntilDate) { - if (xMsImmutabilityPolicyUntilDate == null) { - this.xMsImmutabilityPolicyUntilDate = null; - } else { - this.xMsImmutabilityPolicyUntilDate = new DateTimeRfc1123(xMsImmutabilityPolicyUntilDate); - } - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the xMsBlobSequenceNumber value. - */ - public Long getXMsBlobSequenceNumber() { - return this.xMsBlobSequenceNumber; - } - - /** - * Set the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param xMsBlobSequenceNumber the xMsBlobSequenceNumber value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsBlobSequenceNumber(Long xMsBlobSequenceNumber) { - this.xMsBlobSequenceNumber = xMsBlobSequenceNumber; - return this; - } - - /** - * Get the xMsCopyProgress property: The x-ms-copy-progress property. - * - * @return the xMsCopyProgress value. - */ - public String getXMsCopyProgress() { - return this.xMsCopyProgress; - } - - /** - * Set the xMsCopyProgress property: The x-ms-copy-progress property. - * - * @param xMsCopyProgress the xMsCopyProgress value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsCopyProgress(String xMsCopyProgress) { - this.xMsCopyProgress = xMsCopyProgress; - return this; - } - - /** - * Get the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @return the xMsBlobCommittedBlockCount value. - */ - public Integer getXMsBlobCommittedBlockCount() { - return this.xMsBlobCommittedBlockCount; - } - - /** - * Set the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @param xMsBlobCommittedBlockCount the xMsBlobCommittedBlockCount value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsBlobCommittedBlockCount(Integer xMsBlobCommittedBlockCount) { - this.xMsBlobCommittedBlockCount = xMsBlobCommittedBlockCount; - return this; - } - - /** - * Get the xMsBlobContentMd5 property: The x-ms-blob-content-md5 property. - * - * @return the xMsBlobContentMd5 value. - */ - public byte[] getXMsBlobContentMd5() { - return CoreUtils.clone(this.xMsBlobContentMd5); - } - - /** - * Set the xMsBlobContentMd5 property: The x-ms-blob-content-md5 property. - * - * @param xMsBlobContentMd5 the xMsBlobContentMd5 value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsBlobContentMd5(byte[] xMsBlobContentMd5) { - this.xMsBlobContentMd5 = CoreUtils.clone(xMsBlobContentMd5); - return this; - } - - /** - * Get the xMsMeta property: The x-ms-meta- property. - * - * @return the xMsMeta value. - */ - public Map getXMsMeta() { - return this.xMsMeta; - } - - /** - * Set the xMsMeta property: The x-ms-meta- property. - * - * @param xMsMeta the xMsMeta value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsMeta(Map xMsMeta) { - this.xMsMeta = xMsMeta; - return this; - } - - /** - * Get the xMsLegalHold property: The x-ms-legal-hold property. - * - * @return the xMsLegalHold value. - */ - public Boolean isXMsLegalHold() { - return this.xMsLegalHold; - } - - /** - * Set the xMsLegalHold property: The x-ms-legal-hold property. - * - * @param xMsLegalHold the xMsLegalHold value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsLegalHold(Boolean xMsLegalHold) { - this.xMsLegalHold = xMsLegalHold; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. - * - * @return the xMsCopyCompletionTime value. - */ - public OffsetDateTime getXMsCopyCompletionTime() { - if (this.xMsCopyCompletionTime == null) { - return null; - } - return this.xMsCopyCompletionTime.getDateTime(); - } - - /** - * Set the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. - * - * @param xMsCopyCompletionTime the xMsCopyCompletionTime value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsCopyCompletionTime(OffsetDateTime xMsCopyCompletionTime) { - if (xMsCopyCompletionTime == null) { - this.xMsCopyCompletionTime = null; - } else { - this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); - } - return this; - } - - /** - * Get the acceptRanges property: The Accept-Ranges property. - * - * @return the acceptRanges value. - */ - public String getAcceptRanges() { - return this.acceptRanges; - } - - /** - * Set the acceptRanges property: The Accept-Ranges property. - * - * @param acceptRanges the acceptRanges value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setAcceptRanges(String acceptRanges) { - this.acceptRanges = acceptRanges; - return this; - } - - /** - * Get the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @return the xMsServerEncrypted value. - */ - public Boolean isXMsServerEncrypted() { - return this.xMsServerEncrypted; - } - - /** - * Set the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @param xMsServerEncrypted the xMsServerEncrypted value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsServerEncrypted(Boolean xMsServerEncrypted) { - this.xMsServerEncrypted = xMsServerEncrypted; - return this; - } - - /** - * Get the xMsOrPolicyId property: The x-ms-or-policy-id property. - * - * @return the xMsOrPolicyId value. - */ - public String getXMsOrPolicyId() { - return this.xMsOrPolicyId; - } - - /** - * Set the xMsOrPolicyId property: The x-ms-or-policy-id property. - * - * @param xMsOrPolicyId the xMsOrPolicyId value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsOrPolicyId(String xMsOrPolicyId) { - this.xMsOrPolicyId = xMsOrPolicyId; - return this; - } - - /** - * Get the cacheControl property: The Cache-Control property. - * - * @return the cacheControl value. - */ - public String getCacheControl() { - return this.cacheControl; - } - - /** - * Set the cacheControl property: The Cache-Control property. - * - * @param cacheControl the cacheControl value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the contentDisposition property: The Content-Disposition property. - * - * @return the contentDisposition value. - */ - public String getContentDisposition() { - return this.contentDisposition; - } - - /** - * Set the contentDisposition property: The Content-Disposition property. - * - * @param contentDisposition the contentDisposition value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setContentDisposition(String contentDisposition) { - this.contentDisposition = contentDisposition; - return this; - } - - /** - * Get the xMsCopyStatus property: The x-ms-copy-status property. - * - * @return the xMsCopyStatus value. - */ - public CopyStatusType getXMsCopyStatus() { - return this.xMsCopyStatus; - } - - /** - * Set the xMsCopyStatus property: The x-ms-copy-status property. - * - * @param xMsCopyStatus the xMsCopyStatus value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsCopyStatus(CopyStatusType xMsCopyStatus) { - this.xMsCopyStatus = xMsCopyStatus; - return this; - } - - /** - * Get the contentLanguage property: The Content-Language property. - * - * @return the contentLanguage value. - */ - public String getContentLanguage() { - return this.contentLanguage; - } - - /** - * Set the contentLanguage property: The Content-Language property. - * - * @param contentLanguage the contentLanguage value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the xMsOr property: The x-ms-or- property. - * - * @return the xMsOr value. - */ - public Map getXMsOr() { - return this.xMsOr; - } - - /** - * Set the xMsOr property: The x-ms-or- property. - * - * @param xMsOr the xMsOr value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsOr(Map xMsOr) { - this.xMsOr = xMsOr; - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlobsDownloadHeaders object itself. - */ - public BlobsDownloadHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetAccessControlHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetAccessControlHeaders.java deleted file mode 100644 index 1b3ee4ac2468..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetAccessControlHeaders.java +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The BlobsGetAccessControlHeaders model. */ -@Fluent -public final class BlobsGetAccessControlHeaders { - /* - * The x-ms-group property. - */ - private String xMsGroup; - - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-acl property. - */ - private String xMsAcl; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-permissions property. - */ - private String xMsPermissions; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /* - * The x-ms-owner property. - */ - private String xMsOwner; - - /** - * Get the xMsGroup property: The x-ms-group property. - * - * @return the xMsGroup value. - */ - public String getXMsGroup() { - return this.xMsGroup; - } - - /** - * Set the xMsGroup property: The x-ms-group property. - * - * @param xMsGroup the xMsGroup value to set. - * @return the BlobsGetAccessControlHeaders object itself. - */ - public BlobsGetAccessControlHeaders setXMsGroup(String xMsGroup) { - this.xMsGroup = xMsGroup; - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsGetAccessControlHeaders object itself. - */ - public BlobsGetAccessControlHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsGetAccessControlHeaders object itself. - */ - public BlobsGetAccessControlHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsAcl property: The x-ms-acl property. - * - * @return the xMsAcl value. - */ - public String getXMsAcl() { - return this.xMsAcl; - } - - /** - * Set the xMsAcl property: The x-ms-acl property. - * - * @param xMsAcl the xMsAcl value to set. - * @return the BlobsGetAccessControlHeaders object itself. - */ - public BlobsGetAccessControlHeaders setXMsAcl(String xMsAcl) { - this.xMsAcl = xMsAcl; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsGetAccessControlHeaders object itself. - */ - public BlobsGetAccessControlHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsPermissions property: The x-ms-permissions property. - * - * @return the xMsPermissions value. - */ - public String getXMsPermissions() { - return this.xMsPermissions; - } - - /** - * Set the xMsPermissions property: The x-ms-permissions property. - * - * @param xMsPermissions the xMsPermissions value to set. - * @return the BlobsGetAccessControlHeaders object itself. - */ - public BlobsGetAccessControlHeaders setXMsPermissions(String xMsPermissions) { - this.xMsPermissions = xMsPermissions; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsGetAccessControlHeaders object itself. - */ - public BlobsGetAccessControlHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the BlobsGetAccessControlHeaders object itself. - */ - public BlobsGetAccessControlHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } - - /** - * Get the xMsOwner property: The x-ms-owner property. - * - * @return the xMsOwner value. - */ - public String getXMsOwner() { - return this.xMsOwner; - } - - /** - * Set the xMsOwner property: The x-ms-owner property. - * - * @param xMsOwner the xMsOwner value to set. - * @return the BlobsGetAccessControlHeaders object itself. - */ - public BlobsGetAccessControlHeaders setXMsOwner(String xMsOwner) { - this.xMsOwner = xMsOwner; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetAccountInfoHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetAccountInfoHeaders.java deleted file mode 100644 index 0641cb92778a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetAccountInfoHeaders.java +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.AccountKind; -import com.azure.storage.blob.models.SkuName; -import java.time.OffsetDateTime; - -/** - * The BlobsGetAccountInfoHeaders model. - */ -@Fluent -public final class BlobsGetAccountInfoHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-account-kind property. - */ - private AccountKind xMsAccountKind; - - /* - * The x-ms-is-hns-enabled property. - */ - private Boolean xMsIsHnsEnabled; - - /* - * The x-ms-sku-name property. - */ - private SkuName xMsSkuName; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_ACCOUNT_KIND = HttpHeaderName.fromString("x-ms-account-kind"); - - private static final HttpHeaderName X_MS_IS_HNS_ENABLED = HttpHeaderName.fromString("x-ms-is-hns-enabled"); - - private static final HttpHeaderName X_MS_SKU_NAME = HttpHeaderName.fromString("x-ms-sku-name"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsGetAccountInfoHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsGetAccountInfoHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsAccountKind = rawHeaders.getValue(X_MS_ACCOUNT_KIND); - if (xMsAccountKind != null) { - this.xMsAccountKind = AccountKind.fromString(xMsAccountKind); - } - String xMsIsHnsEnabled = rawHeaders.getValue(X_MS_IS_HNS_ENABLED); - if (xMsIsHnsEnabled != null) { - this.xMsIsHnsEnabled = Boolean.parseBoolean(xMsIsHnsEnabled); - } - String xMsSkuName = rawHeaders.getValue(X_MS_SKU_NAME); - if (xMsSkuName != null) { - this.xMsSkuName = SkuName.fromString(xMsSkuName); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsGetAccountInfoHeaders object itself. - */ - public BlobsGetAccountInfoHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsAccountKind property: The x-ms-account-kind property. - * - * @return the xMsAccountKind value. - */ - public AccountKind getXMsAccountKind() { - return this.xMsAccountKind; - } - - /** - * Set the xMsAccountKind property: The x-ms-account-kind property. - * - * @param xMsAccountKind the xMsAccountKind value to set. - * @return the BlobsGetAccountInfoHeaders object itself. - */ - public BlobsGetAccountInfoHeaders setXMsAccountKind(AccountKind xMsAccountKind) { - this.xMsAccountKind = xMsAccountKind; - return this; - } - - /** - * Get the xMsIsHnsEnabled property: The x-ms-is-hns-enabled property. - * - * @return the xMsIsHnsEnabled value. - */ - public Boolean isXMsIsHnsEnabled() { - return this.xMsIsHnsEnabled; - } - - /** - * Set the xMsIsHnsEnabled property: The x-ms-is-hns-enabled property. - * - * @param xMsIsHnsEnabled the xMsIsHnsEnabled value to set. - * @return the BlobsGetAccountInfoHeaders object itself. - */ - public BlobsGetAccountInfoHeaders setXMsIsHnsEnabled(Boolean xMsIsHnsEnabled) { - this.xMsIsHnsEnabled = xMsIsHnsEnabled; - return this; - } - - /** - * Get the xMsSkuName property: The x-ms-sku-name property. - * - * @return the xMsSkuName value. - */ - public SkuName getXMsSkuName() { - return this.xMsSkuName; - } - - /** - * Set the xMsSkuName property: The x-ms-sku-name property. - * - * @param xMsSkuName the xMsSkuName value to set. - * @return the BlobsGetAccountInfoHeaders object itself. - */ - public BlobsGetAccountInfoHeaders setXMsSkuName(SkuName xMsSkuName) { - this.xMsSkuName = xMsSkuName; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsGetAccountInfoHeaders object itself. - */ - public BlobsGetAccountInfoHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsGetAccountInfoHeaders object itself. - */ - public BlobsGetAccountInfoHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsGetAccountInfoHeaders object itself. - */ - public BlobsGetAccountInfoHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetPropertiesHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetPropertiesHeaders.java deleted file mode 100644 index 1baedc1a91de..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetPropertiesHeaders.java +++ /dev/null @@ -1,1535 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeader; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import java.time.OffsetDateTime; -import java.util.Base64; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * The BlobsGetPropertiesHeaders model. - */ -@Fluent -public final class BlobsGetPropertiesHeaders { - /* - * The x-ms-is-current-version property. - */ - private Boolean xMsIsCurrentVersion; - - /* - * The x-ms-lease-status property. - */ - private LeaseStatusType xMsLeaseStatus; - - /* - * The x-ms-copy-destination-snapshot property. - */ - private String xMsCopyDestinationSnapshot; - - /* - * The x-ms-lease-state property. - */ - private LeaseStateType xMsLeaseState; - - /* - * The x-ms-blob-sealed property. - */ - private Boolean xMsBlobSealed; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-access-tier-change-time property. - */ - private DateTimeRfc1123 xMsAccessTierChangeTime; - - /* - * The x-ms-blob-type property. - */ - private BlobType xMsBlobType; - - /* - * The Content-Encoding property. - */ - private String contentEncoding; - - /* - * The x-ms-creation-time property. - */ - private DateTimeRfc1123 xMsCreationTime; - - /* - * The x-ms-incremental-copy property. - */ - private Boolean xMsIncrementalCopy; - - /* - * The x-ms-lease-duration property. - */ - private LeaseDurationType xMsLeaseDuration; - - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-copy-id property. - */ - private String xMsCopyId; - - /* - * The x-ms-immutability-policy-until-date property. - */ - private DateTimeRfc1123 xMsImmutabilityPolicyUntilDate; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long xMsBlobSequenceNumber; - - /* - * The x-ms-blob-committed-block-count property. - */ - private Integer xMsBlobCommittedBlockCount; - - /* - * The x-ms-legal-hold property. - */ - private Boolean xMsLegalHold; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-or-policy-id property. - */ - private String xMsOrPolicyId; - - /* - * The Cache-Control property. - */ - private String cacheControl; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Content-Disposition property. - */ - private String contentDisposition; - - /* - * The Content-Language property. - */ - private String contentLanguage; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The x-ms-or- property. - */ - private Map xMsOr; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - /* - * The x-ms-tag-count property. - */ - private Long xMsTagCount; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-access-tier-inferred property. - */ - private Boolean xMsAccessTierInferred; - - /* - * The x-ms-immutability-policy-mode property. - */ - private BlobImmutabilityPolicyMode xMsImmutabilityPolicyMode; - - /* - * The x-ms-access-tier property. - */ - private String xMsAccessTier; - - /* - * The x-ms-copy-status-description property. - */ - private String xMsCopyStatusDescription; - - /* - * The Content-Length property. - */ - private Long contentLength; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The Content-Type property. - */ - private String contentType; - - /* - * The x-ms-last-access-time property. - */ - private DateTimeRfc1123 xMsLastAccessTime; - - /* - * The x-ms-copy-source property. - */ - private String xMsCopySource; - - /* - * The x-ms-copy-progress property. - */ - private String xMsCopyProgress; - - /* - * The x-ms-meta- property. - */ - private Map xMsMeta; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The x-ms-expiry-time property. - */ - private DateTimeRfc1123 xMsExpiryTime; - - /* - * The x-ms-copy-completion-time property. - */ - private DateTimeRfc1123 xMsCopyCompletionTime; - - /* - * The Accept-Ranges property. - */ - private String acceptRanges; - - /* - * The x-ms-server-encrypted property. - */ - private Boolean xMsServerEncrypted; - - /* - * The x-ms-rehydrate-priority property. - */ - private String xMsRehydratePriority; - - /* - * The x-ms-copy-status property. - */ - private CopyStatusType xMsCopyStatus; - - /* - * The x-ms-archive-status property. - */ - private String xMsArchiveStatus; - - private static final HttpHeaderName X_MS_IS_CURRENT_VERSION = HttpHeaderName.fromString("x-ms-is-current-version"); - - private static final HttpHeaderName X_MS_LEASE_STATUS = HttpHeaderName.fromString("x-ms-lease-status"); - - private static final HttpHeaderName X_MS_COPY_DESTINATION_SNAPSHOT - = HttpHeaderName.fromString("x-ms-copy-destination-snapshot"); - - private static final HttpHeaderName X_MS_LEASE_STATE = HttpHeaderName.fromString("x-ms-lease-state"); - - private static final HttpHeaderName X_MS_BLOB_SEALED = HttpHeaderName.fromString("x-ms-blob-sealed"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_ACCESS_TIER_CHANGE_TIME - = HttpHeaderName.fromString("x-ms-access-tier-change-time"); - - private static final HttpHeaderName X_MS_BLOB_TYPE = HttpHeaderName.fromString("x-ms-blob-type"); - - private static final HttpHeaderName X_MS_CREATION_TIME = HttpHeaderName.fromString("x-ms-creation-time"); - - private static final HttpHeaderName X_MS_INCREMENTAL_COPY = HttpHeaderName.fromString("x-ms-incremental-copy"); - - private static final HttpHeaderName X_MS_LEASE_DURATION = HttpHeaderName.fromString("x-ms-lease-duration"); - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); - - private static final HttpHeaderName X_MS_IMMUTABILITY_POLICY_UNTIL_DATE - = HttpHeaderName.fromString("x-ms-immutability-policy-until-date"); - - private static final HttpHeaderName X_MS_BLOB_SEQUENCE_NUMBER - = HttpHeaderName.fromString("x-ms-blob-sequence-number"); - - private static final HttpHeaderName X_MS_BLOB_COMMITTED_BLOCK_COUNT - = HttpHeaderName.fromString("x-ms-blob-committed-block-count"); - - private static final HttpHeaderName X_MS_LEGAL_HOLD = HttpHeaderName.fromString("x-ms-legal-hold"); - - private static final HttpHeaderName X_MS_OR_POLICY_ID = HttpHeaderName.fromString("x-ms-or-policy-id"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - private static final HttpHeaderName X_MS_TAG_COUNT = HttpHeaderName.fromString("x-ms-tag-count"); - - private static final HttpHeaderName X_MS_ACCESS_TIER_INFERRED - = HttpHeaderName.fromString("x-ms-access-tier-inferred"); - - private static final HttpHeaderName X_MS_IMMUTABILITY_POLICY_MODE - = HttpHeaderName.fromString("x-ms-immutability-policy-mode"); - - private static final HttpHeaderName X_MS_ACCESS_TIER = HttpHeaderName.fromString("x-ms-access-tier"); - - private static final HttpHeaderName X_MS_COPY_STATUS_DESCRIPTION - = HttpHeaderName.fromString("x-ms-copy-status-description"); - - private static final HttpHeaderName X_MS_LAST_ACCESS_TIME = HttpHeaderName.fromString("x-ms-last-access-time"); - - private static final HttpHeaderName X_MS_COPY_SOURCE = HttpHeaderName.fromString("x-ms-copy-source"); - - private static final HttpHeaderName X_MS_COPY_PROGRESS = HttpHeaderName.fromString("x-ms-copy-progress"); - - private static final HttpHeaderName X_MS_EXPIRY_TIME = HttpHeaderName.fromString("x-ms-expiry-time"); - - private static final HttpHeaderName X_MS_COPY_COMPLETION_TIME - = HttpHeaderName.fromString("x-ms-copy-completion-time"); - - private static final HttpHeaderName X_MS_SERVER_ENCRYPTED = HttpHeaderName.fromString("x-ms-server-encrypted"); - - private static final HttpHeaderName X_MS_REHYDRATE_PRIORITY = HttpHeaderName.fromString("x-ms-rehydrate-priority"); - - private static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); - - private static final HttpHeaderName X_MS_ARCHIVE_STATUS = HttpHeaderName.fromString("x-ms-archive-status"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsGetPropertiesHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsGetPropertiesHeaders(HttpHeaders rawHeaders) { - String xMsIsCurrentVersion = rawHeaders.getValue(X_MS_IS_CURRENT_VERSION); - if (xMsIsCurrentVersion != null) { - this.xMsIsCurrentVersion = Boolean.parseBoolean(xMsIsCurrentVersion); - } - String xMsLeaseStatus = rawHeaders.getValue(X_MS_LEASE_STATUS); - if (xMsLeaseStatus != null) { - this.xMsLeaseStatus = LeaseStatusType.fromString(xMsLeaseStatus); - } - this.xMsCopyDestinationSnapshot = rawHeaders.getValue(X_MS_COPY_DESTINATION_SNAPSHOT); - String xMsLeaseState = rawHeaders.getValue(X_MS_LEASE_STATE); - if (xMsLeaseState != null) { - this.xMsLeaseState = LeaseStateType.fromString(xMsLeaseState); - } - String xMsBlobSealed = rawHeaders.getValue(X_MS_BLOB_SEALED); - if (xMsBlobSealed != null) { - this.xMsBlobSealed = Boolean.parseBoolean(xMsBlobSealed); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - String xMsAccessTierChangeTime = rawHeaders.getValue(X_MS_ACCESS_TIER_CHANGE_TIME); - if (xMsAccessTierChangeTime != null) { - this.xMsAccessTierChangeTime = new DateTimeRfc1123(xMsAccessTierChangeTime); - } - String xMsBlobType = rawHeaders.getValue(X_MS_BLOB_TYPE); - if (xMsBlobType != null) { - this.xMsBlobType = BlobType.fromString(xMsBlobType); - } - this.contentEncoding = rawHeaders.getValue(HttpHeaderName.CONTENT_ENCODING); - String xMsCreationTime = rawHeaders.getValue(X_MS_CREATION_TIME); - if (xMsCreationTime != null) { - this.xMsCreationTime = new DateTimeRfc1123(xMsCreationTime); - } - String xMsIncrementalCopy = rawHeaders.getValue(X_MS_INCREMENTAL_COPY); - if (xMsIncrementalCopy != null) { - this.xMsIncrementalCopy = Boolean.parseBoolean(xMsIncrementalCopy); - } - String xMsLeaseDuration = rawHeaders.getValue(X_MS_LEASE_DURATION); - if (xMsLeaseDuration != null) { - this.xMsLeaseDuration = LeaseDurationType.fromString(xMsLeaseDuration); - } - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsCopyId = rawHeaders.getValue(X_MS_COPY_ID); - String xMsImmutabilityPolicyUntilDate = rawHeaders.getValue(X_MS_IMMUTABILITY_POLICY_UNTIL_DATE); - if (xMsImmutabilityPolicyUntilDate != null) { - this.xMsImmutabilityPolicyUntilDate = new DateTimeRfc1123(xMsImmutabilityPolicyUntilDate); - } - String xMsBlobSequenceNumber = rawHeaders.getValue(X_MS_BLOB_SEQUENCE_NUMBER); - if (xMsBlobSequenceNumber != null) { - this.xMsBlobSequenceNumber = Long.parseLong(xMsBlobSequenceNumber); - } - String xMsBlobCommittedBlockCount = rawHeaders.getValue(X_MS_BLOB_COMMITTED_BLOCK_COUNT); - if (xMsBlobCommittedBlockCount != null) { - this.xMsBlobCommittedBlockCount = Integer.parseInt(xMsBlobCommittedBlockCount); - } - String xMsLegalHold = rawHeaders.getValue(X_MS_LEGAL_HOLD); - if (xMsLegalHold != null) { - this.xMsLegalHold = Boolean.parseBoolean(xMsLegalHold); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsOrPolicyId = rawHeaders.getValue(X_MS_OR_POLICY_ID); - this.cacheControl = rawHeaders.getValue(HttpHeaderName.CACHE_CONTROL); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.contentDisposition = rawHeaders.getValue(HttpHeaderName.CONTENT_DISPOSITION); - this.contentLanguage = rawHeaders.getValue(HttpHeaderName.CONTENT_LANGUAGE); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - String xMsTagCount = rawHeaders.getValue(X_MS_TAG_COUNT); - if (xMsTagCount != null) { - this.xMsTagCount = Long.parseLong(xMsTagCount); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - String xMsAccessTierInferred = rawHeaders.getValue(X_MS_ACCESS_TIER_INFERRED); - if (xMsAccessTierInferred != null) { - this.xMsAccessTierInferred = Boolean.parseBoolean(xMsAccessTierInferred); - } - String xMsImmutabilityPolicyMode = rawHeaders.getValue(X_MS_IMMUTABILITY_POLICY_MODE); - if (xMsImmutabilityPolicyMode != null) { - this.xMsImmutabilityPolicyMode = BlobImmutabilityPolicyMode.fromString(xMsImmutabilityPolicyMode); - } - this.xMsAccessTier = rawHeaders.getValue(X_MS_ACCESS_TIER); - this.xMsCopyStatusDescription = rawHeaders.getValue(X_MS_COPY_STATUS_DESCRIPTION); - String contentLength = rawHeaders.getValue(HttpHeaderName.CONTENT_LENGTH); - if (contentLength != null) { - this.contentLength = Long.parseLong(contentLength); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); - String xMsLastAccessTime = rawHeaders.getValue(X_MS_LAST_ACCESS_TIME); - if (xMsLastAccessTime != null) { - this.xMsLastAccessTime = new DateTimeRfc1123(xMsLastAccessTime); - } - this.xMsCopySource = rawHeaders.getValue(X_MS_COPY_SOURCE); - this.xMsCopyProgress = rawHeaders.getValue(X_MS_COPY_PROGRESS); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String xMsExpiryTime = rawHeaders.getValue(X_MS_EXPIRY_TIME); - if (xMsExpiryTime != null) { - this.xMsExpiryTime = new DateTimeRfc1123(xMsExpiryTime); - } - String xMsCopyCompletionTime = rawHeaders.getValue(X_MS_COPY_COMPLETION_TIME); - if (xMsCopyCompletionTime != null) { - this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); - } - this.acceptRanges = rawHeaders.getValue(HttpHeaderName.ACCEPT_RANGES); - String xMsServerEncrypted = rawHeaders.getValue(X_MS_SERVER_ENCRYPTED); - if (xMsServerEncrypted != null) { - this.xMsServerEncrypted = Boolean.parseBoolean(xMsServerEncrypted); - } - this.xMsRehydratePriority = rawHeaders.getValue(X_MS_REHYDRATE_PRIORITY); - String xMsCopyStatus = rawHeaders.getValue(X_MS_COPY_STATUS); - if (xMsCopyStatus != null) { - this.xMsCopyStatus = CopyStatusType.fromString(xMsCopyStatus); - } - this.xMsArchiveStatus = rawHeaders.getValue(X_MS_ARCHIVE_STATUS); - Map xMsOrHeaderCollection = new LinkedHashMap<>(); - Map xMsMetaHeaderCollection = new LinkedHashMap<>(); - - for (HttpHeader header : rawHeaders) { - String headerName = header.getName(); - if (headerName.startsWith("x-ms-or-")) { - xMsOrHeaderCollection.put(headerName.substring(8), header.getValue()); - continue; - } - if (headerName.startsWith("x-ms-meta-")) { - xMsMetaHeaderCollection.put(headerName.substring(10), header.getValue()); - } - } - - this.xMsOr = xMsOrHeaderCollection; - this.xMsMeta = xMsMetaHeaderCollection; - } - - /** - * Get the xMsIsCurrentVersion property: The x-ms-is-current-version property. - * - * @return the xMsIsCurrentVersion value. - */ - public Boolean isXMsIsCurrentVersion() { - return this.xMsIsCurrentVersion; - } - - /** - * Set the xMsIsCurrentVersion property: The x-ms-is-current-version property. - * - * @param xMsIsCurrentVersion the xMsIsCurrentVersion value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsIsCurrentVersion(Boolean xMsIsCurrentVersion) { - this.xMsIsCurrentVersion = xMsIsCurrentVersion; - return this; - } - - /** - * Get the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @return the xMsLeaseStatus value. - */ - public LeaseStatusType getXMsLeaseStatus() { - return this.xMsLeaseStatus; - } - - /** - * Set the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @param xMsLeaseStatus the xMsLeaseStatus value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsLeaseStatus(LeaseStatusType xMsLeaseStatus) { - this.xMsLeaseStatus = xMsLeaseStatus; - return this; - } - - /** - * Get the xMsCopyDestinationSnapshot property: The x-ms-copy-destination-snapshot property. - * - * @return the xMsCopyDestinationSnapshot value. - */ - public String getXMsCopyDestinationSnapshot() { - return this.xMsCopyDestinationSnapshot; - } - - /** - * Set the xMsCopyDestinationSnapshot property: The x-ms-copy-destination-snapshot property. - * - * @param xMsCopyDestinationSnapshot the xMsCopyDestinationSnapshot value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsCopyDestinationSnapshot(String xMsCopyDestinationSnapshot) { - this.xMsCopyDestinationSnapshot = xMsCopyDestinationSnapshot; - return this; - } - - /** - * Get the xMsLeaseState property: The x-ms-lease-state property. - * - * @return the xMsLeaseState value. - */ - public LeaseStateType getXMsLeaseState() { - return this.xMsLeaseState; - } - - /** - * Set the xMsLeaseState property: The x-ms-lease-state property. - * - * @param xMsLeaseState the xMsLeaseState value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsLeaseState(LeaseStateType xMsLeaseState) { - this.xMsLeaseState = xMsLeaseState; - return this; - } - - /** - * Get the xMsBlobSealed property: The x-ms-blob-sealed property. - * - * @return the xMsBlobSealed value. - */ - public Boolean isXMsBlobSealed() { - return this.xMsBlobSealed; - } - - /** - * Set the xMsBlobSealed property: The x-ms-blob-sealed property. - * - * @param xMsBlobSealed the xMsBlobSealed value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsBlobSealed(Boolean xMsBlobSealed) { - this.xMsBlobSealed = xMsBlobSealed; - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsAccessTierChangeTime property: The x-ms-access-tier-change-time property. - * - * @return the xMsAccessTierChangeTime value. - */ - public OffsetDateTime getXMsAccessTierChangeTime() { - if (this.xMsAccessTierChangeTime == null) { - return null; - } - return this.xMsAccessTierChangeTime.getDateTime(); - } - - /** - * Set the xMsAccessTierChangeTime property: The x-ms-access-tier-change-time property. - * - * @param xMsAccessTierChangeTime the xMsAccessTierChangeTime value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsAccessTierChangeTime(OffsetDateTime xMsAccessTierChangeTime) { - if (xMsAccessTierChangeTime == null) { - this.xMsAccessTierChangeTime = null; - } else { - this.xMsAccessTierChangeTime = new DateTimeRfc1123(xMsAccessTierChangeTime); - } - return this; - } - - /** - * Get the xMsBlobType property: The x-ms-blob-type property. - * - * @return the xMsBlobType value. - */ - public BlobType getXMsBlobType() { - return this.xMsBlobType; - } - - /** - * Set the xMsBlobType property: The x-ms-blob-type property. - * - * @param xMsBlobType the xMsBlobType value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsBlobType(BlobType xMsBlobType) { - this.xMsBlobType = xMsBlobType; - return this; - } - - /** - * Get the contentEncoding property: The Content-Encoding property. - * - * @return the contentEncoding value. - */ - public String getContentEncoding() { - return this.contentEncoding; - } - - /** - * Set the contentEncoding property: The Content-Encoding property. - * - * @param contentEncoding the contentEncoding value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - /** - * Get the xMsCreationTime property: The x-ms-creation-time property. - * - * @return the xMsCreationTime value. - */ - public OffsetDateTime getXMsCreationTime() { - if (this.xMsCreationTime == null) { - return null; - } - return this.xMsCreationTime.getDateTime(); - } - - /** - * Set the xMsCreationTime property: The x-ms-creation-time property. - * - * @param xMsCreationTime the xMsCreationTime value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsCreationTime(OffsetDateTime xMsCreationTime) { - if (xMsCreationTime == null) { - this.xMsCreationTime = null; - } else { - this.xMsCreationTime = new DateTimeRfc1123(xMsCreationTime); - } - return this; - } - - /** - * Get the xMsIncrementalCopy property: The x-ms-incremental-copy property. - * - * @return the xMsIncrementalCopy value. - */ - public Boolean isXMsIncrementalCopy() { - return this.xMsIncrementalCopy; - } - - /** - * Set the xMsIncrementalCopy property: The x-ms-incremental-copy property. - * - * @param xMsIncrementalCopy the xMsIncrementalCopy value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsIncrementalCopy(Boolean xMsIncrementalCopy) { - this.xMsIncrementalCopy = xMsIncrementalCopy; - return this; - } - - /** - * Get the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @return the xMsLeaseDuration value. - */ - public LeaseDurationType getXMsLeaseDuration() { - return this.xMsLeaseDuration; - } - - /** - * Set the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @param xMsLeaseDuration the xMsLeaseDuration value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsLeaseDuration(LeaseDurationType xMsLeaseDuration) { - this.xMsLeaseDuration = xMsLeaseDuration; - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsCopyId property: The x-ms-copy-id property. - * - * @return the xMsCopyId value. - */ - public String getXMsCopyId() { - return this.xMsCopyId; - } - - /** - * Set the xMsCopyId property: The x-ms-copy-id property. - * - * @param xMsCopyId the xMsCopyId value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsCopyId(String xMsCopyId) { - this.xMsCopyId = xMsCopyId; - return this; - } - - /** - * Get the xMsImmutabilityPolicyUntilDate property: The x-ms-immutability-policy-until-date property. - * - * @return the xMsImmutabilityPolicyUntilDate value. - */ - public OffsetDateTime getXMsImmutabilityPolicyUntilDate() { - if (this.xMsImmutabilityPolicyUntilDate == null) { - return null; - } - return this.xMsImmutabilityPolicyUntilDate.getDateTime(); - } - - /** - * Set the xMsImmutabilityPolicyUntilDate property: The x-ms-immutability-policy-until-date property. - * - * @param xMsImmutabilityPolicyUntilDate the xMsImmutabilityPolicyUntilDate value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsImmutabilityPolicyUntilDate(OffsetDateTime xMsImmutabilityPolicyUntilDate) { - if (xMsImmutabilityPolicyUntilDate == null) { - this.xMsImmutabilityPolicyUntilDate = null; - } else { - this.xMsImmutabilityPolicyUntilDate = new DateTimeRfc1123(xMsImmutabilityPolicyUntilDate); - } - return this; - } - - /** - * Get the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the xMsBlobSequenceNumber value. - */ - public Long getXMsBlobSequenceNumber() { - return this.xMsBlobSequenceNumber; - } - - /** - * Set the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param xMsBlobSequenceNumber the xMsBlobSequenceNumber value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsBlobSequenceNumber(Long xMsBlobSequenceNumber) { - this.xMsBlobSequenceNumber = xMsBlobSequenceNumber; - return this; - } - - /** - * Get the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @return the xMsBlobCommittedBlockCount value. - */ - public Integer getXMsBlobCommittedBlockCount() { - return this.xMsBlobCommittedBlockCount; - } - - /** - * Set the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @param xMsBlobCommittedBlockCount the xMsBlobCommittedBlockCount value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsBlobCommittedBlockCount(Integer xMsBlobCommittedBlockCount) { - this.xMsBlobCommittedBlockCount = xMsBlobCommittedBlockCount; - return this; - } - - /** - * Get the xMsLegalHold property: The x-ms-legal-hold property. - * - * @return the xMsLegalHold value. - */ - public Boolean isXMsLegalHold() { - return this.xMsLegalHold; - } - - /** - * Set the xMsLegalHold property: The x-ms-legal-hold property. - * - * @param xMsLegalHold the xMsLegalHold value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsLegalHold(Boolean xMsLegalHold) { - this.xMsLegalHold = xMsLegalHold; - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsOrPolicyId property: The x-ms-or-policy-id property. - * - * @return the xMsOrPolicyId value. - */ - public String getXMsOrPolicyId() { - return this.xMsOrPolicyId; - } - - /** - * Set the xMsOrPolicyId property: The x-ms-or-policy-id property. - * - * @param xMsOrPolicyId the xMsOrPolicyId value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsOrPolicyId(String xMsOrPolicyId) { - this.xMsOrPolicyId = xMsOrPolicyId; - return this; - } - - /** - * Get the cacheControl property: The Cache-Control property. - * - * @return the cacheControl value. - */ - public String getCacheControl() { - return this.cacheControl; - } - - /** - * Set the cacheControl property: The Cache-Control property. - * - * @param cacheControl the cacheControl value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the contentDisposition property: The Content-Disposition property. - * - * @return the contentDisposition value. - */ - public String getContentDisposition() { - return this.contentDisposition; - } - - /** - * Set the contentDisposition property: The Content-Disposition property. - * - * @param contentDisposition the contentDisposition value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setContentDisposition(String contentDisposition) { - this.contentDisposition = contentDisposition; - return this; - } - - /** - * Get the contentLanguage property: The Content-Language property. - * - * @return the contentLanguage value. - */ - public String getContentLanguage() { - return this.contentLanguage; - } - - /** - * Set the contentLanguage property: The Content-Language property. - * - * @param contentLanguage the contentLanguage value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the xMsOr property: The x-ms-or- property. - * - * @return the xMsOr value. - */ - public Map getXMsOr() { - return this.xMsOr; - } - - /** - * Set the xMsOr property: The x-ms-or- property. - * - * @param xMsOr the xMsOr value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsOr(Map xMsOr) { - this.xMsOr = xMsOr; - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } - - /** - * Get the xMsTagCount property: The x-ms-tag-count property. - * - * @return the xMsTagCount value. - */ - public Long getXMsTagCount() { - return this.xMsTagCount; - } - - /** - * Set the xMsTagCount property: The x-ms-tag-count property. - * - * @param xMsTagCount the xMsTagCount value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsTagCount(Long xMsTagCount) { - this.xMsTagCount = xMsTagCount; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsAccessTierInferred property: The x-ms-access-tier-inferred property. - * - * @return the xMsAccessTierInferred value. - */ - public Boolean isXMsAccessTierInferred() { - return this.xMsAccessTierInferred; - } - - /** - * Set the xMsAccessTierInferred property: The x-ms-access-tier-inferred property. - * - * @param xMsAccessTierInferred the xMsAccessTierInferred value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsAccessTierInferred(Boolean xMsAccessTierInferred) { - this.xMsAccessTierInferred = xMsAccessTierInferred; - return this; - } - - /** - * Get the xMsImmutabilityPolicyMode property: The x-ms-immutability-policy-mode property. - * - * @return the xMsImmutabilityPolicyMode value. - */ - public BlobImmutabilityPolicyMode getXMsImmutabilityPolicyMode() { - return this.xMsImmutabilityPolicyMode; - } - - /** - * Set the xMsImmutabilityPolicyMode property: The x-ms-immutability-policy-mode property. - * - * @param xMsImmutabilityPolicyMode the xMsImmutabilityPolicyMode value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders - setXMsImmutabilityPolicyMode(BlobImmutabilityPolicyMode xMsImmutabilityPolicyMode) { - this.xMsImmutabilityPolicyMode = xMsImmutabilityPolicyMode; - return this; - } - - /** - * Get the xMsAccessTier property: The x-ms-access-tier property. - * - * @return the xMsAccessTier value. - */ - public String getXMsAccessTier() { - return this.xMsAccessTier; - } - - /** - * Set the xMsAccessTier property: The x-ms-access-tier property. - * - * @param xMsAccessTier the xMsAccessTier value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsAccessTier(String xMsAccessTier) { - this.xMsAccessTier = xMsAccessTier; - return this; - } - - /** - * Get the xMsCopyStatusDescription property: The x-ms-copy-status-description property. - * - * @return the xMsCopyStatusDescription value. - */ - public String getXMsCopyStatusDescription() { - return this.xMsCopyStatusDescription; - } - - /** - * Set the xMsCopyStatusDescription property: The x-ms-copy-status-description property. - * - * @param xMsCopyStatusDescription the xMsCopyStatusDescription value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsCopyStatusDescription(String xMsCopyStatusDescription) { - this.xMsCopyStatusDescription = xMsCopyStatusDescription; - return this; - } - - /** - * Get the contentLength property: The Content-Length property. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return this.contentLength; - } - - /** - * Set the contentLength property: The Content-Length property. - * - * @param contentLength the contentLength value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setContentLength(Long contentLength) { - this.contentLength = contentLength; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Get the xMsLastAccessTime property: The x-ms-last-access-time property. - * - * @return the xMsLastAccessTime value. - */ - public OffsetDateTime getXMsLastAccessTime() { - if (this.xMsLastAccessTime == null) { - return null; - } - return this.xMsLastAccessTime.getDateTime(); - } - - /** - * Set the xMsLastAccessTime property: The x-ms-last-access-time property. - * - * @param xMsLastAccessTime the xMsLastAccessTime value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsLastAccessTime(OffsetDateTime xMsLastAccessTime) { - if (xMsLastAccessTime == null) { - this.xMsLastAccessTime = null; - } else { - this.xMsLastAccessTime = new DateTimeRfc1123(xMsLastAccessTime); - } - return this; - } - - /** - * Get the xMsCopySource property: The x-ms-copy-source property. - * - * @return the xMsCopySource value. - */ - public String getXMsCopySource() { - return this.xMsCopySource; - } - - /** - * Set the xMsCopySource property: The x-ms-copy-source property. - * - * @param xMsCopySource the xMsCopySource value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsCopySource(String xMsCopySource) { - this.xMsCopySource = xMsCopySource; - return this; - } - - /** - * Get the xMsCopyProgress property: The x-ms-copy-progress property. - * - * @return the xMsCopyProgress value. - */ - public String getXMsCopyProgress() { - return this.xMsCopyProgress; - } - - /** - * Set the xMsCopyProgress property: The x-ms-copy-progress property. - * - * @param xMsCopyProgress the xMsCopyProgress value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsCopyProgress(String xMsCopyProgress) { - this.xMsCopyProgress = xMsCopyProgress; - return this; - } - - /** - * Get the xMsMeta property: The x-ms-meta- property. - * - * @return the xMsMeta value. - */ - public Map getXMsMeta() { - return this.xMsMeta; - } - - /** - * Set the xMsMeta property: The x-ms-meta- property. - * - * @param xMsMeta the xMsMeta value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsMeta(Map xMsMeta) { - this.xMsMeta = xMsMeta; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the xMsExpiryTime property: The x-ms-expiry-time property. - * - * @return the xMsExpiryTime value. - */ - public OffsetDateTime getXMsExpiryTime() { - if (this.xMsExpiryTime == null) { - return null; - } - return this.xMsExpiryTime.getDateTime(); - } - - /** - * Set the xMsExpiryTime property: The x-ms-expiry-time property. - * - * @param xMsExpiryTime the xMsExpiryTime value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsExpiryTime(OffsetDateTime xMsExpiryTime) { - if (xMsExpiryTime == null) { - this.xMsExpiryTime = null; - } else { - this.xMsExpiryTime = new DateTimeRfc1123(xMsExpiryTime); - } - return this; - } - - /** - * Get the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. - * - * @return the xMsCopyCompletionTime value. - */ - public OffsetDateTime getXMsCopyCompletionTime() { - if (this.xMsCopyCompletionTime == null) { - return null; - } - return this.xMsCopyCompletionTime.getDateTime(); - } - - /** - * Set the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. - * - * @param xMsCopyCompletionTime the xMsCopyCompletionTime value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsCopyCompletionTime(OffsetDateTime xMsCopyCompletionTime) { - if (xMsCopyCompletionTime == null) { - this.xMsCopyCompletionTime = null; - } else { - this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); - } - return this; - } - - /** - * Get the acceptRanges property: The Accept-Ranges property. - * - * @return the acceptRanges value. - */ - public String getAcceptRanges() { - return this.acceptRanges; - } - - /** - * Set the acceptRanges property: The Accept-Ranges property. - * - * @param acceptRanges the acceptRanges value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setAcceptRanges(String acceptRanges) { - this.acceptRanges = acceptRanges; - return this; - } - - /** - * Get the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @return the xMsServerEncrypted value. - */ - public Boolean isXMsServerEncrypted() { - return this.xMsServerEncrypted; - } - - /** - * Set the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @param xMsServerEncrypted the xMsServerEncrypted value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsServerEncrypted(Boolean xMsServerEncrypted) { - this.xMsServerEncrypted = xMsServerEncrypted; - return this; - } - - /** - * Get the xMsRehydratePriority property: The x-ms-rehydrate-priority property. - * - * @return the xMsRehydratePriority value. - */ - public String getXMsRehydratePriority() { - return this.xMsRehydratePriority; - } - - /** - * Set the xMsRehydratePriority property: The x-ms-rehydrate-priority property. - * - * @param xMsRehydratePriority the xMsRehydratePriority value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsRehydratePriority(String xMsRehydratePriority) { - this.xMsRehydratePriority = xMsRehydratePriority; - return this; - } - - /** - * Get the xMsCopyStatus property: The x-ms-copy-status property. - * - * @return the xMsCopyStatus value. - */ - public CopyStatusType getXMsCopyStatus() { - return this.xMsCopyStatus; - } - - /** - * Set the xMsCopyStatus property: The x-ms-copy-status property. - * - * @param xMsCopyStatus the xMsCopyStatus value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsCopyStatus(CopyStatusType xMsCopyStatus) { - this.xMsCopyStatus = xMsCopyStatus; - return this; - } - - /** - * Get the xMsArchiveStatus property: The x-ms-archive-status property. - * - * @return the xMsArchiveStatus value. - */ - public String getXMsArchiveStatus() { - return this.xMsArchiveStatus; - } - - /** - * Set the xMsArchiveStatus property: The x-ms-archive-status property. - * - * @param xMsArchiveStatus the xMsArchiveStatus value to set. - * @return the BlobsGetPropertiesHeaders object itself. - */ - public BlobsGetPropertiesHeaders setXMsArchiveStatus(String xMsArchiveStatus) { - this.xMsArchiveStatus = xMsArchiveStatus; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetTagsHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetTagsHeaders.java deleted file mode 100644 index 5eb10c0e01a6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetTagsHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsGetTagsHeaders model. - */ -@Fluent -public final class BlobsGetTagsHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsGetTagsHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsGetTagsHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsGetTagsHeaders object itself. - */ - public BlobsGetTagsHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsGetTagsHeaders object itself. - */ - public BlobsGetTagsHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsGetTagsHeaders object itself. - */ - public BlobsGetTagsHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsGetTagsHeaders object itself. - */ - public BlobsGetTagsHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsQueryHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsQueryHeaders.java deleted file mode 100644 index 3a976acbc4b3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsQueryHeaders.java +++ /dev/null @@ -1,1010 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeader; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import java.time.OffsetDateTime; -import java.util.Base64; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * The BlobsQueryHeaders model. - */ -@Fluent -public final class BlobsQueryHeaders { - /* - * The x-ms-lease-status property. - */ - private LeaseStatusType xMsLeaseStatus; - - /* - * The Content-Range property. - */ - private String contentRange; - - /* - * The x-ms-lease-state property. - */ - private LeaseStateType xMsLeaseState; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-blob-type property. - */ - private BlobType xMsBlobType; - - /* - * The Content-Encoding property. - */ - private String contentEncoding; - - /* - * The x-ms-copy-status-description property. - */ - private String xMsCopyStatusDescription; - - /* - * The x-ms-lease-duration property. - */ - private LeaseDurationType xMsLeaseDuration; - - /* - * The Content-Length property. - */ - private Long contentLength; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The Content-Type property. - */ - private String contentType; - - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-copy-id property. - */ - private String xMsCopyId; - - /* - * The x-ms-copy-source property. - */ - private String xMsCopySource; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long xMsBlobSequenceNumber; - - /* - * The x-ms-copy-progress property. - */ - private String xMsCopyProgress; - - /* - * The x-ms-blob-committed-block-count property. - */ - private Integer xMsBlobCommittedBlockCount; - - /* - * The x-ms-blob-content-md5 property. - */ - private byte[] xMsBlobContentMd5; - - /* - * The x-ms-meta- property. - */ - private Map xMsMeta; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-copy-completion-time property. - */ - private DateTimeRfc1123 xMsCopyCompletionTime; - - /* - * The Accept-Ranges property. - */ - private String acceptRanges; - - /* - * The x-ms-server-encrypted property. - */ - private Boolean xMsServerEncrypted; - - /* - * The Cache-Control property. - */ - private String cacheControl; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Content-Disposition property. - */ - private String contentDisposition; - - /* - * The x-ms-copy-status property. - */ - private CopyStatusType xMsCopyStatus; - - /* - * The Content-Language property. - */ - private String contentLanguage; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_LEASE_STATUS = HttpHeaderName.fromString("x-ms-lease-status"); - - private static final HttpHeaderName X_MS_LEASE_STATE = HttpHeaderName.fromString("x-ms-lease-state"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_BLOB_TYPE = HttpHeaderName.fromString("x-ms-blob-type"); - - private static final HttpHeaderName X_MS_COPY_STATUS_DESCRIPTION - = HttpHeaderName.fromString("x-ms-copy-status-description"); - - private static final HttpHeaderName X_MS_LEASE_DURATION = HttpHeaderName.fromString("x-ms-lease-duration"); - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); - - private static final HttpHeaderName X_MS_COPY_SOURCE = HttpHeaderName.fromString("x-ms-copy-source"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_BLOB_SEQUENCE_NUMBER - = HttpHeaderName.fromString("x-ms-blob-sequence-number"); - - private static final HttpHeaderName X_MS_COPY_PROGRESS = HttpHeaderName.fromString("x-ms-copy-progress"); - - private static final HttpHeaderName X_MS_BLOB_COMMITTED_BLOCK_COUNT - = HttpHeaderName.fromString("x-ms-blob-committed-block-count"); - - private static final HttpHeaderName X_MS_BLOB_CONTENT_MD5 = HttpHeaderName.fromString("x-ms-blob-content-md5"); - - private static final HttpHeaderName X_MS_COPY_COMPLETION_TIME - = HttpHeaderName.fromString("x-ms-copy-completion-time"); - - private static final HttpHeaderName X_MS_SERVER_ENCRYPTED = HttpHeaderName.fromString("x-ms-server-encrypted"); - - private static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsQueryHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsQueryHeaders(HttpHeaders rawHeaders) { - String xMsLeaseStatus = rawHeaders.getValue(X_MS_LEASE_STATUS); - if (xMsLeaseStatus != null) { - this.xMsLeaseStatus = LeaseStatusType.fromString(xMsLeaseStatus); - } - this.contentRange = rawHeaders.getValue(HttpHeaderName.CONTENT_RANGE); - String xMsLeaseState = rawHeaders.getValue(X_MS_LEASE_STATE); - if (xMsLeaseState != null) { - this.xMsLeaseState = LeaseStateType.fromString(xMsLeaseState); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - String xMsBlobType = rawHeaders.getValue(X_MS_BLOB_TYPE); - if (xMsBlobType != null) { - this.xMsBlobType = BlobType.fromString(xMsBlobType); - } - this.contentEncoding = rawHeaders.getValue(HttpHeaderName.CONTENT_ENCODING); - this.xMsCopyStatusDescription = rawHeaders.getValue(X_MS_COPY_STATUS_DESCRIPTION); - String xMsLeaseDuration = rawHeaders.getValue(X_MS_LEASE_DURATION); - if (xMsLeaseDuration != null) { - this.xMsLeaseDuration = LeaseDurationType.fromString(xMsLeaseDuration); - } - String contentLength = rawHeaders.getValue(HttpHeaderName.CONTENT_LENGTH); - if (contentLength != null) { - this.contentLength = Long.parseLong(contentLength); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsCopyId = rawHeaders.getValue(X_MS_COPY_ID); - this.xMsCopySource = rawHeaders.getValue(X_MS_COPY_SOURCE); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - String xMsBlobSequenceNumber = rawHeaders.getValue(X_MS_BLOB_SEQUENCE_NUMBER); - if (xMsBlobSequenceNumber != null) { - this.xMsBlobSequenceNumber = Long.parseLong(xMsBlobSequenceNumber); - } - this.xMsCopyProgress = rawHeaders.getValue(X_MS_COPY_PROGRESS); - String xMsBlobCommittedBlockCount = rawHeaders.getValue(X_MS_BLOB_COMMITTED_BLOCK_COUNT); - if (xMsBlobCommittedBlockCount != null) { - this.xMsBlobCommittedBlockCount = Integer.parseInt(xMsBlobCommittedBlockCount); - } - String xMsBlobContentMd5 = rawHeaders.getValue(X_MS_BLOB_CONTENT_MD5); - if (xMsBlobContentMd5 != null) { - this.xMsBlobContentMd5 = Base64.getDecoder().decode(xMsBlobContentMd5); - } - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - String xMsCopyCompletionTime = rawHeaders.getValue(X_MS_COPY_COMPLETION_TIME); - if (xMsCopyCompletionTime != null) { - this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); - } - this.acceptRanges = rawHeaders.getValue(HttpHeaderName.ACCEPT_RANGES); - String xMsServerEncrypted = rawHeaders.getValue(X_MS_SERVER_ENCRYPTED); - if (xMsServerEncrypted != null) { - this.xMsServerEncrypted = Boolean.parseBoolean(xMsServerEncrypted); - } - this.cacheControl = rawHeaders.getValue(HttpHeaderName.CACHE_CONTROL); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.contentDisposition = rawHeaders.getValue(HttpHeaderName.CONTENT_DISPOSITION); - String xMsCopyStatus = rawHeaders.getValue(X_MS_COPY_STATUS); - if (xMsCopyStatus != null) { - this.xMsCopyStatus = CopyStatusType.fromString(xMsCopyStatus); - } - this.contentLanguage = rawHeaders.getValue(HttpHeaderName.CONTENT_LANGUAGE); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - Map xMsMetaHeaderCollection = new LinkedHashMap<>(); - - for (HttpHeader header : rawHeaders) { - String headerName = header.getName(); - if (headerName.startsWith("x-ms-meta-")) { - xMsMetaHeaderCollection.put(headerName.substring(10), header.getValue()); - } - } - - this.xMsMeta = xMsMetaHeaderCollection; - } - - /** - * Get the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @return the xMsLeaseStatus value. - */ - public LeaseStatusType getXMsLeaseStatus() { - return this.xMsLeaseStatus; - } - - /** - * Set the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @param xMsLeaseStatus the xMsLeaseStatus value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsLeaseStatus(LeaseStatusType xMsLeaseStatus) { - this.xMsLeaseStatus = xMsLeaseStatus; - return this; - } - - /** - * Get the contentRange property: The Content-Range property. - * - * @return the contentRange value. - */ - public String getContentRange() { - return this.contentRange; - } - - /** - * Set the contentRange property: The Content-Range property. - * - * @param contentRange the contentRange value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setContentRange(String contentRange) { - this.contentRange = contentRange; - return this; - } - - /** - * Get the xMsLeaseState property: The x-ms-lease-state property. - * - * @return the xMsLeaseState value. - */ - public LeaseStateType getXMsLeaseState() { - return this.xMsLeaseState; - } - - /** - * Set the xMsLeaseState property: The x-ms-lease-state property. - * - * @param xMsLeaseState the xMsLeaseState value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsLeaseState(LeaseStateType xMsLeaseState) { - this.xMsLeaseState = xMsLeaseState; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsBlobType property: The x-ms-blob-type property. - * - * @return the xMsBlobType value. - */ - public BlobType getXMsBlobType() { - return this.xMsBlobType; - } - - /** - * Set the xMsBlobType property: The x-ms-blob-type property. - * - * @param xMsBlobType the xMsBlobType value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsBlobType(BlobType xMsBlobType) { - this.xMsBlobType = xMsBlobType; - return this; - } - - /** - * Get the contentEncoding property: The Content-Encoding property. - * - * @return the contentEncoding value. - */ - public String getContentEncoding() { - return this.contentEncoding; - } - - /** - * Set the contentEncoding property: The Content-Encoding property. - * - * @param contentEncoding the contentEncoding value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - /** - * Get the xMsCopyStatusDescription property: The x-ms-copy-status-description property. - * - * @return the xMsCopyStatusDescription value. - */ - public String getXMsCopyStatusDescription() { - return this.xMsCopyStatusDescription; - } - - /** - * Set the xMsCopyStatusDescription property: The x-ms-copy-status-description property. - * - * @param xMsCopyStatusDescription the xMsCopyStatusDescription value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsCopyStatusDescription(String xMsCopyStatusDescription) { - this.xMsCopyStatusDescription = xMsCopyStatusDescription; - return this; - } - - /** - * Get the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @return the xMsLeaseDuration value. - */ - public LeaseDurationType getXMsLeaseDuration() { - return this.xMsLeaseDuration; - } - - /** - * Set the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @param xMsLeaseDuration the xMsLeaseDuration value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsLeaseDuration(LeaseDurationType xMsLeaseDuration) { - this.xMsLeaseDuration = xMsLeaseDuration; - return this; - } - - /** - * Get the contentLength property: The Content-Length property. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return this.contentLength; - } - - /** - * Set the contentLength property: The Content-Length property. - * - * @param contentLength the contentLength value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setContentLength(Long contentLength) { - this.contentLength = contentLength; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsCopyId property: The x-ms-copy-id property. - * - * @return the xMsCopyId value. - */ - public String getXMsCopyId() { - return this.xMsCopyId; - } - - /** - * Set the xMsCopyId property: The x-ms-copy-id property. - * - * @param xMsCopyId the xMsCopyId value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsCopyId(String xMsCopyId) { - this.xMsCopyId = xMsCopyId; - return this; - } - - /** - * Get the xMsCopySource property: The x-ms-copy-source property. - * - * @return the xMsCopySource value. - */ - public String getXMsCopySource() { - return this.xMsCopySource; - } - - /** - * Set the xMsCopySource property: The x-ms-copy-source property. - * - * @param xMsCopySource the xMsCopySource value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsCopySource(String xMsCopySource) { - this.xMsCopySource = xMsCopySource; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the xMsBlobSequenceNumber value. - */ - public Long getXMsBlobSequenceNumber() { - return this.xMsBlobSequenceNumber; - } - - /** - * Set the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param xMsBlobSequenceNumber the xMsBlobSequenceNumber value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsBlobSequenceNumber(Long xMsBlobSequenceNumber) { - this.xMsBlobSequenceNumber = xMsBlobSequenceNumber; - return this; - } - - /** - * Get the xMsCopyProgress property: The x-ms-copy-progress property. - * - * @return the xMsCopyProgress value. - */ - public String getXMsCopyProgress() { - return this.xMsCopyProgress; - } - - /** - * Set the xMsCopyProgress property: The x-ms-copy-progress property. - * - * @param xMsCopyProgress the xMsCopyProgress value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsCopyProgress(String xMsCopyProgress) { - this.xMsCopyProgress = xMsCopyProgress; - return this; - } - - /** - * Get the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @return the xMsBlobCommittedBlockCount value. - */ - public Integer getXMsBlobCommittedBlockCount() { - return this.xMsBlobCommittedBlockCount; - } - - /** - * Set the xMsBlobCommittedBlockCount property: The x-ms-blob-committed-block-count property. - * - * @param xMsBlobCommittedBlockCount the xMsBlobCommittedBlockCount value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsBlobCommittedBlockCount(Integer xMsBlobCommittedBlockCount) { - this.xMsBlobCommittedBlockCount = xMsBlobCommittedBlockCount; - return this; - } - - /** - * Get the xMsBlobContentMd5 property: The x-ms-blob-content-md5 property. - * - * @return the xMsBlobContentMd5 value. - */ - public byte[] getXMsBlobContentMd5() { - return CoreUtils.clone(this.xMsBlobContentMd5); - } - - /** - * Set the xMsBlobContentMd5 property: The x-ms-blob-content-md5 property. - * - * @param xMsBlobContentMd5 the xMsBlobContentMd5 value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsBlobContentMd5(byte[] xMsBlobContentMd5) { - this.xMsBlobContentMd5 = CoreUtils.clone(xMsBlobContentMd5); - return this; - } - - /** - * Get the xMsMeta property: The x-ms-meta- property. - * - * @return the xMsMeta value. - */ - public Map getXMsMeta() { - return this.xMsMeta; - } - - /** - * Set the xMsMeta property: The x-ms-meta- property. - * - * @param xMsMeta the xMsMeta value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsMeta(Map xMsMeta) { - this.xMsMeta = xMsMeta; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. - * - * @return the xMsCopyCompletionTime value. - */ - public OffsetDateTime getXMsCopyCompletionTime() { - if (this.xMsCopyCompletionTime == null) { - return null; - } - return this.xMsCopyCompletionTime.getDateTime(); - } - - /** - * Set the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. - * - * @param xMsCopyCompletionTime the xMsCopyCompletionTime value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsCopyCompletionTime(OffsetDateTime xMsCopyCompletionTime) { - if (xMsCopyCompletionTime == null) { - this.xMsCopyCompletionTime = null; - } else { - this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); - } - return this; - } - - /** - * Get the acceptRanges property: The Accept-Ranges property. - * - * @return the acceptRanges value. - */ - public String getAcceptRanges() { - return this.acceptRanges; - } - - /** - * Set the acceptRanges property: The Accept-Ranges property. - * - * @param acceptRanges the acceptRanges value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setAcceptRanges(String acceptRanges) { - this.acceptRanges = acceptRanges; - return this; - } - - /** - * Get the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @return the xMsServerEncrypted value. - */ - public Boolean isXMsServerEncrypted() { - return this.xMsServerEncrypted; - } - - /** - * Set the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @param xMsServerEncrypted the xMsServerEncrypted value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsServerEncrypted(Boolean xMsServerEncrypted) { - this.xMsServerEncrypted = xMsServerEncrypted; - return this; - } - - /** - * Get the cacheControl property: The Cache-Control property. - * - * @return the cacheControl value. - */ - public String getCacheControl() { - return this.cacheControl; - } - - /** - * Set the cacheControl property: The Cache-Control property. - * - * @param cacheControl the cacheControl value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the contentDisposition property: The Content-Disposition property. - * - * @return the contentDisposition value. - */ - public String getContentDisposition() { - return this.contentDisposition; - } - - /** - * Set the contentDisposition property: The Content-Disposition property. - * - * @param contentDisposition the contentDisposition value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setContentDisposition(String contentDisposition) { - this.contentDisposition = contentDisposition; - return this; - } - - /** - * Get the xMsCopyStatus property: The x-ms-copy-status property. - * - * @return the xMsCopyStatus value. - */ - public CopyStatusType getXMsCopyStatus() { - return this.xMsCopyStatus; - } - - /** - * Set the xMsCopyStatus property: The x-ms-copy-status property. - * - * @param xMsCopyStatus the xMsCopyStatus value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsCopyStatus(CopyStatusType xMsCopyStatus) { - this.xMsCopyStatus = xMsCopyStatus; - return this; - } - - /** - * Get the contentLanguage property: The Content-Language property. - * - * @return the contentLanguage value. - */ - public String getContentLanguage() { - return this.contentLanguage; - } - - /** - * Set the contentLanguage property: The Content-Language property. - * - * @param contentLanguage the contentLanguage value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlobsQueryHeaders object itself. - */ - public BlobsQueryHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsReleaseLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsReleaseLeaseHeaders.java deleted file mode 100644 index 3e406bc913f3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsReleaseLeaseHeaders.java +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsReleaseLeaseHeaders model. - */ -@Fluent -public final class BlobsReleaseLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsReleaseLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsReleaseLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsReleaseLeaseHeaders object itself. - */ - public BlobsReleaseLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsReleaseLeaseHeaders object itself. - */ - public BlobsReleaseLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsReleaseLeaseHeaders object itself. - */ - public BlobsReleaseLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsReleaseLeaseHeaders object itself. - */ - public BlobsReleaseLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsReleaseLeaseHeaders object itself. - */ - public BlobsReleaseLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsReleaseLeaseHeaders object itself. - */ - public BlobsReleaseLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsRenameHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsRenameHeaders.java deleted file mode 100644 index b772b3519cdc..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsRenameHeaders.java +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The BlobsRenameHeaders model. */ -@Fluent -public final class BlobsRenameHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The Content-Length property. - */ - private Long contentLength; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsRenameHeaders object itself. - */ - public BlobsRenameHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsRenameHeaders object itself. - */ - public BlobsRenameHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsRenameHeaders object itself. - */ - public BlobsRenameHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the contentLength property: The Content-Length property. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return this.contentLength; - } - - /** - * Set the contentLength property: The Content-Length property. - * - * @param contentLength the contentLength value to set. - * @return the BlobsRenameHeaders object itself. - */ - public BlobsRenameHeaders setContentLength(Long contentLength) { - this.contentLength = contentLength; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsRenameHeaders object itself. - */ - public BlobsRenameHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsRenameHeaders object itself. - */ - public BlobsRenameHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the BlobsRenameHeaders object itself. - */ - public BlobsRenameHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsRenewLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsRenewLeaseHeaders.java deleted file mode 100644 index 9c6ab394e58c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsRenewLeaseHeaders.java +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsRenewLeaseHeaders model. - */ -@Fluent -public final class BlobsRenewLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-lease-id property. - */ - private String xMsLeaseId; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_LEASE_ID = HttpHeaderName.fromString("x-ms-lease-id"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsRenewLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsRenewLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.xMsLeaseId = rawHeaders.getValue(X_MS_LEASE_ID); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsRenewLeaseHeaders object itself. - */ - public BlobsRenewLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsRenewLeaseHeaders object itself. - */ - public BlobsRenewLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsLeaseId property: The x-ms-lease-id property. - * - * @return the xMsLeaseId value. - */ - public String getXMsLeaseId() { - return this.xMsLeaseId; - } - - /** - * Set the xMsLeaseId property: The x-ms-lease-id property. - * - * @param xMsLeaseId the xMsLeaseId value to set. - * @return the BlobsRenewLeaseHeaders object itself. - */ - public BlobsRenewLeaseHeaders setXMsLeaseId(String xMsLeaseId) { - this.xMsLeaseId = xMsLeaseId; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsRenewLeaseHeaders object itself. - */ - public BlobsRenewLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsRenewLeaseHeaders object itself. - */ - public BlobsRenewLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsRenewLeaseHeaders object itself. - */ - public BlobsRenewLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsRenewLeaseHeaders object itself. - */ - public BlobsRenewLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetAccessControlHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetAccessControlHeaders.java deleted file mode 100644 index 0f8d1d705788..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetAccessControlHeaders.java +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The BlobsSetAccessControlHeaders model. */ -@Fluent -public final class BlobsSetAccessControlHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsSetAccessControlHeaders object itself. - */ - public BlobsSetAccessControlHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsSetAccessControlHeaders object itself. - */ - public BlobsSetAccessControlHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsSetAccessControlHeaders object itself. - */ - public BlobsSetAccessControlHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsSetAccessControlHeaders object itself. - */ - public BlobsSetAccessControlHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the BlobsSetAccessControlHeaders object itself. - */ - public BlobsSetAccessControlHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetExpiryHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetExpiryHeaders.java deleted file mode 100644 index 2a0b94222531..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetExpiryHeaders.java +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsSetExpiryHeaders model. - */ -@Fluent -public final class BlobsSetExpiryHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsSetExpiryHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsSetExpiryHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsSetExpiryHeaders object itself. - */ - public BlobsSetExpiryHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsSetExpiryHeaders object itself. - */ - public BlobsSetExpiryHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsSetExpiryHeaders object itself. - */ - public BlobsSetExpiryHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsSetExpiryHeaders object itself. - */ - public BlobsSetExpiryHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsSetExpiryHeaders object itself. - */ - public BlobsSetExpiryHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsSetExpiryHeaders object itself. - */ - public BlobsSetExpiryHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetHttpHeadersHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetHttpHeadersHeaders.java deleted file mode 100644 index 72c91deab0f1..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetHttpHeadersHeaders.java +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsSetHttpHeadersHeaders model. - */ -@Fluent -public final class BlobsSetHttpHeadersHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long xMsBlobSequenceNumber; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_BLOB_SEQUENCE_NUMBER - = HttpHeaderName.fromString("x-ms-blob-sequence-number"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsSetHttpHeadersHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsSetHttpHeadersHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsBlobSequenceNumber = rawHeaders.getValue(X_MS_BLOB_SEQUENCE_NUMBER); - if (xMsBlobSequenceNumber != null) { - this.xMsBlobSequenceNumber = Long.parseLong(xMsBlobSequenceNumber); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsSetHttpHeadersHeaders object itself. - */ - public BlobsSetHttpHeadersHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsSetHttpHeadersHeaders object itself. - */ - public BlobsSetHttpHeadersHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the xMsBlobSequenceNumber value. - */ - public Long getXMsBlobSequenceNumber() { - return this.xMsBlobSequenceNumber; - } - - /** - * Set the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param xMsBlobSequenceNumber the xMsBlobSequenceNumber value to set. - * @return the BlobsSetHttpHeadersHeaders object itself. - */ - public BlobsSetHttpHeadersHeaders setXMsBlobSequenceNumber(Long xMsBlobSequenceNumber) { - this.xMsBlobSequenceNumber = xMsBlobSequenceNumber; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsSetHttpHeadersHeaders object itself. - */ - public BlobsSetHttpHeadersHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsSetHttpHeadersHeaders object itself. - */ - public BlobsSetHttpHeadersHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsSetHttpHeadersHeaders object itself. - */ - public BlobsSetHttpHeadersHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsSetHttpHeadersHeaders object itself. - */ - public BlobsSetHttpHeadersHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetImmutabilityPolicyHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetImmutabilityPolicyHeaders.java deleted file mode 100644 index 5e7e019ecc18..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetImmutabilityPolicyHeaders.java +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import java.time.OffsetDateTime; - -/** - * The BlobsSetImmutabilityPolicyHeaders model. - */ -@Fluent -public final class BlobsSetImmutabilityPolicyHeaders { - /* - * The x-ms-immutability-policy-mode property. - */ - private BlobImmutabilityPolicyMode xMsImmutabilityPolicyMode; - - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-immutability-policy-until-date property. - */ - private DateTimeRfc1123 xMsImmutabilityPolicyUntilDate; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_IMMUTABILITY_POLICY_MODE - = HttpHeaderName.fromString("x-ms-immutability-policy-mode"); - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_IMMUTABILITY_POLICY_UNTIL_DATE - = HttpHeaderName.fromString("x-ms-immutability-policy-until-date"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsSetImmutabilityPolicyHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsSetImmutabilityPolicyHeaders(HttpHeaders rawHeaders) { - String xMsImmutabilityPolicyMode = rawHeaders.getValue(X_MS_IMMUTABILITY_POLICY_MODE); - if (xMsImmutabilityPolicyMode != null) { - this.xMsImmutabilityPolicyMode = BlobImmutabilityPolicyMode.fromString(xMsImmutabilityPolicyMode); - } - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsImmutabilityPolicyUntilDate = rawHeaders.getValue(X_MS_IMMUTABILITY_POLICY_UNTIL_DATE); - if (xMsImmutabilityPolicyUntilDate != null) { - this.xMsImmutabilityPolicyUntilDate = new DateTimeRfc1123(xMsImmutabilityPolicyUntilDate); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsImmutabilityPolicyMode property: The x-ms-immutability-policy-mode property. - * - * @return the xMsImmutabilityPolicyMode value. - */ - public BlobImmutabilityPolicyMode getXMsImmutabilityPolicyMode() { - return this.xMsImmutabilityPolicyMode; - } - - /** - * Set the xMsImmutabilityPolicyMode property: The x-ms-immutability-policy-mode property. - * - * @param xMsImmutabilityPolicyMode the xMsImmutabilityPolicyMode value to set. - * @return the BlobsSetImmutabilityPolicyHeaders object itself. - */ - public BlobsSetImmutabilityPolicyHeaders - setXMsImmutabilityPolicyMode(BlobImmutabilityPolicyMode xMsImmutabilityPolicyMode) { - this.xMsImmutabilityPolicyMode = xMsImmutabilityPolicyMode; - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsSetImmutabilityPolicyHeaders object itself. - */ - public BlobsSetImmutabilityPolicyHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsImmutabilityPolicyUntilDate property: The x-ms-immutability-policy-until-date property. - * - * @return the xMsImmutabilityPolicyUntilDate value. - */ - public OffsetDateTime getXMsImmutabilityPolicyUntilDate() { - if (this.xMsImmutabilityPolicyUntilDate == null) { - return null; - } - return this.xMsImmutabilityPolicyUntilDate.getDateTime(); - } - - /** - * Set the xMsImmutabilityPolicyUntilDate property: The x-ms-immutability-policy-until-date property. - * - * @param xMsImmutabilityPolicyUntilDate the xMsImmutabilityPolicyUntilDate value to set. - * @return the BlobsSetImmutabilityPolicyHeaders object itself. - */ - public BlobsSetImmutabilityPolicyHeaders - setXMsImmutabilityPolicyUntilDate(OffsetDateTime xMsImmutabilityPolicyUntilDate) { - if (xMsImmutabilityPolicyUntilDate == null) { - this.xMsImmutabilityPolicyUntilDate = null; - } else { - this.xMsImmutabilityPolicyUntilDate = new DateTimeRfc1123(xMsImmutabilityPolicyUntilDate); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsSetImmutabilityPolicyHeaders object itself. - */ - public BlobsSetImmutabilityPolicyHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsSetImmutabilityPolicyHeaders object itself. - */ - public BlobsSetImmutabilityPolicyHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsSetImmutabilityPolicyHeaders object itself. - */ - public BlobsSetImmutabilityPolicyHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetLegalHoldHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetLegalHoldHeaders.java deleted file mode 100644 index da39f6609b9b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetLegalHoldHeaders.java +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsSetLegalHoldHeaders model. - */ -@Fluent -public final class BlobsSetLegalHoldHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-legal-hold property. - */ - private Boolean xMsLegalHold; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_LEGAL_HOLD = HttpHeaderName.fromString("x-ms-legal-hold"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsSetLegalHoldHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsSetLegalHoldHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsLegalHold = rawHeaders.getValue(X_MS_LEGAL_HOLD); - if (xMsLegalHold != null) { - this.xMsLegalHold = Boolean.parseBoolean(xMsLegalHold); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsSetLegalHoldHeaders object itself. - */ - public BlobsSetLegalHoldHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsSetLegalHoldHeaders object itself. - */ - public BlobsSetLegalHoldHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsLegalHold property: The x-ms-legal-hold property. - * - * @return the xMsLegalHold value. - */ - public Boolean isXMsLegalHold() { - return this.xMsLegalHold; - } - - /** - * Set the xMsLegalHold property: The x-ms-legal-hold property. - * - * @param xMsLegalHold the xMsLegalHold value to set. - * @return the BlobsSetLegalHoldHeaders object itself. - */ - public BlobsSetLegalHoldHeaders setXMsLegalHold(Boolean xMsLegalHold) { - this.xMsLegalHold = xMsLegalHold; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsSetLegalHoldHeaders object itself. - */ - public BlobsSetLegalHoldHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsSetLegalHoldHeaders object itself. - */ - public BlobsSetLegalHoldHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetMetadataHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetMetadataHeaders.java deleted file mode 100644 index a0ebd14cd9d6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetMetadataHeaders.java +++ /dev/null @@ -1,321 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsSetMetadataHeaders model. - */ -@Fluent -public final class BlobsSetMetadataHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsSetMetadataHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsSetMetadataHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlobsSetMetadataHeaders object itself. - */ - public BlobsSetMetadataHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetTagsHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetTagsHeaders.java deleted file mode 100644 index 9bc6fe450dba..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetTagsHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsSetTagsHeaders model. - */ -@Fluent -public final class BlobsSetTagsHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsSetTagsHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsSetTagsHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsSetTagsHeaders object itself. - */ - public BlobsSetTagsHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsSetTagsHeaders object itself. - */ - public BlobsSetTagsHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsSetTagsHeaders object itself. - */ - public BlobsSetTagsHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsSetTagsHeaders object itself. - */ - public BlobsSetTagsHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetTierHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetTierHeaders.java deleted file mode 100644 index a10d31c653b2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetTierHeaders.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; - -/** - * The BlobsSetTierHeaders model. - */ -@Fluent -public final class BlobsSetTierHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsSetTierHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsSetTierHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsSetTierHeaders object itself. - */ - public BlobsSetTierHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsSetTierHeaders object itself. - */ - public BlobsSetTierHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsSetTierHeaders object itself. - */ - public BlobsSetTierHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsStartCopyFromURLHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsStartCopyFromURLHeaders.java deleted file mode 100644 index 8d0fc6cbf12a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsStartCopyFromURLHeaders.java +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.CopyStatusType; -import java.time.OffsetDateTime; - -/** - * The BlobsStartCopyFromURLHeaders model. - */ -@Fluent -public final class BlobsStartCopyFromURLHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-copy-id property. - */ - private String xMsCopyId; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-copy-status property. - */ - private CopyStatusType xMsCopyStatus; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsStartCopyFromURLHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsStartCopyFromURLHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsCopyId = rawHeaders.getValue(X_MS_COPY_ID); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - String xMsCopyStatus = rawHeaders.getValue(X_MS_COPY_STATUS); - if (xMsCopyStatus != null) { - this.xMsCopyStatus = CopyStatusType.fromString(xMsCopyStatus); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsStartCopyFromURLHeaders object itself. - */ - public BlobsStartCopyFromURLHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsCopyId property: The x-ms-copy-id property. - * - * @return the xMsCopyId value. - */ - public String getXMsCopyId() { - return this.xMsCopyId; - } - - /** - * Set the xMsCopyId property: The x-ms-copy-id property. - * - * @param xMsCopyId the xMsCopyId value to set. - * @return the BlobsStartCopyFromURLHeaders object itself. - */ - public BlobsStartCopyFromURLHeaders setXMsCopyId(String xMsCopyId) { - this.xMsCopyId = xMsCopyId; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlobsStartCopyFromURLHeaders object itself. - */ - public BlobsStartCopyFromURLHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobsStartCopyFromURLHeaders object itself. - */ - public BlobsStartCopyFromURLHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the BlobsStartCopyFromURLHeaders object itself. - */ - public BlobsStartCopyFromURLHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsCopyStatus property: The x-ms-copy-status property. - * - * @return the xMsCopyStatus value. - */ - public CopyStatusType getXMsCopyStatus() { - return this.xMsCopyStatus; - } - - /** - * Set the xMsCopyStatus property: The x-ms-copy-status property. - * - * @param xMsCopyStatus the xMsCopyStatus value to set. - * @return the BlobsStartCopyFromURLHeaders object itself. - */ - public BlobsStartCopyFromURLHeaders setXMsCopyStatus(CopyStatusType xMsCopyStatus) { - this.xMsCopyStatus = xMsCopyStatus; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsStartCopyFromURLHeaders object itself. - */ - public BlobsStartCopyFromURLHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsStartCopyFromURLHeaders object itself. - */ - public BlobsStartCopyFromURLHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsStartCopyFromURLHeaders object itself. - */ - public BlobsStartCopyFromURLHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsUndeleteHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsUndeleteHeaders.java deleted file mode 100644 index 1f4447341af7..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsUndeleteHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlobsUndeleteHeaders model. - */ -@Fluent -public final class BlobsUndeleteHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlobsUndeleteHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlobsUndeleteHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlobsUndeleteHeaders object itself. - */ - public BlobsUndeleteHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlobsUndeleteHeaders object itself. - */ - public BlobsUndeleteHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlobsUndeleteHeaders object itself. - */ - public BlobsUndeleteHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlobsUndeleteHeaders object itself. - */ - public BlobsUndeleteHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsCommitBlockListHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsCommitBlockListHeaders.java deleted file mode 100644 index 303156d60326..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsCommitBlockListHeaders.java +++ /dev/null @@ -1,383 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The BlockBlobsCommitBlockListHeaders model. - */ -@Fluent -public final class BlockBlobsCommitBlockListHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlockBlobsCommitBlockListHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlockBlobsCommitBlockListHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlockBlobsCommitBlockListHeaders object itself. - */ - public BlockBlobsCommitBlockListHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsGetBlockListHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsGetBlockListHeaders.java deleted file mode 100644 index 30e91dd9fb7e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsGetBlockListHeaders.java +++ /dev/null @@ -1,262 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The BlockBlobsGetBlockListHeaders model. - */ -@Fluent -public final class BlockBlobsGetBlockListHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-blob-content-length property. - */ - private Long xMsBlobContentLength; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-Type property. - */ - private String contentType; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_BLOB_CONTENT_LENGTH - = HttpHeaderName.fromString("x-ms-blob-content-length"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlockBlobsGetBlockListHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlockBlobsGetBlockListHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsBlobContentLength = rawHeaders.getValue(X_MS_BLOB_CONTENT_LENGTH); - if (xMsBlobContentLength != null) { - this.xMsBlobContentLength = Long.parseLong(xMsBlobContentLength); - } - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlockBlobsGetBlockListHeaders object itself. - */ - public BlockBlobsGetBlockListHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @return the xMsBlobContentLength value. - */ - public Long getXMsBlobContentLength() { - return this.xMsBlobContentLength; - } - - /** - * Set the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @param xMsBlobContentLength the xMsBlobContentLength value to set. - * @return the BlockBlobsGetBlockListHeaders object itself. - */ - public BlockBlobsGetBlockListHeaders setXMsBlobContentLength(Long xMsBlobContentLength) { - this.xMsBlobContentLength = xMsBlobContentLength; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlockBlobsGetBlockListHeaders object itself. - */ - public BlockBlobsGetBlockListHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlockBlobsGetBlockListHeaders object itself. - */ - public BlockBlobsGetBlockListHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlockBlobsGetBlockListHeaders object itself. - */ - public BlockBlobsGetBlockListHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlockBlobsGetBlockListHeaders object itself. - */ - public BlockBlobsGetBlockListHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlockBlobsGetBlockListHeaders object itself. - */ - public BlockBlobsGetBlockListHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the BlockBlobsGetBlockListHeaders object itself. - */ - public BlockBlobsGetBlockListHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsPutBlobFromUrlHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsPutBlobFromUrlHeaders.java deleted file mode 100644 index 27b376404458..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsPutBlobFromUrlHeaders.java +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The BlockBlobsPutBlobFromUrlHeaders model. - */ -@Fluent -public final class BlockBlobsPutBlobFromUrlHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlockBlobsPutBlobFromUrlHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlockBlobsPutBlobFromUrlHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlockBlobsPutBlobFromUrlHeaders object itself. - */ - public BlockBlobsPutBlobFromUrlHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsStageBlockFromURLHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsStageBlockFromURLHeaders.java deleted file mode 100644 index 1e2d2f524d05..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsStageBlockFromURLHeaders.java +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The BlockBlobsStageBlockFromURLHeaders model. - */ -@Fluent -public final class BlockBlobsStageBlockFromURLHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlockBlobsStageBlockFromURLHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlockBlobsStageBlockFromURLHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlockBlobsStageBlockFromURLHeaders object itself. - */ - public BlockBlobsStageBlockFromURLHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the BlockBlobsStageBlockFromURLHeaders object itself. - */ - public BlockBlobsStageBlockFromURLHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the BlockBlobsStageBlockFromURLHeaders object itself. - */ - public BlockBlobsStageBlockFromURLHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlockBlobsStageBlockFromURLHeaders object itself. - */ - public BlockBlobsStageBlockFromURLHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the BlockBlobsStageBlockFromURLHeaders object itself. - */ - public BlockBlobsStageBlockFromURLHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlockBlobsStageBlockFromURLHeaders object itself. - */ - public BlockBlobsStageBlockFromURLHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlockBlobsStageBlockFromURLHeaders object itself. - */ - public BlockBlobsStageBlockFromURLHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the BlockBlobsStageBlockFromURLHeaders object itself. - */ - public BlockBlobsStageBlockFromURLHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlockBlobsStageBlockFromURLHeaders object itself. - */ - public BlockBlobsStageBlockFromURLHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsStageBlockHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsStageBlockHeaders.java deleted file mode 100644 index 79fd93864fb8..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsStageBlockHeaders.java +++ /dev/null @@ -1,321 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The BlockBlobsStageBlockHeaders model. - */ -@Fluent -public final class BlockBlobsStageBlockHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-structured-body property. - */ - private String xMsStructuredBody; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_STRUCTURED_BODY = HttpHeaderName.fromString("x-ms-structured-body"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlockBlobsStageBlockHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlockBlobsStageBlockHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsStructuredBody = rawHeaders.getValue(X_MS_STRUCTURED_BODY); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsStructuredBody property: The x-ms-structured-body property. - * - * @return the xMsStructuredBody value. - */ - public String getXMsStructuredBody() { - return this.xMsStructuredBody; - } - - /** - * Set the xMsStructuredBody property: The x-ms-structured-body property. - * - * @param xMsStructuredBody the xMsStructuredBody value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setXMsStructuredBody(String xMsStructuredBody) { - this.xMsStructuredBody = xMsStructuredBody; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlockBlobsStageBlockHeaders object itself. - */ - public BlockBlobsStageBlockHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsUploadHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsUploadHeaders.java deleted file mode 100644 index de90dd871288..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlockBlobsUploadHeaders.java +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The BlockBlobsUploadHeaders model. - */ -@Fluent -public final class BlockBlobsUploadHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-structured-body property. - */ - private String xMsStructuredBody; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_STRUCTURED_BODY = HttpHeaderName.fromString("x-ms-structured-body"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of BlockBlobsUploadHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public BlockBlobsUploadHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsStructuredBody = rawHeaders.getValue(X_MS_STRUCTURED_BODY); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsStructuredBody property: The x-ms-structured-body property. - * - * @return the xMsStructuredBody value. - */ - public String getXMsStructuredBody() { - return this.xMsStructuredBody; - } - - /** - * Set the xMsStructuredBody property: The x-ms-structured-body property. - * - * @param xMsStructuredBody the xMsStructuredBody value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setXMsStructuredBody(String xMsStructuredBody) { - this.xMsStructuredBody = xMsStructuredBody; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the BlockBlobsUploadHeaders object itself. - */ - public BlockBlobsUploadHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersAcquireLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersAcquireLeaseHeaders.java deleted file mode 100644 index d5d9d55126af..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersAcquireLeaseHeaders.java +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersAcquireLeaseHeaders model. - */ -@Fluent -public final class ContainersAcquireLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-lease-id property. - */ - private String xMsLeaseId; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_LEASE_ID = HttpHeaderName.fromString("x-ms-lease-id"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersAcquireLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersAcquireLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.xMsLeaseId = rawHeaders.getValue(X_MS_LEASE_ID); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersAcquireLeaseHeaders object itself. - */ - public ContainersAcquireLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersAcquireLeaseHeaders object itself. - */ - public ContainersAcquireLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsLeaseId property: The x-ms-lease-id property. - * - * @return the xMsLeaseId value. - */ - public String getXMsLeaseId() { - return this.xMsLeaseId; - } - - /** - * Set the xMsLeaseId property: The x-ms-lease-id property. - * - * @param xMsLeaseId the xMsLeaseId value to set. - * @return the ContainersAcquireLeaseHeaders object itself. - */ - public ContainersAcquireLeaseHeaders setXMsLeaseId(String xMsLeaseId) { - this.xMsLeaseId = xMsLeaseId; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersAcquireLeaseHeaders object itself. - */ - public ContainersAcquireLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersAcquireLeaseHeaders object itself. - */ - public ContainersAcquireLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersAcquireLeaseHeaders object itself. - */ - public ContainersAcquireLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersAcquireLeaseHeaders object itself. - */ - public ContainersAcquireLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersBreakLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersBreakLeaseHeaders.java deleted file mode 100644 index e98ae25057fb..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersBreakLeaseHeaders.java +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersBreakLeaseHeaders model. - */ -@Fluent -public final class ContainersBreakLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-lease-time property. - */ - private Integer xMsLeaseTime; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_LEASE_TIME = HttpHeaderName.fromString("x-ms-lease-time"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersBreakLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersBreakLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsLeaseTime = rawHeaders.getValue(X_MS_LEASE_TIME); - if (xMsLeaseTime != null) { - this.xMsLeaseTime = Integer.parseInt(xMsLeaseTime); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersBreakLeaseHeaders object itself. - */ - public ContainersBreakLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersBreakLeaseHeaders object itself. - */ - public ContainersBreakLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsLeaseTime property: The x-ms-lease-time property. - * - * @return the xMsLeaseTime value. - */ - public Integer getXMsLeaseTime() { - return this.xMsLeaseTime; - } - - /** - * Set the xMsLeaseTime property: The x-ms-lease-time property. - * - * @param xMsLeaseTime the xMsLeaseTime value to set. - * @return the ContainersBreakLeaseHeaders object itself. - */ - public ContainersBreakLeaseHeaders setXMsLeaseTime(Integer xMsLeaseTime) { - this.xMsLeaseTime = xMsLeaseTime; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersBreakLeaseHeaders object itself. - */ - public ContainersBreakLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersBreakLeaseHeaders object itself. - */ - public ContainersBreakLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersBreakLeaseHeaders object itself. - */ - public ContainersBreakLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersBreakLeaseHeaders object itself. - */ - public ContainersBreakLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersChangeLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersChangeLeaseHeaders.java deleted file mode 100644 index 587179e913d9..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersChangeLeaseHeaders.java +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersChangeLeaseHeaders model. - */ -@Fluent -public final class ContainersChangeLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-lease-id property. - */ - private String xMsLeaseId; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_LEASE_ID = HttpHeaderName.fromString("x-ms-lease-id"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersChangeLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersChangeLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.xMsLeaseId = rawHeaders.getValue(X_MS_LEASE_ID); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersChangeLeaseHeaders object itself. - */ - public ContainersChangeLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersChangeLeaseHeaders object itself. - */ - public ContainersChangeLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsLeaseId property: The x-ms-lease-id property. - * - * @return the xMsLeaseId value. - */ - public String getXMsLeaseId() { - return this.xMsLeaseId; - } - - /** - * Set the xMsLeaseId property: The x-ms-lease-id property. - * - * @param xMsLeaseId the xMsLeaseId value to set. - * @return the ContainersChangeLeaseHeaders object itself. - */ - public ContainersChangeLeaseHeaders setXMsLeaseId(String xMsLeaseId) { - this.xMsLeaseId = xMsLeaseId; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersChangeLeaseHeaders object itself. - */ - public ContainersChangeLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersChangeLeaseHeaders object itself. - */ - public ContainersChangeLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersChangeLeaseHeaders object itself. - */ - public ContainersChangeLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersChangeLeaseHeaders object itself. - */ - public ContainersChangeLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersCreateHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersCreateHeaders.java deleted file mode 100644 index b68c7814c67b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersCreateHeaders.java +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersCreateHeaders model. - */ -@Fluent -public final class ContainersCreateHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersCreateHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersCreateHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersCreateHeaders object itself. - */ - public ContainersCreateHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersCreateHeaders object itself. - */ - public ContainersCreateHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersCreateHeaders object itself. - */ - public ContainersCreateHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersCreateHeaders object itself. - */ - public ContainersCreateHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersCreateHeaders object itself. - */ - public ContainersCreateHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersCreateHeaders object itself. - */ - public ContainersCreateHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersDeleteHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersDeleteHeaders.java deleted file mode 100644 index 1764c6373bc0..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersDeleteHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersDeleteHeaders model. - */ -@Fluent -public final class ContainersDeleteHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersDeleteHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersDeleteHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersDeleteHeaders object itself. - */ - public ContainersDeleteHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersDeleteHeaders object itself. - */ - public ContainersDeleteHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersDeleteHeaders object itself. - */ - public ContainersDeleteHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersDeleteHeaders object itself. - */ - public ContainersDeleteHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersFilterBlobsHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersFilterBlobsHeaders.java deleted file mode 100644 index c38a4de459db..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersFilterBlobsHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersFilterBlobsHeaders model. - */ -@Fluent -public final class ContainersFilterBlobsHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersFilterBlobsHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersFilterBlobsHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersFilterBlobsHeaders object itself. - */ - public ContainersFilterBlobsHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersFilterBlobsHeaders object itself. - */ - public ContainersFilterBlobsHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersFilterBlobsHeaders object itself. - */ - public ContainersFilterBlobsHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersFilterBlobsHeaders object itself. - */ - public ContainersFilterBlobsHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetAccessPolicyHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetAccessPolicyHeaders.java deleted file mode 100644 index 46ac1b4d27b9..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetAccessPolicyHeaders.java +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.PublicAccessType; -import java.time.OffsetDateTime; - -/** - * The ContainersGetAccessPolicyHeaders model. - */ -@Fluent -public final class ContainersGetAccessPolicyHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-blob-public-access property. - */ - private PublicAccessType xMsBlobPublicAccess; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_BLOB_PUBLIC_ACCESS = HttpHeaderName.fromString("x-ms-blob-public-access"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersGetAccessPolicyHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersGetAccessPolicyHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - String xMsBlobPublicAccess = rawHeaders.getValue(X_MS_BLOB_PUBLIC_ACCESS); - if (xMsBlobPublicAccess != null) { - this.xMsBlobPublicAccess = PublicAccessType.fromString(xMsBlobPublicAccess); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersGetAccessPolicyHeaders object itself. - */ - public ContainersGetAccessPolicyHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersGetAccessPolicyHeaders object itself. - */ - public ContainersGetAccessPolicyHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersGetAccessPolicyHeaders object itself. - */ - public ContainersGetAccessPolicyHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsBlobPublicAccess property: The x-ms-blob-public-access property. - * - * @return the xMsBlobPublicAccess value. - */ - public PublicAccessType getXMsBlobPublicAccess() { - return this.xMsBlobPublicAccess; - } - - /** - * Set the xMsBlobPublicAccess property: The x-ms-blob-public-access property. - * - * @param xMsBlobPublicAccess the xMsBlobPublicAccess value to set. - * @return the ContainersGetAccessPolicyHeaders object itself. - */ - public ContainersGetAccessPolicyHeaders setXMsBlobPublicAccess(PublicAccessType xMsBlobPublicAccess) { - this.xMsBlobPublicAccess = xMsBlobPublicAccess; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersGetAccessPolicyHeaders object itself. - */ - public ContainersGetAccessPolicyHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersGetAccessPolicyHeaders object itself. - */ - public ContainersGetAccessPolicyHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersGetAccessPolicyHeaders object itself. - */ - public ContainersGetAccessPolicyHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetAccountInfoHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetAccountInfoHeaders.java deleted file mode 100644 index a5fc4bfb9066..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetAccountInfoHeaders.java +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.AccountKind; -import com.azure.storage.blob.models.SkuName; -import java.time.OffsetDateTime; - -/** - * The ContainersGetAccountInfoHeaders model. - */ -@Fluent -public final class ContainersGetAccountInfoHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-account-kind property. - */ - private AccountKind xMsAccountKind; - - /* - * The x-ms-is-hns-enabled property. - */ - private Boolean xMsIsHnsEnabled; - - /* - * The x-ms-sku-name property. - */ - private SkuName xMsSkuName; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_ACCOUNT_KIND = HttpHeaderName.fromString("x-ms-account-kind"); - - private static final HttpHeaderName X_MS_IS_HNS_ENABLED = HttpHeaderName.fromString("x-ms-is-hns-enabled"); - - private static final HttpHeaderName X_MS_SKU_NAME = HttpHeaderName.fromString("x-ms-sku-name"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersGetAccountInfoHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersGetAccountInfoHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsAccountKind = rawHeaders.getValue(X_MS_ACCOUNT_KIND); - if (xMsAccountKind != null) { - this.xMsAccountKind = AccountKind.fromString(xMsAccountKind); - } - String xMsIsHnsEnabled = rawHeaders.getValue(X_MS_IS_HNS_ENABLED); - if (xMsIsHnsEnabled != null) { - this.xMsIsHnsEnabled = Boolean.parseBoolean(xMsIsHnsEnabled); - } - String xMsSkuName = rawHeaders.getValue(X_MS_SKU_NAME); - if (xMsSkuName != null) { - this.xMsSkuName = SkuName.fromString(xMsSkuName); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersGetAccountInfoHeaders object itself. - */ - public ContainersGetAccountInfoHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsAccountKind property: The x-ms-account-kind property. - * - * @return the xMsAccountKind value. - */ - public AccountKind getXMsAccountKind() { - return this.xMsAccountKind; - } - - /** - * Set the xMsAccountKind property: The x-ms-account-kind property. - * - * @param xMsAccountKind the xMsAccountKind value to set. - * @return the ContainersGetAccountInfoHeaders object itself. - */ - public ContainersGetAccountInfoHeaders setXMsAccountKind(AccountKind xMsAccountKind) { - this.xMsAccountKind = xMsAccountKind; - return this; - } - - /** - * Get the xMsIsHnsEnabled property: The x-ms-is-hns-enabled property. - * - * @return the xMsIsHnsEnabled value. - */ - public Boolean isXMsIsHnsEnabled() { - return this.xMsIsHnsEnabled; - } - - /** - * Set the xMsIsHnsEnabled property: The x-ms-is-hns-enabled property. - * - * @param xMsIsHnsEnabled the xMsIsHnsEnabled value to set. - * @return the ContainersGetAccountInfoHeaders object itself. - */ - public ContainersGetAccountInfoHeaders setXMsIsHnsEnabled(Boolean xMsIsHnsEnabled) { - this.xMsIsHnsEnabled = xMsIsHnsEnabled; - return this; - } - - /** - * Get the xMsSkuName property: The x-ms-sku-name property. - * - * @return the xMsSkuName value. - */ - public SkuName getXMsSkuName() { - return this.xMsSkuName; - } - - /** - * Set the xMsSkuName property: The x-ms-sku-name property. - * - * @param xMsSkuName the xMsSkuName value to set. - * @return the ContainersGetAccountInfoHeaders object itself. - */ - public ContainersGetAccountInfoHeaders setXMsSkuName(SkuName xMsSkuName) { - this.xMsSkuName = xMsSkuName; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersGetAccountInfoHeaders object itself. - */ - public ContainersGetAccountInfoHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersGetAccountInfoHeaders object itself. - */ - public ContainersGetAccountInfoHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersGetAccountInfoHeaders object itself. - */ - public ContainersGetAccountInfoHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetPropertiesHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetPropertiesHeaders.java deleted file mode 100644 index 1fa24cb6d6d2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersGetPropertiesHeaders.java +++ /dev/null @@ -1,531 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeader; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import com.azure.storage.blob.models.PublicAccessType; -import java.time.OffsetDateTime; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * The ContainersGetPropertiesHeaders model. - */ -@Fluent -public final class ContainersGetPropertiesHeaders { - /* - * The x-ms-lease-status property. - */ - private LeaseStatusType xMsLeaseStatus; - - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-immutable-storage-with-versioning-enabled property. - */ - private Boolean xMsImmutableStorageWithVersioningEnabled; - - /* - * The x-ms-lease-state property. - */ - private LeaseStateType xMsLeaseState; - - /* - * The x-ms-deny-encryption-scope-override property. - */ - private Boolean xMsDenyEncryptionScopeOverride; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-meta- property. - */ - private Map xMsMeta; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The x-ms-has-legal-hold property. - */ - private Boolean xMsHasLegalHold; - - /* - * The x-ms-default-encryption-scope property. - */ - private String xMsDefaultEncryptionScope; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-has-immutability-policy property. - */ - private Boolean xMsHasImmutabilityPolicy; - - /* - * The x-ms-lease-duration property. - */ - private LeaseDurationType xMsLeaseDuration; - - /* - * The x-ms-blob-public-access property. - */ - private PublicAccessType xMsBlobPublicAccess; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - private static final HttpHeaderName X_MS_LEASE_STATUS = HttpHeaderName.fromString("x-ms-lease-status"); - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_IMMUTABLE_STORAGE_WITH_VERSIONING_ENABLED - = HttpHeaderName.fromString("x-ms-immutable-storage-with-versioning-enabled"); - - private static final HttpHeaderName X_MS_LEASE_STATE = HttpHeaderName.fromString("x-ms-lease-state"); - - private static final HttpHeaderName X_MS_DENY_ENCRYPTION_SCOPE_OVERRIDE - = HttpHeaderName.fromString("x-ms-deny-encryption-scope-override"); - - private static final HttpHeaderName X_MS_HAS_LEGAL_HOLD = HttpHeaderName.fromString("x-ms-has-legal-hold"); - - private static final HttpHeaderName X_MS_DEFAULT_ENCRYPTION_SCOPE - = HttpHeaderName.fromString("x-ms-default-encryption-scope"); - - private static final HttpHeaderName X_MS_HAS_IMMUTABILITY_POLICY - = HttpHeaderName.fromString("x-ms-has-immutability-policy"); - - private static final HttpHeaderName X_MS_LEASE_DURATION = HttpHeaderName.fromString("x-ms-lease-duration"); - - private static final HttpHeaderName X_MS_BLOB_PUBLIC_ACCESS = HttpHeaderName.fromString("x-ms-blob-public-access"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersGetPropertiesHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersGetPropertiesHeaders(HttpHeaders rawHeaders) { - String xMsLeaseStatus = rawHeaders.getValue(X_MS_LEASE_STATUS); - if (xMsLeaseStatus != null) { - this.xMsLeaseStatus = LeaseStatusType.fromString(xMsLeaseStatus); - } - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsImmutableStorageWithVersioningEnabled - = rawHeaders.getValue(X_MS_IMMUTABLE_STORAGE_WITH_VERSIONING_ENABLED); - if (xMsImmutableStorageWithVersioningEnabled != null) { - this.xMsImmutableStorageWithVersioningEnabled - = Boolean.parseBoolean(xMsImmutableStorageWithVersioningEnabled); - } - String xMsLeaseState = rawHeaders.getValue(X_MS_LEASE_STATE); - if (xMsLeaseState != null) { - this.xMsLeaseState = LeaseStateType.fromString(xMsLeaseState); - } - String xMsDenyEncryptionScopeOverride = rawHeaders.getValue(X_MS_DENY_ENCRYPTION_SCOPE_OVERRIDE); - if (xMsDenyEncryptionScopeOverride != null) { - this.xMsDenyEncryptionScopeOverride = Boolean.parseBoolean(xMsDenyEncryptionScopeOverride); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String xMsHasLegalHold = rawHeaders.getValue(X_MS_HAS_LEGAL_HOLD); - if (xMsHasLegalHold != null) { - this.xMsHasLegalHold = Boolean.parseBoolean(xMsHasLegalHold); - } - this.xMsDefaultEncryptionScope = rawHeaders.getValue(X_MS_DEFAULT_ENCRYPTION_SCOPE); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsHasImmutabilityPolicy = rawHeaders.getValue(X_MS_HAS_IMMUTABILITY_POLICY); - if (xMsHasImmutabilityPolicy != null) { - this.xMsHasImmutabilityPolicy = Boolean.parseBoolean(xMsHasImmutabilityPolicy); - } - String xMsLeaseDuration = rawHeaders.getValue(X_MS_LEASE_DURATION); - if (xMsLeaseDuration != null) { - this.xMsLeaseDuration = LeaseDurationType.fromString(xMsLeaseDuration); - } - String xMsBlobPublicAccess = rawHeaders.getValue(X_MS_BLOB_PUBLIC_ACCESS); - if (xMsBlobPublicAccess != null) { - this.xMsBlobPublicAccess = PublicAccessType.fromString(xMsBlobPublicAccess); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - Map xMsMetaHeaderCollection = new LinkedHashMap<>(); - - for (HttpHeader header : rawHeaders) { - String headerName = header.getName(); - if (headerName.startsWith("x-ms-meta-")) { - xMsMetaHeaderCollection.put(headerName.substring(10), header.getValue()); - } - } - - this.xMsMeta = xMsMetaHeaderCollection; - } - - /** - * Get the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @return the xMsLeaseStatus value. - */ - public LeaseStatusType getXMsLeaseStatus() { - return this.xMsLeaseStatus; - } - - /** - * Set the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @param xMsLeaseStatus the xMsLeaseStatus value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsLeaseStatus(LeaseStatusType xMsLeaseStatus) { - this.xMsLeaseStatus = xMsLeaseStatus; - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsImmutableStorageWithVersioningEnabled property: The x-ms-immutable-storage-with-versioning-enabled - * property. - * - * @return the xMsImmutableStorageWithVersioningEnabled value. - */ - public Boolean isXMsImmutableStorageWithVersioningEnabled() { - return this.xMsImmutableStorageWithVersioningEnabled; - } - - /** - * Set the xMsImmutableStorageWithVersioningEnabled property: The x-ms-immutable-storage-with-versioning-enabled - * property. - * - * @param xMsImmutableStorageWithVersioningEnabled the xMsImmutableStorageWithVersioningEnabled value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders - setXMsImmutableStorageWithVersioningEnabled(Boolean xMsImmutableStorageWithVersioningEnabled) { - this.xMsImmutableStorageWithVersioningEnabled = xMsImmutableStorageWithVersioningEnabled; - return this; - } - - /** - * Get the xMsLeaseState property: The x-ms-lease-state property. - * - * @return the xMsLeaseState value. - */ - public LeaseStateType getXMsLeaseState() { - return this.xMsLeaseState; - } - - /** - * Set the xMsLeaseState property: The x-ms-lease-state property. - * - * @param xMsLeaseState the xMsLeaseState value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsLeaseState(LeaseStateType xMsLeaseState) { - this.xMsLeaseState = xMsLeaseState; - return this; - } - - /** - * Get the xMsDenyEncryptionScopeOverride property: The x-ms-deny-encryption-scope-override property. - * - * @return the xMsDenyEncryptionScopeOverride value. - */ - public Boolean isXMsDenyEncryptionScopeOverride() { - return this.xMsDenyEncryptionScopeOverride; - } - - /** - * Set the xMsDenyEncryptionScopeOverride property: The x-ms-deny-encryption-scope-override property. - * - * @param xMsDenyEncryptionScopeOverride the xMsDenyEncryptionScopeOverride value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsDenyEncryptionScopeOverride(Boolean xMsDenyEncryptionScopeOverride) { - this.xMsDenyEncryptionScopeOverride = xMsDenyEncryptionScopeOverride; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsMeta property: The x-ms-meta- property. - * - * @return the xMsMeta value. - */ - public Map getXMsMeta() { - return this.xMsMeta; - } - - /** - * Set the xMsMeta property: The x-ms-meta- property. - * - * @param xMsMeta the xMsMeta value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsMeta(Map xMsMeta) { - this.xMsMeta = xMsMeta; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the xMsHasLegalHold property: The x-ms-has-legal-hold property. - * - * @return the xMsHasLegalHold value. - */ - public Boolean isXMsHasLegalHold() { - return this.xMsHasLegalHold; - } - - /** - * Set the xMsHasLegalHold property: The x-ms-has-legal-hold property. - * - * @param xMsHasLegalHold the xMsHasLegalHold value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsHasLegalHold(Boolean xMsHasLegalHold) { - this.xMsHasLegalHold = xMsHasLegalHold; - return this; - } - - /** - * Get the xMsDefaultEncryptionScope property: The x-ms-default-encryption-scope property. - * - * @return the xMsDefaultEncryptionScope value. - */ - public String getXMsDefaultEncryptionScope() { - return this.xMsDefaultEncryptionScope; - } - - /** - * Set the xMsDefaultEncryptionScope property: The x-ms-default-encryption-scope property. - * - * @param xMsDefaultEncryptionScope the xMsDefaultEncryptionScope value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsDefaultEncryptionScope(String xMsDefaultEncryptionScope) { - this.xMsDefaultEncryptionScope = xMsDefaultEncryptionScope; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsHasImmutabilityPolicy property: The x-ms-has-immutability-policy property. - * - * @return the xMsHasImmutabilityPolicy value. - */ - public Boolean isXMsHasImmutabilityPolicy() { - return this.xMsHasImmutabilityPolicy; - } - - /** - * Set the xMsHasImmutabilityPolicy property: The x-ms-has-immutability-policy property. - * - * @param xMsHasImmutabilityPolicy the xMsHasImmutabilityPolicy value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsHasImmutabilityPolicy(Boolean xMsHasImmutabilityPolicy) { - this.xMsHasImmutabilityPolicy = xMsHasImmutabilityPolicy; - return this; - } - - /** - * Get the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @return the xMsLeaseDuration value. - */ - public LeaseDurationType getXMsLeaseDuration() { - return this.xMsLeaseDuration; - } - - /** - * Set the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @param xMsLeaseDuration the xMsLeaseDuration value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsLeaseDuration(LeaseDurationType xMsLeaseDuration) { - this.xMsLeaseDuration = xMsLeaseDuration; - return this; - } - - /** - * Get the xMsBlobPublicAccess property: The x-ms-blob-public-access property. - * - * @return the xMsBlobPublicAccess value. - */ - public PublicAccessType getXMsBlobPublicAccess() { - return this.xMsBlobPublicAccess; - } - - /** - * Set the xMsBlobPublicAccess property: The x-ms-blob-public-access property. - * - * @param xMsBlobPublicAccess the xMsBlobPublicAccess value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsBlobPublicAccess(PublicAccessType xMsBlobPublicAccess) { - this.xMsBlobPublicAccess = xMsBlobPublicAccess; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersGetPropertiesHeaders object itself. - */ - public ContainersGetPropertiesHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersListBlobFlatSegmentHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersListBlobFlatSegmentHeaders.java deleted file mode 100644 index d1e6b59f8f66..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersListBlobFlatSegmentHeaders.java +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersListBlobFlatSegmentHeaders model. - */ -@Fluent -public final class ContainersListBlobFlatSegmentHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-Type property. - */ - private String contentType; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersListBlobFlatSegmentHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersListBlobFlatSegmentHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersListBlobFlatSegmentHeaders object itself. - */ - public ContainersListBlobFlatSegmentHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersListBlobFlatSegmentHeaders object itself. - */ - public ContainersListBlobFlatSegmentHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersListBlobFlatSegmentHeaders object itself. - */ - public ContainersListBlobFlatSegmentHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersListBlobFlatSegmentHeaders object itself. - */ - public ContainersListBlobFlatSegmentHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the ContainersListBlobFlatSegmentHeaders object itself. - */ - public ContainersListBlobFlatSegmentHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersListBlobHierarchySegmentHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersListBlobHierarchySegmentHeaders.java deleted file mode 100644 index 06605076db9e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersListBlobHierarchySegmentHeaders.java +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersListBlobHierarchySegmentHeaders model. - */ -@Fluent -public final class ContainersListBlobHierarchySegmentHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-Type property. - */ - private String contentType; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersListBlobHierarchySegmentHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersListBlobHierarchySegmentHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersListBlobHierarchySegmentHeaders object itself. - */ - public ContainersListBlobHierarchySegmentHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersListBlobHierarchySegmentHeaders object itself. - */ - public ContainersListBlobHierarchySegmentHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersListBlobHierarchySegmentHeaders object itself. - */ - public ContainersListBlobHierarchySegmentHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersListBlobHierarchySegmentHeaders object itself. - */ - public ContainersListBlobHierarchySegmentHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the ContainersListBlobHierarchySegmentHeaders object itself. - */ - public ContainersListBlobHierarchySegmentHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersReleaseLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersReleaseLeaseHeaders.java deleted file mode 100644 index 6b963eb88cf8..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersReleaseLeaseHeaders.java +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersReleaseLeaseHeaders model. - */ -@Fluent -public final class ContainersReleaseLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersReleaseLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersReleaseLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersReleaseLeaseHeaders object itself. - */ - public ContainersReleaseLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersReleaseLeaseHeaders object itself. - */ - public ContainersReleaseLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersReleaseLeaseHeaders object itself. - */ - public ContainersReleaseLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersReleaseLeaseHeaders object itself. - */ - public ContainersReleaseLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersReleaseLeaseHeaders object itself. - */ - public ContainersReleaseLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersReleaseLeaseHeaders object itself. - */ - public ContainersReleaseLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRenameHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRenameHeaders.java deleted file mode 100644 index 137db8a3e297..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRenameHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersRenameHeaders model. - */ -@Fluent -public final class ContainersRenameHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersRenameHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersRenameHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersRenameHeaders object itself. - */ - public ContainersRenameHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersRenameHeaders object itself. - */ - public ContainersRenameHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersRenameHeaders object itself. - */ - public ContainersRenameHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersRenameHeaders object itself. - */ - public ContainersRenameHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRenewLeaseHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRenewLeaseHeaders.java deleted file mode 100644 index ffc55396253c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRenewLeaseHeaders.java +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersRenewLeaseHeaders model. - */ -@Fluent -public final class ContainersRenewLeaseHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-lease-id property. - */ - private String xMsLeaseId; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_LEASE_ID = HttpHeaderName.fromString("x-ms-lease-id"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersRenewLeaseHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersRenewLeaseHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.xMsLeaseId = rawHeaders.getValue(X_MS_LEASE_ID); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersRenewLeaseHeaders object itself. - */ - public ContainersRenewLeaseHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersRenewLeaseHeaders object itself. - */ - public ContainersRenewLeaseHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsLeaseId property: The x-ms-lease-id property. - * - * @return the xMsLeaseId value. - */ - public String getXMsLeaseId() { - return this.xMsLeaseId; - } - - /** - * Set the xMsLeaseId property: The x-ms-lease-id property. - * - * @param xMsLeaseId the xMsLeaseId value to set. - * @return the ContainersRenewLeaseHeaders object itself. - */ - public ContainersRenewLeaseHeaders setXMsLeaseId(String xMsLeaseId) { - this.xMsLeaseId = xMsLeaseId; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersRenewLeaseHeaders object itself. - */ - public ContainersRenewLeaseHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersRenewLeaseHeaders object itself. - */ - public ContainersRenewLeaseHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersRenewLeaseHeaders object itself. - */ - public ContainersRenewLeaseHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersRenewLeaseHeaders object itself. - */ - public ContainersRenewLeaseHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRestoreHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRestoreHeaders.java deleted file mode 100644 index 50e6ef0d04f4..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersRestoreHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersRestoreHeaders model. - */ -@Fluent -public final class ContainersRestoreHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersRestoreHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersRestoreHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersRestoreHeaders object itself. - */ - public ContainersRestoreHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersRestoreHeaders object itself. - */ - public ContainersRestoreHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersRestoreHeaders object itself. - */ - public ContainersRestoreHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersRestoreHeaders object itself. - */ - public ContainersRestoreHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSetAccessPolicyHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSetAccessPolicyHeaders.java deleted file mode 100644 index b115bd124df1..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSetAccessPolicyHeaders.java +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersSetAccessPolicyHeaders model. - */ -@Fluent -public final class ContainersSetAccessPolicyHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersSetAccessPolicyHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersSetAccessPolicyHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersSetAccessPolicyHeaders object itself. - */ - public ContainersSetAccessPolicyHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersSetAccessPolicyHeaders object itself. - */ - public ContainersSetAccessPolicyHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersSetAccessPolicyHeaders object itself. - */ - public ContainersSetAccessPolicyHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersSetAccessPolicyHeaders object itself. - */ - public ContainersSetAccessPolicyHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersSetAccessPolicyHeaders object itself. - */ - public ContainersSetAccessPolicyHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersSetAccessPolicyHeaders object itself. - */ - public ContainersSetAccessPolicyHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSetMetadataHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSetMetadataHeaders.java deleted file mode 100644 index e421ff2be59b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSetMetadataHeaders.java +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ContainersSetMetadataHeaders model. - */ -@Fluent -public final class ContainersSetMetadataHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersSetMetadataHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersSetMetadataHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersSetMetadataHeaders object itself. - */ - public ContainersSetMetadataHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the ContainersSetMetadataHeaders object itself. - */ - public ContainersSetMetadataHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the ContainersSetMetadataHeaders object itself. - */ - public ContainersSetMetadataHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersSetMetadataHeaders object itself. - */ - public ContainersSetMetadataHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ContainersSetMetadataHeaders object itself. - */ - public ContainersSetMetadataHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ContainersSetMetadataHeaders object itself. - */ - public ContainersSetMetadataHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSubmitBatchHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSubmitBatchHeaders.java deleted file mode 100644 index 94d4f3c7ff0c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ContainersSubmitBatchHeaders.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; - -/** - * The ContainersSubmitBatchHeaders model. - */ -@Fluent -public final class ContainersSubmitBatchHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The Content-Type property. - */ - private String contentType; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ContainersSubmitBatchHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ContainersSubmitBatchHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ContainersSubmitBatchHeaders object itself. - */ - public ContainersSubmitBatchHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ContainersSubmitBatchHeaders object itself. - */ - public ContainersSubmitBatchHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the ContainersSubmitBatchHeaders object itself. - */ - public ContainersSubmitBatchHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesCreateHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesCreateHeaders.java deleted file mode 100644 index ebf8ea2a2d72..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesCreateHeaders.java +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The DirectoriesCreateHeaders model. */ -@Fluent -public final class DirectoriesCreateHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The Content-Length property. - */ - private Long contentLength; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the DirectoriesCreateHeaders object itself. - */ - public DirectoriesCreateHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the DirectoriesCreateHeaders object itself. - */ - public DirectoriesCreateHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the DirectoriesCreateHeaders object itself. - */ - public DirectoriesCreateHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the contentLength property: The Content-Length property. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return this.contentLength; - } - - /** - * Set the contentLength property: The Content-Length property. - * - * @param contentLength the contentLength value to set. - * @return the DirectoriesCreateHeaders object itself. - */ - public DirectoriesCreateHeaders setContentLength(Long contentLength) { - this.contentLength = contentLength; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the DirectoriesCreateHeaders object itself. - */ - public DirectoriesCreateHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the DirectoriesCreateHeaders object itself. - */ - public DirectoriesCreateHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the DirectoriesCreateHeaders object itself. - */ - public DirectoriesCreateHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesDeleteHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesDeleteHeaders.java deleted file mode 100644 index 7d022a49ce6f..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesDeleteHeaders.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The DirectoriesDeleteHeaders model. */ -@Fluent -public final class DirectoriesDeleteHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-continuation property. - */ - private String xMsContinuation; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the DirectoriesDeleteHeaders object itself. - */ - public DirectoriesDeleteHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsContinuation property: The x-ms-continuation property. - * - * @return the xMsContinuation value. - */ - public String getXMsContinuation() { - return this.xMsContinuation; - } - - /** - * Set the xMsContinuation property: The x-ms-continuation property. - * - * @param xMsContinuation the xMsContinuation value to set. - * @return the DirectoriesDeleteHeaders object itself. - */ - public DirectoriesDeleteHeaders setXMsContinuation(String xMsContinuation) { - this.xMsContinuation = xMsContinuation; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the DirectoriesDeleteHeaders object itself. - */ - public DirectoriesDeleteHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the DirectoriesDeleteHeaders object itself. - */ - public DirectoriesDeleteHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the DirectoriesDeleteHeaders object itself. - */ - public DirectoriesDeleteHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesGetAccessControlHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesGetAccessControlHeaders.java deleted file mode 100644 index 81ef834374d4..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesGetAccessControlHeaders.java +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The DirectoriesGetAccessControlHeaders model. */ -@Fluent -public final class DirectoriesGetAccessControlHeaders { - /* - * The x-ms-group property. - */ - private String xMsGroup; - - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-acl property. - */ - private String xMsAcl; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-permissions property. - */ - private String xMsPermissions; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /* - * The x-ms-owner property. - */ - private String xMsOwner; - - /** - * Get the xMsGroup property: The x-ms-group property. - * - * @return the xMsGroup value. - */ - public String getXMsGroup() { - return this.xMsGroup; - } - - /** - * Set the xMsGroup property: The x-ms-group property. - * - * @param xMsGroup the xMsGroup value to set. - * @return the DirectoriesGetAccessControlHeaders object itself. - */ - public DirectoriesGetAccessControlHeaders setXMsGroup(String xMsGroup) { - this.xMsGroup = xMsGroup; - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the DirectoriesGetAccessControlHeaders object itself. - */ - public DirectoriesGetAccessControlHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the DirectoriesGetAccessControlHeaders object itself. - */ - public DirectoriesGetAccessControlHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsAcl property: The x-ms-acl property. - * - * @return the xMsAcl value. - */ - public String getXMsAcl() { - return this.xMsAcl; - } - - /** - * Set the xMsAcl property: The x-ms-acl property. - * - * @param xMsAcl the xMsAcl value to set. - * @return the DirectoriesGetAccessControlHeaders object itself. - */ - public DirectoriesGetAccessControlHeaders setXMsAcl(String xMsAcl) { - this.xMsAcl = xMsAcl; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the DirectoriesGetAccessControlHeaders object itself. - */ - public DirectoriesGetAccessControlHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsPermissions property: The x-ms-permissions property. - * - * @return the xMsPermissions value. - */ - public String getXMsPermissions() { - return this.xMsPermissions; - } - - /** - * Set the xMsPermissions property: The x-ms-permissions property. - * - * @param xMsPermissions the xMsPermissions value to set. - * @return the DirectoriesGetAccessControlHeaders object itself. - */ - public DirectoriesGetAccessControlHeaders setXMsPermissions(String xMsPermissions) { - this.xMsPermissions = xMsPermissions; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the DirectoriesGetAccessControlHeaders object itself. - */ - public DirectoriesGetAccessControlHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the DirectoriesGetAccessControlHeaders object itself. - */ - public DirectoriesGetAccessControlHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } - - /** - * Get the xMsOwner property: The x-ms-owner property. - * - * @return the xMsOwner value. - */ - public String getXMsOwner() { - return this.xMsOwner; - } - - /** - * Set the xMsOwner property: The x-ms-owner property. - * - * @param xMsOwner the xMsOwner value to set. - * @return the DirectoriesGetAccessControlHeaders object itself. - */ - public DirectoriesGetAccessControlHeaders setXMsOwner(String xMsOwner) { - this.xMsOwner = xMsOwner; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesRenameHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesRenameHeaders.java deleted file mode 100644 index bdbb55aeb8dc..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesRenameHeaders.java +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The DirectoriesRenameHeaders model. */ -@Fluent -public final class DirectoriesRenameHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The Content-Length property. - */ - private Long contentLength; - - /* - * The x-ms-continuation property. - */ - private String xMsContinuation; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the DirectoriesRenameHeaders object itself. - */ - public DirectoriesRenameHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the DirectoriesRenameHeaders object itself. - */ - public DirectoriesRenameHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the DirectoriesRenameHeaders object itself. - */ - public DirectoriesRenameHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the contentLength property: The Content-Length property. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return this.contentLength; - } - - /** - * Set the contentLength property: The Content-Length property. - * - * @param contentLength the contentLength value to set. - * @return the DirectoriesRenameHeaders object itself. - */ - public DirectoriesRenameHeaders setContentLength(Long contentLength) { - this.contentLength = contentLength; - return this; - } - - /** - * Get the xMsContinuation property: The x-ms-continuation property. - * - * @return the xMsContinuation value. - */ - public String getXMsContinuation() { - return this.xMsContinuation; - } - - /** - * Set the xMsContinuation property: The x-ms-continuation property. - * - * @param xMsContinuation the xMsContinuation value to set. - * @return the DirectoriesRenameHeaders object itself. - */ - public DirectoriesRenameHeaders setXMsContinuation(String xMsContinuation) { - this.xMsContinuation = xMsContinuation; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the DirectoriesRenameHeaders object itself. - */ - public DirectoriesRenameHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the DirectoriesRenameHeaders object itself. - */ - public DirectoriesRenameHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the DirectoriesRenameHeaders object itself. - */ - public DirectoriesRenameHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesSetAccessControlHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesSetAccessControlHeaders.java deleted file mode 100644 index 332dd994c6f6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoriesSetAccessControlHeaders.java +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The DirectoriesSetAccessControlHeaders model. */ -@Fluent -public final class DirectoriesSetAccessControlHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the DirectoriesSetAccessControlHeaders object itself. - */ - public DirectoriesSetAccessControlHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the DirectoriesSetAccessControlHeaders object itself. - */ - public DirectoriesSetAccessControlHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the DirectoriesSetAccessControlHeaders object itself. - */ - public DirectoriesSetAccessControlHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the DirectoriesSetAccessControlHeaders object itself. - */ - public DirectoriesSetAccessControlHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the DirectoriesSetAccessControlHeaders object itself. - */ - public DirectoriesSetAccessControlHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoryHttpHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoryHttpHeaders.java deleted file mode 100644 index 9a16c9de11b4..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DirectoryHttpHeaders.java +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; - -/** Parameter group. */ -@Fluent -public final class DirectoryHttpHeaders { - /* - * Cache control for given resource - */ - private String cacheControl; - - /* - * Content type for given resource - */ - private String contentType; - - /* - * Content encoding for given resource - */ - private String contentEncoding; - - /* - * Content language for given resource - */ - private String contentLanguage; - - /* - * Content disposition for given resource - */ - private String contentDisposition; - - /** - * Get the cacheControl property: Cache control for given resource. - * - * @return the cacheControl value. - */ - public String getCacheControl() { - return this.cacheControl; - } - - /** - * Set the cacheControl property: Cache control for given resource. - * - * @param cacheControl the cacheControl value to set. - * @return the DirectoryHttpHeaders object itself. - */ - public DirectoryHttpHeaders setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - /** - * Get the contentType property: Content type for given resource. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: Content type for given resource. - * - * @param contentType the contentType value to set. - * @return the DirectoryHttpHeaders object itself. - */ - public DirectoryHttpHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Get the contentEncoding property: Content encoding for given resource. - * - * @return the contentEncoding value. - */ - public String getContentEncoding() { - return this.contentEncoding; - } - - /** - * Set the contentEncoding property: Content encoding for given resource. - * - * @param contentEncoding the contentEncoding value to set. - * @return the DirectoryHttpHeaders object itself. - */ - public DirectoryHttpHeaders setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - /** - * Get the contentLanguage property: Content language for given resource. - * - * @return the contentLanguage value. - */ - public String getContentLanguage() { - return this.contentLanguage; - } - - /** - * Set the contentLanguage property: Content language for given resource. - * - * @param contentLanguage the contentLanguage value to set. - * @return the DirectoryHttpHeaders object itself. - */ - public DirectoryHttpHeaders setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Get the contentDisposition property: Content disposition for given resource. - * - * @return the contentDisposition value. - */ - public String getContentDisposition() { - return this.contentDisposition; - } - - /** - * Set the contentDisposition property: Content disposition for given resource. - * - * @param contentDisposition the contentDisposition value to set. - * @return the DirectoryHttpHeaders object itself. - */ - public DirectoryHttpHeaders setContentDisposition(String contentDisposition) { - this.contentDisposition = contentDisposition; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/EncryptionScope.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/EncryptionScope.java deleted file mode 100644 index b0a390bbf3a0..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/EncryptionScope.java +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; - -/** - * Parameter group. - */ -@Fluent -public final class EncryptionScope { - /* - * Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data - * provided in the request. If not specified, encryption is performed with the default account encryption scope. For - * more information, see Encryption at Rest for Azure Storage Services. - */ - private String encryptionScope; - - /** - * Creates an instance of EncryptionScope class. - */ - public EncryptionScope() { - } - - /** - * Get the encryptionScope property: Optional. Version 2019-07-07 and later. Specifies the name of the encryption - * scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the - * default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. - * - * @return the encryptionScope value. - */ - public String getEncryptionScope() { - return this.encryptionScope; - } - - /** - * Set the encryptionScope property: Optional. Version 2019-07-07 and later. Specifies the name of the encryption - * scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the - * default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. - * - * @param encryptionScope the encryptionScope value to set. - * @return the EncryptionScope object itself. - */ - public EncryptionScope setEncryptionScope(String encryptionScope) { - this.encryptionScope = encryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobItem.java deleted file mode 100644 index 2e05266e23db..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobItem.java +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Blob info from a Filter Blobs API call. - */ -@Fluent -public final class FilterBlobItem implements XmlSerializable { - /* - * The Name property. - */ - private String name; - - /* - * The ContainerName property. - */ - private String containerName; - - /* - * Blob tags - */ - private BlobTags tags; - - /* - * The VersionId property. - */ - private String versionId; - - /* - * The IsCurrentVersion property. - */ - private Boolean isCurrentVersion; - - /** - * Creates an instance of FilterBlobItem class. - */ - public FilterBlobItem() { - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - public String getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the FilterBlobItem object itself. - */ - public FilterBlobItem setName(String name) { - this.name = name; - return this; - } - - /** - * Get the containerName property: The ContainerName property. - * - * @return the containerName value. - */ - public String getContainerName() { - return this.containerName; - } - - /** - * Set the containerName property: The ContainerName property. - * - * @param containerName the containerName value to set. - * @return the FilterBlobItem object itself. - */ - public FilterBlobItem setContainerName(String containerName) { - this.containerName = containerName; - return this; - } - - /** - * Get the tags property: Blob tags. - * - * @return the tags value. - */ - public BlobTags getTags() { - return this.tags; - } - - /** - * Set the tags property: Blob tags. - * - * @param tags the tags value to set. - * @return the FilterBlobItem object itself. - */ - public FilterBlobItem setTags(BlobTags tags) { - this.tags = tags; - return this; - } - - /** - * Get the versionId property: The VersionId property. - * - * @return the versionId value. - */ - public String getVersionId() { - return this.versionId; - } - - /** - * Set the versionId property: The VersionId property. - * - * @param versionId the versionId value to set. - * @return the FilterBlobItem object itself. - */ - public FilterBlobItem setVersionId(String versionId) { - this.versionId = versionId; - return this; - } - - /** - * Get the isCurrentVersion property: The IsCurrentVersion property. - * - * @return the isCurrentVersion value. - */ - public Boolean isCurrentVersion() { - return this.isCurrentVersion; - } - - /** - * Set the isCurrentVersion property: The IsCurrentVersion property. - * - * @param isCurrentVersion the isCurrentVersion value to set. - * @return the FilterBlobItem object itself. - */ - public FilterBlobItem setIsCurrentVersion(Boolean isCurrentVersion) { - this.isCurrentVersion = isCurrentVersion; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Blob" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Name", this.name); - xmlWriter.writeStringElement("ContainerName", this.containerName); - xmlWriter.writeXml(this.tags, "Tags"); - xmlWriter.writeStringElement("VersionId", this.versionId); - xmlWriter.writeBooleanElement("IsCurrentVersion", this.isCurrentVersion); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of FilterBlobItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of FilterBlobItem if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the FilterBlobItem. - */ - public static FilterBlobItem fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of FilterBlobItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of FilterBlobItem if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the FilterBlobItem. - */ - public static FilterBlobItem fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Blob" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - FilterBlobItem deserializedFilterBlobItem = new FilterBlobItem(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedFilterBlobItem.name = reader.getStringElement(); - } else if ("ContainerName".equals(elementName.getLocalPart())) { - deserializedFilterBlobItem.containerName = reader.getStringElement(); - } else if ("Tags".equals(elementName.getLocalPart())) { - deserializedFilterBlobItem.tags = BlobTags.fromXml(reader, "Tags"); - } else if ("VersionId".equals(elementName.getLocalPart())) { - deserializedFilterBlobItem.versionId = reader.getStringElement(); - } else if ("IsCurrentVersion".equals(elementName.getLocalPart())) { - deserializedFilterBlobItem.isCurrentVersion = reader.getNullableElement(Boolean::parseBoolean); - } else { - reader.skipElement(); - } - } - - return deserializedFilterBlobItem; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobSegment.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobSegment.java deleted file mode 100644 index cfc474e3df26..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobSegment.java +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; -import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * The result of a Filter Blobs API call. - */ -@Fluent -public final class FilterBlobSegment implements XmlSerializable { - /* - * The ServiceEndpoint property. - */ - private String serviceEndpoint; - - /* - * The Where property. - */ - private String where; - - /* - * The Blobs property. - */ - private List blobs; - - /* - * The NextMarker property. - */ - private String nextMarker; - - /** - * Creates an instance of FilterBlobSegment class. - */ - public FilterBlobSegment() { - } - - /** - * Get the serviceEndpoint property: The ServiceEndpoint property. - * - * @return the serviceEndpoint value. - */ - public String getServiceEndpoint() { - return this.serviceEndpoint; - } - - /** - * Set the serviceEndpoint property: The ServiceEndpoint property. - * - * @param serviceEndpoint the serviceEndpoint value to set. - * @return the FilterBlobSegment object itself. - */ - public FilterBlobSegment setServiceEndpoint(String serviceEndpoint) { - this.serviceEndpoint = serviceEndpoint; - return this; - } - - /** - * Get the where property: The Where property. - * - * @return the where value. - */ - public String getWhere() { - return this.where; - } - - /** - * Set the where property: The Where property. - * - * @param where the where value to set. - * @return the FilterBlobSegment object itself. - */ - public FilterBlobSegment setWhere(String where) { - this.where = where; - return this; - } - - /** - * Get the blobs property: The Blobs property. - * - * @return the blobs value. - */ - public List getBlobs() { - if (this.blobs == null) { - this.blobs = new ArrayList<>(); - } - return this.blobs; - } - - /** - * Set the blobs property: The Blobs property. - * - * @param blobs the blobs value to set. - * @return the FilterBlobSegment object itself. - */ - public FilterBlobSegment setBlobs(List blobs) { - this.blobs = blobs; - return this; - } - - /** - * Get the nextMarker property: The NextMarker property. - * - * @return the nextMarker value. - */ - public String getNextMarker() { - return this.nextMarker; - } - - /** - * Set the nextMarker property: The NextMarker property. - * - * @param nextMarker the nextMarker value to set. - * @return the FilterBlobSegment object itself. - */ - public FilterBlobSegment setNextMarker(String nextMarker) { - this.nextMarker = nextMarker; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "EnumerationResults" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringAttribute("ServiceEndpoint", this.serviceEndpoint); - xmlWriter.writeStringElement("Where", this.where); - if (this.blobs != null) { - xmlWriter.writeStartElement("Blobs"); - for (FilterBlobItem element : this.blobs) { - xmlWriter.writeXml(element, "Blob"); - } - xmlWriter.writeEndElement(); - } - xmlWriter.writeStringElement("NextMarker", this.nextMarker); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of FilterBlobSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of FilterBlobSegment if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the FilterBlobSegment. - */ - public static FilterBlobSegment fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of FilterBlobSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of FilterBlobSegment if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the FilterBlobSegment. - */ - public static FilterBlobSegment fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "EnumerationResults" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - FilterBlobSegment deserializedFilterBlobSegment = new FilterBlobSegment(); - deserializedFilterBlobSegment.serviceEndpoint = reader.getStringAttribute(null, "ServiceEndpoint"); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Where".equals(elementName.getLocalPart())) { - deserializedFilterBlobSegment.where = reader.getStringElement(); - } else if ("Blobs".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - elementName = reader.getElementName(); - if ("Blob".equals(elementName.getLocalPart())) { - if (deserializedFilterBlobSegment.blobs == null) { - deserializedFilterBlobSegment.blobs = new ArrayList<>(); - } - deserializedFilterBlobSegment.blobs.add(FilterBlobItem.fromXml(reader, "Blob")); - } else { - reader.skipElement(); - } - } - } else if ("NextMarker".equals(elementName.getLocalPart())) { - deserializedFilterBlobSegment.nextMarker = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedFilterBlobSegment; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobsIncludeItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobsIncludeItem.java deleted file mode 100644 index 0d835b59d578..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/FilterBlobsIncludeItem.java +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -/** - * Defines values for FilterBlobsIncludeItem. - */ -public enum FilterBlobsIncludeItem { - /** - * Enum value none. - */ - NONE("none"), - - /** - * Enum value versions. - */ - VERSIONS("versions"); - - /** - * The actual serialized value for a FilterBlobsIncludeItem instance. - */ - private final String value; - - FilterBlobsIncludeItem(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a FilterBlobsIncludeItem instance. - * - * @param value the serialized value to parse. - * @return the parsed FilterBlobsIncludeItem object, or null if unable to parse. - */ - public static FilterBlobsIncludeItem fromString(String value) { - if (value == null) { - return null; - } - FilterBlobsIncludeItem[] items = FilterBlobsIncludeItem.values(); - for (FilterBlobsIncludeItem item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/GetUserDelegationKeyRequest.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/GetUserDelegationKeyRequest.java new file mode 100644 index 000000000000..e4c7fd803ff0 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/GetUserDelegationKeyRequest.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The GetUserDelegationKeyRequest model. + */ +@Immutable +public final class GetUserDelegationKeyRequest implements JsonSerializable { + /* + * The date-time the key is active. + */ + @Generated + private final String start; + + /* + * The date-time the key expires. + */ + @Generated + private final String expiry; + + /** + * Creates an instance of GetUserDelegationKeyRequest class. + * + * @param start the start value to set. + * @param expiry the expiry value to set. + */ + @Generated + public GetUserDelegationKeyRequest(String start, String expiry) { + this.start = start; + this.expiry = expiry; + } + + /** + * Get the start property: The date-time the key is active. + * + * @return the start value. + */ + @Generated + public String getStart() { + return this.start; + } + + /** + * Get the expiry property: The date-time the key expires. + * + * @return the expiry value. + */ + @Generated + public String getExpiry() { + return this.expiry; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("start", this.start); + jsonWriter.writeStringField("expiry", this.expiry); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetUserDelegationKeyRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetUserDelegationKeyRequest if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the GetUserDelegationKeyRequest. + */ + @Generated + public static GetUserDelegationKeyRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String start = null; + String expiry = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("start".equals(fieldName)) { + start = reader.getString(); + } else if ("expiry".equals(fieldName)) { + expiry = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new GetUserDelegationKeyRequest(start, expiry); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/InternalBlobLegalHoldResult.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/InternalBlobLegalHoldResult.java deleted file mode 100644 index a2b07af0a161..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/InternalBlobLegalHoldResult.java +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.models; - -import com.azure.storage.blob.models.BlobLegalHoldResult; - -/** - * The blob legal hold result. - */ -public class InternalBlobLegalHoldResult implements BlobLegalHoldResult { - - private final boolean hasLegalHold; - - /** - * Creates a new BlobLegalHoldResult - * @param hasLegalHold whether or not a legal hold is enabled on the blob. - */ - public InternalBlobLegalHoldResult(boolean hasLegalHold) { - this.hasLegalHold = hasLegalHold; - } - - /** - * @return whether or not a legal hold is enabled on the blob. - */ - public boolean hasLegalHold() { - return hasLegalHold; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/JsonTextConfiguration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/JsonTextConfiguration.java deleted file mode 100644 index e3bac9a2e9d8..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/JsonTextConfiguration.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * json text configuration. - */ -@Fluent -public final class JsonTextConfiguration implements XmlSerializable { - /* - * The string used to separate records. - */ - private String recordSeparator; - - /** - * Creates an instance of JsonTextConfiguration class. - */ - public JsonTextConfiguration() { - } - - /** - * Get the recordSeparator property: The string used to separate records. - * - * @return the recordSeparator value. - */ - public String getRecordSeparator() { - return this.recordSeparator; - } - - /** - * Set the recordSeparator property: The string used to separate records. - * - * @param recordSeparator the recordSeparator value to set. - * @return the JsonTextConfiguration object itself. - */ - public JsonTextConfiguration setRecordSeparator(String recordSeparator) { - this.recordSeparator = recordSeparator; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "JsonTextConfiguration" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("RecordSeparator", this.recordSeparator); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of JsonTextConfiguration from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of JsonTextConfiguration if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the JsonTextConfiguration. - */ - public static JsonTextConfiguration fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of JsonTextConfiguration from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of JsonTextConfiguration if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the JsonTextConfiguration. - */ - public static JsonTextConfiguration fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName - = CoreUtils.isNullOrEmpty(rootElementName) ? "JsonTextConfiguration" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - JsonTextConfiguration deserializedJsonTextConfiguration = new JsonTextConfiguration(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("RecordSeparator".equals(elementName.getLocalPart())) { - deserializedJsonTextConfiguration.recordSeparator = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedJsonTextConfiguration; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ListBlobsFlatSegmentResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ListBlobsFlatSegmentResponse.java deleted file mode 100644 index 16e553132190..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ListBlobsFlatSegmentResponse.java +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * An enumeration of blobs. - */ -@Fluent -public final class ListBlobsFlatSegmentResponse implements XmlSerializable { - /* - * The ServiceEndpoint property. - */ - private String serviceEndpoint; - - /* - * The ContainerName property. - */ - private String containerName; - - /* - * The Prefix property. - */ - private String prefix; - - /* - * The Marker property. - */ - private String marker; - - /* - * The MaxResults property. - */ - private int maxResults; - - /* - * The Segment property. - */ - private BlobFlatListSegment segment; - - /* - * The NextMarker property. - */ - private String nextMarker; - - /** - * Creates an instance of ListBlobsFlatSegmentResponse class. - */ - public ListBlobsFlatSegmentResponse() { - } - - /** - * Get the serviceEndpoint property: The ServiceEndpoint property. - * - * @return the serviceEndpoint value. - */ - public String getServiceEndpoint() { - return this.serviceEndpoint; - } - - /** - * Set the serviceEndpoint property: The ServiceEndpoint property. - * - * @param serviceEndpoint the serviceEndpoint value to set. - * @return the ListBlobsFlatSegmentResponse object itself. - */ - public ListBlobsFlatSegmentResponse setServiceEndpoint(String serviceEndpoint) { - this.serviceEndpoint = serviceEndpoint; - return this; - } - - /** - * Get the containerName property: The ContainerName property. - * - * @return the containerName value. - */ - public String getContainerName() { - return this.containerName; - } - - /** - * Set the containerName property: The ContainerName property. - * - * @param containerName the containerName value to set. - * @return the ListBlobsFlatSegmentResponse object itself. - */ - public ListBlobsFlatSegmentResponse setContainerName(String containerName) { - this.containerName = containerName; - return this; - } - - /** - * Get the prefix property: The Prefix property. - * - * @return the prefix value. - */ - public String getPrefix() { - return this.prefix; - } - - /** - * Set the prefix property: The Prefix property. - * - * @param prefix the prefix value to set. - * @return the ListBlobsFlatSegmentResponse object itself. - */ - public ListBlobsFlatSegmentResponse setPrefix(String prefix) { - this.prefix = prefix; - return this; - } - - /** - * Get the marker property: The Marker property. - * - * @return the marker value. - */ - public String getMarker() { - return this.marker; - } - - /** - * Set the marker property: The Marker property. - * - * @param marker the marker value to set. - * @return the ListBlobsFlatSegmentResponse object itself. - */ - public ListBlobsFlatSegmentResponse setMarker(String marker) { - this.marker = marker; - return this; - } - - /** - * Get the maxResults property: The MaxResults property. - * - * @return the maxResults value. - */ - public int getMaxResults() { - return this.maxResults; - } - - /** - * Set the maxResults property: The MaxResults property. - * - * @param maxResults the maxResults value to set. - * @return the ListBlobsFlatSegmentResponse object itself. - */ - public ListBlobsFlatSegmentResponse setMaxResults(int maxResults) { - this.maxResults = maxResults; - return this; - } - - /** - * Get the segment property: The Segment property. - * - * @return the segment value. - */ - public BlobFlatListSegment getSegment() { - return this.segment; - } - - /** - * Set the segment property: The Segment property. - * - * @param segment the segment value to set. - * @return the ListBlobsFlatSegmentResponse object itself. - */ - public ListBlobsFlatSegmentResponse setSegment(BlobFlatListSegment segment) { - this.segment = segment; - return this; - } - - /** - * Get the nextMarker property: The NextMarker property. - * - * @return the nextMarker value. - */ - public String getNextMarker() { - return this.nextMarker; - } - - /** - * Set the nextMarker property: The NextMarker property. - * - * @param nextMarker the nextMarker value to set. - * @return the ListBlobsFlatSegmentResponse object itself. - */ - public ListBlobsFlatSegmentResponse setNextMarker(String nextMarker) { - this.nextMarker = nextMarker; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "EnumerationResults" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringAttribute("ServiceEndpoint", this.serviceEndpoint); - xmlWriter.writeStringAttribute("ContainerName", this.containerName); - xmlWriter.writeStringElement("Prefix", this.prefix); - xmlWriter.writeStringElement("Marker", this.marker); - xmlWriter.writeIntElement("MaxResults", this.maxResults); - xmlWriter.writeXml(this.segment, "Blobs"); - xmlWriter.writeStringElement("NextMarker", this.nextMarker); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of ListBlobsFlatSegmentResponse from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of ListBlobsFlatSegmentResponse if the XmlReader was pointing to an instance of it, or null - * if it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the ListBlobsFlatSegmentResponse. - */ - public static ListBlobsFlatSegmentResponse fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of ListBlobsFlatSegmentResponse from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of ListBlobsFlatSegmentResponse if the XmlReader was pointing to an instance of it, or null - * if it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the ListBlobsFlatSegmentResponse. - */ - public static ListBlobsFlatSegmentResponse fromXml(XmlReader xmlReader, String rootElementName) - throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "EnumerationResults" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - ListBlobsFlatSegmentResponse deserializedListBlobsFlatSegmentResponse = new ListBlobsFlatSegmentResponse(); - deserializedListBlobsFlatSegmentResponse.serviceEndpoint - = reader.getStringAttribute(null, "ServiceEndpoint"); - deserializedListBlobsFlatSegmentResponse.containerName = reader.getStringAttribute(null, "ContainerName"); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Prefix".equals(elementName.getLocalPart())) { - deserializedListBlobsFlatSegmentResponse.prefix = reader.getStringElement(); - } else if ("Marker".equals(elementName.getLocalPart())) { - deserializedListBlobsFlatSegmentResponse.marker = reader.getStringElement(); - } else if ("MaxResults".equals(elementName.getLocalPart())) { - deserializedListBlobsFlatSegmentResponse.maxResults = reader.getIntElement(); - } else if ("Blobs".equals(elementName.getLocalPart())) { - deserializedListBlobsFlatSegmentResponse.segment = BlobFlatListSegment.fromXml(reader, "Blobs"); - } else if ("NextMarker".equals(elementName.getLocalPart())) { - deserializedListBlobsFlatSegmentResponse.nextMarker = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedListBlobsFlatSegmentResponse; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ListBlobsHierarchySegmentResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ListBlobsHierarchySegmentResponse.java deleted file mode 100644 index 7c8c4c05cd72..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ListBlobsHierarchySegmentResponse.java +++ /dev/null @@ -1,303 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * An enumeration of blobs. - */ -@Fluent -public final class ListBlobsHierarchySegmentResponse implements XmlSerializable { - /* - * The ServiceEndpoint property. - */ - private String serviceEndpoint; - - /* - * The ContainerName property. - */ - private String containerName; - - /* - * The Prefix property. - */ - private String prefix; - - /* - * The Marker property. - */ - private String marker; - - /* - * The MaxResults property. - */ - private int maxResults; - - /* - * The Delimiter property. - */ - private String delimiter; - - /* - * The Segment property. - */ - private BlobHierarchyListSegment segment; - - /* - * The NextMarker property. - */ - private String nextMarker; - - /** - * Creates an instance of ListBlobsHierarchySegmentResponse class. - */ - public ListBlobsHierarchySegmentResponse() { - } - - /** - * Get the serviceEndpoint property: The ServiceEndpoint property. - * - * @return the serviceEndpoint value. - */ - public String getServiceEndpoint() { - return this.serviceEndpoint; - } - - /** - * Set the serviceEndpoint property: The ServiceEndpoint property. - * - * @param serviceEndpoint the serviceEndpoint value to set. - * @return the ListBlobsHierarchySegmentResponse object itself. - */ - public ListBlobsHierarchySegmentResponse setServiceEndpoint(String serviceEndpoint) { - this.serviceEndpoint = serviceEndpoint; - return this; - } - - /** - * Get the containerName property: The ContainerName property. - * - * @return the containerName value. - */ - public String getContainerName() { - return this.containerName; - } - - /** - * Set the containerName property: The ContainerName property. - * - * @param containerName the containerName value to set. - * @return the ListBlobsHierarchySegmentResponse object itself. - */ - public ListBlobsHierarchySegmentResponse setContainerName(String containerName) { - this.containerName = containerName; - return this; - } - - /** - * Get the prefix property: The Prefix property. - * - * @return the prefix value. - */ - public String getPrefix() { - return this.prefix; - } - - /** - * Set the prefix property: The Prefix property. - * - * @param prefix the prefix value to set. - * @return the ListBlobsHierarchySegmentResponse object itself. - */ - public ListBlobsHierarchySegmentResponse setPrefix(String prefix) { - this.prefix = prefix; - return this; - } - - /** - * Get the marker property: The Marker property. - * - * @return the marker value. - */ - public String getMarker() { - return this.marker; - } - - /** - * Set the marker property: The Marker property. - * - * @param marker the marker value to set. - * @return the ListBlobsHierarchySegmentResponse object itself. - */ - public ListBlobsHierarchySegmentResponse setMarker(String marker) { - this.marker = marker; - return this; - } - - /** - * Get the maxResults property: The MaxResults property. - * - * @return the maxResults value. - */ - public int getMaxResults() { - return this.maxResults; - } - - /** - * Set the maxResults property: The MaxResults property. - * - * @param maxResults the maxResults value to set. - * @return the ListBlobsHierarchySegmentResponse object itself. - */ - public ListBlobsHierarchySegmentResponse setMaxResults(int maxResults) { - this.maxResults = maxResults; - return this; - } - - /** - * Get the delimiter property: The Delimiter property. - * - * @return the delimiter value. - */ - public String getDelimiter() { - return this.delimiter; - } - - /** - * Set the delimiter property: The Delimiter property. - * - * @param delimiter the delimiter value to set. - * @return the ListBlobsHierarchySegmentResponse object itself. - */ - public ListBlobsHierarchySegmentResponse setDelimiter(String delimiter) { - this.delimiter = delimiter; - return this; - } - - /** - * Get the segment property: The Segment property. - * - * @return the segment value. - */ - public BlobHierarchyListSegment getSegment() { - return this.segment; - } - - /** - * Set the segment property: The Segment property. - * - * @param segment the segment value to set. - * @return the ListBlobsHierarchySegmentResponse object itself. - */ - public ListBlobsHierarchySegmentResponse setSegment(BlobHierarchyListSegment segment) { - this.segment = segment; - return this; - } - - /** - * Get the nextMarker property: The NextMarker property. - * - * @return the nextMarker value. - */ - public String getNextMarker() { - return this.nextMarker; - } - - /** - * Set the nextMarker property: The NextMarker property. - * - * @param nextMarker the nextMarker value to set. - * @return the ListBlobsHierarchySegmentResponse object itself. - */ - public ListBlobsHierarchySegmentResponse setNextMarker(String nextMarker) { - this.nextMarker = nextMarker; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "EnumerationResults" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringAttribute("ServiceEndpoint", this.serviceEndpoint); - xmlWriter.writeStringAttribute("ContainerName", this.containerName); - xmlWriter.writeStringElement("Prefix", this.prefix); - xmlWriter.writeStringElement("Marker", this.marker); - xmlWriter.writeIntElement("MaxResults", this.maxResults); - xmlWriter.writeStringElement("Delimiter", this.delimiter); - xmlWriter.writeXml(this.segment, "Blobs"); - xmlWriter.writeStringElement("NextMarker", this.nextMarker); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of ListBlobsHierarchySegmentResponse from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of ListBlobsHierarchySegmentResponse if the XmlReader was pointing to an instance of it, or - * null if it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the ListBlobsHierarchySegmentResponse. - */ - public static ListBlobsHierarchySegmentResponse fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of ListBlobsHierarchySegmentResponse from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of ListBlobsHierarchySegmentResponse if the XmlReader was pointing to an instance of it, or - * null if it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the ListBlobsHierarchySegmentResponse. - */ - public static ListBlobsHierarchySegmentResponse fromXml(XmlReader xmlReader, String rootElementName) - throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "EnumerationResults" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - ListBlobsHierarchySegmentResponse deserializedListBlobsHierarchySegmentResponse - = new ListBlobsHierarchySegmentResponse(); - deserializedListBlobsHierarchySegmentResponse.serviceEndpoint - = reader.getStringAttribute(null, "ServiceEndpoint"); - deserializedListBlobsHierarchySegmentResponse.containerName - = reader.getStringAttribute(null, "ContainerName"); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Prefix".equals(elementName.getLocalPart())) { - deserializedListBlobsHierarchySegmentResponse.prefix = reader.getStringElement(); - } else if ("Marker".equals(elementName.getLocalPart())) { - deserializedListBlobsHierarchySegmentResponse.marker = reader.getStringElement(); - } else if ("MaxResults".equals(elementName.getLocalPart())) { - deserializedListBlobsHierarchySegmentResponse.maxResults = reader.getIntElement(); - } else if ("Delimiter".equals(elementName.getLocalPart())) { - deserializedListBlobsHierarchySegmentResponse.delimiter = reader.getStringElement(); - } else if ("Blobs".equals(elementName.getLocalPart())) { - deserializedListBlobsHierarchySegmentResponse.segment - = BlobHierarchyListSegment.fromXml(reader, "Blobs"); - } else if ("NextMarker".equals(elementName.getLocalPart())) { - deserializedListBlobsHierarchySegmentResponse.nextMarker = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedListBlobsHierarchySegmentResponse; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsClearPagesHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsClearPagesHeaders.java deleted file mode 100644 index 8eda0bd0b09b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsClearPagesHeaders.java +++ /dev/null @@ -1,359 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The PageBlobsClearPagesHeaders model. - */ -@Fluent -public final class PageBlobsClearPagesHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long xMsBlobSequenceNumber; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_BLOB_SEQUENCE_NUMBER - = HttpHeaderName.fromString("x-ms-blob-sequence-number"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of PageBlobsClearPagesHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public PageBlobsClearPagesHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - String xMsBlobSequenceNumber = rawHeaders.getValue(X_MS_BLOB_SEQUENCE_NUMBER); - if (xMsBlobSequenceNumber != null) { - this.xMsBlobSequenceNumber = Long.parseLong(xMsBlobSequenceNumber); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the xMsBlobSequenceNumber value. - */ - public Long getXMsBlobSequenceNumber() { - return this.xMsBlobSequenceNumber; - } - - /** - * Set the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param xMsBlobSequenceNumber the xMsBlobSequenceNumber value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setXMsBlobSequenceNumber(Long xMsBlobSequenceNumber) { - this.xMsBlobSequenceNumber = xMsBlobSequenceNumber; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the PageBlobsClearPagesHeaders object itself. - */ - public PageBlobsClearPagesHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsCopyIncrementalHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsCopyIncrementalHeaders.java deleted file mode 100644 index 1c24595a977a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsCopyIncrementalHeaders.java +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.CopyStatusType; -import java.time.OffsetDateTime; - -/** - * The PageBlobsCopyIncrementalHeaders model. - */ -@Fluent -public final class PageBlobsCopyIncrementalHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-copy-id property. - */ - private String xMsCopyId; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-copy-status property. - */ - private CopyStatusType xMsCopyStatus; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); - - private static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of PageBlobsCopyIncrementalHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public PageBlobsCopyIncrementalHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsCopyId = rawHeaders.getValue(X_MS_COPY_ID); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - String xMsCopyStatus = rawHeaders.getValue(X_MS_COPY_STATUS); - if (xMsCopyStatus != null) { - this.xMsCopyStatus = CopyStatusType.fromString(xMsCopyStatus); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsCopyIncrementalHeaders object itself. - */ - public PageBlobsCopyIncrementalHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsCopyId property: The x-ms-copy-id property. - * - * @return the xMsCopyId value. - */ - public String getXMsCopyId() { - return this.xMsCopyId; - } - - /** - * Set the xMsCopyId property: The x-ms-copy-id property. - * - * @param xMsCopyId the xMsCopyId value to set. - * @return the PageBlobsCopyIncrementalHeaders object itself. - */ - public PageBlobsCopyIncrementalHeaders setXMsCopyId(String xMsCopyId) { - this.xMsCopyId = xMsCopyId; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsCopyIncrementalHeaders object itself. - */ - public PageBlobsCopyIncrementalHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsCopyIncrementalHeaders object itself. - */ - public PageBlobsCopyIncrementalHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsCopyStatus property: The x-ms-copy-status property. - * - * @return the xMsCopyStatus value. - */ - public CopyStatusType getXMsCopyStatus() { - return this.xMsCopyStatus; - } - - /** - * Set the xMsCopyStatus property: The x-ms-copy-status property. - * - * @param xMsCopyStatus the xMsCopyStatus value to set. - * @return the PageBlobsCopyIncrementalHeaders object itself. - */ - public PageBlobsCopyIncrementalHeaders setXMsCopyStatus(CopyStatusType xMsCopyStatus) { - this.xMsCopyStatus = xMsCopyStatus; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsCopyIncrementalHeaders object itself. - */ - public PageBlobsCopyIncrementalHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsCopyIncrementalHeaders object itself. - */ - public PageBlobsCopyIncrementalHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the PageBlobsCopyIncrementalHeaders object itself. - */ - public PageBlobsCopyIncrementalHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsCreateHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsCreateHeaders.java deleted file mode 100644 index f661ad002b2e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsCreateHeaders.java +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The PageBlobsCreateHeaders model. - */ -@Fluent -public final class PageBlobsCreateHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-version-id property. - */ - private String xMsVersionId; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of PageBlobsCreateHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public PageBlobsCreateHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsVersionId = rawHeaders.getValue(X_MS_VERSION_ID); - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsVersionId property: The x-ms-version-id property. - * - * @return the xMsVersionId value. - */ - public String getXMsVersionId() { - return this.xMsVersionId; - } - - /** - * Set the xMsVersionId property: The x-ms-version-id property. - * - * @param xMsVersionId the xMsVersionId value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setXMsVersionId(String xMsVersionId) { - this.xMsVersionId = xMsVersionId; - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the PageBlobsCreateHeaders object itself. - */ - public PageBlobsCreateHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesDiffHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesDiffHeaders.java deleted file mode 100644 index 89ba2b3333fd..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesDiffHeaders.java +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The PageBlobsGetPageRangesDiffHeaders model. - */ -@Fluent -public final class PageBlobsGetPageRangesDiffHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-blob-content-length property. - */ - private Long xMsBlobContentLength; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_BLOB_CONTENT_LENGTH - = HttpHeaderName.fromString("x-ms-blob-content-length"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of PageBlobsGetPageRangesDiffHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public PageBlobsGetPageRangesDiffHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsBlobContentLength = rawHeaders.getValue(X_MS_BLOB_CONTENT_LENGTH); - if (xMsBlobContentLength != null) { - this.xMsBlobContentLength = Long.parseLong(xMsBlobContentLength); - } - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsGetPageRangesDiffHeaders object itself. - */ - public PageBlobsGetPageRangesDiffHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @return the xMsBlobContentLength value. - */ - public Long getXMsBlobContentLength() { - return this.xMsBlobContentLength; - } - - /** - * Set the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @param xMsBlobContentLength the xMsBlobContentLength value to set. - * @return the PageBlobsGetPageRangesDiffHeaders object itself. - */ - public PageBlobsGetPageRangesDiffHeaders setXMsBlobContentLength(Long xMsBlobContentLength) { - this.xMsBlobContentLength = xMsBlobContentLength; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsGetPageRangesDiffHeaders object itself. - */ - public PageBlobsGetPageRangesDiffHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsGetPageRangesDiffHeaders object itself. - */ - public PageBlobsGetPageRangesDiffHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsGetPageRangesDiffHeaders object itself. - */ - public PageBlobsGetPageRangesDiffHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsGetPageRangesDiffHeaders object itself. - */ - public PageBlobsGetPageRangesDiffHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the PageBlobsGetPageRangesDiffHeaders object itself. - */ - public PageBlobsGetPageRangesDiffHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesDiffNextHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesDiffNextHeaders.java deleted file mode 100644 index 606b00cead31..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesDiffNextHeaders.java +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The PageBlobsGetPageRangesDiffNextHeaders model. */ -@Fluent -public final class PageBlobsGetPageRangesDiffNextHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-blob-content-length property. - */ - private Long xMsBlobContentLength; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsGetPageRangesDiffNextHeaders object itself. - */ - public PageBlobsGetPageRangesDiffNextHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @return the xMsBlobContentLength value. - */ - public Long getXMsBlobContentLength() { - return this.xMsBlobContentLength; - } - - /** - * Set the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @param xMsBlobContentLength the xMsBlobContentLength value to set. - * @return the PageBlobsGetPageRangesDiffNextHeaders object itself. - */ - public PageBlobsGetPageRangesDiffNextHeaders setXMsBlobContentLength(Long xMsBlobContentLength) { - this.xMsBlobContentLength = xMsBlobContentLength; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsGetPageRangesDiffNextHeaders object itself. - */ - public PageBlobsGetPageRangesDiffNextHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsGetPageRangesDiffNextHeaders object itself. - */ - public PageBlobsGetPageRangesDiffNextHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsGetPageRangesDiffNextHeaders object itself. - */ - public PageBlobsGetPageRangesDiffNextHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsGetPageRangesDiffNextHeaders object itself. - */ - public PageBlobsGetPageRangesDiffNextHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the PageBlobsGetPageRangesDiffNextHeaders object itself. - */ - public PageBlobsGetPageRangesDiffNextHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesHeaders.java deleted file mode 100644 index 1816501497db..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesHeaders.java +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The PageBlobsGetPageRangesHeaders model. - */ -@Fluent -public final class PageBlobsGetPageRangesHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-blob-content-length property. - */ - private Long xMsBlobContentLength; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_BLOB_CONTENT_LENGTH - = HttpHeaderName.fromString("x-ms-blob-content-length"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of PageBlobsGetPageRangesHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public PageBlobsGetPageRangesHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsBlobContentLength = rawHeaders.getValue(X_MS_BLOB_CONTENT_LENGTH); - if (xMsBlobContentLength != null) { - this.xMsBlobContentLength = Long.parseLong(xMsBlobContentLength); - } - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsGetPageRangesHeaders object itself. - */ - public PageBlobsGetPageRangesHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @return the xMsBlobContentLength value. - */ - public Long getXMsBlobContentLength() { - return this.xMsBlobContentLength; - } - - /** - * Set the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @param xMsBlobContentLength the xMsBlobContentLength value to set. - * @return the PageBlobsGetPageRangesHeaders object itself. - */ - public PageBlobsGetPageRangesHeaders setXMsBlobContentLength(Long xMsBlobContentLength) { - this.xMsBlobContentLength = xMsBlobContentLength; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsGetPageRangesHeaders object itself. - */ - public PageBlobsGetPageRangesHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsGetPageRangesHeaders object itself. - */ - public PageBlobsGetPageRangesHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsGetPageRangesHeaders object itself. - */ - public PageBlobsGetPageRangesHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsGetPageRangesHeaders object itself. - */ - public PageBlobsGetPageRangesHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the PageBlobsGetPageRangesHeaders object itself. - */ - public PageBlobsGetPageRangesHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesNextHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesNextHeaders.java deleted file mode 100644 index e48b103d8d4a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsGetPageRangesNextHeaders.java +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** The PageBlobsGetPageRangesNextHeaders model. */ -@Fluent -public final class PageBlobsGetPageRangesNextHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-blob-content-length property. - */ - private Long xMsBlobContentLength; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 dateProperty; - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsGetPageRangesNextHeaders object itself. - */ - public PageBlobsGetPageRangesNextHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @return the xMsBlobContentLength value. - */ - public Long getXMsBlobContentLength() { - return this.xMsBlobContentLength; - } - - /** - * Set the xMsBlobContentLength property: The x-ms-blob-content-length property. - * - * @param xMsBlobContentLength the xMsBlobContentLength value to set. - * @return the PageBlobsGetPageRangesNextHeaders object itself. - */ - public PageBlobsGetPageRangesNextHeaders setXMsBlobContentLength(Long xMsBlobContentLength) { - this.xMsBlobContentLength = xMsBlobContentLength; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsGetPageRangesNextHeaders object itself. - */ - public PageBlobsGetPageRangesNextHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsGetPageRangesNextHeaders object itself. - */ - public PageBlobsGetPageRangesNextHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsGetPageRangesNextHeaders object itself. - */ - public PageBlobsGetPageRangesNextHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsGetPageRangesNextHeaders object itself. - */ - public PageBlobsGetPageRangesNextHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the dateProperty property: The Date property. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { - return null; - } - return this.dateProperty.getDateTime(); - } - - /** - * Set the dateProperty property: The Date property. - * - * @param dateProperty the dateProperty value to set. - * @return the PageBlobsGetPageRangesNextHeaders object itself. - */ - public PageBlobsGetPageRangesNextHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; - } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsResizeHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsResizeHeaders.java deleted file mode 100644 index 35bb70586ca2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsResizeHeaders.java +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The PageBlobsResizeHeaders model. - */ -@Fluent -public final class PageBlobsResizeHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long xMsBlobSequenceNumber; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_BLOB_SEQUENCE_NUMBER - = HttpHeaderName.fromString("x-ms-blob-sequence-number"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of PageBlobsResizeHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public PageBlobsResizeHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsBlobSequenceNumber = rawHeaders.getValue(X_MS_BLOB_SEQUENCE_NUMBER); - if (xMsBlobSequenceNumber != null) { - this.xMsBlobSequenceNumber = Long.parseLong(xMsBlobSequenceNumber); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsResizeHeaders object itself. - */ - public PageBlobsResizeHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsResizeHeaders object itself. - */ - public PageBlobsResizeHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the xMsBlobSequenceNumber value. - */ - public Long getXMsBlobSequenceNumber() { - return this.xMsBlobSequenceNumber; - } - - /** - * Set the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param xMsBlobSequenceNumber the xMsBlobSequenceNumber value to set. - * @return the PageBlobsResizeHeaders object itself. - */ - public PageBlobsResizeHeaders setXMsBlobSequenceNumber(Long xMsBlobSequenceNumber) { - this.xMsBlobSequenceNumber = xMsBlobSequenceNumber; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsResizeHeaders object itself. - */ - public PageBlobsResizeHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsResizeHeaders object itself. - */ - public PageBlobsResizeHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsResizeHeaders object itself. - */ - public PageBlobsResizeHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the PageBlobsResizeHeaders object itself. - */ - public PageBlobsResizeHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUpdateSequenceNumberHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUpdateSequenceNumberHeaders.java deleted file mode 100644 index b1996ed6895f..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUpdateSequenceNumberHeaders.java +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The PageBlobsUpdateSequenceNumberHeaders model. - */ -@Fluent -public final class PageBlobsUpdateSequenceNumberHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long xMsBlobSequenceNumber; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_BLOB_SEQUENCE_NUMBER - = HttpHeaderName.fromString("x-ms-blob-sequence-number"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of PageBlobsUpdateSequenceNumberHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public PageBlobsUpdateSequenceNumberHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsBlobSequenceNumber = rawHeaders.getValue(X_MS_BLOB_SEQUENCE_NUMBER); - if (xMsBlobSequenceNumber != null) { - this.xMsBlobSequenceNumber = Long.parseLong(xMsBlobSequenceNumber); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsUpdateSequenceNumberHeaders object itself. - */ - public PageBlobsUpdateSequenceNumberHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsUpdateSequenceNumberHeaders object itself. - */ - public PageBlobsUpdateSequenceNumberHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the xMsBlobSequenceNumber value. - */ - public Long getXMsBlobSequenceNumber() { - return this.xMsBlobSequenceNumber; - } - - /** - * Set the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param xMsBlobSequenceNumber the xMsBlobSequenceNumber value to set. - * @return the PageBlobsUpdateSequenceNumberHeaders object itself. - */ - public PageBlobsUpdateSequenceNumberHeaders setXMsBlobSequenceNumber(Long xMsBlobSequenceNumber) { - this.xMsBlobSequenceNumber = xMsBlobSequenceNumber; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsUpdateSequenceNumberHeaders object itself. - */ - public PageBlobsUpdateSequenceNumberHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsUpdateSequenceNumberHeaders object itself. - */ - public PageBlobsUpdateSequenceNumberHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsUpdateSequenceNumberHeaders object itself. - */ - public PageBlobsUpdateSequenceNumberHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the PageBlobsUpdateSequenceNumberHeaders object itself. - */ - public PageBlobsUpdateSequenceNumberHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUploadPagesFromURLHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUploadPagesFromURLHeaders.java deleted file mode 100644 index e69d888db432..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUploadPagesFromURLHeaders.java +++ /dev/null @@ -1,361 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The PageBlobsUploadPagesFromURLHeaders model. - */ -@Fluent -public final class PageBlobsUploadPagesFromURLHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long xMsBlobSequenceNumber; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_BLOB_SEQUENCE_NUMBER - = HttpHeaderName.fromString("x-ms-blob-sequence-number"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of PageBlobsUploadPagesFromURLHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public PageBlobsUploadPagesFromURLHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - String xMsBlobSequenceNumber = rawHeaders.getValue(X_MS_BLOB_SEQUENCE_NUMBER); - if (xMsBlobSequenceNumber != null) { - this.xMsBlobSequenceNumber = Long.parseLong(xMsBlobSequenceNumber); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the xMsBlobSequenceNumber value. - */ - public Long getXMsBlobSequenceNumber() { - return this.xMsBlobSequenceNumber; - } - - /** - * Set the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param xMsBlobSequenceNumber the xMsBlobSequenceNumber value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setXMsBlobSequenceNumber(Long xMsBlobSequenceNumber) { - this.xMsBlobSequenceNumber = xMsBlobSequenceNumber; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the PageBlobsUploadPagesFromURLHeaders object itself. - */ - public PageBlobsUploadPagesFromURLHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUploadPagesHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUploadPagesHeaders.java deleted file mode 100644 index a31ff25b258d..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageBlobsUploadPagesHeaders.java +++ /dev/null @@ -1,415 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; -import java.util.Base64; - -/** - * The PageBlobsUploadPagesHeaders model. - */ -@Fluent -public final class PageBlobsUploadPagesHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-content-crc64 property. - */ - private byte[] xMsContentCrc64; - - /* - * The x-ms-blob-sequence-number property. - */ - private Long xMsBlobSequenceNumber; - - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-encryption-key-sha256 property. - */ - private String xMsEncryptionKeySha256; - - /* - * The x-ms-structured-body property. - */ - private String xMsStructuredBody; - - /* - * The x-ms-request-server-encrypted property. - */ - private Boolean xMsRequestServerEncrypted; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - /* - * The Content-MD5 property. - */ - private byte[] contentMD5; - - /* - * The ETag property. - */ - private String eTag; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The x-ms-encryption-scope property. - */ - private String xMsEncryptionScope; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - - private static final HttpHeaderName X_MS_BLOB_SEQUENCE_NUMBER - = HttpHeaderName.fromString("x-ms-blob-sequence-number"); - - private static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - - private static final HttpHeaderName X_MS_STRUCTURED_BODY = HttpHeaderName.fromString("x-ms-structured-body"); - - private static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - - private static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of PageBlobsUploadPagesHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public PageBlobsUploadPagesHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsContentCrc64 = rawHeaders.getValue(X_MS_CONTENT_CRC64); - if (xMsContentCrc64 != null) { - this.xMsContentCrc64 = Base64.getDecoder().decode(xMsContentCrc64); - } - String xMsBlobSequenceNumber = rawHeaders.getValue(X_MS_BLOB_SEQUENCE_NUMBER); - if (xMsBlobSequenceNumber != null) { - this.xMsBlobSequenceNumber = Long.parseLong(xMsBlobSequenceNumber); - } - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } - this.xMsEncryptionKeySha256 = rawHeaders.getValue(X_MS_ENCRYPTION_KEY_SHA256); - this.xMsStructuredBody = rawHeaders.getValue(X_MS_STRUCTURED_BODY); - String xMsRequestServerEncrypted = rawHeaders.getValue(X_MS_REQUEST_SERVER_ENCRYPTED); - if (xMsRequestServerEncrypted != null) { - this.xMsRequestServerEncrypted = Boolean.parseBoolean(xMsRequestServerEncrypted); - } - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - this.xMsEncryptionScope = rawHeaders.getValue(X_MS_ENCRYPTION_SCOPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @return the xMsContentCrc64 value. - */ - public byte[] getXMsContentCrc64() { - return CoreUtils.clone(this.xMsContentCrc64); - } - - /** - * Set the xMsContentCrc64 property: The x-ms-content-crc64 property. - * - * @param xMsContentCrc64 the xMsContentCrc64 value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setXMsContentCrc64(byte[] xMsContentCrc64) { - this.xMsContentCrc64 = CoreUtils.clone(xMsContentCrc64); - return this; - } - - /** - * Get the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @return the xMsBlobSequenceNumber value. - */ - public Long getXMsBlobSequenceNumber() { - return this.xMsBlobSequenceNumber; - } - - /** - * Set the xMsBlobSequenceNumber property: The x-ms-blob-sequence-number property. - * - * @param xMsBlobSequenceNumber the xMsBlobSequenceNumber value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setXMsBlobSequenceNumber(Long xMsBlobSequenceNumber) { - this.xMsBlobSequenceNumber = xMsBlobSequenceNumber; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @return the xMsEncryptionKeySha256 value. - */ - public String getXMsEncryptionKeySha256() { - return this.xMsEncryptionKeySha256; - } - - /** - * Set the xMsEncryptionKeySha256 property: The x-ms-encryption-key-sha256 property. - * - * @param xMsEncryptionKeySha256 the xMsEncryptionKeySha256 value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setXMsEncryptionKeySha256(String xMsEncryptionKeySha256) { - this.xMsEncryptionKeySha256 = xMsEncryptionKeySha256; - return this; - } - - /** - * Get the xMsStructuredBody property: The x-ms-structured-body property. - * - * @return the xMsStructuredBody value. - */ - public String getXMsStructuredBody() { - return this.xMsStructuredBody; - } - - /** - * Set the xMsStructuredBody property: The x-ms-structured-body property. - * - * @param xMsStructuredBody the xMsStructuredBody value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setXMsStructuredBody(String xMsStructuredBody) { - this.xMsStructuredBody = xMsStructuredBody; - return this; - } - - /** - * Get the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @return the xMsRequestServerEncrypted value. - */ - public Boolean isXMsRequestServerEncrypted() { - return this.xMsRequestServerEncrypted; - } - - /** - * Set the xMsRequestServerEncrypted property: The x-ms-request-server-encrypted property. - * - * @param xMsRequestServerEncrypted the xMsRequestServerEncrypted value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setXMsRequestServerEncrypted(Boolean xMsRequestServerEncrypted) { - this.xMsRequestServerEncrypted = xMsRequestServerEncrypted; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @return the xMsEncryptionScope value. - */ - public String getXMsEncryptionScope() { - return this.xMsEncryptionScope; - } - - /** - * Set the xMsEncryptionScope property: The x-ms-encryption-scope property. - * - * @param xMsEncryptionScope the xMsEncryptionScope value to set. - * @return the PageBlobsUploadPagesHeaders object itself. - */ - public PageBlobsUploadPagesHeaders setXMsEncryptionScope(String xMsEncryptionScope) { - this.xMsEncryptionScope = xMsEncryptionScope; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListCollection.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListCollection.java deleted file mode 100644 index 58b8e92c0a55..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListCollection.java +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.PageRange; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import java.util.ArrayList; -import java.util.List; - -/** The PageListCollection model. */ -@Fluent -public final class PageListCollection implements XmlSerializable { - /* - * The value property. - */ - private List value = new ArrayList<>(); - - /* - * The nextMarker property. - */ - private String nextMarker; - - /** - * Get the value property: The value property. - * - * @return the value value. - */ - public List getValue() { - return this.value; - } - - /** - * Set the value property: The value property. - * - * @param value the value value to set. - * @return the PageListCollection object itself. - */ - public PageListCollection setValue(List value) { - this.value = value; - return this; - } - - /** - * Get the nextMarker property: The nextMarker property. - * - * @return the nextMarker value. - */ - public String getNextMarker() { - return this.nextMarker; - } - - /** - * Set the nextMarker property: The nextMarker property. - * - * @param nextMarker the nextMarker value to set. - * @return the PageListCollection object itself. - */ - public PageListCollection setNextMarker(String nextMarker) { - this.nextMarker = nextMarker; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "PageList" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (this.value != null) { - for (PageRange element : this.value) { - xmlWriter.writeXml(element, "PageRange"); - } - } - xmlWriter.writeStringElement("nextMarker", this.nextMarker); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of PageListCollection from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of PageListCollection if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws IllegalStateException If the deserialized XML object was missing any required properties. - * @throws XMLStreamException If an error occurs while reading the PageListCollection. - */ - public static PageListCollection fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of PageListCollection from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of PageListCollection if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws IllegalStateException If the deserialized XML object was missing any required properties. - * @throws XMLStreamException If an error occurs while reading the PageListCollection. - */ - public static PageListCollection fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "PageList" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - PageListCollection deserializedPageListCollection = new PageListCollection(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("PageRange".equals(elementName.getLocalPart())) { - if (deserializedPageListCollection.value == null) { - deserializedPageListCollection.value = new ArrayList<>(); - } - deserializedPageListCollection.value.add(PageRange.fromXml(reader, "PageRange")); - } else if ("nextMarker".equals(elementName.getLocalPart())) { - deserializedPageListCollection.nextMarker = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedPageListCollection; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListHelper.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListHelper.java deleted file mode 100644 index 8017c7c447e7..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListHelper.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.models; - -import com.azure.storage.blob.models.PageList; - -public class PageListHelper { - private static PageListAccessor accessor; - - public static String getNextMarker(PageList pageList) { - return accessor.getNextMarker(pageList); - } - - public static PageList setNextMarker(PageList pageList, String marker) { - return accessor.setNextMarker(pageList, marker); - } - - public static void setAccessor(PageListAccessor pageListAccessor) { - accessor = pageListAccessor; - } - - public interface PageListAccessor { - String getNextMarker(PageList pageList); - - PageList setNextMarker(PageList pageList, String marker); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListSegment.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListSegment.java deleted file mode 100644 index 2f8ff9e6ae82..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PageListSegment.java +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.ClearRange; -import com.azure.storage.blob.models.PageRange; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import java.util.ArrayList; -import java.util.List; - -/** The PageListSegment model. */ -@Fluent -public final class PageListSegment implements XmlSerializable { - /* - * The PageRanges property. - */ - private List pageRanges = new ArrayList<>(); - - /* - * The ClearRanges property. - */ - private List clearRanges = new ArrayList<>(); - - /* - * The NextMarker property. - */ - private String nextMarker; - - /** - * Get the pageRanges property: The PageRanges property. - * - * @return the pageRanges value. - */ - public List getPageRanges() { - return this.pageRanges; - } - - /** - * Set the pageRanges property: The PageRanges property. - * - * @param pageRanges the pageRanges value to set. - * @return the PageListSegment object itself. - */ - public PageListSegment setPageRanges(List pageRanges) { - this.pageRanges = pageRanges; - return this; - } - - /** - * Get the clearRanges property: The ClearRanges property. - * - * @return the clearRanges value. - */ - public List getClearRanges() { - return this.clearRanges; - } - - /** - * Set the clearRanges property: The ClearRanges property. - * - * @param clearRanges the clearRanges value to set. - * @return the PageListSegment object itself. - */ - public PageListSegment setClearRanges(List clearRanges) { - this.clearRanges = clearRanges; - return this; - } - - /** - * Get the nextMarker property: The NextMarker property. - * - * @return the nextMarker value. - */ - public String getNextMarker() { - return this.nextMarker; - } - - /** - * Set the nextMarker property: The NextMarker property. - * - * @param nextMarker the nextMarker value to set. - * @return the PageListSegment object itself. - */ - public PageListSegment setNextMarker(String nextMarker) { - this.nextMarker = nextMarker; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "PageListSegment" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (this.pageRanges != null) { - for (PageRange element : this.pageRanges) { - xmlWriter.writeXml(element, "PageRange"); - } - } - if (this.clearRanges != null) { - for (ClearRange element : this.clearRanges) { - xmlWriter.writeXml(element, "ClearRange"); - } - } - xmlWriter.writeStringElement(this.nextMarker, "NextMarker"); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of PageListSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of PageListSegment if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws IllegalStateException If the deserialized XML object was missing any required properties. - * @throws XMLStreamException If an error occurs while reading the PageListSegment. - */ - public static PageListSegment fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of PageListSegment from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of PageListSegment if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws IllegalStateException If the deserialized XML object was missing any required properties. - * @throws XMLStreamException If an error occurs while reading the PageListSegment. - */ - public static PageListSegment fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "PageListSegment" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - PageListSegment deserializedPageListSegment = new PageListSegment(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - if ("PageRange".equals(elementName.getLocalPart())) { - if (deserializedPageListSegment.pageRanges == null) { - deserializedPageListSegment.pageRanges = new ArrayList<>(); - } - deserializedPageListSegment.pageRanges.add(PageRange.fromXml(reader, "PageRange")); - } else if ("ClearRange".equals(elementName.getLocalPart())) { - if (deserializedPageListSegment.clearRanges == null) { - deserializedPageListSegment.clearRanges = new ArrayList<>(); - } - deserializedPageListSegment.clearRanges.add(ClearRange.fromXml(reader, "ClearRange")); - } else if ("NextMarker".equals(elementName.getLocalPart())) { - deserializedPageListSegment.nextMarker = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - return deserializedPageListSegment; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormat.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormat.java deleted file mode 100644 index ff63711d4a49..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormat.java +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * The QueryFormat model. - */ -@Fluent -public final class QueryFormat implements XmlSerializable { - /* - * The quick query format type. - */ - private QueryFormatType type; - - /* - * Groups the settings used for interpreting the blob data if the blob is delimited text formatted. - */ - private DelimitedTextConfiguration delimitedTextConfiguration; - - /* - * json text configuration - */ - private JsonTextConfiguration jsonTextConfiguration; - - /* - * Groups the settings used for formatting the response if the response should be Arrow formatted. - */ - private ArrowConfiguration arrowConfiguration; - - /* - * parquet configuration - */ - private Object parquetTextConfiguration; - - /** - * Creates an instance of QueryFormat class. - */ - public QueryFormat() { - } - - /** - * Get the type property: The quick query format type. - * - * @return the type value. - */ - public QueryFormatType getType() { - return this.type; - } - - /** - * Set the type property: The quick query format type. - * - * @param type the type value to set. - * @return the QueryFormat object itself. - */ - public QueryFormat setType(QueryFormatType type) { - this.type = type; - return this; - } - - /** - * Get the delimitedTextConfiguration property: Groups the settings used for interpreting the blob data if the blob - * is delimited text formatted. - * - * @return the delimitedTextConfiguration value. - */ - public DelimitedTextConfiguration getDelimitedTextConfiguration() { - return this.delimitedTextConfiguration; - } - - /** - * Set the delimitedTextConfiguration property: Groups the settings used for interpreting the blob data if the blob - * is delimited text formatted. - * - * @param delimitedTextConfiguration the delimitedTextConfiguration value to set. - * @return the QueryFormat object itself. - */ - public QueryFormat setDelimitedTextConfiguration(DelimitedTextConfiguration delimitedTextConfiguration) { - this.delimitedTextConfiguration = delimitedTextConfiguration; - return this; - } - - /** - * Get the jsonTextConfiguration property: json text configuration. - * - * @return the jsonTextConfiguration value. - */ - public JsonTextConfiguration getJsonTextConfiguration() { - return this.jsonTextConfiguration; - } - - /** - * Set the jsonTextConfiguration property: json text configuration. - * - * @param jsonTextConfiguration the jsonTextConfiguration value to set. - * @return the QueryFormat object itself. - */ - public QueryFormat setJsonTextConfiguration(JsonTextConfiguration jsonTextConfiguration) { - this.jsonTextConfiguration = jsonTextConfiguration; - return this; - } - - /** - * Get the arrowConfiguration property: Groups the settings used for formatting the response if the response should - * be Arrow formatted. - * - * @return the arrowConfiguration value. - */ - public ArrowConfiguration getArrowConfiguration() { - return this.arrowConfiguration; - } - - /** - * Set the arrowConfiguration property: Groups the settings used for formatting the response if the response should - * be Arrow formatted. - * - * @param arrowConfiguration the arrowConfiguration value to set. - * @return the QueryFormat object itself. - */ - public QueryFormat setArrowConfiguration(ArrowConfiguration arrowConfiguration) { - this.arrowConfiguration = arrowConfiguration; - return this; - } - - /** - * Get the parquetTextConfiguration property: parquet configuration. - * - * @return the parquetTextConfiguration value. - */ - public Object getParquetTextConfiguration() { - return this.parquetTextConfiguration; - } - - /** - * Set the parquetTextConfiguration property: parquet configuration. - * - * @param parquetTextConfiguration the parquetTextConfiguration value to set. - * @return the QueryFormat object itself. - */ - public QueryFormat setParquetTextConfiguration(Object parquetTextConfiguration) { - this.parquetTextConfiguration = parquetTextConfiguration; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "QueryFormat" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Type", this.type == null ? null : this.type.toString()); - xmlWriter.writeXml(this.delimitedTextConfiguration, "DelimitedTextConfiguration"); - xmlWriter.writeXml(this.jsonTextConfiguration, "JsonTextConfiguration"); - xmlWriter.writeXml(this.arrowConfiguration, "ArrowConfiguration"); - xmlWriter.writeStartElement("ParquetTextConfiguration").writeEndElement(); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of QueryFormat from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of QueryFormat if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the QueryFormat. - */ - public static QueryFormat fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of QueryFormat from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of QueryFormat if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the QueryFormat. - */ - public static QueryFormat fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "QueryFormat" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - QueryFormat deserializedQueryFormat = new QueryFormat(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Type".equals(elementName.getLocalPart())) { - deserializedQueryFormat.type = QueryFormatType.fromString(reader.getStringElement()); - } else if ("DelimitedTextConfiguration".equals(elementName.getLocalPart())) { - deserializedQueryFormat.delimitedTextConfiguration - = DelimitedTextConfiguration.fromXml(reader, "DelimitedTextConfiguration"); - } else if ("JsonTextConfiguration".equals(elementName.getLocalPart())) { - deserializedQueryFormat.jsonTextConfiguration - = JsonTextConfiguration.fromXml(reader, "JsonTextConfiguration"); - } else if ("ArrowConfiguration".equals(elementName.getLocalPart())) { - deserializedQueryFormat.arrowConfiguration - = ArrowConfiguration.fromXml(reader, "ArrowConfiguration"); - } else if ("ParquetTextConfiguration".equals(elementName.getLocalPart())) { - deserializedQueryFormat.parquetTextConfiguration = new Object(); - xmlReader.skipElement(); - } else { - reader.skipElement(); - } - } - - return deserializedQueryFormat; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormatType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormatType.java deleted file mode 100644 index 677dfb3dc5f5..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormatType.java +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -/** - * The quick query format type. - */ -public enum QueryFormatType { - /** - * Enum value delimited. - */ - DELIMITED("delimited"), - - /** - * Enum value json. - */ - JSON("json"), - - /** - * Enum value arrow. - */ - ARROW("arrow"), - - /** - * Enum value parquet. - */ - PARQUET("parquet"); - - /** - * The actual serialized value for a QueryFormatType instance. - */ - private final String value; - - QueryFormatType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a QueryFormatType instance. - * - * @param value the serialized value to parse. - * @return the parsed QueryFormatType object, or null if unable to parse. - */ - public static QueryFormatType fromString(String value) { - if (value == null) { - return null; - } - QueryFormatType[] items = QueryFormatType.values(); - for (QueryFormatType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryRequest.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryRequest.java deleted file mode 100644 index 5ac5a8f5e87d..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryRequest.java +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Groups the set of query request settings. - */ -@Fluent -public final class QueryRequest implements XmlSerializable { - - /* - * Required. The type of the provided query expression. - */ - private String queryType = "SQL"; - - /* - * The query expression in SQL. The maximum size of the query expression is 256KiB. - */ - private String expression; - - /* - * The InputSerialization property. - */ - private QuerySerialization inputSerialization; - - /* - * The OutputSerialization property. - */ - private QuerySerialization outputSerialization; - - /** - * Creates an instance of QueryRequest class. - */ - public QueryRequest() { - } - - /** - * Get the queryType property: Required. The type of the provided query expression. - * - * @return the queryType value. - */ - public String getQueryType() { - return this.queryType; - } - - /** - * Get the expression property: The query expression in SQL. The maximum size of the query expression is 256KiB. - * - * @return the expression value. - */ - public String getExpression() { - return this.expression; - } - - /** - * Set the expression property: The query expression in SQL. The maximum size of the query expression is 256KiB. - * - * @param expression the expression value to set. - * @return the QueryRequest object itself. - */ - public QueryRequest setExpression(String expression) { - this.expression = expression; - return this; - } - - /** - * Get the inputSerialization property: The InputSerialization property. - * - * @return the inputSerialization value. - */ - public QuerySerialization getInputSerialization() { - return this.inputSerialization; - } - - /** - * Set the inputSerialization property: The InputSerialization property. - * - * @param inputSerialization the inputSerialization value to set. - * @return the QueryRequest object itself. - */ - public QueryRequest setInputSerialization(QuerySerialization inputSerialization) { - this.inputSerialization = inputSerialization; - return this; - } - - /** - * Get the outputSerialization property: The OutputSerialization property. - * - * @return the outputSerialization value. - */ - public QuerySerialization getOutputSerialization() { - return this.outputSerialization; - } - - /** - * Set the outputSerialization property: The OutputSerialization property. - * - * @param outputSerialization the outputSerialization value to set. - * @return the QueryRequest object itself. - */ - public QueryRequest setOutputSerialization(QuerySerialization outputSerialization) { - this.outputSerialization = outputSerialization; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "QueryRequest" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("QueryType", this.queryType); - xmlWriter.writeStringElement("Expression", this.expression); - xmlWriter.writeXml(this.inputSerialization, "InputSerialization"); - xmlWriter.writeXml(this.outputSerialization, "OutputSerialization"); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of QueryRequest from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of QueryRequest if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the QueryRequest. - */ - public static QueryRequest fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of QueryRequest from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of QueryRequest if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the QueryRequest. - */ - public static QueryRequest fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "QueryRequest" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - QueryRequest deserializedQueryRequest = new QueryRequest(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - if ("QueryType".equals(elementName.getLocalPart())) { - deserializedQueryRequest.queryType = reader.getStringElement(); - } else if ("Expression".equals(elementName.getLocalPart())) { - deserializedQueryRequest.expression = reader.getStringElement(); - } else if ("InputSerialization".equals(elementName.getLocalPart())) { - deserializedQueryRequest.inputSerialization - = QuerySerialization.fromXml(reader, "InputSerialization"); - } else if ("OutputSerialization".equals(elementName.getLocalPart())) { - deserializedQueryRequest.outputSerialization - = QuerySerialization.fromXml(reader, "OutputSerialization"); - } else { - reader.skipElement(); - } - } - return deserializedQueryRequest; - }); - } - - /** - * Set the queryType property: Required. The type of the provided query expression. - * - * @param queryType the queryType value to set. - * @return the QueryRequest object itself. - */ - public QueryRequest setQueryType(String queryType) { - this.queryType = queryType; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QuerySerialization.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QuerySerialization.java deleted file mode 100644 index e42c1b2c43fb..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QuerySerialization.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * The QuerySerialization model. - */ -@Fluent -public final class QuerySerialization implements XmlSerializable { - /* - * The Format property. - */ - private QueryFormat format; - - /** - * Creates an instance of QuerySerialization class. - */ - public QuerySerialization() { - } - - /** - * Get the format property: The Format property. - * - * @return the format value. - */ - public QueryFormat getFormat() { - return this.format; - } - - /** - * Set the format property: The Format property. - * - * @param format the format value to set. - * @return the QuerySerialization object itself. - */ - public QuerySerialization setFormat(QueryFormat format) { - this.format = format; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "QuerySerialization" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.format, "Format"); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of QuerySerialization from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of QuerySerialization if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the QuerySerialization. - */ - public static QuerySerialization fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of QuerySerialization from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of QuerySerialization if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the QuerySerialization. - */ - public static QuerySerialization fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "QuerySerialization" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - QuerySerialization deserializedQuerySerialization = new QuerySerialization(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Format".equals(elementName.getLocalPart())) { - deserializedQuerySerialization.format = QueryFormat.fromXml(reader, "Format"); - } else { - reader.skipElement(); - } - } - - return deserializedQuerySerialization; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesFilterBlobsHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesFilterBlobsHeaders.java deleted file mode 100644 index 54f720b74266..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesFilterBlobsHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ServicesFilterBlobsHeaders model. - */ -@Fluent -public final class ServicesFilterBlobsHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ServicesFilterBlobsHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ServicesFilterBlobsHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ServicesFilterBlobsHeaders object itself. - */ - public ServicesFilterBlobsHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ServicesFilterBlobsHeaders object itself. - */ - public ServicesFilterBlobsHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ServicesFilterBlobsHeaders object itself. - */ - public ServicesFilterBlobsHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ServicesFilterBlobsHeaders object itself. - */ - public ServicesFilterBlobsHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetAccountInfoHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetAccountInfoHeaders.java deleted file mode 100644 index 4f55ca4b4b4e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetAccountInfoHeaders.java +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.models.AccountKind; -import com.azure.storage.blob.models.SkuName; -import java.time.OffsetDateTime; - -/** - * The ServicesGetAccountInfoHeaders model. - */ -@Fluent -public final class ServicesGetAccountInfoHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-account-kind property. - */ - private AccountKind xMsAccountKind; - - /* - * The x-ms-is-hns-enabled property. - */ - private Boolean xMsIsHnsEnabled; - - /* - * The x-ms-sku-name property. - */ - private SkuName xMsSkuName; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_ACCOUNT_KIND = HttpHeaderName.fromString("x-ms-account-kind"); - - private static final HttpHeaderName X_MS_IS_HNS_ENABLED = HttpHeaderName.fromString("x-ms-is-hns-enabled"); - - private static final HttpHeaderName X_MS_SKU_NAME = HttpHeaderName.fromString("x-ms-sku-name"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ServicesGetAccountInfoHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ServicesGetAccountInfoHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String xMsAccountKind = rawHeaders.getValue(X_MS_ACCOUNT_KIND); - if (xMsAccountKind != null) { - this.xMsAccountKind = AccountKind.fromString(xMsAccountKind); - } - String xMsIsHnsEnabled = rawHeaders.getValue(X_MS_IS_HNS_ENABLED); - if (xMsIsHnsEnabled != null) { - this.xMsIsHnsEnabled = Boolean.parseBoolean(xMsIsHnsEnabled); - } - String xMsSkuName = rawHeaders.getValue(X_MS_SKU_NAME); - if (xMsSkuName != null) { - this.xMsSkuName = SkuName.fromString(xMsSkuName); - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ServicesGetAccountInfoHeaders object itself. - */ - public ServicesGetAccountInfoHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsAccountKind property: The x-ms-account-kind property. - * - * @return the xMsAccountKind value. - */ - public AccountKind getXMsAccountKind() { - return this.xMsAccountKind; - } - - /** - * Set the xMsAccountKind property: The x-ms-account-kind property. - * - * @param xMsAccountKind the xMsAccountKind value to set. - * @return the ServicesGetAccountInfoHeaders object itself. - */ - public ServicesGetAccountInfoHeaders setXMsAccountKind(AccountKind xMsAccountKind) { - this.xMsAccountKind = xMsAccountKind; - return this; - } - - /** - * Get the xMsIsHnsEnabled property: The x-ms-is-hns-enabled property. - * - * @return the xMsIsHnsEnabled value. - */ - public Boolean isXMsIsHnsEnabled() { - return this.xMsIsHnsEnabled; - } - - /** - * Set the xMsIsHnsEnabled property: The x-ms-is-hns-enabled property. - * - * @param xMsIsHnsEnabled the xMsIsHnsEnabled value to set. - * @return the ServicesGetAccountInfoHeaders object itself. - */ - public ServicesGetAccountInfoHeaders setXMsIsHnsEnabled(Boolean xMsIsHnsEnabled) { - this.xMsIsHnsEnabled = xMsIsHnsEnabled; - return this; - } - - /** - * Get the xMsSkuName property: The x-ms-sku-name property. - * - * @return the xMsSkuName value. - */ - public SkuName getXMsSkuName() { - return this.xMsSkuName; - } - - /** - * Set the xMsSkuName property: The x-ms-sku-name property. - * - * @param xMsSkuName the xMsSkuName value to set. - * @return the ServicesGetAccountInfoHeaders object itself. - */ - public ServicesGetAccountInfoHeaders setXMsSkuName(SkuName xMsSkuName) { - this.xMsSkuName = xMsSkuName; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ServicesGetAccountInfoHeaders object itself. - */ - public ServicesGetAccountInfoHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ServicesGetAccountInfoHeaders object itself. - */ - public ServicesGetAccountInfoHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ServicesGetAccountInfoHeaders object itself. - */ - public ServicesGetAccountInfoHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetPropertiesHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetPropertiesHeaders.java deleted file mode 100644 index e8127d8a60c2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetPropertiesHeaders.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; - -/** - * The ServicesGetPropertiesHeaders model. - */ -@Fluent -public final class ServicesGetPropertiesHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ServicesGetPropertiesHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ServicesGetPropertiesHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ServicesGetPropertiesHeaders object itself. - */ - public ServicesGetPropertiesHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ServicesGetPropertiesHeaders object itself. - */ - public ServicesGetPropertiesHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ServicesGetPropertiesHeaders object itself. - */ - public ServicesGetPropertiesHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetStatisticsHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetStatisticsHeaders.java deleted file mode 100644 index 6d99bb8fa3f9..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetStatisticsHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ServicesGetStatisticsHeaders model. - */ -@Fluent -public final class ServicesGetStatisticsHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ServicesGetStatisticsHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ServicesGetStatisticsHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ServicesGetStatisticsHeaders object itself. - */ - public ServicesGetStatisticsHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ServicesGetStatisticsHeaders object itself. - */ - public ServicesGetStatisticsHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ServicesGetStatisticsHeaders object itself. - */ - public ServicesGetStatisticsHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ServicesGetStatisticsHeaders object itself. - */ - public ServicesGetStatisticsHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetUserDelegationKeyHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetUserDelegationKeyHeaders.java deleted file mode 100644 index 9168138f5d8c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesGetUserDelegationKeyHeaders.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import java.time.OffsetDateTime; - -/** - * The ServicesGetUserDelegationKeyHeaders model. - */ -@Fluent -public final class ServicesGetUserDelegationKeyHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - /* - * The Date property. - */ - private DateTimeRfc1123 date; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ServicesGetUserDelegationKeyHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ServicesGetUserDelegationKeyHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ServicesGetUserDelegationKeyHeaders object itself. - */ - public ServicesGetUserDelegationKeyHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ServicesGetUserDelegationKeyHeaders object itself. - */ - public ServicesGetUserDelegationKeyHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ServicesGetUserDelegationKeyHeaders object itself. - */ - public ServicesGetUserDelegationKeyHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the ServicesGetUserDelegationKeyHeaders object itself. - */ - public ServicesGetUserDelegationKeyHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesListBlobContainersSegmentHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesListBlobContainersSegmentHeaders.java deleted file mode 100644 index 64512684350b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesListBlobContainersSegmentHeaders.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; - -/** - * The ServicesListBlobContainersSegmentHeaders model. - */ -@Fluent -public final class ServicesListBlobContainersSegmentHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ServicesListBlobContainersSegmentHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ServicesListBlobContainersSegmentHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ServicesListBlobContainersSegmentHeaders object itself. - */ - public ServicesListBlobContainersSegmentHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ServicesListBlobContainersSegmentHeaders object itself. - */ - public ServicesListBlobContainersSegmentHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ServicesListBlobContainersSegmentHeaders object itself. - */ - public ServicesListBlobContainersSegmentHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesListBlobContainersSegmentNextHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesListBlobContainersSegmentNextHeaders.java deleted file mode 100644 index 0d8f4d36c430..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesListBlobContainersSegmentNextHeaders.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; - -/** - * The ServicesListBlobContainersSegmentNextHeaders model. - */ -@Fluent -public final class ServicesListBlobContainersSegmentNextHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ServicesListBlobContainersSegmentNextHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ServicesListBlobContainersSegmentNextHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ServicesListBlobContainersSegmentNextHeaders object itself. - */ - public ServicesListBlobContainersSegmentNextHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ServicesListBlobContainersSegmentNextHeaders object itself. - */ - public ServicesListBlobContainersSegmentNextHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ServicesListBlobContainersSegmentNextHeaders object itself. - */ - public ServicesListBlobContainersSegmentNextHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesSetPropertiesHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesSetPropertiesHeaders.java deleted file mode 100644 index 8ee19e86bf64..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesSetPropertiesHeaders.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; - -/** - * The ServicesSetPropertiesHeaders model. - */ -@Fluent -public final class ServicesSetPropertiesHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The x-ms-client-request-id property. - */ - private String xMsClientRequestId; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ServicesSetPropertiesHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ServicesSetPropertiesHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ServicesSetPropertiesHeaders object itself. - */ - public ServicesSetPropertiesHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ServicesSetPropertiesHeaders object itself. - */ - public ServicesSetPropertiesHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @return the xMsClientRequestId value. - */ - public String getXMsClientRequestId() { - return this.xMsClientRequestId; - } - - /** - * Set the xMsClientRequestId property: The x-ms-client-request-id property. - * - * @param xMsClientRequestId the xMsClientRequestId value to set. - * @return the ServicesSetPropertiesHeaders object itself. - */ - public ServicesSetPropertiesHeaders setXMsClientRequestId(String xMsClientRequestId) { - this.xMsClientRequestId = xMsClientRequestId; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesSubmitBatchHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesSubmitBatchHeaders.java deleted file mode 100644 index 19f1dd224b69..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ServicesSubmitBatchHeaders.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; - -/** - * The ServicesSubmitBatchHeaders model. - */ -@Fluent -public final class ServicesSubmitBatchHeaders { - /* - * The x-ms-version property. - */ - private String xMsVersion; - - /* - * The x-ms-request-id property. - */ - private String xMsRequestId; - - /* - * The Content-Type property. - */ - private String contentType; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of ServicesSubmitBatchHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public ServicesSubmitBatchHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the ServicesSubmitBatchHeaders object itself. - */ - public ServicesSubmitBatchHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the ServicesSubmitBatchHeaders object itself. - */ - public ServicesSubmitBatchHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the ServicesSubmitBatchHeaders object itself. - */ - public ServicesSubmitBatchHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/SetPropertiesRequest.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/SetPropertiesRequest.java new file mode 100644 index 000000000000..d4e2dd1694ff --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/SetPropertiesRequest.java @@ -0,0 +1,285 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.storage.blob.models.CorsRule; +import com.azure.storage.blob.models.Logging; +import com.azure.storage.blob.models.Metrics; +import com.azure.storage.blob.models.RetentionPolicy; +import com.azure.storage.blob.models.StaticWebsite; +import java.io.IOException; +import java.util.List; + +/** + * The SetPropertiesRequest model. + */ +@Fluent +public final class SetPropertiesRequest implements JsonSerializable { + /* + * The logging properties. + */ + @Generated + private Logging logging; + + /* + * The hour metrics properties. + */ + @Generated + private Metrics hourMetrics; + + /* + * The minute metrics properties. + */ + @Generated + private Metrics minuteMetrics; + + /* + * The CORS properties. + */ + @Generated + private List cors; + + /* + * The default service version. + */ + @Generated + private String defaultServiceVersion; + + /* + * The delete retention policy. + */ + @Generated + private RetentionPolicy deleteRetentionPolicy; + + /* + * The static website properties. + */ + @Generated + private StaticWebsite staticWebsite; + + /** + * Creates an instance of SetPropertiesRequest class. + */ + @Generated + public SetPropertiesRequest() { + } + + /** + * Get the logging property: The logging properties. + * + * @return the logging value. + */ + @Generated + public Logging getLogging() { + return this.logging; + } + + /** + * Set the logging property: The logging properties. + * + * @param logging the logging value to set. + * @return the SetPropertiesRequest object itself. + */ + @Generated + public SetPropertiesRequest setLogging(Logging logging) { + this.logging = logging; + return this; + } + + /** + * Get the hourMetrics property: The hour metrics properties. + * + * @return the hourMetrics value. + */ + @Generated + public Metrics getHourMetrics() { + return this.hourMetrics; + } + + /** + * Set the hourMetrics property: The hour metrics properties. + * + * @param hourMetrics the hourMetrics value to set. + * @return the SetPropertiesRequest object itself. + */ + @Generated + public SetPropertiesRequest setHourMetrics(Metrics hourMetrics) { + this.hourMetrics = hourMetrics; + return this; + } + + /** + * Get the minuteMetrics property: The minute metrics properties. + * + * @return the minuteMetrics value. + */ + @Generated + public Metrics getMinuteMetrics() { + return this.minuteMetrics; + } + + /** + * Set the minuteMetrics property: The minute metrics properties. + * + * @param minuteMetrics the minuteMetrics value to set. + * @return the SetPropertiesRequest object itself. + */ + @Generated + public SetPropertiesRequest setMinuteMetrics(Metrics minuteMetrics) { + this.minuteMetrics = minuteMetrics; + return this; + } + + /** + * Get the cors property: The CORS properties. + * + * @return the cors value. + */ + @Generated + public List getCors() { + return this.cors; + } + + /** + * Set the cors property: The CORS properties. + * + * @param cors the cors value to set. + * @return the SetPropertiesRequest object itself. + */ + @Generated + public SetPropertiesRequest setCors(List cors) { + this.cors = cors; + return this; + } + + /** + * Get the defaultServiceVersion property: The default service version. + * + * @return the defaultServiceVersion value. + */ + @Generated + public String getDefaultServiceVersion() { + return this.defaultServiceVersion; + } + + /** + * Set the defaultServiceVersion property: The default service version. + * + * @param defaultServiceVersion the defaultServiceVersion value to set. + * @return the SetPropertiesRequest object itself. + */ + @Generated + public SetPropertiesRequest setDefaultServiceVersion(String defaultServiceVersion) { + this.defaultServiceVersion = defaultServiceVersion; + return this; + } + + /** + * Get the deleteRetentionPolicy property: The delete retention policy. + * + * @return the deleteRetentionPolicy value. + */ + @Generated + public RetentionPolicy getDeleteRetentionPolicy() { + return this.deleteRetentionPolicy; + } + + /** + * Set the deleteRetentionPolicy property: The delete retention policy. + * + * @param deleteRetentionPolicy the deleteRetentionPolicy value to set. + * @return the SetPropertiesRequest object itself. + */ + @Generated + public SetPropertiesRequest setDeleteRetentionPolicy(RetentionPolicy deleteRetentionPolicy) { + this.deleteRetentionPolicy = deleteRetentionPolicy; + return this; + } + + /** + * Get the staticWebsite property: The static website properties. + * + * @return the staticWebsite value. + */ + @Generated + public StaticWebsite getStaticWebsite() { + return this.staticWebsite; + } + + /** + * Set the staticWebsite property: The static website properties. + * + * @param staticWebsite the staticWebsite value to set. + * @return the SetPropertiesRequest object itself. + */ + @Generated + public SetPropertiesRequest setStaticWebsite(StaticWebsite staticWebsite) { + this.staticWebsite = staticWebsite; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("logging", this.logging); + jsonWriter.writeJsonField("hourMetrics", this.hourMetrics); + jsonWriter.writeJsonField("minuteMetrics", this.minuteMetrics); + jsonWriter.writeArrayField("cors", this.cors, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("defaultServiceVersion", this.defaultServiceVersion); + jsonWriter.writeJsonField("deleteRetentionPolicy", this.deleteRetentionPolicy); + jsonWriter.writeJsonField("staticWebsite", this.staticWebsite); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SetPropertiesRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SetPropertiesRequest if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the SetPropertiesRequest. + */ + @Generated + public static SetPropertiesRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SetPropertiesRequest deserializedSetPropertiesRequest = new SetPropertiesRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("logging".equals(fieldName)) { + deserializedSetPropertiesRequest.logging = Logging.fromJson(reader); + } else if ("hourMetrics".equals(fieldName)) { + deserializedSetPropertiesRequest.hourMetrics = Metrics.fromJson(reader); + } else if ("minuteMetrics".equals(fieldName)) { + deserializedSetPropertiesRequest.minuteMetrics = Metrics.fromJson(reader); + } else if ("cors".equals(fieldName)) { + List cors = reader.readArray(reader1 -> CorsRule.fromJson(reader1)); + deserializedSetPropertiesRequest.cors = cors; + } else if ("defaultServiceVersion".equals(fieldName)) { + deserializedSetPropertiesRequest.defaultServiceVersion = reader.getString(); + } else if ("deleteRetentionPolicy".equals(fieldName)) { + deserializedSetPropertiesRequest.deleteRetentionPolicy = RetentionPolicy.fromJson(reader); + } else if ("staticWebsite".equals(fieldName)) { + deserializedSetPropertiesRequest.staticWebsite = StaticWebsite.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSetPropertiesRequest; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/StorageError.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/StorageError.java deleted file mode 100644 index c2708b17ee21..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/StorageError.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * The StorageError model. - */ -@Fluent -public final class StorageError implements XmlSerializable { - /* - * The Message property. - */ - private String message; - - /** - * Creates an instance of StorageError class. - */ - public StorageError() { - } - - /** - * Get the message property: The Message property. - * - * @return the message value. - */ - public String getMessage() { - return this.message; - } - - /** - * Set the message property: The Message property. - * - * @param message the message value to set. - * @return the StorageError object itself. - */ - public StorageError setMessage(String message) { - this.message = message; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "StorageError" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Message", this.message); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of StorageError from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of StorageError if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the StorageError. - */ - public static StorageError fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of StorageError from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of StorageError if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the StorageError. - */ - public static StorageError fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "StorageError" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - StorageError deserializedStorageError = new StorageError(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Message".equals(elementName.getLocalPart())) { - deserializedStorageError.message = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedStorageError; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/StorageErrorException.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/StorageErrorException.java deleted file mode 100644 index 2171fe339ef0..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/StorageErrorException.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.implementation.models; - -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpResponse; - -/** - * Exception thrown for an invalid response with StorageError information. - */ -public final class StorageErrorException extends HttpResponseException { - /** - * Initializes a new instance of the StorageErrorException class. - * - * @param message the exception message or the response content if a message is not available. - * @param response the HTTP response. - */ - public StorageErrorException(String message, HttpResponse response) { - super(message, response); - } - - /** - * Initializes a new instance of the StorageErrorException class. - * - * @param message the exception message or the response content if a message is not available. - * @param response the HTTP response. - * @param value the deserialized response value. - */ - public StorageErrorException(String message, HttpResponse response, StorageError value) { - super(message, response, value); - } - - /** - * {@inheritDoc} - */ - @Override - public StorageError getValue() { - return (StorageError) super.getValue(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/package-info.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/package-info.java index 4c7fa15a262d..e99f509a1fce 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/package-info.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/package-info.java @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. /** - * Package containing the data models for AzureBlobStorage. - * null. + * Package containing the data models for Blob. */ package com.azure.storage.blob.implementation.models; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/package-info.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/package-info.java index 639d482c5fda..a6d905921bcb 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/package-info.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/package-info.java @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. /** - * Package containing the implementations for AzureBlobStorage. - * null. + * Package containing the implementations for Blob. */ package com.azure.storage.blob.implementation; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobConstants.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobConstants.java deleted file mode 100644 index 1c78a6c469c8..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobConstants.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -import com.azure.storage.common.implementation.Constants; - -/** - * Constants used in Blob Client classes. - *

- * RESERVED FOR INTERNAL USE. - */ -public final class BlobConstants { - /** - * Special container name for the root container in the Storage account. - */ - public static final String ROOT_CONTAINER_NAME = "$root"; - /** - * Special container name for the static website container in the Storage account. - */ - public static final String STATIC_WEBSITE_CONTAINER_NAME = "$web"; - /** - * Special container name for the logs container in the Storage account. - */ - public static final String LOG_CONTAINER_NAME = "$logs"; - /** - * The block size to use if none is specified in parallel operations. - */ - public static final int BLOB_DEFAULT_UPLOAD_BLOCK_SIZE = 4 * Constants.MB; - /** - * The number of buffers to use if none is specified on the buffered upload method. - */ - public static final int BLOB_DEFAULT_NUMBER_OF_BUFFERS = 8; - /** - * If a blob is known to be greater than 100MB, using a larger block size will trigger some server-side - * optimizations. If the block size is not set and the size of the blob is known to be greater than 100MB, this - * value will be used. - */ - public static final int BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE = 8 * Constants.MB; - /** - * The default block size used in BlobBaseClient and BlobBaseAsyncClient's uploadFromFile. - */ - public static final int DEFAULT_FILE_READ_CHUNK_SIZE = 1024 * 64; - /** - * Indicates the maximum number of bytes that can be sent in a call to appendBlock. - */ - public static final int MAX_APPEND_BLOCK_BYTES_VERSIONS_2021_12_02_AND_BELOW = 4 * Constants.MB; - /** - * Indicates the maximum number of bytes that can be sent in a call to appendBlock. - * For versions 2022-11-02 and above. - */ - public static final int MAX_APPEND_BLOCK_BYTES_VERSIONS_2022_11_02_AND_ABOVE = 100 * Constants.MB; - /** - * Indicates the maximum number of blocks allowed in an append/block blob. - */ - public static final int MAX_BLOCKS = 50000; - /** - * Indicates the maximum number of bytes that can be sent in a call to upload. - */ - public static final long MAX_UPLOAD_BLOB_BYTES_LONG = 5000L * Constants.MB; - /** - * Indicates the maximum number of bytes that can be sent in a call to stageBlock. - */ - public static final long MAX_STAGE_BLOCK_BYTES_LONG = 4000L * Constants.MB; - /** - * Indicates the number of bytes in a page. - */ - public static final int PAGE_BYTES = 512; - /** - * Indicates the maximum number of bytes that may be sent in a call to putPage. - */ - public static final int MAX_PUT_PAGES_BYTES = 4 * Constants.MB; -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobHeadersAndQueryParameters.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobHeadersAndQueryParameters.java deleted file mode 100644 index 52f28ff4029a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobHeadersAndQueryParameters.java +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Storage Blob whitelist headers and parameters for log options. - */ -public class BlobHeadersAndQueryParameters { - private static final Set BLOB_HEADERS = Stream.of("Access-Control-Allow-Origin", "Cache-Control", - "Content-Length", "Content-Type", "Date", "Request-Id", "traceparent", "Transfer-Encoding", "User-Agent", - "x-ms-client-request-id", "x-ms-date", "x-ms-error-code", "x-ms-request-id", "x-ms-return-client-request-id", - "x-ms-version", "Accept-Ranges", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-MD5", - "Content-Range", "ETag", "Last-Modified", "Server", "Vary", "x-ms-content-crc64", "x-ms-copy-action", - "x-ms-copy-completion-time", "x-ms-copy-id", "x-ms-copy-progress", "x-ms-copy-status", - "x-ms-has-immutability-policy", "x-ms-has-legal-hold", "x-ms-lease-state", "x-ms-lease-status", "x-ms-range", - "x-ms-request-server-encrypted", "x-ms-server-encrypted", "x-ms-snapshot", "x-ms-source-range", "If-Match", - "If-Modified-Since", "If-None-Match", "If-Unmodified-Since", "x-ms-access-tier", "x-ms-access-tier-change-time", - "x-ms-access-tier-inferred", "x-ms-account-kind", "x-ms-archive-status", "x-ms-blob-append-offset", - "x-ms-blob-cache-control", "x-ms-blob-committed-block-count", "x-ms-blob-condition-appendpos", - "x-ms-blob-condition-maxsize", "x-ms-blob-content-disposition", "x-ms-blob-content-encoding", - "x-ms-blob-content-language", "x-ms-blob-content-length", "x-ms-blob-content-md5", "x-ms-blob-content-type", - "x-ms-blob-public-access", "x-ms-blob-sequence-number", "x-ms-blob-type", "x-ms-copy-destination-snapshot", - "x-ms-creation-time", "x-ms-default-encryption-scope", "x-ms-delete-snapshots", "x-ms-delete-type-permanent", - "x-ms-deny-encryption-scope-override", "x-ms-encryption-algorithm", "x-ms-if-sequence-number-eq", - "x-ms-if-sequence-number-le", "x-ms-if-sequence-number-lt", "x-ms-incremental-copy", "x-ms-lease-action", - "x-ms-lease-break-period", "x-ms-lease-duration", "x-ms-lease-id", "x-ms-lease-time", "x-ms-page-write", - "x-ms-proposed-lease-id", "x-ms-range-get-content-md5", "x-ms-rehydrate-priority", - "x-ms-sequence-number-action", "x-ms-sku-name", "x-ms-source-content-md5", "x-ms-source-if-match", - "x-ms-source-if-modified-since", "x-ms-source-if-none-match", "x-ms-source-if-unmodified-since", - "x-ms-tag-count", "x-ms-encryption-key-sha256").collect(Collectors.toCollection(HashSet::new)); - - /** - * Gets the Storage Blob whitelist headers for log. - * - * @return the set of Storage Blob whitelist headers. - */ - public static Set getBlobHeaders() { - return BLOB_HEADERS; - } - - private static final Set BLOB_QUERY_PARAMETERS = Stream - .of("comp", "maxresults", "rscc", "rscd", "rsce", "rscl", "rsct", "se", "si", "sip", "sp", "spr", "sr", "srt", - "ss", "st", "sv", "include", "marker", "prefix", "copyid", "restype", "blockid", "blocklisttype", - "delimiter", "prevsnapshot", "ske", "skoid", "sks", "skt", "sktid", "skv", "snapshot") - .collect(Collectors.toCollection(HashSet::new)); - - /** - * Gets the Storage Blob whitelist query parameters for log. - * - * @return the set of Storage Blob whitelist query parameters. - */ - public static Set getBlobQueryParameters() { - return BLOB_QUERY_PARAMETERS; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobQueryReader.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobQueryReader.java deleted file mode 100644 index b3ed269c32bd..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobQueryReader.java +++ /dev/null @@ -1,366 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.models.ArrowConfiguration; -import com.azure.storage.blob.implementation.models.ArrowField; -import com.azure.storage.blob.implementation.models.DelimitedTextConfiguration; -import com.azure.storage.blob.implementation.models.JsonTextConfiguration; -import com.azure.storage.blob.implementation.models.QueryFormat; -import com.azure.storage.blob.implementation.models.QueryFormatType; -import com.azure.storage.blob.implementation.models.QuerySerialization; -import com.azure.storage.blob.models.BlobQueryArrowField; -import com.azure.storage.blob.models.BlobQueryArrowSerialization; -import com.azure.storage.blob.models.BlobQueryDelimitedSerialization; -import com.azure.storage.blob.models.BlobQueryError; -import com.azure.storage.blob.models.BlobQueryJsonSerialization; -import com.azure.storage.blob.models.BlobQueryParquetSerialization; -import com.azure.storage.blob.models.BlobQueryProgress; -import com.azure.storage.blob.models.BlobQuerySerialization; -import com.azure.storage.internal.avro.implementation.AvroConstants; -import com.azure.storage.internal.avro.implementation.AvroObject; -import com.azure.storage.internal.avro.implementation.AvroReaderFactory; -import com.azure.storage.internal.avro.implementation.schema.AvroSchema; -import com.azure.storage.internal.avro.implementation.schema.primitive.AvroNullSchema; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -/** - * This class provides helper methods for blob query functions. - *

- * RESERVED FOR INTERNAL USE. - */ -public class BlobQueryReader { - - private final Flux avro; - private final Consumer progressConsumer; - private final Consumer errorConsumer; - - /** - * Creates a new BlobQueryReader. - * - * @param avro The reactive avro stream. - * @param progressConsumer The progress consumer. - * @param errorConsumer The error consumer. - */ - public BlobQueryReader(Flux avro, Consumer progressConsumer, - Consumer errorConsumer) { - this.avro = avro; - this.progressConsumer = progressConsumer; - this.errorConsumer = errorConsumer; - } - - /** - * Avro parses a query reactive stream. - *

- * The Avro stream is formatted as the Avro Header (that specifies the schema) and the Avro Body (that contains - * a series of blocks of data). The Query Avro schema indicates that the objects being emitted from the parser can - * either be a result data record, an end record, a progress record or an error record. - * - * @return The parsed query reactive stream. - */ - public Flux read() { - return new AvroReaderFactory().getAvroReader(avro) - .read() - .map(AvroObject::getObject) - .concatMap(this::parseRecord); - } - - /** - * Parses a query record. - * - * @param quickQueryRecord The query record. - * @return The optional data in the record. - */ - private Mono parseRecord(Object quickQueryRecord) { - if (!(quickQueryRecord instanceof Map)) { - return Mono.error(new IllegalArgumentException("Expected object to be of type Map")); - } - Map record = (Map) quickQueryRecord; - Object recordSchema = record.get(AvroConstants.RECORD); - - switch (recordSchema.toString()) { - case "resultData": - return parseResultData(record); - - case "end": - return parseEnd(record); - - case "progress": - return parseProgress(record); - - case "error": - return parseError(record); - - default: - return Mono.error(new IllegalStateException(String - .format("Unknown record type %s " + "while parsing query response. ", recordSchema.toString()))); - } - } - - /** - * Parses a query result data record. - * @param dataRecord The query result data record. - * @return The data in the record. - */ - private Mono parseResultData(Map dataRecord) { - Object data = dataRecord.get("data"); - - if (checkParametersNotNull(data)) { - AvroSchema.checkType("data", data, List.class); - return Mono.just(ByteBuffer.wrap(AvroSchema.getBytes((List) data))); - } else { - return Mono.error( - new IllegalArgumentException("Failed to parse result data record from " + "query response stream.")); - } - } - - /** - * Parses a query end record. - * @param endRecord The query end record. - * @return Mono.empty or Mono.error - */ - private Mono parseEnd(Map endRecord) { - if (progressConsumer != null) { - Object totalBytes = endRecord.get("totalBytes"); - - if (checkParametersNotNull(totalBytes)) { - AvroSchema.checkType("totalBytes", totalBytes, Long.class); - progressConsumer.accept(new BlobQueryProgress((long) totalBytes, (long) totalBytes)); - } else { - return Mono - .error(new IllegalArgumentException("Failed to parse end record from query " + "response stream.")); - } - } - return Mono.empty(); - } - - /** - * Parses a query progress record. - * @param progressRecord The query progress record. - * @return Mono.empty or Mono.error - */ - private Mono parseProgress(Map progressRecord) { - if (progressConsumer != null) { - Object bytesScanned = progressRecord.get("bytesScanned"); - Object totalBytes = progressRecord.get("totalBytes"); - - if (checkParametersNotNull(bytesScanned, totalBytes)) { - AvroSchema.checkType("bytesScanned", bytesScanned, Long.class); - AvroSchema.checkType("totalBytes", totalBytes, Long.class); - progressConsumer.accept(new BlobQueryProgress((long) bytesScanned, (long) totalBytes)); - } else { - return Mono.error( - new IllegalArgumentException("Failed to parse progress record from " + "query response stream.")); - } - } - return Mono.empty(); - } - - /** - * Parses a query error record. - * @param errorRecord The query error record. - * @return Mono.empty or Mono.error - */ - private Mono parseError(Map errorRecord) { - Object fatal = errorRecord.get("fatal"); - Object name = errorRecord.get("name"); - Object description = errorRecord.get("description"); - Object position = errorRecord.get("position"); - - if (checkParametersNotNull(fatal, name, description, position)) { - AvroSchema.checkType("fatal", fatal, Boolean.class); - AvroSchema.checkType("name", name, String.class); - AvroSchema.checkType("description", description, String.class); - AvroSchema.checkType("position", position, Long.class); - - BlobQueryError error - = new BlobQueryError((Boolean) fatal, (String) name, (String) description, (Long) position); - - if (errorConsumer != null) { - errorConsumer.accept(error); - } else { - return Mono.error(new IOException("An error was reported during query response processing, " - + System.lineSeparator() + error.toString())); - } - } else { - return Mono - .error(new IllegalArgumentException("Failed to parse error record from " + "query response stream.")); - } - return Mono.empty(); - } - - /** - * Checks whether or not all parameters are non-null. - */ - private static boolean checkParametersNotNull(Object... data) { - for (Object o : data) { - if (o == null || o instanceof AvroNullSchema.Null) { - return false; - } - } - return true; - } - - /** - * Transforms a generic input BlobQuerySerialization into a QuerySerialization. - * @param userSerialization {@link BlobQuerySerialization} - * @param logger {@link ClientLogger} - * @return {@link QuerySerialization} - */ - public static QuerySerialization transformInputSerialization(BlobQuerySerialization userSerialization, - ClientLogger logger) { - if (userSerialization == null) { - return null; - } - - QueryFormat generatedFormat = new QueryFormat(); - if (userSerialization instanceof BlobQueryDelimitedSerialization) { - - generatedFormat.setType(QueryFormatType.DELIMITED); - generatedFormat - .setDelimitedTextConfiguration(transformDelimited((BlobQueryDelimitedSerialization) userSerialization)); - - } else if (userSerialization instanceof BlobQueryJsonSerialization) { - - generatedFormat.setType(QueryFormatType.JSON); - generatedFormat.setJsonTextConfiguration(transformJson((BlobQueryJsonSerialization) userSerialization)); - - } else if (userSerialization instanceof BlobQueryParquetSerialization) { - - generatedFormat.setType(QueryFormatType.PARQUET); - generatedFormat - .setParquetTextConfiguration(transformParquet((BlobQueryParquetSerialization) userSerialization)); - - } else { - throw logger.logExceptionAsError( - new IllegalArgumentException("Please see values of valid input serialization in the documentation " - + "(https://docs.microsoft.com/rest/api/storageservices/query-blob-contents#request-body).")); - } - return new QuerySerialization().setFormat(generatedFormat); - } - - /** - * Transforms a generic input BlobQuerySerialization into a QuerySerialization. - * @param userSerialization {@link BlobQuerySerialization} - * @param logger {@link ClientLogger} - * @return {@link QuerySerialization} - */ - public static QuerySerialization transformOutputSerialization(BlobQuerySerialization userSerialization, - ClientLogger logger) { - if (userSerialization == null) { - return null; - } - - QueryFormat generatedFormat = new QueryFormat(); - if (userSerialization instanceof BlobQueryDelimitedSerialization) { - - generatedFormat.setType(QueryFormatType.DELIMITED); - generatedFormat - .setDelimitedTextConfiguration(transformDelimited((BlobQueryDelimitedSerialization) userSerialization)); - - } else if (userSerialization instanceof BlobQueryJsonSerialization) { - - generatedFormat.setType(QueryFormatType.JSON); - generatedFormat.setJsonTextConfiguration(transformJson((BlobQueryJsonSerialization) userSerialization)); - - } else if (userSerialization instanceof BlobQueryArrowSerialization) { - - generatedFormat.setType(QueryFormatType.ARROW); - generatedFormat.setArrowConfiguration(transformArrow((BlobQueryArrowSerialization) userSerialization)); - - } else { - throw logger.logExceptionAsError( - new IllegalArgumentException("Please see values of valid output serialization in the documentation " - + "(https://docs.microsoft.com/rest/api/storageservices/query-blob-contents#request-body).")); - } - return new QuerySerialization().setFormat(generatedFormat); - } - - /** - * Transforms a BlobQueryDelimitedSerialization into a DelimitedTextConfiguration. - * - * @param delimitedSerialization {@link BlobQueryDelimitedSerialization} - * @return {@link DelimitedTextConfiguration} - */ - private static DelimitedTextConfiguration - transformDelimited(BlobQueryDelimitedSerialization delimitedSerialization) { - if (delimitedSerialization == null) { - return null; - } - return new DelimitedTextConfiguration() - .setColumnSeparator(charToString(delimitedSerialization.getColumnSeparator())) - .setEscapeChar(charToString(delimitedSerialization.getEscapeChar())) - .setFieldQuote(charToString(delimitedSerialization.getFieldQuote())) - .setHeadersPresent(delimitedSerialization.isHeadersPresent()) - .setRecordSeparator(charToString(delimitedSerialization.getRecordSeparator())); - } - - /** - * Transforms a BlobQueryJsonSerialization into a JsonTextConfiguration. - * - * @param jsonSerialization {@link BlobQueryJsonSerialization} - * @return {@link JsonTextConfiguration} - */ - private static JsonTextConfiguration transformJson(BlobQueryJsonSerialization jsonSerialization) { - if (jsonSerialization == null) { - return null; - } - return new JsonTextConfiguration().setRecordSeparator(charToString(jsonSerialization.getRecordSeparator())); - } - - /** - * Transforms a BlobQueryParquetSerialization into an Object. - * - * @param parquetSerialization {@link BlobQueryParquetSerialization} - * @return {@link JsonTextConfiguration} - */ - private static Object transformParquet(BlobQueryParquetSerialization parquetSerialization) { - /* This method returns an Object since the ParquetConfiguration currently accepts no options. This results in - the generator generating ParquetConfiguration as an Object. */ - if (parquetSerialization == null) { - return null; - } - return new Object(); - } - - /** - * Transforms a BlobQueryArrowSerialization into a ArrowConfiguration. - * - * @param arrowSerialization {@link BlobQueryArrowSerialization} - * @return {@link ArrowConfiguration} - */ - private static ArrowConfiguration transformArrow(BlobQueryArrowSerialization arrowSerialization) { - if (arrowSerialization == null) { - return null; - } - List schema - = arrowSerialization.getSchema() == null ? null : new ArrayList<>(arrowSerialization.getSchema().size()); - if (schema != null) { - for (BlobQueryArrowField field : arrowSerialization.getSchema()) { - if (field == null) { - schema.add(null); - } else { - schema.add(new ArrowField().setName(field.getName()) - .setPrecision(field.getPrecision()) - .setScale(field.getScale()) - .setType(field.getType().toString())); - } - } - } - return new ArrowConfiguration().setSchema(schema); - } - - private static String charToString(char c) { - return c == '\0' ? "" : Character.toString(c); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobRequestConditionProperty.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobRequestConditionProperty.java deleted file mode 100644 index e893138fab5d..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobRequestConditionProperty.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -public enum BlobRequestConditionProperty { - LEASE_ID("LeaseId"), - TAGS_CONDITIONS("TagsConditions"), - IF_MODIFIED_SINCE("IfModifiedSince"), - IF_UNMODIFIED_SINCE("IfUnmodifiedSince"), - IF_MATCH("IfMatch"), - IF_NONE_MATCH("IfNoneMatch"); - - /** The actual serialized value for a BlobRequestConditionProperty instance. */ - private final String value; - - BlobRequestConditionProperty(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a BlobRequestConditionProperty instance. - * - * @param value the serialized value to parse. - * @return the parsed BlobRequestConditionProperty object, or null if unable to parse. - */ - public static BlobRequestConditionProperty fromString(String value) { - BlobRequestConditionProperty[] items = BlobRequestConditionProperty.values(); - for (BlobRequestConditionProperty item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java deleted file mode 100644 index 7b8b932d7c81..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java +++ /dev/null @@ -1,459 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -import com.azure.core.util.Configuration; -import com.azure.core.util.Context; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.implementation.TimeAndFormat; -import com.azure.storage.common.sas.SasIpRange; -import com.azure.storage.common.sas.SasProtocol; - -import java.time.OffsetDateTime; -import java.util.Objects; -import java.util.function.Consumer; - -import static com.azure.storage.common.implementation.SasImplUtils.formatQueryParameterDate; -import static com.azure.storage.common.implementation.SasImplUtils.tryAppendQueryParameter; - -/** - * This class provides helper methods for common blob service sas patterns. - * - * RESERVED FOR INTERNAL USE. - */ -public class BlobSasImplUtil { - /** - * The SAS blob constant. - */ - private static final String SAS_BLOB_CONSTANT = "b"; - - /** - * The SAS blob snapshot constant. - */ - private static final String SAS_BLOB_SNAPSHOT_CONSTANT = "bs"; - - /** - * The SAS blob version constant. - */ - private static final String SAS_BLOB_VERSION_CONSTANT = "bv"; - - /** - * The SAS blob container constant. - */ - private static final String SAS_CONTAINER_CONSTANT = "c"; - - private static final ClientLogger LOGGER = new ClientLogger(BlobSasImplUtil.class); - - private static final String VERSION = Configuration.getGlobalConfiguration() - .get(Constants.PROPERTY_AZURE_STORAGE_SAS_SERVICE_VERSION, BlobServiceVersion.getLatest().getVersion()); - - private SasProtocol protocol; - - private OffsetDateTime startTime; - - private OffsetDateTime expiryTime; - - private String permissions; - - private SasIpRange sasIpRange; - - private String containerName; - - private String blobName; - - private String resource; - - private String snapshotId; - - private String versionId; - - private String identifier; - - private String cacheControl; - - private String contentDisposition; - - private String contentEncoding; - - private String contentLanguage; - - private String contentType; - - private String authorizedAadObjectId; - - private String correlationId; - - private String encryptionScope; - - /** - * Creates a new {@link BlobSasImplUtil} with the specified parameters - * - * @param sasValues {@link BlobServiceSasSignatureValues} - * @param containerName The container name - */ - public BlobSasImplUtil(BlobServiceSasSignatureValues sasValues, String containerName) { - this(sasValues, containerName, null, null, null, null); - } - - /** - * Creates a new {@link BlobSasImplUtil} with the specified parameters - * - * @param sasValues {@link BlobServiceSasSignatureValues} - * @param containerName The container name - * @param blobName The blob name - * @param snapshotId The snapshot id - * @param versionId The version id - * @param encryptionScope The encryption scope - */ - public BlobSasImplUtil(BlobServiceSasSignatureValues sasValues, String containerName, String blobName, - String snapshotId, String versionId, String encryptionScope) { - Objects.requireNonNull(sasValues); - if (snapshotId != null && versionId != null) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("'snapshot' and 'versionId' cannot be used at the same time.")); - } - this.protocol = sasValues.getProtocol(); - this.startTime = sasValues.getStartTime(); - this.expiryTime = sasValues.getExpiryTime(); - this.permissions = sasValues.getPermissions(); - this.sasIpRange = sasValues.getSasIpRange(); - this.containerName = containerName; - this.blobName = blobName; - this.snapshotId = snapshotId; - this.versionId = versionId; - this.identifier = sasValues.getIdentifier(); - this.cacheControl = sasValues.getCacheControl(); - this.contentDisposition = sasValues.getContentDisposition(); - this.contentEncoding = sasValues.getContentEncoding(); - this.contentLanguage = sasValues.getContentLanguage(); - this.contentType = sasValues.getContentType(); - this.authorizedAadObjectId = sasValues.getPreauthorizedAgentObjectId(); - this.correlationId = sasValues.getCorrelationId(); - this.encryptionScope = encryptionScope; - } - - /** - * Generates a Sas signed with a {@link StorageSharedKeyCredential} - * - * @param storageSharedKeyCredentials {@link StorageSharedKeyCredential} - * @param context Additional context that is passed through the code when generating a SAS. - * @return A String representing the Sas - */ - public String generateSas(StorageSharedKeyCredential storageSharedKeyCredentials, Context context) { - return generateSas(storageSharedKeyCredentials, null, context); - } - - /** - * Generates a Sas signed with a {@link StorageSharedKeyCredential} - * - * @param storageSharedKeyCredentials {@link StorageSharedKeyCredential} - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * @return The string to sign that will be used to generate the signature for the SAS URL. - */ - public String generateSas(StorageSharedKeyCredential storageSharedKeyCredentials, - Consumer stringToSignHandler, Context context) { - StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); - - ensureState(); - - // Signature is generated on the un-url-encoded values. - final String canonicalName = getCanonicalName(storageSharedKeyCredentials.getAccountName()); - final String stringToSign = stringToSign(canonicalName); - StorageImplUtils.logStringToSign(LOGGER, stringToSign, context); - final String signature = storageSharedKeyCredentials.computeHmac256(stringToSign); - - if (stringToSignHandler != null) { - stringToSignHandler.accept(stringToSign); - } - - return encode(null /* userDelegationKey */, signature); - } - - /** - * Generates a Sas signed with a {@link UserDelegationKey} - * - * @param delegationKey {@link UserDelegationKey} - * @param accountName The account name - * @param context Additional context that is passed through the code when generating a SAS. - * @return A String representing the Sas - */ - public String generateUserDelegationSas(UserDelegationKey delegationKey, String accountName, Context context) { - return generateUserDelegationSas(delegationKey, accountName, null, context); - } - - /** - * Generates a Sas signed with a {@link UserDelegationKey} - * - * @param delegationKey {@link UserDelegationKey} - * @param accountName The account name - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * @return A String representing the Sas - */ - public String generateUserDelegationSas(UserDelegationKey delegationKey, String accountName, - Consumer stringToSignHandler, Context context) { - StorageImplUtils.assertNotNull("delegationKey", delegationKey); - StorageImplUtils.assertNotNull("accountName", accountName); - - ensureState(); - - // Signature is generated on the un-url-encoded values. - final String canonicalName = getCanonicalName(accountName); - final String stringToSign = stringToSign(delegationKey, canonicalName); - StorageImplUtils.logStringToSign(LOGGER, stringToSign, context); - String signature = StorageImplUtils.computeHMac256(delegationKey.getValue(), stringToSign); - - if (stringToSignHandler != null) { - stringToSignHandler.accept(stringToSign); - } - - return encode(delegationKey, signature); - } - - /** - * Encodes a Sas from the values in this type. - * @param userDelegationKey {@link UserDelegationKey} - * @param signature The signature of the Sas. - * @return A String representing the Sas. - */ - private String encode(UserDelegationKey userDelegationKey, String signature) { - /* - We should be url-encoding each key and each value, but because we know all the keys and values will encode to - themselves, we cheat except for the signature value. - */ - StringBuilder sb = new StringBuilder(); - - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SERVICE_VERSION, VERSION); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_PROTOCOL, this.protocol); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_START_TIME, - formatQueryParameterDate(new TimeAndFormat(this.startTime, null))); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_EXPIRY_TIME, - formatQueryParameterDate(new TimeAndFormat(this.expiryTime, null))); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_IP_RANGE, this.sasIpRange); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_IDENTIFIER, this.identifier); - if (userDelegationKey != null) { - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_OBJECT_ID, - userDelegationKey.getSignedObjectId()); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_TENANT_ID, - userDelegationKey.getSignedTenantId()); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_START, - formatQueryParameterDate(new TimeAndFormat(userDelegationKey.getSignedStart(), null))); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_EXPIRY, - formatQueryParameterDate(new TimeAndFormat(userDelegationKey.getSignedExpiry(), null))); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_SERVICE, - userDelegationKey.getSignedService()); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_VERSION, - userDelegationKey.getSignedVersion()); - - /* Only parameters relevant for user delegation SAS. */ - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_PREAUTHORIZED_AGENT_OBJECT_ID, - this.authorizedAadObjectId); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CORRELATION_ID, this.correlationId); - } - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_RESOURCE, this.resource); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_PERMISSIONS, this.permissions); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNATURE, signature); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_ENCRYPTION_SCOPE, this.encryptionScope); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CACHE_CONTROL, this.cacheControl); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_DISPOSITION, this.contentDisposition); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_ENCODING, this.contentEncoding); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_LANGUAGE, this.contentLanguage); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_TYPE, this.contentType); - - return sb.toString(); - - } - - /** - * Ensures that the builder's properties are in a consistent state. - - * 1. If there is no version, use latest. - * 2. If there is no identifier set, ensure expiryTime and permissions are set. - * 3. Resource name is chosen by: - * a. If "BlobName" is _not_ set, it is a container resource. - * b. Otherwise, if "SnapshotId" is set, it is a blob snapshot resource. - * c. Otherwise, if "VersionId" is set, it is a blob version resource. - * d. Otherwise, it is a blob resource. - * 4. Reparse permissions depending on what the resource is. If it is an unrecognized resource, do nothing. - * - * Taken from: - * https://github.com/Azure/azure-storage-blob-go/blob/master/azblob/sas_service.go#L33 - * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/src/Sas/BlobSasBuilder.cs - */ - public void ensureState() { - if (identifier == null) { - if (expiryTime == null || permissions == null) { - throw LOGGER.logExceptionAsError(new IllegalStateException( - "If identifier is not set, expiry time " + "and permissions must be set")); - } - } - - if (CoreUtils.isNullOrEmpty(blobName)) { - resource = SAS_CONTAINER_CONSTANT; - } else if (snapshotId != null) { - resource = SAS_BLOB_SNAPSHOT_CONSTANT; - } else if (versionId != null) { - resource = SAS_BLOB_VERSION_CONSTANT; - } else { - resource = SAS_BLOB_CONSTANT; - } - - if (permissions != null) { - switch (resource) { - case SAS_BLOB_CONSTANT: - case SAS_BLOB_SNAPSHOT_CONSTANT: - case SAS_BLOB_VERSION_CONSTANT: - permissions = BlobSasPermission.parse(permissions).toString(); - break; - - case SAS_CONTAINER_CONSTANT: - permissions = BlobContainerSasPermission.parse(permissions).toString(); - break; - - default: - // We won't reparse the permissions if we don't know the type. - LOGGER.info("Not re-parsing permissions. Resource type '{}' is unknown.", resource); - break; - } - } - } - - /** - * Computes the canonical name for a container or blob resource for SAS signing. - */ - private String getCanonicalName(String account) { - // Container: "/blob/account/containername" - // Blob: "/blob/account/containername/blobname" - return CoreUtils.isNullOrEmpty(blobName) - ? "/blob/" + account + "/" + containerName - : "/blob/" + account + "/" + containerName + "/" + blobName.replace('\\', '/'); - } - - private String stringToSign(String canonicalName) { - String versionSegment = this.snapshotId == null ? this.versionId : this.snapshotId; - if (VERSION.compareTo(BlobServiceVersion.V2020_10_02.getVersion()) <= 0) { - return String.join("\n", this.permissions == null ? "" : permissions, - this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), - canonicalName, this.identifier == null ? "" : this.identifier, - this.sasIpRange == null ? "" : this.sasIpRange.toString(), - this.protocol == null ? "" : this.protocol.toString(), VERSION, resource, - versionSegment == null ? "" : versionSegment, this.cacheControl == null ? "" : this.cacheControl, - this.contentDisposition == null ? "" : this.contentDisposition, - this.contentEncoding == null ? "" : this.contentEncoding, - this.contentLanguage == null ? "" : this.contentLanguage, - this.contentType == null ? "" : this.contentType); - } else { - return String.join("\n", this.permissions == null ? "" : permissions, - this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), - canonicalName, this.identifier == null ? "" : this.identifier, - this.sasIpRange == null ? "" : this.sasIpRange.toString(), - this.protocol == null ? "" : this.protocol.toString(), VERSION, resource, - versionSegment == null ? "" : versionSegment, this.encryptionScope == null ? "" : this.encryptionScope, - this.cacheControl == null ? "" : this.cacheControl, - this.contentDisposition == null ? "" : this.contentDisposition, - this.contentEncoding == null ? "" : this.contentEncoding, - this.contentLanguage == null ? "" : this.contentLanguage, - this.contentType == null ? "" : this.contentType); - } - } - - private String stringToSign(final UserDelegationKey key, String canonicalName) { - String versionSegment = this.snapshotId == null ? this.versionId : this.snapshotId; - if (VERSION.compareTo(BlobServiceVersion.V2019_12_12.getVersion()) <= 0) { - return String.join("\n", this.permissions == null ? "" : this.permissions, - this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), - canonicalName, key.getSignedObjectId() == null ? "" : key.getSignedObjectId(), - key.getSignedTenantId() == null ? "" : key.getSignedTenantId(), - key.getSignedStart() == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedStart()), - key.getSignedExpiry() == null - ? "" - : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedExpiry()), - key.getSignedService() == null ? "" : key.getSignedService(), - key.getSignedVersion() == null ? "" : key.getSignedVersion(), - this.sasIpRange == null ? "" : this.sasIpRange.toString(), - this.protocol == null ? "" : this.protocol.toString(), VERSION, resource, - versionSegment == null ? "" : versionSegment, this.cacheControl == null ? "" : this.cacheControl, - this.contentDisposition == null ? "" : this.contentDisposition, - this.contentEncoding == null ? "" : this.contentEncoding, - this.contentLanguage == null ? "" : this.contentLanguage, - this.contentType == null ? "" : this.contentType); - } else if (VERSION.compareTo(BlobServiceVersion.V2020_10_02.getVersion()) <= 0) { - return String.join("\n", this.permissions == null ? "" : this.permissions, - this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), - canonicalName, key.getSignedObjectId() == null ? "" : key.getSignedObjectId(), - key.getSignedTenantId() == null ? "" : key.getSignedTenantId(), - key.getSignedStart() == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedStart()), - key.getSignedExpiry() == null - ? "" - : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedExpiry()), - key.getSignedService() == null ? "" : key.getSignedService(), - key.getSignedVersion() == null ? "" : key.getSignedVersion(), - this.authorizedAadObjectId == null ? "" : this.authorizedAadObjectId, - "", /* suoid - empty since this applies to HNS only accounts. */ - this.correlationId == null ? "" : this.correlationId, - this.sasIpRange == null ? "" : this.sasIpRange.toString(), - this.protocol == null ? "" : this.protocol.toString(), VERSION, resource, - versionSegment == null ? "" : versionSegment, this.cacheControl == null ? "" : this.cacheControl, - this.contentDisposition == null ? "" : this.contentDisposition, - this.contentEncoding == null ? "" : this.contentEncoding, - this.contentLanguage == null ? "" : this.contentLanguage, - this.contentType == null ? "" : this.contentType); - } else { - return String.join("\n", this.permissions == null ? "" : this.permissions, - this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), - canonicalName, key.getSignedObjectId() == null ? "" : key.getSignedObjectId(), - key.getSignedTenantId() == null ? "" : key.getSignedTenantId(), - key.getSignedStart() == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedStart()), - key.getSignedExpiry() == null - ? "" - : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedExpiry()), - key.getSignedService() == null ? "" : key.getSignedService(), - key.getSignedVersion() == null ? "" : key.getSignedVersion(), - this.authorizedAadObjectId == null ? "" : this.authorizedAadObjectId, - "", /* suoid - empty since this applies to HNS only accounts. */ - this.correlationId == null ? "" : this.correlationId, - this.sasIpRange == null ? "" : this.sasIpRange.toString(), - this.protocol == null ? "" : this.protocol.toString(), VERSION, resource, - versionSegment == null ? "" : versionSegment, this.encryptionScope == null ? "" : this.encryptionScope, - this.cacheControl == null ? "" : this.cacheControl, - this.contentDisposition == null ? "" : this.contentDisposition, - this.contentEncoding == null ? "" : this.contentEncoding, - this.contentLanguage == null ? "" : this.contentLanguage, - this.contentType == null ? "" : this.contentType); - } - } - - /** - * Gets the resource string for SAS token signing. - * @return - */ - public String getResource() { - return this.resource; - } - - /** - * Gets the permissions string for SAS token signing. - * @return - */ - public String getPermissions() { - return this.permissions; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobUserAgentModificationPolicy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobUserAgentModificationPolicy.java deleted file mode 100644 index 3ff2b0ac303e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobUserAgentModificationPolicy.java +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpPipelineCallContext; -import com.azure.core.http.HttpPipelineNextPolicy; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.HttpPipelinePolicy; -import reactor.core.publisher.Mono; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * This policy modifies the blob user agent string for clients created in packages that are dependencies of blob. - * It transforms a User Agent String as follows - * UAbefore: "azsdk-java-azure-storage-blob/12.11.0-beta.2 (11.0.6; Windows 10; 10.0)" - * UAafter: "azsdk-java-azure-storage-blob/12.11.0-beta.2 azsdk-java-azure-storage-blob-batch/12.8.0-beta.2 (11.0.6; Windows 10; 10.0) " - */ -public class BlobUserAgentModificationPolicy implements HttpPipelinePolicy { - - private final String clientName; - private final String clientVersion; - - private static final String REGEX - = "(.*? )?(azsdk-java-azure-storage-blob/12\\.\\d{1,2}\\.\\d{1,2}(?:-beta\\.\\d{1,2})?)( .*?)?"; - private static final Pattern PATTERN = Pattern.compile(REGEX); - - /** - * Creates a new BlobUserAgentModificationPolicy. - * - * @param clientName The name of the package. - * @param clientVersion The version of the package. - */ - public BlobUserAgentModificationPolicy(String clientName, String clientVersion) { - this.clientName = clientName; - this.clientVersion = clientVersion; - } - - @Override - public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { - String userAgent = context.getHttpRequest().getHeaders().getValue(HttpHeaderName.USER_AGENT); - Matcher matcher = PATTERN.matcher(userAgent); - StringBuilder builder = new StringBuilder(); - if (matcher.matches()) { - builder.append(matcher.group(1) == null ? "" : matcher.group(1)) - .append(matcher.group(2) == null ? "" : matcher.group(2)) - .append(" ") - .append("azsdk-java-") - .append(clientName) - .append("/") - .append(clientVersion) - .append(matcher.group(3) == null ? "" : matcher.group(3)); - context.getHttpRequest().getHeaders().set(HttpHeaderName.USER_AGENT, builder.toString()); - } - - return next.process(); - } - - @Override - public HttpPipelinePosition getPipelinePosition() { - return HttpPipelinePosition.PER_CALL; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java deleted file mode 100644 index 7c56941c7014..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -import com.azure.core.credential.AzureSasCredential; -import com.azure.core.credential.TokenCredential; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.policy.AddDatePolicy; -import com.azure.core.http.policy.AddHeadersFromContextPolicy; -import com.azure.core.http.policy.AddHeadersPolicy; -import com.azure.core.http.policy.AzureSasCredentialPolicy; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.HttpLoggingPolicy; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.policy.HttpPolicyProviders; -import com.azure.core.http.policy.RequestIdPolicy; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.http.policy.UserAgentPolicy; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.TracingOptions; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.tracing.Tracer; -import com.azure.core.util.tracing.TracerProvider; -import com.azure.storage.blob.BlobUrlParts; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.BuilderUtils; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.credentials.CredentialValidator; -import com.azure.storage.common.policy.MetadataValidationPolicy; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.ResponseValidationPolicyBuilder; -import com.azure.storage.common.policy.ScrubEtagPolicy; -import com.azure.storage.common.policy.StorageBearerTokenChallengeAuthorizationPolicy; -import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; - -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static com.azure.storage.common.Utility.STORAGE_TRACING_NAMESPACE_VALUE; - -/** - * This class provides helper methods for common builder patterns. - *

- * RESERVED FOR INTERNAL USE. - */ -public final class BuilderHelper { - private static final String CLIENT_NAME; - private static final String CLIENT_VERSION; - - static { - Map properties = CoreUtils.getProperties("azure-storage-blob.properties"); - CLIENT_NAME = properties.getOrDefault("name", "UnknownName"); - CLIENT_VERSION = properties.getOrDefault("version", "UnknownVersion"); - } - - /** - * Constructs a {@link HttpPipeline} from values passed from a builder. - * - * @param storageSharedKeyCredential {@link StorageSharedKeyCredential} if present. - * @param tokenCredential {@link TokenCredential} if present. - * @param azureSasCredential {@link AzureSasCredential} if present. - * @param sasToken SAS token if present. - * @param endpoint The endpoint for the client. - * @param retryOptions Storage's retry options to set in the retry policy. - * @param coreRetryOptions Core's retry options to set in the retry policy. - * @param logOptions Logging options to set in the logging policy. - * @param clientOptions Client options. - * @param httpClient HttpClient to use in the builder. - * @param perCallPolicies Additional {@link HttpPipelinePolicy policies} to set in the pipeline per call. - * @param perRetryPolicies Additional {@link HttpPipelinePolicy policies} to set in the pipeline per retry. - * @param configuration Configuration store contain environment settings. - * @param logger {@link ClientLogger} used to log any exception. - * @param audience {@link BlobAudience} used to determine the audience of the blob. - * @return A new {@link HttpPipeline} from the passed values. - */ - public static HttpPipeline buildPipeline(StorageSharedKeyCredential storageSharedKeyCredential, - TokenCredential tokenCredential, AzureSasCredential azureSasCredential, String sasToken, String endpoint, - RequestRetryOptions retryOptions, RetryOptions coreRetryOptions, HttpLogOptions logOptions, - ClientOptions clientOptions, HttpClient httpClient, List perCallPolicies, - List perRetryPolicies, Configuration configuration, BlobAudience audience, - ClientLogger logger) { - - CredentialValidator.validateSingleCredentialIsPresent(storageSharedKeyCredential, tokenCredential, - azureSasCredential, sasToken, logger); - - // Closest to API goes first, closest to wire goes last. - List policies = new ArrayList<>(); - - policies.add(getUserAgentPolicy(configuration, logOptions, clientOptions)); - policies.add(new RequestIdPolicy()); - - policies.addAll(perCallPolicies); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(BuilderUtils.createRetryPolicy(retryOptions, coreRetryOptions, logger)); - - policies.add(new AddDatePolicy()); - - policies.add(new AddHeadersFromContextPolicy()); - - // We need to place this policy right before the credential policy since headers may affect the string to sign - // of the request. - HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(clientOptions); - if (headers != null) { - policies.add(new AddHeadersPolicy(headers)); - } - policies.add(new MetadataValidationPolicy()); - - HttpPipelinePolicy credentialPolicy; - if (storageSharedKeyCredential != null) { - credentialPolicy = new StorageSharedKeyCredentialPolicy(storageSharedKeyCredential); - } else if (tokenCredential != null) { - httpsValidation(tokenCredential, "bearer token", endpoint, logger); - String scope = audience != null - ? ((audience.toString().endsWith("/") ? audience + ".default" : audience + "/.default")) - : Constants.STORAGE_SCOPE; - credentialPolicy = new StorageBearerTokenChallengeAuthorizationPolicy(tokenCredential, scope); - } else if (azureSasCredential != null) { - credentialPolicy = new AzureSasCredentialPolicy(azureSasCredential, false); - } else if (sasToken != null) { - credentialPolicy = new AzureSasCredentialPolicy(new AzureSasCredential(sasToken), false); - } else { - credentialPolicy = null; - } - - if (credentialPolicy != null) { - policies.add(credentialPolicy); - } - - policies.addAll(perRetryPolicies); - - HttpPolicyProviders.addAfterRetryPolicies(policies); - - policies.add(getResponseValidationPolicy()); - - policies.add(new HttpLoggingPolicy(logOptions)); - - policies.add(new ScrubEtagPolicy()); - - return new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(clientOptions) - .tracer(createTracer(clientOptions)) - .build(); - } - - /** - * Gets the default http log option for Storage Blob. - * - * @return the default http log options. - */ - public static HttpLogOptions getDefaultHttpLogOptions() { - HttpLogOptions defaultOptions = new HttpLogOptions(); - BlobHeadersAndQueryParameters.getBlobHeaders().forEach(defaultOptions::addAllowedHeaderName); - BlobHeadersAndQueryParameters.getBlobQueryParameters().forEach(defaultOptions::addAllowedQueryParamName); - return defaultOptions; - } - - /** - * Gets the endpoint for the blob service based on the parsed URL. - * - * @param parts The {@link BlobUrlParts} from the parse URL. - * @return The endpoint for the blob service. - */ - public static String getEndpoint(BlobUrlParts parts) throws MalformedURLException { - if (ModelHelper.determineAuthorityIsIpStyle(parts.getHost())) { - return parts.getScheme() + "://" + parts.getHost() + "/" + parts.getAccountName(); - } else { - return parts.getScheme() + "://" + parts.getHost(); - } - } - - /** - * Validates that the client is properly configured to use https. - * - * @param objectToCheck The object to check for. - * @param objectName The name of the object. - * @param endpoint The endpoint for the client. - */ - public static void httpsValidation(Object objectToCheck, String objectName, String endpoint, ClientLogger logger) { - if (objectToCheck != null && !BlobUrlParts.parse(endpoint).getScheme().equals(Constants.HTTPS)) { - throw logger - .logExceptionAsError(new IllegalArgumentException("Using a(n) " + objectName + " requires https")); - } - } - - /* - * Creates a {@link UserAgentPolicy} using the default blob module name and version. - * - * @param configuration Configuration store used to determine whether telemetry information should be included. - * @param logOptions Logging options to set in the logging policy. - * @param clientOptions Client options. - * @return The default {@link UserAgentPolicy} for the module. - */ - private static UserAgentPolicy getUserAgentPolicy(Configuration configuration, HttpLogOptions logOptions, - ClientOptions clientOptions) { - configuration = (configuration == null) ? Configuration.NONE : configuration; - String applicationId = CoreUtils.getApplicationId(clientOptions, logOptions); - return new UserAgentPolicy(applicationId, CLIENT_NAME, CLIENT_VERSION, configuration); - } - - /* - * Creates a {@link ResponseValidationPolicyBuilder.ResponseValidationPolicy} used to validate response data from - * the service. - * - * @return The {@link ResponseValidationPolicyBuilder.ResponseValidationPolicy} for the module. - */ - private static HttpPipelinePolicy getResponseValidationPolicy() { - return new ResponseValidationPolicyBuilder().addOptionalEcho(HttpHeaderName.X_MS_CLIENT_REQUEST_ID) - .addOptionalEcho(Constants.HeaderConstants.ENCRYPTION_KEY_SHA256_HEADER_NAME) - .build(); - } - - public static Tracer createTracer(ClientOptions clientOptions) { - TracingOptions tracingOptions = clientOptions == null ? null : clientOptions.getTracingOptions(); - return TracerProvider.getDefaultProvider() - .createTracer(CLIENT_NAME, CLIENT_VERSION, STORAGE_TRACING_NAMESPACE_VALUE, tracingOptions); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ByteBufferBackedOutputStreamUtil.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ByteBufferBackedOutputStreamUtil.java deleted file mode 100644 index 4b38dc933111..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ByteBufferBackedOutputStreamUtil.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.implementation.util; - -import java.io.OutputStream; -import java.nio.ByteBuffer; - -/** - * This class provides methods for seekable byte channel tests. - */ -public class ByteBufferBackedOutputStreamUtil extends OutputStream { - private final ByteBuffer dst; - - /** - * Creates a new ByteBufferBackedOutputStreamUtil. - * - * @param dst The destination byte buffer. - */ - public ByteBufferBackedOutputStreamUtil(ByteBuffer dst) { - this.dst = dst; - } - - @Override - public void write(int b) { - dst.put((byte) b); - } - - @Override - public void write(byte[] b) { - dst.put(b); - } - - @Override - public void write(byte[] b, int off, int len) { - dst.put(b, off, len); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ChunkedDownloadUtils.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ChunkedDownloadUtils.java deleted file mode 100644 index 0505b6a3f6f6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ChunkedDownloadUtils.java +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.util.Context; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.BlobDownloadAsyncResponse; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.common.ParallelTransferOptions; -import com.azure.storage.common.implementation.Constants; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.util.function.Tuple3; -import reactor.util.function.Tuples; - -import java.util.Optional; -import java.util.function.BiFunction; -import java.util.function.Function; - -import static java.lang.StrictMath.toIntExact; - -/** - * This class provides helper methods for lazy/chunked download. - * - * RESERVED FOR INTERNAL USE. - */ -public class ChunkedDownloadUtils { - - public static Mono> downloadFirstChunk( - BlobRange range, ParallelTransferOptions parallelTransferOptions, BlobRequestConditions requestConditions, - BiFunction> downloader, boolean eTagLock) { - return downloadFirstChunk(range, parallelTransferOptions, requestConditions, downloader, eTagLock, null); - } - - /* - Has a context value for additional download adjustments. - - Download the first chunk. Construct a Mono which will emit the total count for calculating the number of chunks, - access conditions containing the etag to lock on, and the response from downloading the first chunk. - */ - @SuppressWarnings("unchecked") - public static Mono> downloadFirstChunk( - BlobRange range, ParallelTransferOptions parallelTransferOptions, BlobRequestConditions requestConditions, - BiFunction> downloader, boolean eTagLock, - Context context) { - // We will scope our initial download to either be one chunk or the total size. - long initialChunkSize - = range.getCount() != null && range.getCount() < parallelTransferOptions.getBlockSizeLong() - ? range.getCount() - : parallelTransferOptions.getBlockSizeLong(); - - return downloader.apply(new BlobRange(range.getOffset(), initialChunkSize), requestConditions) - // Subscribe on boundElastic instead of elastic as elastic is deprecated and boundElastic provided the same - // functionality with the added benefit that it won't infinitely create threads if needed and will instead - // queue. - .map(response -> { - /* - Either the etag was set and it matches because the download succeeded, so this is a no-op, or there - was no etag, so we set it here. ETag locking is vital to ensure we download one, consistent view - of the file. - */ - BlobRequestConditions newConditions = eTagLock - ? setEtag(requestConditions, response.getDeserializedHeaders().getETag()) - : requestConditions; - - // Extract the total length of the blob from the contentRange header. e.g. "bytes 1-6/7" - long totalLength = extractTotalBlobLength(response.getDeserializedHeaders().getContentRange()); - - if (context != null) { - Optional contextAdjustment = context.getData(Constants.ADJUSTED_BLOB_LENGTH_KEY); - if (contextAdjustment.isPresent()) { - totalLength = (long) contextAdjustment.get(); - } - } - /* - If the user either didn't specify a count or they specified a count greater than the size of the - remaining data, take the size of the remaining data. This is to prevent the case where the count - is much much larger than the size of the blob and we could try to download at an invalid offset. - */ - long newCount = range.getCount() == null || range.getCount() > (totalLength - range.getOffset()) - ? totalLength - range.getOffset() - : range.getCount(); - - return Tuples.of(newCount, newConditions, response); - }) - .onErrorResume(BlobStorageException.class, blobStorageException -> { - /* - * In the case of an empty blob, we still want to report success and give back valid headers. - * Attempting a range download on an empty blob will return an InvalidRange error code and a - * Content-Range header of the format "bytes * /0". We need to double check that the total size is zero - * in the case that the customer has attempted an invalid range on a non-zero length blob. - */ - if (blobStorageException.getErrorCode() == BlobErrorCode.INVALID_RANGE - && extractTotalBlobLength( - blobStorageException.getResponse().getHeaders().getValue(HttpHeaderName.CONTENT_RANGE)) == 0) { - - return downloader.apply(new BlobRange(0, 0L), requestConditions) - // Subscribe on boundElastic instead of elastic as elastic is deprecated and boundElastic - // provided the same functionality with the added benefit that it won't infinitely create - // threads if needed and will instead queue. - .handle((response, sink) -> { - /* - Ensure the blob is still 0 length by checking our download was the full length. - (200 is for full blob; 206 is partial). - */ - if (response.getStatusCode() != 200) { - sink.error(new IllegalStateException("Blob was modified mid download. It was " - + "originally 0 bytes and is now larger.")); - } else { - sink.next(Tuples.of(0L, requestConditions, response)); - } - }); - } - - return Mono.error(blobStorageException); - }); - } - - public static Flux downloadChunk(Integer chunkNum, BlobDownloadAsyncResponse initialResponse, - BlobRange finalRange, ParallelTransferOptions finalParallelTransferOptions, - BlobRequestConditions requestConditions, long newCount, - BiFunction> downloader, - Function> returnTransformer) { - // The first chunk was retrieved during setup. - if (chunkNum == 0) { - return returnTransformer.apply(initialResponse); - } - - // Calculate whether we need a full chunk or something smaller because we are at the end. - long modifier = chunkNum.longValue() * finalParallelTransferOptions.getBlockSizeLong(); - long chunkSizeActual = Math.min(finalParallelTransferOptions.getBlockSizeLong(), newCount - modifier); - BlobRange chunkRange = new BlobRange(finalRange.getOffset() + modifier, chunkSizeActual); - - // Make the download call. - return downloader.apply(chunkRange, requestConditions).flatMapMany(returnTransformer); - } - - private static BlobRequestConditions setEtag(BlobRequestConditions requestConditions, String etag) { - // We don't want to modify the user's object, so we'll create a duplicate and set the retrieved etag. - return new BlobRequestConditions().setIfModifiedSince(requestConditions.getIfModifiedSince()) - .setIfUnmodifiedSince(requestConditions.getIfModifiedSince()) - .setIfMatch(etag) - .setIfNoneMatch(requestConditions.getIfNoneMatch()) - .setLeaseId(requestConditions.getLeaseId()); - } - - public static long extractTotalBlobLength(String contentRange) { - return CoreUtils.extractSizeFromContentRange(contentRange); - } - - public static int calculateNumBlocks(long dataSize, long blockLength) { - // Can successfully cast to an int because MaxBlockSize is an int, which this expression must be less than. - int numBlocks = toIntExact(dataSize / blockLength); - // Include an extra block for trailing data. - if (dataSize % blockLength != 0) { - numBlocks++; - } - return numBlocks; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java deleted file mode 100644 index 72e0df6b70ad..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java +++ /dev/null @@ -1,665 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.implementation.accesshelpers.BlobDownloadHeadersConstructorProxy; -import com.azure.storage.blob.implementation.accesshelpers.BlobItemConstructorProxy; -import com.azure.storage.blob.implementation.accesshelpers.BlobPropertiesConstructorProxy; -import com.azure.storage.blob.implementation.accesshelpers.BlobQueryHeadersConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobItemInternal; -import com.azure.storage.blob.implementation.models.BlobName; -import com.azure.storage.blob.implementation.models.BlobPropertiesInternalDownload; -import com.azure.storage.blob.implementation.models.BlobStorageExceptionInternal; -import com.azure.storage.blob.implementation.models.BlobTag; -import com.azure.storage.blob.implementation.models.BlobTags; -import com.azure.storage.blob.implementation.models.BlobsDownloadHeaders; -import com.azure.storage.blob.implementation.models.BlobsQueryHeaders; -import com.azure.storage.blob.implementation.models.FilterBlobItem; -import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; -import com.azure.storage.blob.models.BlobContainerListDetails; -import com.azure.storage.blob.models.BlobCorsRule; -import com.azure.storage.blob.models.BlobDownloadAsyncResponse; -import com.azure.storage.blob.models.BlobDownloadHeaders; -import com.azure.storage.blob.models.BlobDownloadResponse; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobQueryHeaders; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobRetentionPolicy; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.ListBlobContainersIncludeType; -import com.azure.storage.blob.models.ObjectReplicationPolicy; -import com.azure.storage.blob.models.ObjectReplicationRule; -import com.azure.storage.blob.models.ObjectReplicationStatus; -import com.azure.storage.blob.models.PageBlobCopyIncrementalRequestConditions; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.TaggedBlobItem; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * This class provides helper methods for common model patterns. - *

- * RESERVED FOR INTERNAL USE. - */ -public final class ModelHelper { - private static final ClientLogger LOGGER = new ClientLogger(ModelHelper.class); - - /** - * Indicates the default size above which the upload will be broken into blocks and parallelized. - */ - public static final long BLOB_DEFAULT_MAX_SINGLE_UPLOAD_SIZE = 256L * Constants.MB; - - private static final HttpHeaderName X_MS_ERROR_CODE = HttpHeaderName.fromString("x-ms-error-code"); - - /** - * Indicates the number of bytes in a page. - */ - public static final int PAGE_BYTES = 512; - - /** - * Determines whether the passed authority is IP style, that is, it is of the format {@code :}. - * - * @param authority The authority of a URL. - * @throws MalformedURLException If the authority is malformed. - * @return Whether the authority is IP style. - */ - public static boolean determineAuthorityIsIpStyle(String authority) throws MalformedURLException { - return new URL("http://" + authority).getPort() != -1; - } - - /** - * Fills in default values for a ParallelTransferOptions where no value has been set. This will construct a new - * object for safety. - * - * @param other The options to fill in defaults. - * @return An object with defaults filled in for null values in the original. - */ - public static ParallelTransferOptions populateAndApplyDefaults(ParallelTransferOptions other) { - other = other == null ? new ParallelTransferOptions() : other; - - Long blockSize = other.getBlockSizeLong(); - if (blockSize == null) { - blockSize = (long) BlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE; - } - - Integer maxConcurrency = other.getMaxConcurrency(); - if (maxConcurrency == null) { - maxConcurrency = BlobAsyncClient.BLOB_DEFAULT_NUMBER_OF_BUFFERS; - } - - Long maxSingleUploadSize = other.getMaxSingleUploadSizeLong(); - if (maxSingleUploadSize == null) { - maxSingleUploadSize = BLOB_DEFAULT_MAX_SINGLE_UPLOAD_SIZE; - } - - return new ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxConcurrency(maxConcurrency) - .setProgressListener(other.getProgressListener()) - .setMaxSingleUploadSizeLong(maxSingleUploadSize); - } - - /** - * Fills in default values for a ParallelTransferOptions where no value has been set. This will construct a new - * object for safety. - * - * @param other The options to fill in defaults. - * @return An object with defaults filled in for null values in the original. - */ - public static com.azure.storage.common.ParallelTransferOptions - populateAndApplyDefaults(com.azure.storage.common.ParallelTransferOptions other) { - other = other == null ? new com.azure.storage.common.ParallelTransferOptions() : other; - - Long blockSize = other.getBlockSizeLong(); - if (blockSize == null) { - blockSize = (long) BlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE; - } - - Integer maxConcurrency = other.getMaxConcurrency(); - if (maxConcurrency == null) { - maxConcurrency = BlobAsyncClient.BLOB_DEFAULT_NUMBER_OF_BUFFERS; - } - - Long maxSingleUploadSize = other.getMaxSingleUploadSizeLong(); - if (maxSingleUploadSize == null) { - maxSingleUploadSize = BLOB_DEFAULT_MAX_SINGLE_UPLOAD_SIZE; - } - - return new com.azure.storage.common.ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxConcurrency(maxConcurrency) - .setProgressListener(other.getProgressListener()) - .setMaxSingleUploadSizeLong(maxSingleUploadSize); - } - - /** - * Transforms a blob type into a common type. - * @param blobOptions {@link ParallelTransferOptions} - * @return {@link com.azure.storage.common.ParallelTransferOptions} - */ - public static com.azure.storage.common.ParallelTransferOptions - wrapBlobOptions(ParallelTransferOptions blobOptions) { - return new com.azure.storage.common.ParallelTransferOptions().setBlockSizeLong(blobOptions.getBlockSizeLong()) - .setMaxConcurrency(blobOptions.getMaxConcurrency()) - .setProgressListener(blobOptions.getProgressListener()) - .setMaxSingleUploadSizeLong(blobOptions.getMaxSingleUploadSizeLong()); - } - - /** - * Transforms {@link BlobsDownloadHeaders} into a public {@link BlobDownloadHeaders}. - * - * @param internalHeaders {@link BlobsDownloadHeaders} - * @return {@link BlobDownloadHeaders} - */ - public static BlobDownloadHeaders populateBlobDownloadHeaders(BlobsDownloadHeaders internalHeaders, - String errorCode) { - /* - We have these two types because we needed to update this interface in a way that could not be generated - (getObjectReplicationSourcePolicies), so we switched to generating BlobDownloadHeaders into implementation and - wrapping it. Because it's headers type, we couldn't change the name of the generated type. - */ - return BlobDownloadHeadersConstructorProxy.create(internalHeaders).setErrorCode(errorCode); - } - - /** - * Transforms {@link BlobItemInternal} into a public {@link BlobItem}. - * - * @param blobItemInternal {@link BlobItemInternal} - * @return {@link BlobItem} - */ - public static BlobItem populateBlobItem(BlobItemInternal blobItemInternal) { - return BlobItemConstructorProxy.create(blobItemInternal); - } - - public static String toBlobNameString(BlobName blobName) { - return blobName.isEncoded() != null && blobName.isEncoded() - ? Utility.urlDecode(blobName.getContent()) - : blobName.getContent(); - } - - public static TaggedBlobItem populateTaggedBlobItem(FilterBlobItem filterBlobItem) { - return new TaggedBlobItem(filterBlobItem.getContainerName(), filterBlobItem.getName(), - tagMapFromBlobTags(filterBlobItem.getTags())); - } - - public static Map tagMapFromBlobTags(BlobTags blobTags) { - if (blobTags == null || CoreUtils.isNullOrEmpty(blobTags.getBlobTagSet())) { - return Collections.emptyMap(); - } else { - Map tags = new HashMap<>((int) (blobTags.getBlobTagSet().size() / 0.75F)); - for (BlobTag tag : blobTags.getBlobTagSet()) { - tags.put(tag.getKey(), tag.getValue()); - } - return tags; - } - } - - public static BlobTags toBlobTags(Map tags) { - if (tags == null) { - return null; - } - - if (tags.isEmpty()) { - return new BlobTags().setBlobTagSet(new ArrayList<>()); - } - - List blobTagSet = new ArrayList<>(tags.size()); - tags.forEach((key, value) -> blobTagSet.add(new BlobTag().setKey(key).setValue(value))); - - return new BlobTags().setBlobTagSet(blobTagSet); - } - - public static List - transformObjectReplicationMetadata(Map objectReplicationMetadata) { - if (CoreUtils.isNullOrEmpty(objectReplicationMetadata)) { - return null; - } - - Map> internalSourcePolicies = new HashMap<>(); - for (Map.Entry entry : objectReplicationMetadata.entrySet()) { - String orString = entry.getKey(); - int startIndex = orString.startsWith("or-") ? 3 : 0; - int index = orString.indexOf('_', startIndex); - String policyId = orString.substring(startIndex, index); - String ruleId = orString.substring(index + 1); - ObjectReplicationRule rule - = new ObjectReplicationRule(ruleId, ObjectReplicationStatus.fromString(entry.getValue())); - if (!internalSourcePolicies.containsKey(policyId)) { - internalSourcePolicies.put(policyId, new ArrayList<>()); - } - internalSourcePolicies.get(policyId).add(rule); - } - - List objectReplicationSourcePolicies = new ArrayList<>(internalSourcePolicies.size()); - for (Map.Entry> entry : internalSourcePolicies.entrySet()) { - objectReplicationSourcePolicies.add(new ObjectReplicationPolicy(entry.getKey(), entry.getValue())); - } - return objectReplicationSourcePolicies; - } - - public static Map toObjectReplicationMetadata(List policies) { - if (policies == null) { - return null; - } - - if (policies.isEmpty()) { - return new HashMap<>(); - } - - Map objectReplicationMetadata = new HashMap<>((int) (policies.size() / 0.75F)); - policies.forEach(policy -> { - for (ObjectReplicationRule rule : policy.getRules()) { - String key = "or-" + policy.getPolicyId() + "_" + rule.getRuleId(); - objectReplicationMetadata.put(key, rule.getStatus().toString()); - } - }); - - return objectReplicationMetadata; - } - - /** - * Transforms {@link RequestConditions} into a {@link BlobLeaseRequestConditions}. - * - * @param requestConditions {@link RequestConditions} - * @return {@link BlobLeaseRequestConditions} - */ - public static BlobLeaseRequestConditions populateBlobLeaseRequestConditions(RequestConditions requestConditions) { - if (requestConditions == null) { - return null; - } - - return new BlobLeaseRequestConditions().setIfMatch(requestConditions.getIfMatch()) - .setIfNoneMatch(requestConditions.getIfNoneMatch()) - .setIfModifiedSince(requestConditions.getIfModifiedSince()) - .setIfUnmodifiedSince(requestConditions.getIfUnmodifiedSince()) - .setTagsConditions(null); - } - - /** - * Transforms {@link RequestConditions} into a {@link BlobBeginCopySourceRequestConditions}. - * - * @param requestConditions {@link RequestConditions} - * @return {@link BlobBeginCopySourceRequestConditions} - */ - public static BlobBeginCopySourceRequestConditions - populateBlobSourceRequestConditions(RequestConditions requestConditions) { - if (requestConditions == null) { - return null; - } - - return new BlobBeginCopySourceRequestConditions().setIfMatch(requestConditions.getIfMatch()) - .setIfNoneMatch(requestConditions.getIfNoneMatch()) - .setIfModifiedSince(requestConditions.getIfModifiedSince()) - .setIfUnmodifiedSince(requestConditions.getIfUnmodifiedSince()) - .setTagsConditions(null); - } - - /** - * Transforms {@link RequestConditions} into a {@link PageBlobCopyIncrementalRequestConditions}. - * - * @param requestConditions {@link RequestConditions} - * @return {@link PageBlobCopyIncrementalRequestConditions} - */ - public static PageBlobCopyIncrementalRequestConditions - populateBlobDestinationRequestConditions(RequestConditions requestConditions) { - if (requestConditions == null) { - return null; - } - - return new PageBlobCopyIncrementalRequestConditions().setIfMatch(requestConditions.getIfMatch()) - .setIfNoneMatch(requestConditions.getIfNoneMatch()) - .setIfModifiedSince(requestConditions.getIfModifiedSince()) - .setIfUnmodifiedSince(requestConditions.getIfUnmodifiedSince()) - .setTagsConditions(null); - } - - public static String getObjectReplicationDestinationPolicyId(Map objectReplicationStatus) { - if (CoreUtils.isNullOrEmpty(objectReplicationStatus)) { - return null; - } - - return objectReplicationStatus.get("policy-id"); - } - - public static List - getObjectReplicationSourcePolicies(Map objectReplicationStatus) { - if (CoreUtils.isNullOrEmpty(objectReplicationStatus)) { - return new ArrayList<>(); - } - - Map> internalSourcePolicies = new HashMap<>(); - if (getObjectReplicationDestinationPolicyId(objectReplicationStatus) == null) { - for (Map.Entry entry : objectReplicationStatus.entrySet()) { - String key = entry.getKey(); - int index = key.indexOf('_'); - String policyId = key.substring(0, index); - String ruleId = key.substring(index + 1); - ObjectReplicationRule rule - = new ObjectReplicationRule(ruleId, ObjectReplicationStatus.fromString(entry.getValue())); - if (!internalSourcePolicies.containsKey(policyId)) { - internalSourcePolicies.put(policyId, new ArrayList<>()); - } - internalSourcePolicies.get(policyId).add(rule); - } - } - List objectReplicationSourcePolicies = new ArrayList<>(internalSourcePolicies.size()); - for (Map.Entry> entry : internalSourcePolicies.entrySet()) { - objectReplicationSourcePolicies.add(new ObjectReplicationPolicy(entry.getKey(), entry.getValue())); - } - return objectReplicationSourcePolicies; - } - - public static String getErrorCode(HttpHeaders headers) { - return getHeaderValue(headers, X_MS_ERROR_CODE); - } - - public static String getETag(HttpHeaders headers) { - return getHeaderValue(headers, HttpHeaderName.ETAG); - } - - private static String getHeaderValue(HttpHeaders headers, HttpHeaderName headerName) { - if (headers == null) { - return null; - } - return headers.getValue(headerName); - } - - public static BlobsDownloadHeaders transformBlobDownloadHeaders(HttpHeaders headers) { - return new BlobsDownloadHeaders(headers); - } - - public static BlobQueryHeaders transformQueryHeaders(BlobsQueryHeaders headers, HttpHeaders rawHeaders) { - return BlobQueryHeadersConstructorProxy.create(headers).setErrorCode(ModelHelper.getErrorCode(rawHeaders)); - } - - public static void validateConditionsNotPresent(BlobRequestConditions requestConditions, - EnumSet invalidConditions, String operationName, String parameterName) { - if (requestConditions == null) { - return; - } - List invalidConditionsFound = null; - - for (BlobRequestConditionProperty condition : invalidConditions) { - switch (condition) { - case LEASE_ID: - if (requestConditions.getLeaseId() != null) { - invalidConditionsFound - = invalidConditionsFound == null ? new ArrayList<>() : invalidConditionsFound; - invalidConditionsFound.add(BlobRequestConditionProperty.LEASE_ID.toString()); - } - break; - - case TAGS_CONDITIONS: - if (requestConditions.getTagsConditions() != null) { - invalidConditionsFound - = invalidConditionsFound == null ? new ArrayList<>() : invalidConditionsFound; - invalidConditionsFound.add(BlobRequestConditionProperty.TAGS_CONDITIONS.toString()); - } - break; - - case IF_MODIFIED_SINCE: - if (requestConditions.getIfModifiedSince() != null) { - invalidConditionsFound - = invalidConditionsFound == null ? new ArrayList<>() : invalidConditionsFound; - invalidConditionsFound.add(BlobRequestConditionProperty.IF_MODIFIED_SINCE.toString()); - } - break; - - case IF_UNMODIFIED_SINCE: - if (requestConditions.getIfUnmodifiedSince() != null) { - invalidConditionsFound - = invalidConditionsFound == null ? new ArrayList<>() : invalidConditionsFound; - invalidConditionsFound.add(BlobRequestConditionProperty.IF_UNMODIFIED_SINCE.toString()); - } - break; - - case IF_MATCH: - if (requestConditions.getIfMatch() != null) { - invalidConditionsFound - = invalidConditionsFound == null ? new ArrayList<>() : invalidConditionsFound; - invalidConditionsFound.add(BlobRequestConditionProperty.IF_MATCH.toString()); - } - break; - - case IF_NONE_MATCH: - if (requestConditions.getIfNoneMatch() != null) { - invalidConditionsFound - = invalidConditionsFound == null ? new ArrayList<>() : invalidConditionsFound; - invalidConditionsFound.add(BlobRequestConditionProperty.IF_NONE_MATCH.toString()); - } - break; - - default: - break; - } - } - if (invalidConditionsFound != null && !invalidConditionsFound.isEmpty()) { - String unsupported = String.join(", ", invalidConditionsFound); - throw LOGGER.logExceptionAsError(new IllegalArgumentException( - String.format("%s does not support the %s request condition(s) for parameter '%s'.", operationName, - unsupported, parameterName))); - } - } - - public static Response buildBlobPropertiesResponse(BlobDownloadAsyncResponse response) { - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - BlobPropertiesConstructorProxy - .create(new BlobPropertiesInternalDownload(response.getDeserializedHeaders()))); - } - - public static Response buildBlobPropertiesResponse(BlobDownloadResponse response) { - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - BlobPropertiesConstructorProxy - .create(new BlobPropertiesInternalDownload(response.getDeserializedHeaders()))); - } - - public static long getBlobLength(BlobDownloadHeaders headers) { - return headers.getContentRange() == null - ? headers.getContentLength() - : ChunkedDownloadUtils.extractTotalBlobLength(headers.getContentRange()); - } - - public static String tagsToString(Map tags) { - if (tags == null || tags.isEmpty()) { - return null; - } - StringBuilder sb = new StringBuilder(); - boolean first = true; // Flag to track if it's the first element in the loop - for (Map.Entry entry : tags.entrySet()) { - try { - if (!first) { - sb.append("&"); // Append the delimiter before the key-value pair, except for the first - } else { - first = false; // Update flag after processing the first entry - } - sb.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8.toString())); - sb.append("="); - sb.append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString())); - } catch (UnsupportedEncodingException e) { - throw LOGGER.logExceptionAsError(new IllegalStateException(e)); - } - } - return sb.toString(); - } - - public static LongRunningOperationStatus mapStatusToLongRunningOperationStatus(CopyStatusType status) { - LongRunningOperationStatus operationStatus; - switch (status) { - case SUCCESS: - operationStatus = LongRunningOperationStatus.SUCCESSFULLY_COMPLETED; - break; - - case FAILED: - operationStatus = LongRunningOperationStatus.FAILED; - break; - - case ABORTED: - operationStatus = LongRunningOperationStatus.USER_CANCELLED; - break; - - case PENDING: - operationStatus = LongRunningOperationStatus.IN_PROGRESS; - break; - - default: - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("CopyStatusType is not supported. Status: " + status)); - } - return operationStatus; - } - - public static boolean validateNoETag(BlobRequestConditions modifiedRequestConditions) { - if (modifiedRequestConditions == null) { - return true; - } - return modifiedRequestConditions.getIfMatch() == null && modifiedRequestConditions.getIfNoneMatch() == null; - } - - /** - * Converts {@link BlobContainerListDetails} into list of {@link ListBlobContainersIncludeType} - * that contains only options selected. If no option is selected then null is returned. - * - * @return a list of selected options converted into {@link ListBlobContainersIncludeType}, null if none - * of options has been selected. - */ - public static List - toIncludeTypes(BlobContainerListDetails blobContainerListDetails) { - boolean hasDetails = blobContainerListDetails != null - && (blobContainerListDetails.getRetrieveMetadata() - || blobContainerListDetails.getRetrieveDeleted() - || blobContainerListDetails.getRetrieveSystemContainers()); - if (hasDetails) { - List flags = new ArrayList<>(3); - if (blobContainerListDetails.getRetrieveDeleted()) { - flags.add(ListBlobContainersIncludeType.DELETED); - } - if (blobContainerListDetails.getRetrieveMetadata()) { - flags.add(ListBlobContainersIncludeType.METADATA); - } - if (blobContainerListDetails.getRetrieveSystemContainers()) { - flags.add(ListBlobContainersIncludeType.SYSTEM); - } - return flags; - } else { - return null; - } - } - - /** - * Validates a {@link BlobRetentionPolicy} according to service specs for set properties. - * @param retentionPolicy {@link BlobRetentionPolicy} - * @param policyName The name of the variable for errors. - */ - public static void validateRetentionPolicy(BlobRetentionPolicy retentionPolicy, String policyName) { - if (retentionPolicy == null) { - return; - } - if (retentionPolicy.isEnabled()) { - StorageImplUtils.assertInBounds(policyName, retentionPolicy.getDays(), 1, 365); - } - } - - /** - * Sets any null fields to "" since the service requires all Cors rules to be set if some are set. - * @param originalRule {@link BlobCorsRule} - * @return The validated {@link BlobCorsRule} - */ - public static BlobCorsRule validatedCorsRule(BlobCorsRule originalRule) { - if (originalRule == null) { - return null; - } - BlobCorsRule validRule = new BlobCorsRule(); - validRule.setAllowedHeaders(StorageImplUtils.emptyIfNull(originalRule.getAllowedHeaders())); - validRule.setAllowedMethods(StorageImplUtils.emptyIfNull(originalRule.getAllowedMethods())); - validRule.setAllowedOrigins(StorageImplUtils.emptyIfNull(originalRule.getAllowedOrigins())); - validRule.setExposedHeaders(StorageImplUtils.emptyIfNull(originalRule.getExposedHeaders())); - validRule.setMaxAgeInSeconds(originalRule.getMaxAgeInSeconds()); - return validRule; - } - - public static String pageRangeToString(PageRange pageRange) { - if (pageRange.getStart() < 0 || pageRange.getEnd() <= 0) { - throw new IllegalArgumentException( - "PageRange's start and end values must be greater than or equal to " + "0 if specified."); - } - if (pageRange.getStart() % PAGE_BYTES != 0) { - throw new IllegalArgumentException("PageRange's start value must be a multiple of 512."); - } - if (pageRange.getEnd() % PAGE_BYTES != PAGE_BYTES - 1) { - throw new IllegalArgumentException("PageRange's end value must be 1 less than a multiple of 512."); - } - if (pageRange.getEnd() <= pageRange.getStart()) { - throw new IllegalArgumentException("PageRange's End value must be after the start."); - } - return "bytes=" + pageRange.getStart() + '-' + pageRange.getEnd(); - } - - public static List - truncateTimeForBlobSignedIdentifier(List identifiers) { - if (identifiers == null) { - return null; - } - /* - We truncate to seconds because the service only supports nanoseconds or seconds, but doing an - OffsetDateTime.now will only give back milliseconds (more precise fields are zeroed and not serialized). This - allows for proper serialization with no real detriment to users as sub-second precision on active time for - signed identifiers is not really necessary. - */ - for (BlobSignedIdentifier identifier : identifiers) { - if (identifier.getAccessPolicy() != null && identifier.getAccessPolicy().getStartsOn() != null) { - identifier.getAccessPolicy() - .setStartsOn(identifier.getAccessPolicy().getStartsOn().truncatedTo(ChronoUnit.SECONDS)); - } - if (identifier.getAccessPolicy() != null && identifier.getAccessPolicy().getExpiresOn() != null) { - identifier.getAccessPolicy() - .setExpiresOn(identifier.getAccessPolicy().getExpiresOn().truncatedTo(ChronoUnit.SECONDS)); - } - } - return identifiers; - } - - /** - * Maps the internal exception to a public exception, if and only if {@code internal} is an instance of - * {@link BlobStorageExceptionInternal} and it will be mapped to {@link BlobStorageException}. - *

- * The internal exception is required as the public exception was created using Object as the exception value. This - * was incorrect and should have been a specific type that was XML deserializable. So, an internal exception was - * added to handle this and we map that to the public exception, keeping the API the same. - * - * @param internal The internal exception. - * @return The public exception. - */ - public static BlobStorageException mapToBlobStorageException(BlobStorageExceptionInternal internal) { - return new BlobStorageException(internal.getMessage(), internal.getResponse(), internal.getValue()); - } - - private ModelHelper() { - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/StorageBlockingSink.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/StorageBlockingSink.java deleted file mode 100644 index 7a5d8d33a1b2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/StorageBlockingSink.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.implementation.util; - -import com.azure.core.util.logging.ClientLogger; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Sinks; - -import java.nio.ByteBuffer; -import java.util.concurrent.LinkedBlockingQueue; - -/** - * This is a lightweight wrapper around Sinks.Many to implement a Sink backed by a LinkedBlockingQueue, effectively - * implementing a BlockingSink. - */ -public final class StorageBlockingSink { - private static final ClientLogger LOGGER = new ClientLogger(StorageBlockingSink.class); - - /* - Note: Though this is used only by BlockBlobOutputStream, the decision was made to abstract this type out to make - testing easier. - */ - private final Sinks.Many writeSink; - private final LinkedBlockingQueue writeLimitQueue; - - /* Overridden implementation of LinkedBlockingQueue to effectively implement a true BlockingSink. */ - private static final class ProducerBlockingQueue extends LinkedBlockingQueue { - private final transient ClientLogger logger; - private static final long serialVersionUID = 1; - - ProducerBlockingQueue(int queueSize, ClientLogger logger) { - super(queueSize); - this.logger = logger; - } - - /* The Reactor implementation of Sinks(UnicastProcessor).tryEmitNext (see usage below) makes a call to - queue.offer(). The desired functionality of tryEmitNext is for it to block on backpressure until there is - space in the queue. Since this code is called from user thread on BlobOutputStream.write and blocking on that - API until data can be written is ok, this is the simplest way to get desired behavior. */ - @Override - public boolean offer(ByteBuffer o) { - try { - super.put(o); - return true; - } catch (InterruptedException e) { - throw logger.logExceptionAsError(new RuntimeException(e)); - } - } - } - - /** - * Create a new StorageBlockingSink. - */ - public StorageBlockingSink() { - /* - We use a ProducerBlockingQueue to effectively block the thread that calls tryEmitNext if there is - backpressure from downstream. Its capacity is 1 to keep the buffer as small as possible, as downstream - implementations do their own buffering. - */ - this.writeLimitQueue = new ProducerBlockingQueue<>(1, LOGGER); - this.writeSink = Sinks.many().unicast().onBackpressureBuffer(writeLimitQueue); - } - - /** - * Try to emit an element. - * - * @param buffer {@link ByteBuffer} to emit. - */ - public void emitNext(ByteBuffer buffer) { - try { - this.writeSink.tryEmitNext(buffer).orThrow(); - /* Here are different cases that tryEmitNext can return. - * OK: Success - * FAIL_OVERFLOW: When the writeLimitQueue overflows. This indicates there is backpressure. NOTE: If this - * ever gets hit, it indicates that there is a mismatch between the way Reactor implements tryEmitNext - * and they way ProducerBlockingQueue is designed. - * FAIL_TERMINATED: The Flux already emitted a completion signal. We implicitly save ourselves from hitting - * this case by calling checkStreamState before write in BlockBlobOutputStream. - * FAIL_CANCELLED: The Flux received a cancellation signal. This can happen due to timeouts. - * FAIL_NON_SERIALIZED: Concurrent calls to tryEmitNext. This is invalid for OutputStreams anyway. - * FAIL_ZERO_SUBSCRIBER: The Flux was never subscribed to. We implicitly save ourselves from hitting this - * case since we manage the subscribe process in the constructor of BlockBlobOutputStream - */ - } catch (Exception e) { - throw LOGGER.logExceptionAsError( - new IllegalStateException("Faulted stream due to underlying sink " + "write failure", e)); - } - } - - /** - * Try to emit a complete signal, otherwise throw. - */ - public void emitCompleteOrThrow() { - this.writeSink.tryEmitComplete().orThrow(); - } - - /** - * @return The Flux that represents the Sink. - */ - public Flux asFlux() { - return this.writeSink.asFlux(); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/package-info.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/package-info.java deleted file mode 100644 index 39f95bfeb0d1..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package containing implementation specific utilities for Azure Storage Blobs. - */ -package com.azure.storage.blob.implementation.util; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccessPolicy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccessPolicy.java new file mode 100644 index 000000000000..eb6c9b6440d7 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccessPolicy.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Represents an access policy. + */ +@Immutable +public final class AccessPolicy implements JsonSerializable { + /* + * The date-time the policy is active. + */ + @Generated + private final OffsetDateTime start; + + /* + * The date-time the policy expires. + */ + @Generated + private final OffsetDateTime expiry; + + /* + * The permissions for acl the policy. + */ + @Generated + private final String permission; + + /** + * Creates an instance of AccessPolicy class. + * + * @param start the start value to set. + * @param expiry the expiry value to set. + * @param permission the permission value to set. + */ + @Generated + public AccessPolicy(OffsetDateTime start, OffsetDateTime expiry, String permission) { + this.start = start; + this.expiry = expiry; + this.permission = permission; + } + + /** + * Get the start property: The date-time the policy is active. + * + * @return the start value. + */ + @Generated + public OffsetDateTime getStart() { + return this.start; + } + + /** + * Get the expiry property: The date-time the policy expires. + * + * @return the expiry value. + */ + @Generated + public OffsetDateTime getExpiry() { + return this.expiry; + } + + /** + * Get the permission property: The permissions for acl the policy. + * + * @return the permission value. + */ + @Generated + public String getPermission() { + return this.permission; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("start", + this.start == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.start)); + jsonWriter.writeStringField("expiry", + this.expiry == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.expiry)); + jsonWriter.writeStringField("permission", this.permission); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AccessPolicy from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AccessPolicy if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AccessPolicy. + */ + @Generated + public static AccessPolicy fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime start = null; + OffsetDateTime expiry = null; + String permission = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("start".equals(fieldName)) { + start = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("expiry".equals(fieldName)) { + expiry = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("permission".equals(fieldName)) { + permission = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new AccessPolicy(start, expiry, permission); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccessTier.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccessTier.java index 007106aa2acb..f755d5e00f4e 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccessTier.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccessTier.java @@ -1,94 +1,111 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; /** - * Defines values for AccessTier. + * The access tiers. */ public final class AccessTier extends ExpandableStringEnum { /** - * Static value P4 for AccessTier. + * The hot P4 tier. */ + @Generated public static final AccessTier P4 = fromString("P4"); /** - * Static value P6 for AccessTier. + * The hot P6 tier. */ + @Generated public static final AccessTier P6 = fromString("P6"); /** - * Static value P10 for AccessTier. + * The hot P10 tier. */ + @Generated public static final AccessTier P10 = fromString("P10"); /** - * Static value P15 for AccessTier. + * The hot P15 tier. */ + @Generated public static final AccessTier P15 = fromString("P15"); /** - * Static value P20 for AccessTier. + * The hot P20 tier. */ + @Generated public static final AccessTier P20 = fromString("P20"); /** - * Static value P30 for AccessTier. + * The hot P30 tier. */ + @Generated public static final AccessTier P30 = fromString("P30"); /** - * Static value P40 for AccessTier. + * The hot P40 tier. */ + @Generated public static final AccessTier P40 = fromString("P40"); /** - * Static value P50 for AccessTier. + * The hot P50 tier. */ + @Generated public static final AccessTier P50 = fromString("P50"); /** - * Static value P60 for AccessTier. + * The hot P60 tier. */ + @Generated public static final AccessTier P60 = fromString("P60"); /** - * Static value P70 for AccessTier. + * The hot P70 tier. */ + @Generated public static final AccessTier P70 = fromString("P70"); /** - * Static value P80 for AccessTier. + * The hot P80 tier. */ + @Generated public static final AccessTier P80 = fromString("P80"); /** - * Static value Hot for AccessTier. + * The hot access tier. */ + @Generated public static final AccessTier HOT = fromString("Hot"); /** - * Static value Cool for AccessTier. + * The cool access tier. */ + @Generated public static final AccessTier COOL = fromString("Cool"); /** - * Static value Archive for AccessTier. + * The archive access tier. */ + @Generated public static final AccessTier ARCHIVE = fromString("Archive"); /** - * Static value Premium for AccessTier. + * The Premium access tier. */ + @Generated public static final AccessTier PREMIUM = fromString("Premium"); /** - * Static value Cold for AccessTier. + * The Cold access tier. */ + @Generated public static final AccessTier COLD = fromString("Cold"); /** @@ -96,6 +113,7 @@ public final class AccessTier extends ExpandableStringEnum { * * @deprecated Use the {@link #fromString(String)} factory method. */ + @Generated @Deprecated public AccessTier() { } @@ -106,6 +124,7 @@ public AccessTier() { * @param name a name to look for. * @return the corresponding AccessTier. */ + @Generated public static AccessTier fromString(String name) { return fromString(name, AccessTier.class); } @@ -115,6 +134,7 @@ public static AccessTier fromString(String name) { * * @return known AccessTier values. */ + @Generated public static Collection values() { return values(AccessTier.class); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccountKind.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccountKind.java deleted file mode 100644 index 4223a28e59a0..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AccountKind.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -/** - * Defines values for AccountKind. - */ -public enum AccountKind { - /** - * Enum value Storage. - */ - STORAGE("Storage"), - - /** - * Enum value BlobStorage. - */ - BLOB_STORAGE("BlobStorage"), - - /** - * Enum value StorageV2. - */ - STORAGE_V2("StorageV2"), - - /** - * Enum value FileStorage. - */ - FILE_STORAGE("FileStorage"), - - /** - * Enum value BlockBlobStorage. - */ - BLOCK_BLOB_STORAGE("BlockBlobStorage"); - - /** - * The actual serialized value for a AccountKind instance. - */ - private final String value; - - AccountKind(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a AccountKind instance. - * - * @param value the serialized value to parse. - * @return the parsed AccountKind object, or null if unable to parse. - */ - public static AccountKind fromString(String value) { - if (value == null) { - return null; - } - AccountKind[] items = AccountKind.values(); - for (AccountKind item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AppendBlobItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AppendBlobItem.java deleted file mode 100644 index 8acbf7de2813..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AppendBlobItem.java +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; -import com.azure.core.util.CoreUtils; - -import java.time.OffsetDateTime; - -/** - * This class contains the properties about an append blob. - */ -@Immutable -public class AppendBlobItem { - private final String eTag; - private final OffsetDateTime lastModified; - private final byte[] contentMd5; - private final boolean isServerEncrypted; - private final String encryptionKeySha256; - private final String encryptionScope; - private final String blobAppendOffset; - private final Integer blobCommittedBlockCount; - private final String versionId; - - /** - * Constructs an {@link AppendBlobItem}. - * - * @param eTag ETag of the append blob. - * @param lastModified Last modified time of the append blob. - * @param contentMd5 Content MD5 of the append blob. - * @param isServerEncrypted Flag indicating if the page blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the page blob. - * @param blobAppendOffset The offset at which the block was committed to the block blob. - * @param blobCommittedBlockCount The number of committed blocks in the block blob. - */ - public AppendBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final boolean isServerEncrypted, final String encryptionKeySha256, final String blobAppendOffset, - final Integer blobCommittedBlockCount) { - this(eTag, lastModified, contentMd5, isServerEncrypted, encryptionKeySha256, null, blobAppendOffset, - blobCommittedBlockCount); - } - - /** - * Constructs an {@link AppendBlobItem}. - * - * @param eTag ETag of the append blob. - * @param lastModified Last modified time of the append blob. - * @param contentMd5 Content MD5 of the append blob. - * @param isServerEncrypted Flag indicating if the page blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the append blob. - * @param encryptionScope The encryption scope used to encrypt the append blob. - * @param blobAppendOffset The offset at which the block was committed to the append blob. - * @param blobCommittedBlockCount The number of committed blocks in the append blob. - */ - public AppendBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope, - final String blobAppendOffset, final Integer blobCommittedBlockCount) { - this(eTag, lastModified, contentMd5, isServerEncrypted, encryptionKeySha256, encryptionScope, blobAppendOffset, - blobCommittedBlockCount, null); - } - - /** - * Constructs an {@link AppendBlobItem}. - * - * @param eTag ETag of the append blob. - * @param lastModified Last modified time of the append blob. - * @param contentMd5 Content MD5 of the append blob. - * @param isServerEncrypted Flag indicating if the page blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the append blob. - * @param encryptionScope The encryption scope used to encrypt the append blob. - * @param blobAppendOffset The offset at which the block was committed to the append blob. - * @param blobCommittedBlockCount The number of committed blocks in the append blob. - * @param versionId The version identifier of the append blob. - */ - public AppendBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope, - final String blobAppendOffset, final Integer blobCommittedBlockCount, final String versionId) { - this.eTag = eTag; - this.lastModified = lastModified; - this.contentMd5 = CoreUtils.clone(contentMd5); - this.isServerEncrypted = isServerEncrypted; - this.encryptionKeySha256 = encryptionKeySha256; - this.encryptionScope = encryptionScope; - this.blobAppendOffset = blobAppendOffset; - this.blobCommittedBlockCount = blobCommittedBlockCount; - this.versionId = versionId; - } - - /** - * Gets the eTag of the append blob. - * - * @return the eTag of the append blob - */ - public String getETag() { - return eTag; - } - - /** - * Gets the time this append blob was last modified. - * - * @return the time this append blob was last modified - */ - public OffsetDateTime getLastModified() { - return lastModified; - }; - - /** - * Gets the encryption status of the append blob on the server. - * - * @return the encryption status of the append blob on the server - */ - public boolean isServerEncrypted() { - return isServerEncrypted; - } - - /** - * Gets the key that was used to encrypt the append blob. - * - * @return the key that was used to encrypt the append blob - */ - public String getEncryptionKeySha256() { - return encryptionKeySha256; - } - - /** - * Gets the encryption scope that was used to encrypt the append blob. - * - * @return the encryption scope that was used to encrypt the append blob - */ - public String getEncryptionScope() { - return encryptionScope; - } - - /** - * Gets the calculated MD5 of the append blob. - * - * @return the calculated MD5 of the append blob - */ - public byte[] getContentMd5() { - return CoreUtils.clone(contentMd5); - } - - /** - * Gets the offset of the append blob. - * - * @return the offset of the append blob - */ - public String getBlobAppendOffset() { - return blobAppendOffset; - } - - /** - * Gets the number of committed blocks in the append blob. - * - * @return the number of committed blocks in the append blob - */ - public Integer getBlobCommittedBlockCount() { - return blobCommittedBlockCount; - } - - /** - * Gets the version identifier of the append blob. - * - * @return the version identifier of the append blob - */ - public String getVersionId() { - return versionId; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AppendBlobRequestConditions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AppendBlobRequestConditions.java deleted file mode 100644 index dbec22904040..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/AppendBlobRequestConditions.java +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; - -import java.time.OffsetDateTime; - -/** - * This class contains values that restrict the successful completion of AppendBlock operations to certain conditions. - * Any field may be set to null if no access conditions are desired. - *

- * Please refer to the request header section - * here for more conceptual - * information. - */ -@Fluent -public final class AppendBlobRequestConditions extends BlobRequestConditions { - private Long maxSize; - private Long appendPosition; - - /** - * Creates a new instance of {@link AppendBlobRequestConditions}. - */ - public AppendBlobRequestConditions() { - } - - /** - * Optionally limit requests to resources that match the passed ETag. - * - * @param ifMatch ETag that resources must match. - * @return The updated AppendBlobRequestConditions object. - */ - @Override - public AppendBlobRequestConditions setIfMatch(String ifMatch) { - super.setIfMatch(ifMatch); - return this; - } - - /** - * Optionally limit requests to resources that do not match the passed ETag. - * - * @param ifNoneMatch ETag that resources must not match. - * @return The updated AppendBlobRequestConditions object. - */ - @Override - public AppendBlobRequestConditions setIfNoneMatch(String ifNoneMatch) { - super.setIfNoneMatch(ifNoneMatch); - return this; - } - - /** - * Optionally limit requests to resources that have only been modified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifModifiedSince The datetime that resources must have been modified since. - * @return The updated AppendBlobRequestConditions object. - */ - @Override - public AppendBlobRequestConditions setIfModifiedSince(OffsetDateTime ifModifiedSince) { - super.setIfModifiedSince(ifModifiedSince); - return this; - } - - /** - * Optionally limit requests to resources that have remained unmodified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifUnmodifiedSince The datetime that resources must have remained unmodified since. - * @return The updated AppendBlobRequestConditions object. - */ - @Override - public AppendBlobRequestConditions setIfUnmodifiedSince(OffsetDateTime ifUnmodifiedSince) { - super.setIfUnmodifiedSince(ifUnmodifiedSince); - return this; - } - - /** - * Optionally limits requests to blobs and containers that match the lease ID. - * - * @param leaseId Lease ID that blobs and containers must match. - * @return The updated AppendBlobRequestConditions object. - */ - @Override - public AppendBlobRequestConditions setLeaseId(String leaseId) { - super.setLeaseId(leaseId); - return this; - } - - /** - * Optionally applies the SQL statement to the tags of the blob. - * - * @param tagsConditions The SQL statement that apply to the tags of the blob. - * @return The updated BlobRequestConditions object. - */ - @Override - public AppendBlobRequestConditions setTagsConditions(String tagsConditions) { - super.setTagsConditions(tagsConditions); - return this; - } - - /** - * Gets the max length in bytes allowed for the append blob. - * - *

If the operation would cause the append blob to grow larger than the limit the request will fail.

- * - * @return The max length in bytes allowed for the append blob. - */ - public Long getMaxSize() { - return maxSize; - } - - /** - * Sets the max length in bytes allowed for the append blob. - * - *

If the operation would cause the append blob to grow larger than the limit the request will fail.

- * - * @param maxSize Append blob size byte limit. - * @return The updated AppendBlobRequestConditions object. - */ - public AppendBlobRequestConditions setMaxSize(Long maxSize) { - this.maxSize = maxSize; - return this; - } - - /** - * Gets the byte offset that the append position of the append blob must match. - * - * @return The byte offset that must match the append position. - */ - public Long getAppendPosition() { - return appendPosition; - } - - /** - * Sets the byte offset that the append position of the append blob must match. - * - * @param appendPosition Byte offset to compare to the append position. - * @return The updated AppendBlobRequestConditions object. - */ - public AppendBlobRequestConditions setAppendPosition(Long appendPosition) { - this.appendPosition = appendPosition; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArchiveStatus.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArchiveStatus.java index 05aee8f998c8..999535e55ac1 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArchiveStatus.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArchiveStatus.java @@ -1,29 +1,33 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; /** - * Defines values for ArchiveStatus. + * The archive status. */ public final class ArchiveStatus extends ExpandableStringEnum { /** - * Static value rehydrate-pending-to-hot for ArchiveStatus. + * The archive status is rehydrating pending to hot. */ + @Generated public static final ArchiveStatus REHYDRATE_PENDING_TO_HOT = fromString("rehydrate-pending-to-hot"); /** - * Static value rehydrate-pending-to-cool for ArchiveStatus. + * The archive status is rehydrating pending to cool. */ + @Generated public static final ArchiveStatus REHYDRATE_PENDING_TO_COOL = fromString("rehydrate-pending-to-cool"); /** - * Static value rehydrate-pending-to-cold for ArchiveStatus. + * The archive status is rehydrating pending to archive. */ + @Generated public static final ArchiveStatus REHYDRATE_PENDING_TO_COLD = fromString("rehydrate-pending-to-cold"); /** @@ -31,6 +35,7 @@ public final class ArchiveStatus extends ExpandableStringEnum { * * @deprecated Use the {@link #fromString(String)} factory method. */ + @Generated @Deprecated public ArchiveStatus() { } @@ -41,6 +46,7 @@ public ArchiveStatus() { * @param name a name to look for. * @return the corresponding ArchiveStatus. */ + @Generated public static ArchiveStatus fromString(String name) { return fromString(name, ArchiveStatus.class); } @@ -50,6 +56,7 @@ public static ArchiveStatus fromString(String name) { * * @return known ArchiveStatus values. */ + @Generated public static Collection values() { return values(ArchiveStatus.class); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArrowConfiguration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArrowConfiguration.java new file mode 100644 index 000000000000..489928e445b0 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArrowConfiguration.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents the Apache Arrow configuration. + */ +@Immutable +public final class ArrowConfiguration implements JsonSerializable { + /* + * The Apache Arrow schema + */ + @Generated + private final List schema; + + /** + * Creates an instance of ArrowConfiguration class. + * + * @param schema the schema value to set. + */ + @Generated + public ArrowConfiguration(List schema) { + this.schema = schema; + } + + /** + * Get the schema property: The Apache Arrow schema. + * + * @return the schema value. + */ + @Generated + public List getSchema() { + return this.schema; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("schema", this.schema, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ArrowConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ArrowConfiguration if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ArrowConfiguration. + */ + @Generated + public static ArrowConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List schema = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("schema".equals(fieldName)) { + schema = reader.readArray(reader1 -> ArrowField.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new ArrowConfiguration(schema); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArrowField.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArrowField.java new file mode 100644 index 000000000000..2a6eaa1103d5 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArrowField.java @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents an Apache Arrow field. + */ +@Fluent +public final class ArrowField implements JsonSerializable { + /* + * The arrow field type. + */ + @Generated + private final String type; + + /* + * The arrow field name. + */ + @Generated + private String name; + + /* + * The arrow field precision. + */ + @Generated + private Integer precision; + + /* + * The arrow field scale. + */ + @Generated + private Integer scale; + + /** + * Creates an instance of ArrowField class. + * + * @param type the type value to set. + */ + @Generated + public ArrowField(String type) { + this.type = type; + } + + /** + * Get the type property: The arrow field type. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the name property: The arrow field name. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The arrow field name. + * + * @param name the name value to set. + * @return the ArrowField object itself. + */ + @Generated + public ArrowField setName(String name) { + this.name = name; + return this; + } + + /** + * Get the precision property: The arrow field precision. + * + * @return the precision value. + */ + @Generated + public Integer getPrecision() { + return this.precision; + } + + /** + * Set the precision property: The arrow field precision. + * + * @param precision the precision value to set. + * @return the ArrowField object itself. + */ + @Generated + public ArrowField setPrecision(Integer precision) { + this.precision = precision; + return this; + } + + /** + * Get the scale property: The arrow field scale. + * + * @return the scale value. + */ + @Generated + public Integer getScale() { + return this.scale; + } + + /** + * Set the scale property: The arrow field scale. + * + * @param scale the scale value to set. + * @return the ArrowField object itself. + */ + @Generated + public ArrowField setScale(Integer scale) { + this.scale = scale; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeNumberField("precision", this.precision); + jsonWriter.writeNumberField("scale", this.scale); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ArrowField from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ArrowField if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ArrowField. + */ + @Generated + public static ArrowField fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String type = null; + String name = null; + Integer precision = null; + Integer scale = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("precision".equals(fieldName)) { + precision = reader.getNullable(JsonReader::getInt); + } else if ("scale".equals(fieldName)) { + scale = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + ArrowField deserializedArrowField = new ArrowField(type); + deserializedArrowField.name = name; + deserializedArrowField.precision = precision; + deserializedArrowField.scale = scale; + + return deserializedArrowField; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAccessPolicy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAccessPolicy.java deleted file mode 100644 index 7e539d5fe152..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAccessPolicy.java +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.time.OffsetDateTime; -import java.time.format.DateTimeFormatter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * An Access policy. - */ -@Fluent -public final class BlobAccessPolicy implements XmlSerializable { - /* - * the date-time the policy is active - */ - private OffsetDateTime startsOn; - - /* - * the date-time the policy expires - */ - private OffsetDateTime expiresOn; - - /* - * the permissions for the acl policy - */ - private String permissions; - - /** - * Creates an instance of BlobAccessPolicy class. - */ - public BlobAccessPolicy() { - } - - /** - * Get the startsOn property: the date-time the policy is active. - * - * @return the startsOn value. - */ - public OffsetDateTime getStartsOn() { - return this.startsOn; - } - - /** - * Set the startsOn property: the date-time the policy is active. - * - * @param startsOn the startsOn value to set. - * @return the BlobAccessPolicy object itself. - */ - public BlobAccessPolicy setStartsOn(OffsetDateTime startsOn) { - this.startsOn = startsOn; - return this; - } - - /** - * Get the expiresOn property: the date-time the policy expires. - * - * @return the expiresOn value. - */ - public OffsetDateTime getExpiresOn() { - return this.expiresOn; - } - - /** - * Set the expiresOn property: the date-time the policy expires. - * - * @param expiresOn the expiresOn value to set. - * @return the BlobAccessPolicy object itself. - */ - public BlobAccessPolicy setExpiresOn(OffsetDateTime expiresOn) { - this.expiresOn = expiresOn; - return this; - } - - /** - * Get the permissions property: the permissions for the acl policy. - * - * @return the permissions value. - */ - public String getPermissions() { - return this.permissions; - } - - /** - * Set the permissions property: the permissions for the acl policy. - * - * @param permissions the permissions value to set. - * @return the BlobAccessPolicy object itself. - */ - public BlobAccessPolicy setPermissions(String permissions) { - this.permissions = permissions; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobAccessPolicy" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Start", - this.startsOn == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startsOn)); - xmlWriter.writeStringElement("Expiry", - this.expiresOn == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.expiresOn)); - xmlWriter.writeStringElement("Permission", this.permissions); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobAccessPolicy from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobAccessPolicy if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobAccessPolicy. - */ - public static BlobAccessPolicy fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobAccessPolicy from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobAccessPolicy if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobAccessPolicy. - */ - public static BlobAccessPolicy fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobAccessPolicy" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobAccessPolicy deserializedBlobAccessPolicy = new BlobAccessPolicy(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Start".equals(elementName.getLocalPart())) { - deserializedBlobAccessPolicy.startsOn - = reader.getNullableElement(dateString -> CoreUtils.parseBestOffsetDateTime(dateString)); - } else if ("Expiry".equals(elementName.getLocalPart())) { - deserializedBlobAccessPolicy.expiresOn - = reader.getNullableElement(dateString -> CoreUtils.parseBestOffsetDateTime(dateString)); - } else if ("Permission".equals(elementName.getLocalPart())) { - deserializedBlobAccessPolicy.permissions = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedBlobAccessPolicy; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAnalyticsLogging.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAnalyticsLogging.java deleted file mode 100644 index b8abd01a2750..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAnalyticsLogging.java +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Azure Analytics Logging settings. - */ -@Fluent -public final class BlobAnalyticsLogging implements XmlSerializable { - /* - * The version of Storage Analytics to configure. - */ - private String version; - - /* - * Indicates whether all delete requests should be logged. - */ - private boolean delete; - - /* - * Indicates whether all read requests should be logged. - */ - private boolean read; - - /* - * Indicates whether all write requests should be logged. - */ - private boolean write; - - /* - * the retention policy which determines how long the associated data should persist - */ - private BlobRetentionPolicy retentionPolicy; - - /** - * Creates an instance of BlobAnalyticsLogging class. - */ - public BlobAnalyticsLogging() { - } - - /** - * Get the version property: The version of Storage Analytics to configure. - * - * @return the version value. - */ - public String getVersion() { - return this.version; - } - - /** - * Set the version property: The version of Storage Analytics to configure. - * - * @param version the version value to set. - * @return the BlobAnalyticsLogging object itself. - */ - public BlobAnalyticsLogging setVersion(String version) { - this.version = version; - return this; - } - - /** - * Get the delete property: Indicates whether all delete requests should be logged. - * - * @return the delete value. - */ - public boolean isDelete() { - return this.delete; - } - - /** - * Set the delete property: Indicates whether all delete requests should be logged. - * - * @param delete the delete value to set. - * @return the BlobAnalyticsLogging object itself. - */ - public BlobAnalyticsLogging setDelete(boolean delete) { - this.delete = delete; - return this; - } - - /** - * Get the read property: Indicates whether all read requests should be logged. - * - * @return the read value. - */ - public boolean isRead() { - return this.read; - } - - /** - * Set the read property: Indicates whether all read requests should be logged. - * - * @param read the read value to set. - * @return the BlobAnalyticsLogging object itself. - */ - public BlobAnalyticsLogging setRead(boolean read) { - this.read = read; - return this; - } - - /** - * Get the write property: Indicates whether all write requests should be logged. - * - * @return the write value. - */ - public boolean isWrite() { - return this.write; - } - - /** - * Set the write property: Indicates whether all write requests should be logged. - * - * @param write the write value to set. - * @return the BlobAnalyticsLogging object itself. - */ - public BlobAnalyticsLogging setWrite(boolean write) { - this.write = write; - return this; - } - - /** - * Get the retentionPolicy property: the retention policy which determines how long the associated data should - * persist. - * - * @return the retentionPolicy value. - */ - public BlobRetentionPolicy getRetentionPolicy() { - return this.retentionPolicy; - } - - /** - * Set the retentionPolicy property: the retention policy which determines how long the associated data should - * persist. - * - * @param retentionPolicy the retentionPolicy value to set. - * @return the BlobAnalyticsLogging object itself. - */ - public BlobAnalyticsLogging setRetentionPolicy(BlobRetentionPolicy retentionPolicy) { - this.retentionPolicy = retentionPolicy; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobAnalyticsLogging" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Version", this.version); - xmlWriter.writeBooleanElement("Delete", this.delete); - xmlWriter.writeBooleanElement("Read", this.read); - xmlWriter.writeBooleanElement("Write", this.write); - xmlWriter.writeXml(this.retentionPolicy, "RetentionPolicy"); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobAnalyticsLogging from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobAnalyticsLogging if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobAnalyticsLogging. - */ - public static BlobAnalyticsLogging fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobAnalyticsLogging from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobAnalyticsLogging if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobAnalyticsLogging. - */ - public static BlobAnalyticsLogging fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName - = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobAnalyticsLogging" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobAnalyticsLogging deserializedBlobAnalyticsLogging = new BlobAnalyticsLogging(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Version".equals(elementName.getLocalPart())) { - deserializedBlobAnalyticsLogging.version = reader.getStringElement(); - } else if ("Delete".equals(elementName.getLocalPart())) { - deserializedBlobAnalyticsLogging.delete = reader.getBooleanElement(); - } else if ("Read".equals(elementName.getLocalPart())) { - deserializedBlobAnalyticsLogging.read = reader.getBooleanElement(); - } else if ("Write".equals(elementName.getLocalPart())) { - deserializedBlobAnalyticsLogging.write = reader.getBooleanElement(); - } else if ("RetentionPolicy".equals(elementName.getLocalPart())) { - deserializedBlobAnalyticsLogging.retentionPolicy - = BlobRetentionPolicy.fromXml(reader, "RetentionPolicy"); - } else { - reader.skipElement(); - } - } - - return deserializedBlobAnalyticsLogging; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAudience.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAudience.java deleted file mode 100644 index 296201bcb409..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobAudience.java +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.util.ExpandableStringEnum; - -import java.util.Collection; - -/** - * The audience to be used when requesting a token from Azure Active Directory (AAD). - * Note: This audience only has an effect when authenticating a TokenCredential. - */ -public class BlobAudience extends ExpandableStringEnum { - - /** - * Gets default Audience used to acquire a token for authorizing requests to any Azure Storage account. - * If no audience is specified, this resource ID is the default value: "https://storage.azure.com/". - */ - public static final BlobAudience AZURE_PUBLIC_CLOUD = fromString("https://storage.azure.com/"); - - /** - * Creates a new instance of {@link BlobAudience} without a {@link #toString()} value. - * This constructor shouldn't be called as it will produce a {@link BlobAudience} which doesn't have a String enum - * value. - * - * @deprecated Use one of the constants or the {@link #fromString(String)} factory method. - */ - @Deprecated - public BlobAudience() { - } - - /** - * The service endpoint for a given storage account. Use this method to acquire a token for authorizing requests to - * that specific Azure Storage account and service only. - * - * @param storageAccountName The storage account name used to populate the service endpoint. - * @return the audience with the blob service endpoint. - */ - public static BlobAudience createBlobServiceAccountAudience(String storageAccountName) { - return fromString(String.format("https://%s.blob.core.windows.net/", storageAccountName)); - } - - /** - * The Azure Active Directory audience to use when forming authorization scopes. - * For the Language service, this value corresponds to a URL that identifies the Azure cloud where the resource is - * located. - * For more information see - * - * Authorize access to Azure blobs using Azure Active Directory. - * - * @param audience The Azure Active Directory audience to use when forming authorization scopes. - * @return the corresponding BlobAudience. - */ - public static BlobAudience fromString(String audience) { - return fromString(audience, BlobAudience.class); - } - - /** - * Get the known BlobAudience values. - * - * @return known BlobAudience values. - */ - public static Collection values() { - return values(BlobAudience.class); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobBeginCopySourceRequestConditions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobBeginCopySourceRequestConditions.java deleted file mode 100644 index 5cdaeeb5cbea..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobBeginCopySourceRequestConditions.java +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.http.RequestConditions; - -import java.time.OffsetDateTime; - -/** - * This class contains values which will restrict the successful operation of a variety of blob requests to the - * conditions present on the source blob. These conditions are entirely optional. The entire object or any of its - * properties may be set to null when passed to a method to indicate that those conditions are not desired. Please - * refer to the type of each field for more information on those particular access conditions. - */ -public class BlobBeginCopySourceRequestConditions extends RequestConditions { - private String tagsConditions; - - /** - * Creates a new instance of {@link BlobBeginCopySourceRequestConditions}. - */ - public BlobBeginCopySourceRequestConditions() { - } - - /** - * Optionally limit requests to resources that match the passed ETag. - * - * @param ifMatch ETag that resources must match. - * @return The updated BlobSourceRequestConditions object. - */ - @Override - public BlobBeginCopySourceRequestConditions setIfMatch(String ifMatch) { - super.setIfMatch(ifMatch); - return this; - } - - /** - * Optionally limit requests to resources that do not match the passed ETag. - * - * @param ifNoneMatch ETag that resources must not match. - * @return The updated BlobSourceRequestConditions object. - */ - @Override - public BlobBeginCopySourceRequestConditions setIfNoneMatch(String ifNoneMatch) { - super.setIfNoneMatch(ifNoneMatch); - return this; - } - - /** - * Optionally limit requests to resources that have only been modified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifModifiedSince The datetime that resources must have been modified since. - * @return The updated BlobSourceRequestConditions object. - */ - @Override - public BlobBeginCopySourceRequestConditions setIfModifiedSince(OffsetDateTime ifModifiedSince) { - super.setIfModifiedSince(ifModifiedSince); - return this; - } - - /** - * Optionally limit requests to resources that have remained unmodified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifUnmodifiedSince The datetime that resources must have remained unmodified since. - * @return The updated BlobSourceRequestConditions object. - */ - @Override - public BlobBeginCopySourceRequestConditions setIfUnmodifiedSince(OffsetDateTime ifUnmodifiedSince) { - super.setIfUnmodifiedSince(ifUnmodifiedSince); - return this; - } - - /** - * Gets the SQL statement that apply to the tags of the blob. - * - * @return The SQL statement that apply to the tags of the blob. - */ - public String getTagsConditions() { - return tagsConditions; - } - - /** - * Optionally applies the SQL statement to the tags of the blob. - * - * @param tagsConditions The SQL statement that apply to the tags of the blob. - * @return The updated BlobSourceRequestConditions object. - */ - public BlobBeginCopySourceRequestConditions setTagsConditions(String tagsConditions) { - this.tagsConditions = tagsConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerAccessPolicies.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerAccessPolicies.java deleted file mode 100644 index ec800a3daefa..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerAccessPolicies.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; - -import java.util.List; - -/** - * This class contains values which correlate to the access polices set on a specific container. - */ -@Immutable -public class BlobContainerAccessPolicies { - private final PublicAccessType blobAccessType; - private final List identifiers; - - /** - * Constructs a {@link BlobContainerAccessPolicies}. - * - * @param blobAccessType Level of public access the container allows. - * @param identifiers {@link BlobSignedIdentifier BlobSignedIdentifiers} associated with the container. - */ - public BlobContainerAccessPolicies(PublicAccessType blobAccessType, List identifiers) { - this.blobAccessType = blobAccessType; - this.identifiers = identifiers; - } - - /** - * Gets the level of public access the container allows. - * - * @return the level of public access the container allows. - */ - public PublicAccessType getBlobAccessType() { - return blobAccessType; - } - - /** - * Gets the {@link BlobSignedIdentifier BlobSignedIdentifiers} associated with the container. - * - * @return the {@link BlobSignedIdentifier BlobSignedIdentifiers} associated with the container. - */ - public List getIdentifiers() { - return this.identifiers; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerEncryptionScope.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerEncryptionScope.java deleted file mode 100644 index f12c19c696f1..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerEncryptionScope.java +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; - -/** - * Parameter group. - */ -@Fluent -public final class BlobContainerEncryptionScope { - /* - * Optional. Version 2019-07-07 and later. Specifies the default encryption scope to set on the container and use - * for all future writes. - */ - private String defaultEncryptionScope; - - /* - * Optional. Version 2019-07-07 and newer. If true, prevents any request from specifying a different encryption - * scope than the scope set on the container. - */ - private Boolean encryptionScopeOverridePrevented; - - /** - * Creates an instance of BlobContainerEncryptionScope class. - */ - public BlobContainerEncryptionScope() { - } - - /** - * Get the defaultEncryptionScope property: Optional. Version 2019-07-07 and later. Specifies the default encryption - * scope to set on the container and use for all future writes. - * - * @return the defaultEncryptionScope value. - */ - public String getDefaultEncryptionScope() { - return this.defaultEncryptionScope; - } - - /** - * Set the defaultEncryptionScope property: Optional. Version 2019-07-07 and later. Specifies the default encryption - * scope to set on the container and use for all future writes. - * - * @param defaultEncryptionScope the defaultEncryptionScope value to set. - * @return the BlobContainerEncryptionScope object itself. - */ - public BlobContainerEncryptionScope setDefaultEncryptionScope(String defaultEncryptionScope) { - this.defaultEncryptionScope = defaultEncryptionScope; - return this; - } - - /** - * Get the encryptionScopeOverridePrevented property: Optional. Version 2019-07-07 and newer. If true, prevents any - * request from specifying a different encryption scope than the scope set on the container. - * - * @return the encryptionScopeOverridePrevented value. - */ - public boolean isEncryptionScopeOverridePrevented() { - Boolean returnValue = this.encryptionScopeOverridePrevented; - return Boolean.TRUE.equals(returnValue); - } - - /** - * Set the encryptionScopeOverridePrevented property: Optional. Version 2019-07-07 and newer. If true, prevents any - * request from specifying a different encryption scope than the scope set on the container. - * - * @param encryptionScopeOverridePrevented the encryptionScopeOverridePrevented value to set. - * @return the BlobContainerEncryptionScope object itself. - */ - public BlobContainerEncryptionScope setEncryptionScopeOverridePrevented(Boolean encryptionScopeOverridePrevented) { - this.encryptionScopeOverridePrevented = encryptionScopeOverridePrevented; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItem.java deleted file mode 100644 index f500a19d85df..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItem.java +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * An Azure Storage container. - */ -@Fluent -public final class BlobContainerItem implements XmlSerializable { - /* - * The Name property. - */ - private String name; - - /* - * The Deleted property. - */ - private Boolean deleted; - - /* - * The Version property. - */ - private String version; - - /* - * Properties of a container - */ - private BlobContainerItemProperties properties; - - /* - * Dictionary of - */ - private Map metadata; - - /** - * Creates an instance of BlobContainerItem class. - */ - public BlobContainerItem() { - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - public String getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the BlobContainerItem object itself. - */ - public BlobContainerItem setName(String name) { - this.name = name; - return this; - } - - /** - * Get the deleted property: The Deleted property. - * - * @return the deleted value. - */ - public Boolean isDeleted() { - return this.deleted; - } - - /** - * Set the deleted property: The Deleted property. - * - * @param deleted the deleted value to set. - * @return the BlobContainerItem object itself. - */ - public BlobContainerItem setDeleted(Boolean deleted) { - this.deleted = deleted; - return this; - } - - /** - * Get the version property: The Version property. - * - * @return the version value. - */ - public String getVersion() { - return this.version; - } - - /** - * Set the version property: The Version property. - * - * @param version the version value to set. - * @return the BlobContainerItem object itself. - */ - public BlobContainerItem setVersion(String version) { - this.version = version; - return this; - } - - /** - * Get the properties property: Properties of a container. - * - * @return the properties value. - */ - public BlobContainerItemProperties getProperties() { - return this.properties; - } - - /** - * Set the properties property: Properties of a container. - * - * @param properties the properties value to set. - * @return the BlobContainerItem object itself. - */ - public BlobContainerItem setProperties(BlobContainerItemProperties properties) { - this.properties = properties; - return this; - } - - /** - * Get the metadata property: Dictionary of <string>. - * - * @return the metadata value. - */ - public Map getMetadata() { - return this.metadata; - } - - /** - * Set the metadata property: Dictionary of <string>. - * - * @param metadata the metadata value to set. - * @return the BlobContainerItem object itself. - */ - public BlobContainerItem setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Container" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Name", this.name); - xmlWriter.writeBooleanElement("Deleted", this.deleted); - xmlWriter.writeStringElement("Version", this.version); - xmlWriter.writeXml(this.properties, "Properties"); - if (this.metadata != null) { - xmlWriter.writeStartElement("Metadata"); - for (Map.Entry entry : this.metadata.entrySet()) { - xmlWriter.writeStringElement(entry.getKey(), entry.getValue()); - } - xmlWriter.writeEndElement(); - } - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobContainerItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobContainerItem if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobContainerItem. - */ - public static BlobContainerItem fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobContainerItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobContainerItem if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobContainerItem. - */ - public static BlobContainerItem fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Container" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobContainerItem deserializedBlobContainerItem = new BlobContainerItem(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedBlobContainerItem.name = reader.getStringElement(); - } else if ("Deleted".equals(elementName.getLocalPart())) { - deserializedBlobContainerItem.deleted = reader.getNullableElement(Boolean::parseBoolean); - } else if ("Version".equals(elementName.getLocalPart())) { - deserializedBlobContainerItem.version = reader.getStringElement(); - } else if ("Properties".equals(elementName.getLocalPart())) { - deserializedBlobContainerItem.properties - = BlobContainerItemProperties.fromXml(reader, "Properties"); - } else if ("Metadata".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - if (deserializedBlobContainerItem.metadata == null) { - deserializedBlobContainerItem.metadata = new LinkedHashMap<>(); - } - deserializedBlobContainerItem.metadata.put(reader.getElementName().getLocalPart(), - reader.getStringElement()); - } - } else { - reader.skipElement(); - } - } - - return deserializedBlobContainerItem; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItemProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItemProperties.java deleted file mode 100644 index 8fc538521ec6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItemProperties.java +++ /dev/null @@ -1,476 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.time.OffsetDateTime; -import java.util.Objects; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Properties of a container. - */ -@Fluent -public final class BlobContainerItemProperties implements XmlSerializable { - /* - * The Last-Modified property. - */ - private DateTimeRfc1123 lastModified; - - /* - * The Etag property. - */ - private String eTag; - - /* - * The LeaseStatus property. - */ - private LeaseStatusType leaseStatus; - - /* - * The LeaseState property. - */ - private LeaseStateType leaseState; - - /* - * The LeaseDuration property. - */ - private LeaseDurationType leaseDuration; - - /* - * The PublicAccess property. - */ - private PublicAccessType publicAccess; - - /* - * The HasImmutabilityPolicy property. - */ - private Boolean hasImmutabilityPolicy; - - /* - * The HasLegalHold property. - */ - private Boolean hasLegalHold; - - /* - * The DefaultEncryptionScope property. - */ - private String defaultEncryptionScope; - - /* - * The DenyEncryptionScopeOverride property. - */ - private Boolean encryptionScopeOverridePrevented; - - /* - * The DeletedTime property. - */ - private DateTimeRfc1123 deletedTime; - - /* - * The RemainingRetentionDays property. - */ - private Integer remainingRetentionDays; - - /* - * Indicates if version level worm is enabled on this container. - */ - private Boolean isImmutableStorageWithVersioningEnabled; - - /** - * Creates an instance of BlobContainerItemProperties class. - */ - public BlobContainerItemProperties() { - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the eTag property: The Etag property. - * - * @return the eTag value. - */ - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The Etag property. - * - * @param eTag the eTag value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the leaseStatus property: The LeaseStatus property. - * - * @return the leaseStatus value. - */ - public LeaseStatusType getLeaseStatus() { - return this.leaseStatus; - } - - /** - * Set the leaseStatus property: The LeaseStatus property. - * - * @param leaseStatus the leaseStatus value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setLeaseStatus(LeaseStatusType leaseStatus) { - this.leaseStatus = leaseStatus; - return this; - } - - /** - * Get the leaseState property: The LeaseState property. - * - * @return the leaseState value. - */ - public LeaseStateType getLeaseState() { - return this.leaseState; - } - - /** - * Set the leaseState property: The LeaseState property. - * - * @param leaseState the leaseState value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setLeaseState(LeaseStateType leaseState) { - this.leaseState = leaseState; - return this; - } - - /** - * Get the leaseDuration property: The LeaseDuration property. - * - * @return the leaseDuration value. - */ - public LeaseDurationType getLeaseDuration() { - return this.leaseDuration; - } - - /** - * Set the leaseDuration property: The LeaseDuration property. - * - * @param leaseDuration the leaseDuration value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setLeaseDuration(LeaseDurationType leaseDuration) { - this.leaseDuration = leaseDuration; - return this; - } - - /** - * Get the publicAccess property: The PublicAccess property. - * - * @return the publicAccess value. - */ - public PublicAccessType getPublicAccess() { - return this.publicAccess; - } - - /** - * Set the publicAccess property: The PublicAccess property. - * - * @param publicAccess the publicAccess value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setPublicAccess(PublicAccessType publicAccess) { - this.publicAccess = publicAccess; - return this; - } - - /** - * Get the hasImmutabilityPolicy property: The HasImmutabilityPolicy property. - * - * @return the hasImmutabilityPolicy value. - */ - public Boolean isHasImmutabilityPolicy() { - return this.hasImmutabilityPolicy; - } - - /** - * Set the hasImmutabilityPolicy property: The HasImmutabilityPolicy property. - * - * @param hasImmutabilityPolicy the hasImmutabilityPolicy value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setHasImmutabilityPolicy(Boolean hasImmutabilityPolicy) { - this.hasImmutabilityPolicy = hasImmutabilityPolicy; - return this; - } - - /** - * Get the hasLegalHold property: The HasLegalHold property. - * - * @return the hasLegalHold value. - */ - public Boolean isHasLegalHold() { - return this.hasLegalHold; - } - - /** - * Set the hasLegalHold property: The HasLegalHold property. - * - * @param hasLegalHold the hasLegalHold value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setHasLegalHold(Boolean hasLegalHold) { - this.hasLegalHold = hasLegalHold; - return this; - } - - /** - * Get the defaultEncryptionScope property: The DefaultEncryptionScope property. - * - * @return the defaultEncryptionScope value. - */ - public String getDefaultEncryptionScope() { - return this.defaultEncryptionScope; - } - - /** - * Set the defaultEncryptionScope property: The DefaultEncryptionScope property. - * - * @param defaultEncryptionScope the defaultEncryptionScope value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setDefaultEncryptionScope(String defaultEncryptionScope) { - this.defaultEncryptionScope = defaultEncryptionScope; - return this; - } - - /** - * Get the encryptionScopeOverridePrevented property: The DenyEncryptionScopeOverride property. - * - * @return the encryptionScopeOverridePrevented value. - */ - public boolean isEncryptionScopeOverridePrevented() { - Boolean returnValue = this.encryptionScopeOverridePrevented; - return Boolean.TRUE.equals(returnValue); - } - - /** - * Set the encryptionScopeOverridePrevented property: The DenyEncryptionScopeOverride property. - * - * @param encryptionScopeOverridePrevented the encryptionScopeOverridePrevented value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setEncryptionScopeOverridePrevented(boolean encryptionScopeOverridePrevented) { - this.encryptionScopeOverridePrevented = encryptionScopeOverridePrevented; - return this; - } - - /** - * Get the deletedTime property: The DeletedTime property. - * - * @return the deletedTime value. - */ - public OffsetDateTime getDeletedTime() { - if (this.deletedTime == null) { - return null; - } - return this.deletedTime.getDateTime(); - } - - /** - * Set the deletedTime property: The DeletedTime property. - * - * @param deletedTime the deletedTime value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setDeletedTime(OffsetDateTime deletedTime) { - if (deletedTime == null) { - this.deletedTime = null; - } else { - this.deletedTime = new DateTimeRfc1123(deletedTime); - } - return this; - } - - /** - * Get the remainingRetentionDays property: The RemainingRetentionDays property. - * - * @return the remainingRetentionDays value. - */ - public Integer getRemainingRetentionDays() { - return this.remainingRetentionDays; - } - - /** - * Set the remainingRetentionDays property: The RemainingRetentionDays property. - * - * @param remainingRetentionDays the remainingRetentionDays value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties setRemainingRetentionDays(Integer remainingRetentionDays) { - this.remainingRetentionDays = remainingRetentionDays; - return this; - } - - /** - * Get the isImmutableStorageWithVersioningEnabled property: Indicates if version level worm is enabled on this - * container. - * - * @return the isImmutableStorageWithVersioningEnabled value. - */ - public Boolean isImmutableStorageWithVersioningEnabled() { - return this.isImmutableStorageWithVersioningEnabled; - } - - /** - * Set the isImmutableStorageWithVersioningEnabled property: Indicates if version level worm is enabled on this - * container. - * - * @param isImmutableStorageWithVersioningEnabled the isImmutableStorageWithVersioningEnabled value to set. - * @return the BlobContainerItemProperties object itself. - */ - public BlobContainerItemProperties - setImmutableStorageWithVersioningEnabled(Boolean isImmutableStorageWithVersioningEnabled) { - this.isImmutableStorageWithVersioningEnabled = isImmutableStorageWithVersioningEnabled; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobContainerItemProperties" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Last-Modified", Objects.toString(this.lastModified, null)); - xmlWriter.writeStringElement("Etag", this.eTag); - xmlWriter.writeStringElement("LeaseStatus", this.leaseStatus == null ? null : this.leaseStatus.toString()); - xmlWriter.writeStringElement("LeaseState", this.leaseState == null ? null : this.leaseState.toString()); - xmlWriter.writeStringElement("LeaseDuration", - this.leaseDuration == null ? null : this.leaseDuration.toString()); - xmlWriter.writeStringElement("PublicAccess", this.publicAccess == null ? null : this.publicAccess.toString()); - xmlWriter.writeBooleanElement("HasImmutabilityPolicy", this.hasImmutabilityPolicy); - xmlWriter.writeBooleanElement("HasLegalHold", this.hasLegalHold); - xmlWriter.writeStringElement("DefaultEncryptionScope", this.defaultEncryptionScope); - xmlWriter.writeBooleanElement("DenyEncryptionScopeOverride", this.encryptionScopeOverridePrevented); - xmlWriter.writeStringElement("DeletedTime", Objects.toString(this.deletedTime, null)); - xmlWriter.writeNumberElement("RemainingRetentionDays", this.remainingRetentionDays); - xmlWriter.writeBooleanElement("ImmutableStorageWithVersioningEnabled", - this.isImmutableStorageWithVersioningEnabled); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobContainerItemProperties from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobContainerItemProperties if the XmlReader was pointing to an instance of it, or null if - * it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobContainerItemProperties. - */ - public static BlobContainerItemProperties fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobContainerItemProperties from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobContainerItemProperties if the XmlReader was pointing to an instance of it, or null if - * it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobContainerItemProperties. - */ - public static BlobContainerItemProperties fromXml(XmlReader xmlReader, String rootElementName) - throws XMLStreamException { - String finalRootElementName - = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobContainerItemProperties" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobContainerItemProperties deserializedBlobContainerItemProperties = new BlobContainerItemProperties(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Last-Modified".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.lastModified - = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("Etag".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.eTag = reader.getStringElement(); - } else if ("LeaseStatus".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.leaseStatus - = LeaseStatusType.fromString(reader.getStringElement()); - } else if ("LeaseState".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.leaseState - = LeaseStateType.fromString(reader.getStringElement()); - } else if ("LeaseDuration".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.leaseDuration - = LeaseDurationType.fromString(reader.getStringElement()); - } else if ("PublicAccess".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.publicAccess - = PublicAccessType.fromString(reader.getStringElement()); - } else if ("HasImmutabilityPolicy".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.hasImmutabilityPolicy - = reader.getNullableElement(Boolean::parseBoolean); - } else if ("HasLegalHold".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.hasLegalHold - = reader.getNullableElement(Boolean::parseBoolean); - } else if ("DefaultEncryptionScope".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.defaultEncryptionScope = reader.getStringElement(); - } else if ("DenyEncryptionScopeOverride".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.encryptionScopeOverridePrevented - = reader.getNullableElement(Boolean::parseBoolean); - } else if ("DeletedTime".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.deletedTime - = reader.getNullableElement(DateTimeRfc1123::new); - } else if ("RemainingRetentionDays".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.remainingRetentionDays - = reader.getNullableElement(Integer::parseInt); - } else if ("ImmutableStorageWithVersioningEnabled".equals(elementName.getLocalPart())) { - deserializedBlobContainerItemProperties.isImmutableStorageWithVersioningEnabled - = reader.getNullableElement(Boolean::parseBoolean); - } else { - reader.skipElement(); - } - } - - return deserializedBlobContainerItemProperties; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerListDetails.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerListDetails.java deleted file mode 100644 index 8ea187737d44..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerListDetails.java +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.BlobServiceClient; - -/** - * This type allows users to specify additional information the service should return with each container when listing - * containers in an account (via a {@link BlobServiceClient} object). Null may - * be passed if none of the options are desirable. - */ -@Fluent -public final class BlobContainerListDetails { - private boolean retrieveMetadata; - private boolean retrieveDeleted; - private boolean retrieveSystemContainers; - - /** - * Constructs an unpopulated {@link BlobContainerListDetails}. - */ - public BlobContainerListDetails() { - } - - /** - * Whether metadata should be returned. - * - * @return a flag indicating whether metadata should be returned in the listing - */ - public boolean getRetrieveMetadata() { - return this.retrieveMetadata; - } - - /** - * Whether metadata should be returned. - * - * @param retrieveMetadata Flag indicating whether metadata should be returned - * @return the updated ContainerListDetails object - */ - public BlobContainerListDetails setRetrieveMetadata(boolean retrieveMetadata) { - this.retrieveMetadata = retrieveMetadata; - return this; - } - - /** - * Whether deleted containers should be returned. - * - * @return a flag indicating whether deleted containers should be returned - */ - public boolean getRetrieveDeleted() { - return this.retrieveDeleted; - } - - /** - * Whether deleted containers should be returned. - * - * @param retrieveDeleted Flag indicating whether deleted containers should be returned. - * @return the updated ContainerListDetails object - */ - public BlobContainerListDetails setRetrieveDeleted(boolean retrieveDeleted) { - this.retrieveDeleted = retrieveDeleted; - return this; - } - - /** - * Whether system containers should be returned. - * - * @return a flag indicating whether system containers should be returned in the listing - */ - public boolean getRetrieveSystemContainers() { - return this.retrieveSystemContainers; - } - - /** - * Whether system containers should be returned. - * - * @param retrieveSystemContainers Flag indicating whether system containers should be returned - * @return the updated ContainerListDetails object - */ - public BlobContainerListDetails setRetrieveSystemContainers(boolean retrieveSystemContainers) { - this.retrieveSystemContainers = retrieveSystemContainers; - return this; - } - - /** - * Gets the listing flags. - * - * @return the listing flags - * @deprecated {@link BlobContainerListDetails} now contains multiple options. - * This will only convert result of {{@link #setRetrieveMetadata(boolean)}} for backwards compatibility. - */ - @Deprecated - public ListBlobContainersIncludeType toIncludeType() { - if (this.retrieveMetadata) { - return ListBlobContainersIncludeType.METADATA; - } - return null; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerProperties.java deleted file mode 100644 index 5302d4098fde..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerProperties.java +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; - -import java.time.OffsetDateTime; -import java.util.Map; - -/** - * This class contains the response information returned from the service when getting container properties. - */ -@Immutable -public final class BlobContainerProperties { - - private final Map metadata; - private final String eTag; - private final OffsetDateTime lastModified; - private final LeaseDurationType leaseDuration; - private final LeaseStateType leaseState; - private final LeaseStatusType leaseStatus; - private final PublicAccessType blobPublicAccess; - private final boolean hasImmutabilityPolicy; - private final boolean hasLegalHold; - private final String defaultEncryptionScope; - private final Boolean encryptionScopeOverridePrevented; - private final Boolean isImmutableStorageWithVersioningEnabled; - - /** - * Constructs a {@link BlobContainerProperties}. - * - * @param metadata Metadata associated with the container. - * @param eTag ETag of the container. - * @param lastModified Datetime when the container was last modified. - * @param leaseDuration Type of the lease on the container. - * @param leaseState State of the lease on the container. - * @param leaseStatus Status of the lease on the container. - * @param blobPublicAccess Public access status for the container. - * @param hasImmutabilityPolicy Flag indicating if the container has an immutability policy set on it. - * @param hasLegalHold Flag indicating if the container has a legal hold. - */ - public BlobContainerProperties(final Map metadata, final String eTag, - final OffsetDateTime lastModified, final LeaseDurationType leaseDuration, final LeaseStateType leaseState, - final LeaseStatusType leaseStatus, final PublicAccessType blobPublicAccess, final boolean hasImmutabilityPolicy, - final boolean hasLegalHold) { - this(metadata, eTag, lastModified, leaseDuration, leaseState, leaseStatus, blobPublicAccess, - hasImmutabilityPolicy, hasLegalHold, null, false); - } - - /** - * Constructs a {@link BlobContainerProperties}. - * - * @param metadata Metadata associated with the container. - * @param eTag ETag of the container. - * @param lastModified Datetime when the container was last modified. - * @param leaseDuration Type of the lease on the container. - * @param leaseState State of the lease on the container. - * @param leaseStatus Status of the lease on the container. - * @param blobPublicAccess Public access status for the container. - * @param hasImmutabilityPolicy Flag indicating if the container has an immutability policy set on it. - * @param hasLegalHold Flag indicating if the container has a legal hold. - * @param defaultEncryptionScope The container's default encryption scope to encrypt blobs with. - * @param encryptionScopeOverridePrevented Whether or not a container's default encryption scope can be overridden - */ - public BlobContainerProperties(final Map metadata, final String eTag, - final OffsetDateTime lastModified, final LeaseDurationType leaseDuration, final LeaseStateType leaseState, - final LeaseStatusType leaseStatus, final PublicAccessType blobPublicAccess, final boolean hasImmutabilityPolicy, - final boolean hasLegalHold, final String defaultEncryptionScope, - final Boolean encryptionScopeOverridePrevented) { - this(metadata, eTag, lastModified, leaseDuration, leaseState, leaseStatus, blobPublicAccess, - hasImmutabilityPolicy, hasLegalHold, defaultEncryptionScope, encryptionScopeOverridePrevented, null); - } - - /** - * Constructs a {@link BlobContainerProperties}. - * - * @param metadata Metadata associated with the container. - * @param eTag ETag of the container. - * @param lastModified Datetime when the container was last modified. - * @param leaseDuration Type of the lease on the container. - * @param leaseState State of the lease on the container. - * @param leaseStatus Status of the lease on the container. - * @param blobPublicAccess Public access status for the container. - * @param hasImmutabilityPolicy Flag indicating if the container has an immutability policy set on it. - * @param hasLegalHold Flag indicating if the container has a legal hold. - * @param defaultEncryptionScope The container's default encryption scope to encrypt blobs with. - * @param encryptionScopeOverridePrevented Whether or not a container's default encryption scope can be overridden - * @param isImmutableStorageWithVersioningEnabled Whether or not immutable storage with versioning is enabled on - * this container. - */ - public BlobContainerProperties(final Map metadata, final String eTag, - final OffsetDateTime lastModified, final LeaseDurationType leaseDuration, final LeaseStateType leaseState, - final LeaseStatusType leaseStatus, final PublicAccessType blobPublicAccess, final boolean hasImmutabilityPolicy, - final boolean hasLegalHold, final String defaultEncryptionScope, final Boolean encryptionScopeOverridePrevented, - final Boolean isImmutableStorageWithVersioningEnabled) { - this.metadata = metadata; - this.eTag = eTag; - this.lastModified = lastModified; - this.leaseDuration = leaseDuration; - this.leaseState = leaseState; - this.leaseStatus = leaseStatus; - this.blobPublicAccess = blobPublicAccess; - this.hasImmutabilityPolicy = hasImmutabilityPolicy; - this.hasLegalHold = hasLegalHold; - this.defaultEncryptionScope = defaultEncryptionScope; - this.encryptionScopeOverridePrevented = encryptionScopeOverridePrevented; - this.isImmutableStorageWithVersioningEnabled = isImmutableStorageWithVersioningEnabled; - } - - /** - * Gets the metadata associated with the container. - * - * @return the metadata associated with the container - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the eTag of the container. - * - * @return the eTag of the container - */ - public String getETag() { - return eTag; - } - - /** - * Gets the time the container was last modified. - * - * @return the time the container was last modified - */ - public OffsetDateTime getLastModified() { - return lastModified; - } - - /** - * Gets the type of lease on the container. - * - * @return the type of lease on the container - */ - public LeaseDurationType getLeaseDuration() { - return leaseDuration; - } - - /** - * Gets the lease state of the container. - * - * @return the lease state of the container - */ - public LeaseStateType getLeaseState() { - return leaseState; - } - - /** - * Gets the lease status of the container. - * - * @return the lease status of the container - */ - public LeaseStatusType getLeaseStatus() { - return leaseStatus; - } - - /** - * Gets the access type for the container. - * - * @return the access type for the container - */ - public PublicAccessType getBlobPublicAccess() { - return blobPublicAccess; - } - - /** - * Gets the immutability status for the container. - * - * @return the immutability status for the container - */ - public boolean hasImmutabilityPolicy() { - return hasImmutabilityPolicy; - } - - /** - * Gets the legal hold status for the container. - * - * @return the legal hold status for the container - */ - public boolean hasLegalHold() { - return hasLegalHold; - } - - /** - * Gets the container's default encryption scope. - * - * @return the container's default encryption scope - */ - public String getDefaultEncryptionScope() { - return defaultEncryptionScope; - } - - /** - * Gets the container's deny encryption scope override property. - * - * @return the container's deny encryption scope override property. - */ - public Boolean isEncryptionScopeOverridePrevented() { - return encryptionScopeOverridePrevented; - } - - /** - * Gets whether immutable storage with versioning is enabled on this container. - * - * @return Whether immutable storage with versioning is enabled on this container. - */ - public Boolean isImmutableStorageWithVersioningEnabled() { - return isImmutableStorageWithVersioningEnabled; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCopyInfo.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCopyInfo.java deleted file mode 100644 index 045ba5eea545..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCopyInfo.java +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobClient; - -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Objects; - -/** - * The status of a long running Azure Blob copy operation. - * - * @see BlobAsyncClient#beginCopy(String, Duration) - * @see BlobClient#beginCopy(String, Duration) - */ -@Immutable -public class BlobCopyInfo { - private final String copyId; - private final String copySource; - private final CopyStatusType copyStatus; - private final String encryptionScope; - private final String eTag; - private final OffsetDateTime lastModified; - private final String error; - private final String versionId; - - /** - * Creates an instance of {@link BlobCopyInfo}. - * - * @param copyId The identifier of the copy operation. - * @param copySource The url of the source blob. The contents are being copied from this blob. - * @param copyStatus The status of the copy operation. - * @param error An error message for the copy operation. {@code null} if there are no errors. - * @param eTag If the copy is completed, contains the ETag of the destination blob. If the copy is not complete, - * contains the ETag of the empty blob created. - * @param lastModified The date/time that the copy operation to the destination blob completed. - * @throws NullPointerException If {@code copyId}, {@code copySource}, {@code eTag}, or {@code copyStatus} is null. - */ - public BlobCopyInfo(String copySource, String copyId, CopyStatusType copyStatus, String eTag, - OffsetDateTime lastModified, String error) { - this(copySource, copyId, copyStatus, eTag, lastModified, error, null); - } - - /** - * Creates an instance of {@link BlobCopyInfo}. - * - * @param copyId The identifier of the copy operation. - * @param copySource The url of the source blob. The contents are being copied from this blob. - * @param copyStatus The status of the copy operation. - * @param error An error message for the copy operation. {@code null} if there are no errors. - * @param eTag If the copy is completed, contains the ETag of the destination blob. If the copy is not complete, - * contains the ETag of the empty blob created. - * @param lastModified The date/time that the copy operation to the destination blob completed. - * @param versionId The version identifier of the destination blob. - * @throws NullPointerException If {@code copyId}, {@code copySource}, {@code eTag}, or {@code copyStatus} is null. - */ - public BlobCopyInfo(String copySource, String copyId, CopyStatusType copyStatus, String eTag, - OffsetDateTime lastModified, String error, String versionId) { - this(copySource, copyId, copyStatus, eTag, lastModified, error, versionId, null); - } - - /** - * Creates an instance of {@link BlobCopyInfo}. - * - * @param copyId The identifier of the copy operation. - * @param copySource The url of the source blob. The contents are being copied from this blob. - * @param copyStatus The status of the copy operation. - * @param error An error message for the copy operation. {@code null} if there are no errors. - * @param eTag If the copy is completed, contains the ETag of the destination blob. If the copy is not complete, - * contains the ETag of the empty blob created. - * @param lastModified The date/time that the copy operation to the destination blob completed. - * @param versionId The version identifier of the destination blob. - * @param encryptionScope The encryptionScope that will be applied to the destination blob. - * @throws NullPointerException If {@code copyId}, {@code copySource}, {@code eTag}, or {@code copyStatus} is null. - */ - public BlobCopyInfo(String copySource, String copyId, CopyStatusType copyStatus, String eTag, - OffsetDateTime lastModified, String error, String versionId, String encryptionScope) { - this.copyId = Objects.requireNonNull(copyId, "'copyId' cannot be null."); - this.copySource = Objects.requireNonNull(copySource, "'copySource' cannot be null."); - this.copyStatus = Objects.requireNonNull(copyStatus, "'copyStatus' cannot be null."); - this.eTag = Objects.requireNonNull(eTag, "'eTag' cannot be null."); - this.lastModified = lastModified; - this.error = error; - this.versionId = versionId; - this.encryptionScope = encryptionScope; - } - - /** - * Gets the identifier for the copy operation. - * - * @return The identifier for the copy operation. - */ - public String getCopyId() { - return copyId; - } - - /** - * Gets the url of the source blob. - * - * @return The url of the source blob. - */ - public String getCopySourceUrl() { - return copySource; - } - - /** - * Gets the status of the copy operation. - * - * @return The status of the copy operation. - */ - public CopyStatusType getCopyStatus() { - return copyStatus; - } - - /** - * Gets an error description associated with the copy operation. - * - * @return An error description associated with the copy, or {@code null} if there is no error associated with this - * copy operation. - */ - public String getError() { - return error; - } - - /** - * Gets the date/time that the copy operation to the destination blob completed. - * - * @return The date/time that the copy operation to the destination blob completed. - */ - public OffsetDateTime getLastModified() { - return lastModified; - } - - /** - * If the copy is complete, contains the ETag of the destination blob. If the copy isn't complete, contains the - * ETag of the empty blob created at the start of the copy. - *

- * The ETag value will be in quotes. - * - * @return The ETag for the copy. - */ - public String getETag() { - return eTag; - } - - /** - * Gets the version identifier of the destination blob completed. - * - * @return The version identifier of the destination blob completed. - */ - public String getVersionId() { - return versionId; - } - - /** - * Gets the encryption scope of the destination blob. - * - * @return The encryption scope of the destination blob. - */ - public String getEncryptionScope() { - return encryptionScope; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCopySourceTagsMode.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCopySourceTagsMode.java deleted file mode 100644 index dee472e69476..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCopySourceTagsMode.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.util.ExpandableStringEnum; -import java.util.Collection; - -/** - * Defines values for BlobCopySourceTagsMode. - */ -public final class BlobCopySourceTagsMode extends ExpandableStringEnum { - /** - * Static value REPLACE for BlobCopySourceTagsMode. - */ - public static final BlobCopySourceTagsMode REPLACE = fromString("REPLACE"); - - /** - * Static value COPY for BlobCopySourceTagsMode. - */ - public static final BlobCopySourceTagsMode COPY = fromString("COPY"); - - /** - * Creates a new instance of BlobCopySourceTagsMode value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Deprecated - public BlobCopySourceTagsMode() { - } - - /** - * Creates or finds a BlobCopySourceTagsMode from its string representation. - * - * @param name a name to look for. - * @return the corresponding BlobCopySourceTagsMode. - */ - public static BlobCopySourceTagsMode fromString(String name) { - return fromString(name, BlobCopySourceTagsMode.class); - } - - /** - * Gets known BlobCopySourceTagsMode values. - * - * @return known BlobCopySourceTagsMode values. - */ - public static Collection values() { - return values(BlobCopySourceTagsMode.class); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCorsRule.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCorsRule.java deleted file mode 100644 index 37d7d31b8fbb..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobCorsRule.java +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * CORS is an HTTP feature that enables a web application running under one domain to access resources in another - * domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page from - * calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs - * in another domain. - */ -@Fluent -public final class BlobCorsRule implements XmlSerializable { - /* - * The origin domains that are permitted to make a request against the storage service via CORS. The origin domain - * is the domain from which the request originates. Note that the origin must be an exact case-sensitive match with - * the origin that the user age sends to the service. You can also use the wildcard character '*' to allow all - * origin domains to make requests via CORS. - */ - private String allowedOrigins; - - /* - * The methods (HTTP request verbs) that the origin domain may use for a CORS request. (comma separated) - */ - private String allowedMethods; - - /* - * the request headers that the origin domain may specify on the CORS request. - */ - private String allowedHeaders; - - /* - * The response headers that may be sent in the response to the CORS request and exposed by the browser to the - * request issuer - */ - private String exposedHeaders; - - /* - * The maximum amount time that a browser should cache the preflight OPTIONS request. - */ - private int maxAgeInSeconds; - - /** - * Creates an instance of BlobCorsRule class. - */ - public BlobCorsRule() { - } - - /** - * Get the allowedOrigins property: The origin domains that are permitted to make a request against the storage - * service via CORS. The origin domain is the domain from which the request originates. Note that the origin must be - * an exact case-sensitive match with the origin that the user age sends to the service. You can also use the - * wildcard character '*' to allow all origin domains to make requests via CORS. - * - * @return the allowedOrigins value. - */ - public String getAllowedOrigins() { - return this.allowedOrigins; - } - - /** - * Set the allowedOrigins property: The origin domains that are permitted to make a request against the storage - * service via CORS. The origin domain is the domain from which the request originates. Note that the origin must be - * an exact case-sensitive match with the origin that the user age sends to the service. You can also use the - * wildcard character '*' to allow all origin domains to make requests via CORS. - * - * @param allowedOrigins the allowedOrigins value to set. - * @return the BlobCorsRule object itself. - */ - public BlobCorsRule setAllowedOrigins(String allowedOrigins) { - this.allowedOrigins = allowedOrigins; - return this; - } - - /** - * Get the allowedMethods property: The methods (HTTP request verbs) that the origin domain may use for a CORS - * request. (comma separated). - * - * @return the allowedMethods value. - */ - public String getAllowedMethods() { - return this.allowedMethods; - } - - /** - * Set the allowedMethods property: The methods (HTTP request verbs) that the origin domain may use for a CORS - * request. (comma separated). - * - * @param allowedMethods the allowedMethods value to set. - * @return the BlobCorsRule object itself. - */ - public BlobCorsRule setAllowedMethods(String allowedMethods) { - this.allowedMethods = allowedMethods; - return this; - } - - /** - * Get the allowedHeaders property: the request headers that the origin domain may specify on the CORS request. - * - * @return the allowedHeaders value. - */ - public String getAllowedHeaders() { - return this.allowedHeaders; - } - - /** - * Set the allowedHeaders property: the request headers that the origin domain may specify on the CORS request. - * - * @param allowedHeaders the allowedHeaders value to set. - * @return the BlobCorsRule object itself. - */ - public BlobCorsRule setAllowedHeaders(String allowedHeaders) { - this.allowedHeaders = allowedHeaders; - return this; - } - - /** - * Get the exposedHeaders property: The response headers that may be sent in the response to the CORS request and - * exposed by the browser to the request issuer. - * - * @return the exposedHeaders value. - */ - public String getExposedHeaders() { - return this.exposedHeaders; - } - - /** - * Set the exposedHeaders property: The response headers that may be sent in the response to the CORS request and - * exposed by the browser to the request issuer. - * - * @param exposedHeaders the exposedHeaders value to set. - * @return the BlobCorsRule object itself. - */ - public BlobCorsRule setExposedHeaders(String exposedHeaders) { - this.exposedHeaders = exposedHeaders; - return this; - } - - /** - * Get the maxAgeInSeconds property: The maximum amount time that a browser should cache the preflight OPTIONS - * request. - * - * @return the maxAgeInSeconds value. - */ - public int getMaxAgeInSeconds() { - return this.maxAgeInSeconds; - } - - /** - * Set the maxAgeInSeconds property: The maximum amount time that a browser should cache the preflight OPTIONS - * request. - * - * @param maxAgeInSeconds the maxAgeInSeconds value to set. - * @return the BlobCorsRule object itself. - */ - public BlobCorsRule setMaxAgeInSeconds(int maxAgeInSeconds) { - this.maxAgeInSeconds = maxAgeInSeconds; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "CorsRule" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("AllowedOrigins", this.allowedOrigins); - xmlWriter.writeStringElement("AllowedMethods", this.allowedMethods); - xmlWriter.writeStringElement("AllowedHeaders", this.allowedHeaders); - xmlWriter.writeStringElement("ExposedHeaders", this.exposedHeaders); - xmlWriter.writeIntElement("MaxAgeInSeconds", this.maxAgeInSeconds); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobCorsRule from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobCorsRule if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobCorsRule. - */ - public static BlobCorsRule fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobCorsRule from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobCorsRule if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobCorsRule. - */ - public static BlobCorsRule fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "CorsRule" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobCorsRule deserializedBlobCorsRule = new BlobCorsRule(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("AllowedOrigins".equals(elementName.getLocalPart())) { - deserializedBlobCorsRule.allowedOrigins = reader.getStringElement(); - } else if ("AllowedMethods".equals(elementName.getLocalPart())) { - deserializedBlobCorsRule.allowedMethods = reader.getStringElement(); - } else if ("AllowedHeaders".equals(elementName.getLocalPart())) { - deserializedBlobCorsRule.allowedHeaders = reader.getStringElement(); - } else if ("ExposedHeaders".equals(elementName.getLocalPart())) { - deserializedBlobCorsRule.exposedHeaders = reader.getStringElement(); - } else if ("MaxAgeInSeconds".equals(elementName.getLocalPart())) { - deserializedBlobCorsRule.maxAgeInSeconds = reader.getIntElement(); - } else { - reader.skipElement(); - } - } - - return deserializedBlobCorsRule; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobDeleteType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDeleteType.java similarity index 80% rename from sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobDeleteType.java rename to sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDeleteType.java index 692b452f6362..74e771d498c6 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobDeleteType.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDeleteType.java @@ -1,19 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.storage.blob.implementation.models; +package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; /** - * Defines values for BlobDeleteType. + * The type of blob deletions. */ public final class BlobDeleteType extends ExpandableStringEnum { /** - * Static value Permanent for BlobDeleteType. + * Permanently delete the blob. */ + @Generated public static final BlobDeleteType PERMANENT = fromString("Permanent"); /** @@ -21,6 +23,7 @@ public final class BlobDeleteType extends ExpandableStringEnum { * * @deprecated Use the {@link #fromString(String)} factory method. */ + @Generated @Deprecated public BlobDeleteType() { } @@ -31,6 +34,7 @@ public BlobDeleteType() { * @param name a name to look for. * @return the corresponding BlobDeleteType. */ + @Generated public static BlobDeleteType fromString(String name) { return fromString(name, BlobDeleteType.class); } @@ -40,6 +44,7 @@ public static BlobDeleteType fromString(String name) { * * @return known BlobDeleteType values. */ + @Generated public static Collection values() { return values(BlobDeleteType.class); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadAsyncResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadAsyncResponse.java deleted file mode 100644 index c1c62368d093..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadAsyncResponse.java +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.StreamResponse; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.ProgressReporter; -import com.azure.core.util.io.IOUtils; -import com.azure.storage.blob.implementation.accesshelpers.BlobDownloadAsyncResponseConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobsDownloadHeaders; -import com.azure.storage.blob.implementation.util.ModelHelper; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.Closeable; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.AsynchronousByteChannel; -import java.util.Objects; -import java.util.function.BiFunction; - -/** - * This class contains the response information returned from the server when downloading a blob. - */ -public final class BlobDownloadAsyncResponse extends ResponseBase> - implements Closeable { - - static { - BlobDownloadAsyncResponseConstructorProxy.setAccessor(BlobDownloadAsyncResponse::new); - } - - private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0); - - private final StreamResponse sourceResponse; - private final BiFunction> onErrorResume; - private final DownloadRetryOptions retryOptions; - - /** - * Constructs a {@link BlobDownloadAsyncResponse}. - * - * @param request Request sent to the service. - * @param statusCode Response status code returned by the service. - * @param headers Raw headers returned by the response. - * @param value Stream of download data being returned by the service. - * @param deserializedHeaders Headers deserialized into an object. - */ - public BlobDownloadAsyncResponse(HttpRequest request, int statusCode, HttpHeaders headers, Flux value, - BlobDownloadHeaders deserializedHeaders) { - super(request, statusCode, headers, value, deserializedHeaders); - this.sourceResponse = null; - this.onErrorResume = null; - this.retryOptions = null; - } - - /** - * Constructs a {@link BlobDownloadAsyncResponse}. - * - * @param sourceResponse The initial Stream Response - * @param onErrorResume Function used to resume. - * @param retryOptions Retry options. - */ - BlobDownloadAsyncResponse(StreamResponse sourceResponse, - BiFunction> onErrorResume, DownloadRetryOptions retryOptions) { - super(sourceResponse.getRequest(), sourceResponse.getStatusCode(), sourceResponse.getHeaders(), - createResponseFlux(sourceResponse, onErrorResume, retryOptions), extractHeaders(sourceResponse)); - this.sourceResponse = Objects.requireNonNull(sourceResponse, "'sourceResponse' must not be null"); - this.onErrorResume = Objects.requireNonNull(onErrorResume, "'onErrorResume' must not be null"); - this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' must not be null"); - } - - private static BlobDownloadHeaders extractHeaders(StreamResponse response) { - HttpHeaders headers = response.getHeaders(); - return ModelHelper.populateBlobDownloadHeaders(new BlobsDownloadHeaders(headers), - ModelHelper.getErrorCode(headers)); - } - - private static Flux createResponseFlux(StreamResponse sourceResponse, - BiFunction> onErrorResume, DownloadRetryOptions retryOptions) { - return FluxUtil - .createRetriableDownloadFlux(sourceResponse::getValue, - (throwable, position) -> onErrorResume.apply(throwable, position).flatMapMany(StreamResponse::getValue), - retryOptions.getMaxRetryRequests()) - .defaultIfEmpty(EMPTY_BUFFER); - } - - /** - * Transfers content bytes to the {@link AsynchronousByteChannel}. - * @param channel The destination {@link AsynchronousByteChannel}. - * @param progressReporter Optional {@link ProgressReporter}. - * @return A {@link Mono} that completes when transfer is completed. - */ - public Mono writeValueToAsync(AsynchronousByteChannel channel, ProgressReporter progressReporter) { - Objects.requireNonNull(channel, "'channel' must not be null"); - if (sourceResponse != null) { - return IOUtils.transferStreamResponseToAsynchronousByteChannel(channel, sourceResponse, onErrorResume, - progressReporter, retryOptions.getMaxRetryRequests()); - } else if (super.getValue() != null) { - return FluxUtil.writeToAsynchronousByteChannel( - FluxUtil.addProgressReporting(super.getValue(), progressReporter), channel); - } else { - return Mono.empty(); - } - } - - @Override - public void close() throws IOException { - if (sourceResponse != null) { - sourceResponse.close(); - } else { - super.getValue().subscribe().dispose(); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadContentAsyncResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadContentAsyncResponse.java deleted file mode 100644 index b22ca226366b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadContentAsyncResponse.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.util.BinaryData; - -/** - * This class contains the response information returned from the server when downloading a blob. - */ -public final class BlobDownloadContentAsyncResponse extends ResponseBase { - /** - * Constructs a {@link BlobDownloadContentAsyncResponse}. - * - * @param request Request sent to the service. - * @param statusCode Response status code returned by the service. - * @param headers Raw headers returned in the response. - * @param value Stream of download data being returned by the service. - * @param deserializedHeaders Headers deserialized into an object. - */ - public BlobDownloadContentAsyncResponse(HttpRequest request, int statusCode, HttpHeaders headers, BinaryData value, - BlobDownloadHeaders deserializedHeaders) { - super(request, statusCode, headers, value, deserializedHeaders); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadContentResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadContentResponse.java deleted file mode 100644 index c055715a3ed3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadContentResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.util.BinaryData; - -/** - * This class contains the response information return from the server when downloading a blob. - */ -public final class BlobDownloadContentResponse extends ResponseBase { - /** - * Constructs a {@link BlobDownloadContentResponse}. - * - * @param response Response returned from the service. - */ - public BlobDownloadContentResponse(BlobDownloadContentAsyncResponse response) { - super(response.getRequest(), response.getStatusCode(), response.getHeaders(), response.getValue(), - response.getDeserializedHeaders()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java deleted file mode 100644 index dfd93a535fc6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java +++ /dev/null @@ -1,1047 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.implementation.accesshelpers.BlobDownloadHeadersConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobsDownloadHeaders; -import com.azure.storage.blob.implementation.util.ModelHelper; - -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Defines headers for Download operation. - */ -@Fluent -public final class BlobDownloadHeaders { - private final BlobsDownloadHeaders internalHeaders; - - static { - BlobDownloadHeadersConstructorProxy.setAccessor(BlobDownloadHeaders::new); - } - - private BlobDownloadHeaders(BlobsDownloadHeaders internalHeaders) { - this.internalHeaders = internalHeaders; - } - - /** - * Constructs a new instance of {@link BlobDownloadHeaders}. - */ - public BlobDownloadHeaders() { - // Added to maintain backwards compatibility as the private constructor removes the implicit no args - // constructor. - this.internalHeaders = new BlobsDownloadHeaders(new HttpHeaders()); - } - - /* - * The errorCode property. - */ - private String errorCode; - - /** - * Get the lastModified property: Returns the date and time the container was last modified. Any operation that - * modifies the blob, including an update of the blob's metadata or properties, changes the last-modified time of - * the blob. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - return internalHeaders.getLastModified(); - } - - /** - * Set the lastModified property: Returns the date and time the container was last modified. Any operation that - * modifies the blob, including an update of the blob's metadata or properties, changes the last-modified time of - * the blob. - * - * @param lastModified the lastModified value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setLastModified(OffsetDateTime lastModified) { - internalHeaders.setLastModified(lastModified); - return this; - } - - /** - * Get the metadata property: The metadata property. - * - * @return the metadata value. - */ - public Map getMetadata() { - return internalHeaders.getXMsMeta(); - } - - /** - * Set the metadata property: The metadata property. - * - * @param metadata the metadata value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setMetadata(Map metadata) { - internalHeaders.setXMsMeta(metadata); - return this; - } - - /** - * Get the objectReplicationDestinationPolicyId property: Optional. Only valid when Object Replication is enabled - * for the storage container and on the destination blob of the replication. - * - * @return the objectReplicationDestinationPolicyId value. - */ - public String getObjectReplicationDestinationPolicyId() { - return internalHeaders.getXMsOrPolicyId(); - } - - /** - * Set the objectReplicationDestinationPolicyId property: Optional. Only valid when Object Replication is enabled - * for the storage container and on the destination blob of the replication. - * - * @param objectReplicationDestinationPolicyId the objectReplicationDestinationPolicyId value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setObjectReplicationDestinationPolicyId(String objectReplicationDestinationPolicyId) { - internalHeaders.setXMsOrPolicyId(objectReplicationDestinationPolicyId); - return this; - } - - /** - * Get the objectReplicationSourcePolicies property: The objectReplicationSourcePolicies property. - * - * @return the objectReplicationSourcePolicies value. - */ - public List getObjectReplicationSourcePolicies() { - return Collections.unmodifiableList(ModelHelper.getObjectReplicationSourcePolicies(internalHeaders.getXMsOr())); - } - - /** - * Set the objectReplicationSourcePolicies property: The objectReplicationSourcePolicies property. - * - * @param objectReplicationSourcePolicies the objectReplicationSourcePolicies value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders - setObjectReplicationSourcePolicies(List objectReplicationSourcePolicies) { - Map xMsOr = new HashMap<>(); - - if (!CoreUtils.isNullOrEmpty(objectReplicationSourcePolicies)) { - for (ObjectReplicationPolicy policy : objectReplicationSourcePolicies) { - String policyId = policy.getPolicyId(); - for (ObjectReplicationRule rule : policy.getRules()) { - xMsOr.put(policyId + "_" + rule.getRuleId(), rule.getStatus().toString()); - } - } - } - - internalHeaders.setXMsOr(xMsOr); - return this; - } - - /** - * Get the contentLength property: The number of bytes present in the response body. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return internalHeaders.getContentLength(); - } - - /** - * Set the contentLength property: The number of bytes present in the response body. - * - * @param contentLength the contentLength value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setContentLength(Long contentLength) { - internalHeaders.setContentLength(contentLength); - return this; - } - - /** - * Get the contentType property: The media type of the body of the response. For Download Blob this is - * 'application/octet-stream'. - * - * @return the contentType value. - */ - public String getContentType() { - return internalHeaders.getContentType(); - } - - /** - * Set the contentType property: The media type of the body of the response. For Download Blob this is - * 'application/octet-stream'. - * - * @param contentType the contentType value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setContentType(String contentType) { - internalHeaders.setContentType(contentType); - return this; - } - - /** - * Get the contentRange property: Indicates the range of bytes returned in the event that the client requested a - * subset of the blob by setting the 'Range' request header. - * - * @return the contentRange value. - */ - public String getContentRange() { - return internalHeaders.getContentRange(); - } - - /** - * Set the contentRange property: Indicates the range of bytes returned in the event that the client requested a - * subset of the blob by setting the 'Range' request header. - * - * @param contentRange the contentRange value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setContentRange(String contentRange) { - internalHeaders.setContentRange(contentRange); - return this; - } - - /** - * Get the eTag property: The ETag contains a value that you can use to perform operations conditionally. If the - * request version is 2011-08-18 or newer, the ETag value will be in quotes. - * - * @return the eTag value. - */ - public String getETag() { - return internalHeaders.getETag(); - } - - /** - * Set the eTag property: The ETag contains a value that you can use to perform operations conditionally. If the - * request version is 2011-08-18 or newer, the ETag value will be in quotes. - * - * @param eTag the eTag value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setETag(String eTag) { - internalHeaders.setETag(eTag); - return this; - } - - /** - * Get the contentMd5 property: If the blob has an MD5 hash and this operation is to read the full blob, this - * response header is returned so that the client can check for message content integrity. - * - * @return the contentMd5 value. - */ - public byte[] getContentMd5() { - return CoreUtils.clone(internalHeaders.getContentMD5()); - } - - /** - * Set the contentMd5 property: If the blob has an MD5 hash and this operation is to read the full blob, this - * response header is returned so that the client can check for message content integrity. - * - * @param contentMd5 the contentMd5 value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setContentMd5(byte[] contentMd5) { - internalHeaders.setContentMD5(CoreUtils.clone(contentMd5)); - return this; - } - - /** - * Get the contentEncoding property: This header returns the value that was specified for the Content-Encoding - * request header. - * - * @return the contentEncoding value. - */ - public String getContentEncoding() { - return internalHeaders.getContentEncoding(); - } - - /** - * Set the contentEncoding property: This header returns the value that was specified for the Content-Encoding - * request header. - * - * @param contentEncoding the contentEncoding value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setContentEncoding(String contentEncoding) { - internalHeaders.setContentEncoding(contentEncoding); - return this; - } - - /** - * Get the cacheControl property: This header is returned if it was previously specified for the blob. - * - * @return the cacheControl value. - */ - public String getCacheControl() { - return internalHeaders.getCacheControl(); - } - - /** - * Set the cacheControl property: This header is returned if it was previously specified for the blob. - * - * @param cacheControl the cacheControl value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setCacheControl(String cacheControl) { - internalHeaders.setCacheControl(cacheControl); - return this; - } - - /** - * Get the contentDisposition property: This header returns the value that was specified for the - * 'x-ms-blob-content-disposition' header. The Content-Disposition response header field conveys additional - * information about how to process the response payload, and also can be used to attach additional metadata. For - * example, if set to attachment, it indicates that the user-agent should not display the response, but instead show - * a Save As dialog with a filename other than the blob name specified. - * - * @return the contentDisposition value. - */ - public String getContentDisposition() { - return internalHeaders.getContentDisposition(); - } - - /** - * Set the contentDisposition property: This header returns the value that was specified for the - * 'x-ms-blob-content-disposition' header. The Content-Disposition response header field conveys additional - * information about how to process the response payload, and also can be used to attach additional metadata. For - * example, if set to attachment, it indicates that the user-agent should not display the response, but instead show - * a Save As dialog with a filename other than the blob name specified. - * - * @param contentDisposition the contentDisposition value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setContentDisposition(String contentDisposition) { - internalHeaders.setContentDisposition(contentDisposition); - return this; - } - - /** - * Get the contentLanguage property: This header returns the value that was specified for the Content-Language - * request header. - * - * @return the contentLanguage value. - */ - public String getContentLanguage() { - return internalHeaders.getContentLanguage(); - } - - /** - * Set the contentLanguage property: This header returns the value that was specified for the Content-Language - * request header. - * - * @param contentLanguage the contentLanguage value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setContentLanguage(String contentLanguage) { - internalHeaders.setContentLanguage(contentLanguage); - return this; - } - - /** - * Get the blobSequenceNumber property: The current sequence number for a page blob. This header is not returned for - * block blobs or append blobs. - * - * @return the blobSequenceNumber value. - */ - public Long getBlobSequenceNumber() { - return internalHeaders.getXMsBlobSequenceNumber(); - } - - /** - * Set the blobSequenceNumber property: The current sequence number for a page blob. This header is not returned for - * block blobs or append blobs. - * - * @param blobSequenceNumber the blobSequenceNumber value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setBlobSequenceNumber(Long blobSequenceNumber) { - internalHeaders.setXMsBlobSequenceNumber(blobSequenceNumber); - return this; - } - - /** - * Get the blobType property: The blob's type. Possible values include: 'BlockBlob', 'PageBlob', 'AppendBlob'. - * - * @return the blobType value. - */ - public BlobType getBlobType() { - return internalHeaders.getXMsBlobType(); - } - - /** - * Set the blobType property: The blob's type. Possible values include: 'BlockBlob', 'PageBlob', 'AppendBlob'. - * - * @param blobType the blobType value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setBlobType(BlobType blobType) { - internalHeaders.setXMsBlobType(blobType); - return this; - } - - /** - * Get the copyCompletionTime property: Conclusion time of the last attempted Copy Blob operation where this blob - * was the destination blob. This value can specify the time of a completed, aborted, or failed copy attempt. This - * header does not appear if a copy is pending, if this blob has never been the destination in a Copy Blob - * operation, or if this blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put - * Blob, or Put Block List. - * - * @return the copyCompletionTime value. - */ - public OffsetDateTime getCopyCompletionTime() { - return internalHeaders.getXMsCopyCompletionTime(); - } - - /** - * Set the copyCompletionTime property: Conclusion time of the last attempted Copy Blob operation where this blob - * was the destination blob. This value can specify the time of a completed, aborted, or failed copy attempt. This - * header does not appear if a copy is pending, if this blob has never been the destination in a Copy Blob - * operation, or if this blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put - * Blob, or Put Block List. - * - * @param copyCompletionTime the copyCompletionTime value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setCopyCompletionTime(OffsetDateTime copyCompletionTime) { - internalHeaders.setXMsCopyCompletionTime(copyCompletionTime); - return this; - } - - /** - * Get the copyStatusDescription property: Only appears when x-ms-copy-status is failed or pending. Describes the - * cause of the last fatal or non-fatal copy operation failure. This header does not appear if this blob has never - * been the destination in a Copy Blob operation, or if this blob has been modified after a concluded Copy Blob - * operation using Set Blob Properties, Put Blob, or Put Block List. - * - * @return the copyStatusDescription value. - */ - public String getCopyStatusDescription() { - return internalHeaders.getXMsCopyStatusDescription(); - } - - /** - * Set the copyStatusDescription property: Only appears when x-ms-copy-status is failed or pending. Describes the - * cause of the last fatal or non-fatal copy operation failure. This header does not appear if this blob has never - * been the destination in a Copy Blob operation, or if this blob has been modified after a concluded Copy Blob - * operation using Set Blob Properties, Put Blob, or Put Block List. - * - * @param copyStatusDescription the copyStatusDescription value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setCopyStatusDescription(String copyStatusDescription) { - internalHeaders.setXMsCopyStatusDescription(copyStatusDescription); - return this; - } - - /** - * Get the copyId property: String identifier for this copy operation. Use with Get Blob Properties to check the - * status of this copy operation, or pass to Abort Copy Blob to abort a pending copy. - * - * @return the copyId value. - */ - public String getCopyId() { - return internalHeaders.getXMsCopyId(); - } - - /** - * Set the copyId property: String identifier for this copy operation. Use with Get Blob Properties to check the - * status of this copy operation, or pass to Abort Copy Blob to abort a pending copy. - * - * @param copyId the copyId value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setCopyId(String copyId) { - internalHeaders.setXMsCopyId(copyId); - return this; - } - - /** - * Get the copyProgress property: Contains the number of bytes copied and the total bytes in the source in the last - * attempted Copy Blob operation where this blob was the destination blob. Can show between 0 and Content-Length - * bytes copied. This header does not appear if this blob has never been the destination in a Copy Blob operation, - * or if this blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put Blob, or - * Put Block List. - * - * @return the copyProgress value. - */ - public String getCopyProgress() { - return internalHeaders.getXMsCopyProgress(); - } - - /** - * Set the copyProgress property: Contains the number of bytes copied and the total bytes in the source in the last - * attempted Copy Blob operation where this blob was the destination blob. Can show between 0 and Content-Length - * bytes copied. This header does not appear if this blob has never been the destination in a Copy Blob operation, - * or if this blob has been modified after a concluded Copy Blob operation using Set Blob Properties, Put Blob, or - * Put Block List. - * - * @param copyProgress the copyProgress value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setCopyProgress(String copyProgress) { - internalHeaders.setXMsCopyProgress(copyProgress); - return this; - } - - /** - * Get the copySource property: URL up to 2 KB in length that specifies the source blob or file used in the last - * attempted Copy Blob operation where this blob was the destination blob. This header does not appear if this blob - * has never been the destination in a Copy Blob operation, or if this blob has been modified after a concluded Copy - * Blob operation using Set Blob Properties, Put Blob, or Put Block List. - * - * @return the copySource value. - */ - public String getCopySource() { - return internalHeaders.getXMsCopySource(); - } - - /** - * Set the copySource property: URL up to 2 KB in length that specifies the source blob or file used in the last - * attempted Copy Blob operation where this blob was the destination blob. This header does not appear if this blob - * has never been the destination in a Copy Blob operation, or if this blob has been modified after a concluded Copy - * Blob operation using Set Blob Properties, Put Blob, or Put Block List. - * - * @param copySource the copySource value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setCopySource(String copySource) { - internalHeaders.setXMsCopySource(copySource); - return this; - } - - /** - * Get the copyStatus property: State of the copy operation identified by x-ms-copy-id. Possible values include: - * 'pending', 'success', 'aborted', 'failed'. - * - * @return the copyStatus value. - */ - public CopyStatusType getCopyStatus() { - return internalHeaders.getXMsCopyStatus(); - } - - /** - * Set the copyStatus property: State of the copy operation identified by x-ms-copy-id. Possible values include: - * 'pending', 'success', 'aborted', 'failed'. - * - * @param copyStatus the copyStatus value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setCopyStatus(CopyStatusType copyStatus) { - internalHeaders.setXMsCopyStatus(copyStatus); - return this; - } - - /** - * Get the leaseDuration property: When a blob is leased, specifies whether the lease is of infinite or fixed - * duration. Possible values include: 'infinite', 'fixed'. - * - * @return the leaseDuration value. - */ - public LeaseDurationType getLeaseDuration() { - return internalHeaders.getXMsLeaseDuration(); - } - - /** - * Set the leaseDuration property: When a blob is leased, specifies whether the lease is of infinite or fixed - * duration. Possible values include: 'infinite', 'fixed'. - * - * @param leaseDuration the leaseDuration value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setLeaseDuration(LeaseDurationType leaseDuration) { - internalHeaders.setXMsLeaseDuration(leaseDuration); - return this; - } - - /** - * Get the leaseState property: Lease state of the blob. Possible values include: 'available', 'leased', 'expired', - * 'breaking', 'broken'. - * - * @return the leaseState value. - */ - public LeaseStateType getLeaseState() { - return internalHeaders.getXMsLeaseState(); - } - - /** - * Set the leaseState property: Lease state of the blob. Possible values include: 'available', 'leased', 'expired', - * 'breaking', 'broken'. - * - * @param leaseState the leaseState value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setLeaseState(LeaseStateType leaseState) { - internalHeaders.setXMsLeaseState(leaseState); - return this; - } - - /** - * Get the leaseStatus property: The current lease status of the blob. Possible values include: 'locked', - * 'unlocked'. - * - * @return the leaseStatus value. - */ - public LeaseStatusType getLeaseStatus() { - return internalHeaders.getXMsLeaseStatus(); - } - - /** - * Set the leaseStatus property: The current lease status of the blob. Possible values include: 'locked', - * 'unlocked'. - * - * @param leaseStatus the leaseStatus value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setLeaseStatus(LeaseStatusType leaseStatus) { - internalHeaders.setXMsLeaseStatus(leaseStatus); - return this; - } - - /** - * Get the clientRequestId property: If a client request id header is sent in the request, this header will be - * present in the response with the same value. - * - * @return the clientRequestId value. - */ - public String getClientRequestId() { - return internalHeaders.getXMsClientRequestId(); - } - - /** - * Set the clientRequestId property: If a client request id header is sent in the request, this header will be - * present in the response with the same value. - * - * @param clientRequestId the clientRequestId value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setClientRequestId(String clientRequestId) { - internalHeaders.setXMsClientRequestId(clientRequestId); - return this; - } - - /** - * Get the requestId property: This header uniquely identifies the request that was made and can be used for - * troubleshooting the request. - * - * @return the requestId value. - */ - public String getRequestId() { - return internalHeaders.getXMsRequestId(); - } - - /** - * Set the requestId property: This header uniquely identifies the request that was made and can be used for - * troubleshooting the request. - * - * @param requestId the requestId value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setRequestId(String requestId) { - internalHeaders.setXMsRequestId(requestId); - return this; - } - - /** - * Get the version property: Indicates the version of the Blob service used to execute the request. This header is - * returned for requests made against version 2009-09-19 and above. - * - * @return the version value. - */ - public String getVersion() { - return internalHeaders.getXMsVersion(); - } - - /** - * Set the version property: Indicates the version of the Blob service used to execute the request. This header is - * returned for requests made against version 2009-09-19 and above. - * - * @param version the version value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setVersion(String version) { - internalHeaders.setXMsVersion(version); - return this; - } - - /** - * Get the versionId property: A DateTime value returned by the service that uniquely identifies the blob. The value - * of this header indicates the blob version, and may be used in subsequent requests to access this version of the - * blob. - * - * @return the versionId value. - */ - public String getVersionId() { - return internalHeaders.getXMsVersionId(); - } - - /** - * Set the versionId property: A DateTime value returned by the service that uniquely identifies the blob. The value - * of this header indicates the blob version, and may be used in subsequent requests to access this version of the - * blob. - * - * @param versionId the versionId value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setVersionId(String versionId) { - internalHeaders.setXMsVersionId(versionId); - return this; - } - - /** - * Get the acceptRanges property: Indicates that the service supports requests for partial blob content. - * - * @return the acceptRanges value. - */ - public String getAcceptRanges() { - return internalHeaders.getAcceptRanges(); - } - - /** - * Set the acceptRanges property: Indicates that the service supports requests for partial blob content. - * - * @param acceptRanges the acceptRanges value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setAcceptRanges(String acceptRanges) { - internalHeaders.setAcceptRanges(acceptRanges); - return this; - } - - /** - * Get the dateProperty property: UTC date/time value generated by the service that indicates the time at which the - * response was initiated. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - return internalHeaders.getDate(); - } - - /** - * Set the dateProperty property: UTC date/time value generated by the service that indicates the time at which the - * response was initiated. - * - * @param dateProperty the dateProperty value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setDateProperty(OffsetDateTime dateProperty) { - internalHeaders.setDate(dateProperty); - return this; - } - - /** - * Get the blobCommittedBlockCount property: The number of committed blocks present in the blob. This header is - * returned only for append blobs. - * - * @return the blobCommittedBlockCount value. - */ - public Integer getBlobCommittedBlockCount() { - return internalHeaders.getXMsBlobCommittedBlockCount(); - } - - /** - * Set the blobCommittedBlockCount property: The number of committed blocks present in the blob. This header is - * returned only for append blobs. - * - * @param blobCommittedBlockCount the blobCommittedBlockCount value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setBlobCommittedBlockCount(Integer blobCommittedBlockCount) { - internalHeaders.setXMsBlobCommittedBlockCount(blobCommittedBlockCount); - return this; - } - - /** - * Get the isServerEncrypted property: The value of this header is set to true if the blob data and application - * metadata are completely encrypted using the specified algorithm. Otherwise, the value is set to false (when the - * blob is unencrypted, or if only parts of the blob/application metadata are encrypted). - * - * @return the isServerEncrypted value. - */ - public Boolean isServerEncrypted() { - return internalHeaders.isXMsServerEncrypted(); - } - - /** - * Set the isServerEncrypted property: The value of this header is set to true if the blob data and application - * metadata are completely encrypted using the specified algorithm. Otherwise, the value is set to false (when the - * blob is unencrypted, or if only parts of the blob/application metadata are encrypted). - * - * @param isServerEncrypted the isServerEncrypted value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setIsServerEncrypted(Boolean isServerEncrypted) { - internalHeaders.setXMsServerEncrypted(isServerEncrypted); - return this; - } - - /** - * Get the encryptionKeySha256 property: The SHA-256 hash of the encryption key used to encrypt the blob. This - * header is only returned when the blob was encrypted with a customer-provided key. - * - * @return the encryptionKeySha256 value. - */ - public String getEncryptionKeySha256() { - return internalHeaders.getXMsEncryptionKeySha256(); - } - - /** - * Set the encryptionKeySha256 property: The SHA-256 hash of the encryption key used to encrypt the blob. This - * header is only returned when the blob was encrypted with a customer-provided key. - * - * @param encryptionKeySha256 the encryptionKeySha256 value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setEncryptionKeySha256(String encryptionKeySha256) { - internalHeaders.setXMsEncryptionKeySha256(encryptionKeySha256); - return this; - } - - /** - * Get the encryptionScope property: Returns the name of the encryption scope used to encrypt the blob contents and - * application metadata. Note that the absence of this header implies use of the default account encryption scope. - * - * @return the encryptionScope value. - */ - public String getEncryptionScope() { - return internalHeaders.getXMsEncryptionScope(); - } - - /** - * Set the encryptionScope property: Returns the name of the encryption scope used to encrypt the blob contents and - * application metadata. Note that the absence of this header implies use of the default account encryption scope. - * - * @param encryptionScope the encryptionScope value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setEncryptionScope(String encryptionScope) { - internalHeaders.setXMsEncryptionScope(encryptionScope); - return this; - } - - /** - * Get the blobContentMD5 property: If the blob has a MD5 hash, and if request contains range header (Range or - * x-ms-range), this response header is returned with the value of the whole blob's MD5 value. This value may or may - * not be equal to the value returned in Content-MD5 header, with the latter calculated from the requested range. - * - * @return the blobContentMD5 value. - */ - public byte[] getBlobContentMD5() { - return CoreUtils.clone(internalHeaders.getXMsBlobContentMd5()); - } - - /** - * Set the blobContentMD5 property: If the blob has a MD5 hash, and if request contains range header (Range or - * x-ms-range), this response header is returned with the value of the whole blob's MD5 value. This value may or may - * not be equal to the value returned in Content-MD5 header, with the latter calculated from the requested range. - * - * @param blobContentMD5 the blobContentMD5 value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setBlobContentMD5(byte[] blobContentMD5) { - internalHeaders.setXMsBlobContentMd5(CoreUtils.clone(blobContentMD5)); - return this; - } - - /** - * Get the tagCount property: The number of tags associated with the blob. - * - * @return the tagCount value. - */ - public Long getTagCount() { - return internalHeaders.getXMsTagCount(); - } - - /** - * Set the tagCount property: The number of tags associated with the blob. - * - * @param tagCount the tagCount value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setTagCount(Long tagCount) { - internalHeaders.setXMsTagCount(tagCount); - return this; - } - - /** - * Get the contentCrc64 property: If the request is to read a specified range and the x-ms-range-get-content-crc64 - * is set to true, then the request returns a crc64 for the range, as long as the range size is less than or equal - * to 4 MB. If both x-ms-range-get-content-crc64 & x-ms-range-get-content-md5 is specified in the same request, - * it will fail with 400(Bad Request). - * - * @return the contentCrc64 value. - */ - public byte[] getContentCrc64() { - return CoreUtils.clone(internalHeaders.getXMsContentCrc64()); - } - - /** - * Set the contentCrc64 property: If the request is to read a specified range and the x-ms-range-get-content-crc64 - * is set to true, then the request returns a crc64 for the range, as long as the range size is less than or equal - * to 4 MB. If both x-ms-range-get-content-crc64 & x-ms-range-get-content-md5 is specified in the same request, - * it will fail with 400(Bad Request). - * - * @param contentCrc64 the contentCrc64 value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setContentCrc64(byte[] contentCrc64) { - internalHeaders.setXMsContentCrc64(CoreUtils.clone(contentCrc64)); - return this; - } - - /** - * Get the errorCode property: The errorCode property. - * - * @return the errorCode value. - */ - public String getErrorCode() { - return this.errorCode; - } - - /** - * Set the errorCode property: The errorCode property. - * - * @param errorCode the errorCode value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setErrorCode(String errorCode) { - this.errorCode = errorCode; - return this; - } - - /** - * Get the sealed property: The sealed property. - * - * @return Whether the blob is sealed (marked as read only). This is only applicable for Append blobs. - */ - public Boolean isSealed() { - return internalHeaders.isXMsBlobSealed(); - } - - /** - * Set the sealed property: The sealed property. - * - * @param sealed Whether the blob is sealed (marked as read only). This is only applicable for Append blobs. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setSealed(Boolean sealed) { - internalHeaders.setXMsBlobSealed(sealed); - return this; - } - - /** - * Get the lastAccessedTime property: The lastAccessedTime property. - * - * @return the lastAccessedTime value. - */ - public OffsetDateTime getLastAccessedTime() { - return internalHeaders.getXMsLastAccessTime(); - } - - /** - * Set the lastAccessedTime property: The lastAccessedTime property. - * - * @param lastAccessedTime the lastAccessedTime value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setLastAccessedTime(OffsetDateTime lastAccessedTime) { - internalHeaders.setXMsLastAccessTime(lastAccessedTime); - return this; - } - - /** - * Get the currentVersion property: The x-ms-is-current-version property. - * - * @return the currentVersion value. - */ - public Boolean isCurrentVersion() { - return internalHeaders.isXMsIsCurrentVersion(); - } - - /** - * Set the currentVersion property: The x-ms-is-current-version property. - * - * @param currentVersion the currentVersion value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setCurrentVersion(Boolean currentVersion) { - internalHeaders.setXMsIsCurrentVersion(currentVersion); - return this; - } - - /** - * Get the immutabilityPolicy property: The x-ms-immutability-policy-mode and x-ms-immutability-policy-until-date - * property. - * - * @return the immutabilityPolicy value. - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return new BlobImmutabilityPolicy() - .setPolicyMode(BlobImmutabilityPolicyMode.fromString(internalHeaders.getXMsImmutabilityPolicyMode())) - .setExpiryTime(internalHeaders.getXMsImmutabilityPolicyUntilDate()); - } - - /** - * Set the immutabilityPolicy property: x-ms-immutability-policy-mode and x-ms-immutability-policy-until-date - * property. - * - * @param immutabilityPolicy the immutabilityPolicy value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - if (immutabilityPolicy == null) { - internalHeaders.setXMsImmutabilityPolicyMode(null); - internalHeaders.setXMsImmutabilityPolicyUntilDate(null); - } else { - internalHeaders.setXMsImmutabilityPolicyMode(immutabilityPolicy.getPolicyMode().toString()); - internalHeaders.setXMsImmutabilityPolicyUntilDate(immutabilityPolicy.getExpiryTime()); - } - return this; - } - - /** - * Get the hasLegalHold property: The x-ms-legal-hold property. - * - * @return the hasLegalHold value. - */ - public Boolean hasLegalHold() { - return internalHeaders.isXMsLegalHold(); - } - - /** - * Set the hasLegalHold property: The x-ms-legal-hold property. - * - * @param hasLegalHold the xMsLegalHold value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setHasLegalHold(Boolean hasLegalHold) { - internalHeaders.setXMsLegalHold(hasLegalHold); - return this; - } - - /** - * Get the xMsCreationTime property: The x-ms-creation-time property. - * - * @return the creation time value. - */ - public OffsetDateTime getCreationTime() { - return internalHeaders.getXMsCreationTime(); - } - - /** - * Set the xMsCreationTime property: The x-ms-creation-time property. - * - * @param creationTime the xMsCreationTime value to set. - * @return the BlobDownloadHeaders object itself. - */ - public BlobDownloadHeaders setCreationTime(OffsetDateTime creationTime) { - internalHeaders.setXMsCreationTime(creationTime); - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadResponse.java deleted file mode 100644 index 64247319e0f8..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.http.rest.ResponseBase; - -/** - * This class contains the response information return from the server when downloading a blob. - */ -public final class BlobDownloadResponse extends ResponseBase { - /** - * Constructs a {@link BlobDownloadResponse}. - * - * @param response Response returned from the service. - */ - public BlobDownloadResponse(BlobDownloadAsyncResponse response) { - super(response.getRequest(), response.getStatusCode(), response.getHeaders(), null, - response.getDeserializedHeaders()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobErrorCode.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobErrorCode.java deleted file mode 100644 index b4bbb9cc3df3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobErrorCode.java +++ /dev/null @@ -1,649 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.util.ExpandableStringEnum; -import java.util.Collection; - -/** - * Error codes returned by the service. - */ -public final class BlobErrorCode extends ExpandableStringEnum { - /** - * Static value AccountAlreadyExists for BlobErrorCode. - */ - public static final BlobErrorCode ACCOUNT_ALREADY_EXISTS = fromString("AccountAlreadyExists"); - - /** - * Static value AccountBeingCreated for BlobErrorCode. - */ - public static final BlobErrorCode ACCOUNT_BEING_CREATED = fromString("AccountBeingCreated"); - - /** - * Static value AccountIsDisabled for BlobErrorCode. - */ - public static final BlobErrorCode ACCOUNT_IS_DISABLED = fromString("AccountIsDisabled"); - - /** - * Static value AuthenticationFailed for BlobErrorCode. - */ - public static final BlobErrorCode AUTHENTICATION_FAILED = fromString("AuthenticationFailed"); - - /** - * Static value AuthorizationFailure for BlobErrorCode. - */ - public static final BlobErrorCode AUTHORIZATION_FAILURE = fromString("AuthorizationFailure"); - - /** - * Static value ConditionHeadersNotSupported for BlobErrorCode. - */ - public static final BlobErrorCode CONDITION_HEADERS_NOT_SUPPORTED = fromString("ConditionHeadersNotSupported"); - - /** - * Static value ConditionNotMet for BlobErrorCode. - */ - public static final BlobErrorCode CONDITION_NOT_MET = fromString("ConditionNotMet"); - - /** - * Static value EmptyMetadataKey for BlobErrorCode. - */ - public static final BlobErrorCode EMPTY_METADATA_KEY = fromString("EmptyMetadataKey"); - - /** - * Static value InsufficientAccountPermissions for BlobErrorCode. - */ - public static final BlobErrorCode INSUFFICIENT_ACCOUNT_PERMISSIONS = fromString("InsufficientAccountPermissions"); - - /** - * Static value InternalError for BlobErrorCode. - */ - public static final BlobErrorCode INTERNAL_ERROR = fromString("InternalError"); - - /** - * Static value InvalidAuthenticationInfo for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_AUTHENTICATION_INFO = fromString("InvalidAuthenticationInfo"); - - /** - * Static value InvalidHeaderValue for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_HEADER_VALUE = fromString("InvalidHeaderValue"); - - /** - * Static value InvalidHttpVerb for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_HTTP_VERB = fromString("InvalidHttpVerb"); - - /** - * Static value InvalidInput for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_INPUT = fromString("InvalidInput"); - - /** - * Static value InvalidMd5 for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_MD5 = fromString("InvalidMd5"); - - /** - * Static value InvalidMetadata for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_METADATA = fromString("InvalidMetadata"); - - /** - * Static value InvalidQueryParameterValue for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_QUERY_PARAMETER_VALUE = fromString("InvalidQueryParameterValue"); - - /** - * Static value InvalidRange for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_RANGE = fromString("InvalidRange"); - - /** - * Static value InvalidResourceName for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_RESOURCE_NAME = fromString("InvalidResourceName"); - - /** - * Static value InvalidUri for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_URI = fromString("InvalidUri"); - - /** - * Static value InvalidXmlDocument for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_XML_DOCUMENT = fromString("InvalidXmlDocument"); - - /** - * Static value InvalidXmlNodeValue for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_XML_NODE_VALUE = fromString("InvalidXmlNodeValue"); - - /** - * Static value Md5Mismatch for BlobErrorCode. - */ - public static final BlobErrorCode MD5MISMATCH = fromString("Md5Mismatch"); - - /** - * Static value MetadataTooLarge for BlobErrorCode. - */ - public static final BlobErrorCode METADATA_TOO_LARGE = fromString("MetadataTooLarge"); - - /** - * Static value MissingContentLengthHeader for BlobErrorCode. - */ - public static final BlobErrorCode MISSING_CONTENT_LENGTH_HEADER = fromString("MissingContentLengthHeader"); - - /** - * Static value MissingRequiredQueryParameter for BlobErrorCode. - */ - public static final BlobErrorCode MISSING_REQUIRED_QUERY_PARAMETER = fromString("MissingRequiredQueryParameter"); - - /** - * Static value MissingRequiredHeader for BlobErrorCode. - */ - public static final BlobErrorCode MISSING_REQUIRED_HEADER = fromString("MissingRequiredHeader"); - - /** - * Static value MissingRequiredXmlNode for BlobErrorCode. - */ - public static final BlobErrorCode MISSING_REQUIRED_XML_NODE = fromString("MissingRequiredXmlNode"); - - /** - * Static value MultipleConditionHeadersNotSupported for BlobErrorCode. - */ - public static final BlobErrorCode MULTIPLE_CONDITION_HEADERS_NOT_SUPPORTED - = fromString("MultipleConditionHeadersNotSupported"); - - /** - * Static value OperationTimedOut for BlobErrorCode. - */ - public static final BlobErrorCode OPERATION_TIMED_OUT = fromString("OperationTimedOut"); - - /** - * Static value OutOfRangeInput for BlobErrorCode. - */ - public static final BlobErrorCode OUT_OF_RANGE_INPUT = fromString("OutOfRangeInput"); - - /** - * Static value OutOfRangeQueryParameterValue for BlobErrorCode. - */ - public static final BlobErrorCode OUT_OF_RANGE_QUERY_PARAMETER_VALUE = fromString("OutOfRangeQueryParameterValue"); - - /** - * Static value RequestBodyTooLarge for BlobErrorCode. - */ - public static final BlobErrorCode REQUEST_BODY_TOO_LARGE = fromString("RequestBodyTooLarge"); - - /** - * Static value ResourceTypeMismatch for BlobErrorCode. - */ - public static final BlobErrorCode RESOURCE_TYPE_MISMATCH = fromString("ResourceTypeMismatch"); - - /** - * Static value RequestUrlFailedToParse for BlobErrorCode. - */ - public static final BlobErrorCode REQUEST_URL_FAILED_TO_PARSE = fromString("RequestUrlFailedToParse"); - - /** - * Static value ResourceAlreadyExists for BlobErrorCode. - */ - public static final BlobErrorCode RESOURCE_ALREADY_EXISTS = fromString("ResourceAlreadyExists"); - - /** - * Static value ResourceNotFound for BlobErrorCode. - */ - public static final BlobErrorCode RESOURCE_NOT_FOUND = fromString("ResourceNotFound"); - - /** - * Static value ServerBusy for BlobErrorCode. - */ - public static final BlobErrorCode SERVER_BUSY = fromString("ServerBusy"); - - /** - * Static value UnsupportedHeader for BlobErrorCode. - */ - public static final BlobErrorCode UNSUPPORTED_HEADER = fromString("UnsupportedHeader"); - - /** - * Static value UnsupportedXmlNode for BlobErrorCode. - */ - public static final BlobErrorCode UNSUPPORTED_XML_NODE = fromString("UnsupportedXmlNode"); - - /** - * Static value UnsupportedQueryParameter for BlobErrorCode. - */ - public static final BlobErrorCode UNSUPPORTED_QUERY_PARAMETER = fromString("UnsupportedQueryParameter"); - - /** - * Static value UnsupportedHttpVerb for BlobErrorCode. - */ - public static final BlobErrorCode UNSUPPORTED_HTTP_VERB = fromString("UnsupportedHttpVerb"); - - /** - * Static value AppendPositionConditionNotMet for BlobErrorCode. - */ - public static final BlobErrorCode APPEND_POSITION_CONDITION_NOT_MET = fromString("AppendPositionConditionNotMet"); - - /** - * Static value BlobAlreadyExists for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_ALREADY_EXISTS = fromString("BlobAlreadyExists"); - - /** - * Static value BlobImmutableDueToPolicy for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_IMMUTABLE_DUE_TO_POLICY = fromString("BlobImmutableDueToPolicy"); - - /** - * Static value BlobNotFound for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_NOT_FOUND = fromString("BlobNotFound"); - - /** - * Static value BlobOverwritten for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_OVERWRITTEN = fromString("BlobOverwritten"); - - /** - * Static value BlobTierInadequateForContentLength for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_TIER_INADEQUATE_FOR_CONTENT_LENGTH - = fromString("BlobTierInadequateForContentLength"); - - /** - * Static value BlobUsesCustomerSpecifiedEncryption for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_USES_CUSTOMER_SPECIFIED_ENCRYPTION - = fromString("BlobUsesCustomerSpecifiedEncryption"); - - /** - * Static value BlockCountExceedsLimit for BlobErrorCode. - */ - public static final BlobErrorCode BLOCK_COUNT_EXCEEDS_LIMIT = fromString("BlockCountExceedsLimit"); - - /** - * Static value BlockListTooLong for BlobErrorCode. - */ - public static final BlobErrorCode BLOCK_LIST_TOO_LONG = fromString("BlockListTooLong"); - - /** - * Static value CannotChangeToLowerTier for BlobErrorCode. - */ - public static final BlobErrorCode CANNOT_CHANGE_TO_LOWER_TIER = fromString("CannotChangeToLowerTier"); - - /** - * Static value CannotVerifyCopySource for BlobErrorCode. - */ - public static final BlobErrorCode CANNOT_VERIFY_COPY_SOURCE = fromString("CannotVerifyCopySource"); - - /** - * Static value ContainerAlreadyExists for BlobErrorCode. - */ - public static final BlobErrorCode CONTAINER_ALREADY_EXISTS = fromString("ContainerAlreadyExists"); - - /** - * Static value ContainerBeingDeleted for BlobErrorCode. - */ - public static final BlobErrorCode CONTAINER_BEING_DELETED = fromString("ContainerBeingDeleted"); - - /** - * Static value ContainerDisabled for BlobErrorCode. - */ - public static final BlobErrorCode CONTAINER_DISABLED = fromString("ContainerDisabled"); - - /** - * Static value ContainerNotFound for BlobErrorCode. - */ - public static final BlobErrorCode CONTAINER_NOT_FOUND = fromString("ContainerNotFound"); - - /** - * Static value ContentLengthLargerThanTierLimit for BlobErrorCode. - */ - public static final BlobErrorCode CONTENT_LENGTH_LARGER_THAN_TIER_LIMIT - = fromString("ContentLengthLargerThanTierLimit"); - - /** - * Static value CopyAcrossAccountsNotSupported for BlobErrorCode. - */ - public static final BlobErrorCode COPY_ACROSS_ACCOUNTS_NOT_SUPPORTED = fromString("CopyAcrossAccountsNotSupported"); - - /** - * Static value CopyIdMismatch for BlobErrorCode. - */ - public static final BlobErrorCode COPY_ID_MISMATCH = fromString("CopyIdMismatch"); - - /** - * Static value FeatureVersionMismatch for BlobErrorCode. - */ - public static final BlobErrorCode FEATURE_VERSION_MISMATCH = fromString("FeatureVersionMismatch"); - - /** - * Static value IncrementalCopyBlobMismatch for BlobErrorCode. - */ - public static final BlobErrorCode INCREMENTAL_COPY_BLOB_MISMATCH = fromString("IncrementalCopyBlobMismatch"); - - /** - * Static value IncrementalCopyOfEarlierVersionSnapshotNotAllowed for BlobErrorCode. - */ - public static final BlobErrorCode INCREMENTAL_COPY_OF_EARLIER_VERSION_SNAPSHOT_NOT_ALLOWED - = fromString("IncrementalCopyOfEarlierVersionSnapshotNotAllowed"); - - /** - * Static value IncrementalCopySourceMustBeSnapshot for BlobErrorCode. - */ - public static final BlobErrorCode INCREMENTAL_COPY_SOURCE_MUST_BE_SNAPSHOT - = fromString("IncrementalCopySourceMustBeSnapshot"); - - /** - * Static value InfiniteLeaseDurationRequired for BlobErrorCode. - */ - public static final BlobErrorCode INFINITE_LEASE_DURATION_REQUIRED = fromString("InfiniteLeaseDurationRequired"); - - /** - * Static value InvalidBlobOrBlock for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_BLOB_OR_BLOCK = fromString("InvalidBlobOrBlock"); - - /** - * Static value InvalidBlobTier for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_BLOB_TIER = fromString("InvalidBlobTier"); - - /** - * Static value InvalidBlobType for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_BLOB_TYPE = fromString("InvalidBlobType"); - - /** - * Static value InvalidBlockId for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_BLOCK_ID = fromString("InvalidBlockId"); - - /** - * Static value InvalidBlockList for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_BLOCK_LIST = fromString("InvalidBlockList"); - - /** - * Static value InvalidOperation for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_OPERATION = fromString("InvalidOperation"); - - /** - * Static value InvalidPageRange for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_PAGE_RANGE = fromString("InvalidPageRange"); - - /** - * Static value InvalidSourceBlobType for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_SOURCE_BLOB_TYPE = fromString("InvalidSourceBlobType"); - - /** - * Static value InvalidSourceBlobUrl for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_SOURCE_BLOB_URL = fromString("InvalidSourceBlobUrl"); - - /** - * Static value InvalidVersionForPageBlobOperation for BlobErrorCode. - */ - public static final BlobErrorCode INVALID_VERSION_FOR_PAGE_BLOB_OPERATION - = fromString("InvalidVersionForPageBlobOperation"); - - /** - * Static value LeaseAlreadyPresent for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_ALREADY_PRESENT = fromString("LeaseAlreadyPresent"); - - /** - * Static value LeaseAlreadyBroken for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_ALREADY_BROKEN = fromString("LeaseAlreadyBroken"); - - /** - * Static value LeaseIdMismatchWithBlobOperation for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_ID_MISMATCH_WITH_BLOB_OPERATION - = fromString("LeaseIdMismatchWithBlobOperation"); - - /** - * Static value LeaseIdMismatchWithContainerOperation for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_ID_MISMATCH_WITH_CONTAINER_OPERATION - = fromString("LeaseIdMismatchWithContainerOperation"); - - /** - * Static value LeaseIdMismatchWithLeaseOperation for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_ID_MISMATCH_WITH_LEASE_OPERATION - = fromString("LeaseIdMismatchWithLeaseOperation"); - - /** - * Static value LeaseIdMissing for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_ID_MISSING = fromString("LeaseIdMissing"); - - /** - * Static value LeaseIsBreakingAndCannotBeAcquired for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_IS_BREAKING_AND_CANNOT_BE_ACQUIRED - = fromString("LeaseIsBreakingAndCannotBeAcquired"); - - /** - * Static value LeaseIsBreakingAndCannotBeChanged for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_IS_BREAKING_AND_CANNOT_BE_CHANGED - = fromString("LeaseIsBreakingAndCannotBeChanged"); - - /** - * Static value LeaseIsBrokenAndCannotBeRenewed for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_IS_BROKEN_AND_CANNOT_BE_RENEWED - = fromString("LeaseIsBrokenAndCannotBeRenewed"); - - /** - * Static value LeaseLost for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_LOST = fromString("LeaseLost"); - - /** - * Static value LeaseNotPresentWithBlobOperation for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_NOT_PRESENT_WITH_BLOB_OPERATION - = fromString("LeaseNotPresentWithBlobOperation"); - - /** - * Static value LeaseNotPresentWithContainerOperation for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_NOT_PRESENT_WITH_CONTAINER_OPERATION - = fromString("LeaseNotPresentWithContainerOperation"); - - /** - * Static value LeaseNotPresentWithLeaseOperation for BlobErrorCode. - */ - public static final BlobErrorCode LEASE_NOT_PRESENT_WITH_LEASE_OPERATION - = fromString("LeaseNotPresentWithLeaseOperation"); - - /** - * Static value MaxBlobSizeConditionNotMet for BlobErrorCode. - */ - public static final BlobErrorCode MAX_BLOB_SIZE_CONDITION_NOT_MET = fromString("MaxBlobSizeConditionNotMet"); - - /** - * Static value NoAuthenticationInformation for BlobErrorCode. - */ - public static final BlobErrorCode NO_AUTHENTICATION_INFORMATION = fromString("NoAuthenticationInformation"); - - /** - * Static value NoPendingCopyOperation for BlobErrorCode. - */ - public static final BlobErrorCode NO_PENDING_COPY_OPERATION = fromString("NoPendingCopyOperation"); - - /** - * Static value OperationNotAllowedOnIncrementalCopyBlob for BlobErrorCode. - */ - public static final BlobErrorCode OPERATION_NOT_ALLOWED_ON_INCREMENTAL_COPY_BLOB - = fromString("OperationNotAllowedOnIncrementalCopyBlob"); - - /** - * Static value PendingCopyOperation for BlobErrorCode. - */ - public static final BlobErrorCode PENDING_COPY_OPERATION = fromString("PendingCopyOperation"); - - /** - * Static value PreviousSnapshotCannotBeNewer for BlobErrorCode. - */ - public static final BlobErrorCode PREVIOUS_SNAPSHOT_CANNOT_BE_NEWER = fromString("PreviousSnapshotCannotBeNewer"); - - /** - * Static value PreviousSnapshotNotFound for BlobErrorCode. - */ - public static final BlobErrorCode PREVIOUS_SNAPSHOT_NOT_FOUND = fromString("PreviousSnapshotNotFound"); - - /** - * Static value PreviousSnapshotOperationNotSupported for BlobErrorCode. - */ - public static final BlobErrorCode PREVIOUS_SNAPSHOT_OPERATION_NOT_SUPPORTED - = fromString("PreviousSnapshotOperationNotSupported"); - - /** - * Static value SequenceNumberConditionNotMet for BlobErrorCode. - */ - public static final BlobErrorCode SEQUENCE_NUMBER_CONDITION_NOT_MET = fromString("SequenceNumberConditionNotMet"); - - /** - * Static value SequenceNumberIncrementTooLarge for BlobErrorCode. - */ - public static final BlobErrorCode SEQUENCE_NUMBER_INCREMENT_TOO_LARGE - = fromString("SequenceNumberIncrementTooLarge"); - - /** - * Static value SnapshotCountExceeded for BlobErrorCode. - */ - public static final BlobErrorCode SNAPSHOT_COUNT_EXCEEDED = fromString("SnapshotCountExceeded"); - - /** - * Static value SnapshotOperationRateExceeded for BlobErrorCode. - */ - public static final BlobErrorCode SNAPSHOT_OPERATION_RATE_EXCEEDED = fromString("SnapshotOperationRateExceeded"); - - /** - * Static value SnapshotsPresent for BlobErrorCode. - */ - public static final BlobErrorCode SNAPSHOTS_PRESENT = fromString("SnapshotsPresent"); - - /** - * Static value SourceConditionNotMet for BlobErrorCode. - */ - public static final BlobErrorCode SOURCE_CONDITION_NOT_MET = fromString("SourceConditionNotMet"); - - /** - * Static value SystemInUse for BlobErrorCode. - */ - public static final BlobErrorCode SYSTEM_IN_USE = fromString("SystemInUse"); - - /** - * Static value TargetConditionNotMet for BlobErrorCode. - */ - public static final BlobErrorCode TARGET_CONDITION_NOT_MET = fromString("TargetConditionNotMet"); - - /** - * Static value UnauthorizedBlobOverwrite for BlobErrorCode. - */ - public static final BlobErrorCode UNAUTHORIZED_BLOB_OVERWRITE = fromString("UnauthorizedBlobOverwrite"); - - /** - * Static value BlobBeingRehydrated for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_BEING_REHYDRATED = fromString("BlobBeingRehydrated"); - - /** - * Static value BlobArchived for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_ARCHIVED = fromString("BlobArchived"); - - /** - * Static value BlobNotArchived for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_NOT_ARCHIVED = fromString("BlobNotArchived"); - - /** - * Static value AuthorizationSourceIPMismatch for BlobErrorCode. - */ - public static final BlobErrorCode AUTHORIZATION_SOURCE_IPMISMATCH = fromString("AuthorizationSourceIPMismatch"); - - /** - * Static value AuthorizationProtocolMismatch for BlobErrorCode. - */ - public static final BlobErrorCode AUTHORIZATION_PROTOCOL_MISMATCH = fromString("AuthorizationProtocolMismatch"); - - /** - * Static value AuthorizationPermissionMismatch for BlobErrorCode. - */ - public static final BlobErrorCode AUTHORIZATION_PERMISSION_MISMATCH = fromString("AuthorizationPermissionMismatch"); - - /** - * Static value AuthorizationServiceMismatch for BlobErrorCode. - */ - public static final BlobErrorCode AUTHORIZATION_SERVICE_MISMATCH = fromString("AuthorizationServiceMismatch"); - - /** - * Static value AuthorizationResourceTypeMismatch for BlobErrorCode. - */ - public static final BlobErrorCode AUTHORIZATION_RESOURCE_TYPE_MISMATCH - = fromString("AuthorizationResourceTypeMismatch"); - - /** - * Static value BlobAccessTierNotSupportedForAccountType for BlobErrorCode. - */ - public static final BlobErrorCode BLOB_ACCESS_TIER_NOT_SUPPORTED_FOR_ACCOUNT_TYPE - = fromString("BlobAccessTierNotSupportedForAccountType"); - - /** - * Static value SnapshotOperationRateExceeded for BlobErrorCode. - * - * @deprecated Please use {@link BlobErrorCode#SNAPSHOT_OPERATION_RATE_EXCEEDED} - */ - @Deprecated - public static final BlobErrorCode SNAPHOT_OPERATION_RATE_EXCEEDED = fromString("SnapshotOperationRateExceeded"); - - /** - * Static value IncrementalCopyOfEralierVersionSnapshotNotAllowed for BlobErrorCode. - * - * @deprecated Please use {@link BlobErrorCode#INCREMENTAL_COPY_OF_EARLIER_VERSION_SNAPSHOT_NOT_ALLOWED} - */ - @Deprecated - public static final BlobErrorCode INCREMENTAL_COPY_OF_ERALIER_VERSION_SNAPSHOT_NOT_ALLOWED - = fromString("IncrementalCopyOfEralierVersionSnapshotNotAllowed"); - - /** - * Creates a new instance of BlobErrorCode value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Deprecated - public BlobErrorCode() { - } - - /** - * Creates or finds a BlobErrorCode from its string representation. - * - * @param name a name to look for. - * @return the corresponding BlobErrorCode. - */ - public static BlobErrorCode fromString(String name) { - return fromString(name, BlobErrorCode.class); - } - - /** - * Gets known BlobErrorCode values. - * - * @return known BlobErrorCode values. - */ - public static Collection values() { - return values(BlobErrorCode.class); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobExpiryOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobExpiryOptions.java similarity index 79% rename from sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobExpiryOptions.java rename to sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobExpiryOptions.java index adece5bc410e..d2d3e9639866 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobExpiryOptions.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobExpiryOptions.java @@ -1,34 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.storage.blob.implementation.models; +package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; /** - * Defines values for BlobExpiryOptions. + * The blob expiration options. */ public final class BlobExpiryOptions extends ExpandableStringEnum { /** - * Static value NeverExpire for BlobExpiryOptions. + * Never expire. */ + @Generated public static final BlobExpiryOptions NEVER_EXPIRE = fromString("NeverExpire"); /** - * Static value RelativeToCreation for BlobExpiryOptions. + * Relative to creation time. */ + @Generated public static final BlobExpiryOptions RELATIVE_TO_CREATION = fromString("RelativeToCreation"); /** - * Static value RelativeToNow for BlobExpiryOptions. + * Relative to now. */ + @Generated public static final BlobExpiryOptions RELATIVE_TO_NOW = fromString("RelativeToNow"); /** - * Static value Absolute for BlobExpiryOptions. + * Absolute time. */ + @Generated public static final BlobExpiryOptions ABSOLUTE = fromString("Absolute"); /** @@ -36,6 +41,7 @@ public final class BlobExpiryOptions extends ExpandableStringEnum values() { return values(BlobExpiryOptions.class); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobFlatListSegment.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobFlatListSegment.java new file mode 100644 index 000000000000..523c67e5eaa5 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobFlatListSegment.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The blob flat list segment. + */ +@Immutable +public final class BlobFlatListSegment implements JsonSerializable { + /* + * The blob items. + */ + @Generated + private final List blobItems; + + /** + * Creates an instance of BlobFlatListSegment class. + * + * @param blobItems the blobItems value to set. + */ + @Generated + private BlobFlatListSegment(List blobItems) { + this.blobItems = blobItems; + } + + /** + * Get the blobItems property: The blob items. + * + * @return the blobItems value. + */ + @Generated + public List getBlobItems() { + return this.blobItems; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("blobItems", this.blobItems, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobFlatListSegment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobFlatListSegment if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobFlatListSegment. + */ + @Generated + public static BlobFlatListSegment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List blobItems = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blobItems".equals(fieldName)) { + blobItems = reader.readArray(reader1 -> BlobItemInternal.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new BlobFlatListSegment(blobItems); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobHierarchyListSegment.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobHierarchyListSegment.java new file mode 100644 index 000000000000..7906d979c950 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobHierarchyListSegment.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents an array of blobs. + */ +@Immutable +public final class BlobHierarchyListSegment implements JsonSerializable { + /* + * The blob items + */ + @Generated + private final List blobItems; + + /* + * The blob prefixes. + */ + @Generated + private List blobPrefixes; + + /** + * Creates an instance of BlobHierarchyListSegment class. + * + * @param blobItems the blobItems value to set. + */ + @Generated + private BlobHierarchyListSegment(List blobItems) { + this.blobItems = blobItems; + } + + /** + * Get the blobItems property: The blob items. + * + * @return the blobItems value. + */ + @Generated + public List getBlobItems() { + return this.blobItems; + } + + /** + * Get the blobPrefixes property: The blob prefixes. + * + * @return the blobPrefixes value. + */ + @Generated + public List getBlobPrefixes() { + return this.blobPrefixes; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("blobItems", this.blobItems, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("blobPrefixes", this.blobPrefixes, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobHierarchyListSegment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobHierarchyListSegment if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobHierarchyListSegment. + */ + @Generated + public static BlobHierarchyListSegment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List blobItems = null; + List blobPrefixes = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blobItems".equals(fieldName)) { + blobItems = reader.readArray(reader1 -> BlobItemInternal.fromJson(reader1)); + } else if ("blobPrefixes".equals(fieldName)) { + blobPrefixes = reader.readArray(reader1 -> BlobPrefix.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + BlobHierarchyListSegment deserializedBlobHierarchyListSegment = new BlobHierarchyListSegment(blobItems); + deserializedBlobHierarchyListSegment.blobPrefixes = blobPrefixes; + + return deserializedBlobHierarchyListSegment; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobHttpHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobHttpHeaders.java deleted file mode 100644 index 407fd6eabe20..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobHttpHeaders.java +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; - -/** - * Parameter group. - */ -@Fluent -public final class BlobHttpHeaders { - /* - * Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a - * read request. - */ - private String cacheControl; - - /* - * Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a - * read request. - */ - private String contentType; - - /* - * Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual - * blocks were validated when each was uploaded. The value does not need to be base64 encoded as the SDK will - * perform the encoding. - */ - private byte[] contentMd5; - - /* - * Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with - * a read request. - */ - private String contentEncoding; - - /* - * Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with - * a read request. - */ - private String contentLanguage; - - /* - * Optional. Sets the blob's Content-Disposition header. - */ - private String contentDisposition; - - /** - * Creates an instance of BlobHttpHeaders class. - */ - public BlobHttpHeaders() { - } - - /** - * Get the cacheControl property: Optional. Sets the blob's cache control. If specified, this property is stored - * with the blob and returned with a read request. - * - * @return the cacheControl value. - */ - public String getCacheControl() { - return this.cacheControl; - } - - /** - * Set the cacheControl property: Optional. Sets the blob's cache control. If specified, this property is stored - * with the blob and returned with a read request. - * - * @param cacheControl the cacheControl value to set. - * @return the BlobHttpHeaders object itself. - */ - public BlobHttpHeaders setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - /** - * Get the contentType property: Optional. Sets the blob's content type. If specified, this property is stored with - * the blob and returned with a read request. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: Optional. Sets the blob's content type. If specified, this property is stored with - * the blob and returned with a read request. - * - * @param contentType the contentType value to set. - * @return the BlobHttpHeaders object itself. - */ - public BlobHttpHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Get the contentMd5 property: Optional. An MD5 hash of the blob content. Note that this hash is not validated, as - * the hashes for the individual blocks were validated when each was uploaded. The value does not need to be base64 - * encoded as the SDK will perform the encoding. - * - * @return the contentMd5 value. - */ - public byte[] getContentMd5() { - return CoreUtils.clone(this.contentMd5); - } - - /** - * Set the contentMd5 property: Optional. An MD5 hash of the blob content. Note that this hash is not validated, as - * the hashes for the individual blocks were validated when each was uploaded. The value does not need to be base64 - * encoded as the SDK will perform the encoding. - * - * @param contentMd5 the contentMd5 value to set. - * @return the BlobHttpHeaders object itself. - */ - public BlobHttpHeaders setContentMd5(byte[] contentMd5) { - this.contentMd5 = CoreUtils.clone(contentMd5); - return this; - } - - /** - * Get the contentEncoding property: Optional. Sets the blob's content encoding. If specified, this property is - * stored with the blob and returned with a read request. - * - * @return the contentEncoding value. - */ - public String getContentEncoding() { - return this.contentEncoding; - } - - /** - * Set the contentEncoding property: Optional. Sets the blob's content encoding. If specified, this property is - * stored with the blob and returned with a read request. - * - * @param contentEncoding the contentEncoding value to set. - * @return the BlobHttpHeaders object itself. - */ - public BlobHttpHeaders setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - /** - * Get the contentLanguage property: Optional. Set the blob's content language. If specified, this property is - * stored with the blob and returned with a read request. - * - * @return the contentLanguage value. - */ - public String getContentLanguage() { - return this.contentLanguage; - } - - /** - * Set the contentLanguage property: Optional. Set the blob's content language. If specified, this property is - * stored with the blob and returned with a read request. - * - * @param contentLanguage the contentLanguage value to set. - * @return the BlobHttpHeaders object itself. - */ - public BlobHttpHeaders setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Get the contentDisposition property: Optional. Sets the blob's Content-Disposition header. - * - * @return the contentDisposition value. - */ - public String getContentDisposition() { - return this.contentDisposition; - } - - /** - * Set the contentDisposition property: Optional. Sets the blob's Content-Disposition header. - * - * @param contentDisposition the contentDisposition value to set. - * @return the BlobHttpHeaders object itself. - */ - public BlobHttpHeaders setContentDisposition(String contentDisposition) { - this.contentDisposition = contentDisposition; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicy.java deleted file mode 100644 index edb18e7328fc..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicy.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import java.time.OffsetDateTime; - -/** - * Optional parameters for setting the immutability policy of a blob, blob snapshot or blob version. - */ -public final class BlobImmutabilityPolicy { - private OffsetDateTime expiryTime; - private BlobImmutabilityPolicyMode policyMode; - - /** - * Creates an instance of {@link BlobImmutabilityPolicy}. - */ - public BlobImmutabilityPolicy() { - } - - /** - * Gets the time when the immutability policy expires. - * - * @return The time when the immutability policy expires. - */ - public OffsetDateTime getExpiryTime() { - return expiryTime; - } - - /** - * Sets the time when the immutability policy expires. - * - * @param expiryTime The time when the immutability policy expires. - * @return The updated BlobImmutabilityPolicy - */ - public BlobImmutabilityPolicy setExpiryTime(OffsetDateTime expiryTime) { - this.expiryTime = expiryTime; - return this; - } - - /** - * Gets the immutability policy mode. - * - * @return The immutability policy mode. - */ - public BlobImmutabilityPolicyMode getPolicyMode() { - return policyMode; - } - - /** - * Sets the immutability policy mode. - * - * @param policyMode The immutability policy mode. - * @return The updated BlobImmutabilityPolicy - */ - public BlobImmutabilityPolicy setPolicyMode(BlobImmutabilityPolicyMode policyMode) { - this.policyMode = policyMode; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicyMode.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicyMode.java index cdbf65dad1d0..74094506d1b0 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicyMode.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicyMode.java @@ -1,61 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + /** - * Defines values for BlobImmutabilityPolicyMode. + * The immutability policy mode. */ -public enum BlobImmutabilityPolicyMode { +public final class BlobImmutabilityPolicyMode extends ExpandableStringEnum { /** - * Enum value Mutable. + * The immutability policy is mutable. */ - MUTABLE("Mutable"), + @Generated + public static final BlobImmutabilityPolicyMode MUTABLE = fromString("Mutable"); /** - * Enum value Unlocked. + * The immutability policy is locked. */ - UNLOCKED("Unlocked"), + @Generated + public static final BlobImmutabilityPolicyMode LOCKED = fromString("Locked"); /** - * Enum value Locked. + * The immutability policy is unlocked. */ - LOCKED("Locked"); + @Generated + public static final BlobImmutabilityPolicyMode UNLOCKED = fromString("Unlocked"); /** - * The actual serialized value for a BlobImmutabilityPolicyMode instance. + * Creates a new instance of BlobImmutabilityPolicyMode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. */ - private final String value; - - BlobImmutabilityPolicyMode(String value) { - this.value = value; + @Generated + @Deprecated + public BlobImmutabilityPolicyMode() { } /** - * Parses a serialized value to a BlobImmutabilityPolicyMode instance. + * Creates or finds a BlobImmutabilityPolicyMode from its string representation. * - * @param value the serialized value to parse. - * @return the parsed BlobImmutabilityPolicyMode object, or null if unable to parse. + * @param name a name to look for. + * @return the corresponding BlobImmutabilityPolicyMode. */ - public static BlobImmutabilityPolicyMode fromString(String value) { - if (value == null) { - return null; - } - BlobImmutabilityPolicyMode[] items = BlobImmutabilityPolicyMode.values(); - for (BlobImmutabilityPolicyMode item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; + @Generated + public static BlobImmutabilityPolicyMode fromString(String name) { + return fromString(name, BlobImmutabilityPolicyMode.class); } /** - * {@inheritDoc} + * Gets known BlobImmutabilityPolicyMode values. + * + * @return known BlobImmutabilityPolicyMode values. */ - @Override - public String toString() { - return this.value; + @Generated + public static Collection values() { + return values(BlobImmutabilityPolicyMode.class); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItem.java deleted file mode 100644 index 7b3558005a5e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItem.java +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.implementation.accesshelpers.BlobItemConstructorProxy; -import com.azure.storage.blob.implementation.accesshelpers.BlobItemPropertiesConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobItemInternal; -import com.azure.storage.blob.implementation.models.BlobName; - -import java.util.List; -import java.util.Map; - -import static com.azure.storage.blob.implementation.util.ModelHelper.tagMapFromBlobTags; -import static com.azure.storage.blob.implementation.util.ModelHelper.toBlobNameString; -import static com.azure.storage.blob.implementation.util.ModelHelper.toBlobTags; -import static com.azure.storage.blob.implementation.util.ModelHelper.toObjectReplicationMetadata; -import static com.azure.storage.blob.implementation.util.ModelHelper.transformObjectReplicationMetadata; - -/** - * An Azure Storage blob. - */ -@Fluent -public final class BlobItem { - private final BlobItemInternal blobItemInternal; - - static { - BlobItemConstructorProxy.setAccessor(BlobItem::new); - } - - private BlobItem(BlobItemInternal blobItemInternal) { - this.blobItemInternal = blobItemInternal; - } - - /** - * Constructs a new instance of {@link BlobItem}. - */ - public BlobItem() { - // Added to maintain backwards compatibility as the private constructor removes the implicit no args - // constructor. - this.blobItemInternal = new BlobItemInternal(); - } - - private String convertedName; - private BlobItemProperties convertedProperties; - private Map convertedTags; - private List convertedObjectReplicationSourcePolicies; - - /** - * Get the name property: The name property. - * - * @return the name value. - */ - public String getName() { - if (convertedName == null) { - convertedName = toBlobNameString(blobItemInternal.getName()); - } - - return convertedName; - } - - /** - * Set the name property: The name property. - * - * @param name the name value to set. - * @return the BlobItem object itself. - */ - public BlobItem setName(String name) { - convertedName = name; - blobItemInternal.setName(new BlobName().setContent(name)); - return this; - } - - /** - * Get the deleted property: The deleted property. - * - * @return the deleted value. - */ - public boolean isDeleted() { - return blobItemInternal.isDeleted(); - } - - /** - * Set the deleted property: The deleted property. - * - * @param deleted the deleted value to set. - * @return the BlobItem object itself. - */ - public BlobItem setDeleted(boolean deleted) { - blobItemInternal.setDeleted(deleted); - return this; - } - - /** - * Get the snapshot property: The snapshot property. - * - * @return the snapshot value. - */ - public String getSnapshot() { - return blobItemInternal.getSnapshot(); - } - - /** - * Set the snapshot property: The snapshot property. - * - * @param snapshot the snapshot value to set. - * @return the BlobItem object itself. - */ - public BlobItem setSnapshot(String snapshot) { - blobItemInternal.setSnapshot(snapshot); - return this; - } - - /** - * Get the properties property: The properties property. - * - * @return the properties value. - */ - public BlobItemProperties getProperties() { - if (convertedProperties == null) { - convertedProperties = BlobItemPropertiesConstructorProxy.create(blobItemInternal.getProperties()); - } - - return convertedProperties; - } - - /** - * Set the properties property: The properties property. - * - * @param properties the properties value to set. - * @return the BlobItem object itself. - */ - public BlobItem setProperties(BlobItemProperties properties) { - this.convertedProperties = properties; - blobItemInternal.setProperties(BlobItemPropertiesConstructorProxy.getInternalProperties(properties)); - - return this; - } - - /** - * Get the metadata property: The metadata property. - * - * @return the metadata value. - */ - public Map getMetadata() { - return blobItemInternal.getMetadata(); - } - - /** - * Set the metadata property: The metadata property. - * - * @param metadata the metadata value to set. - * @return the BlobItem object itself. - */ - public BlobItem setMetadata(Map metadata) { - blobItemInternal.setMetadata(metadata); - return this; - } - - /** - * Get the tags property: The tags property. - * - * @return the metadata value. - */ - public Map getTags() { - if (convertedTags == null) { - convertedTags = tagMapFromBlobTags(blobItemInternal.getBlobTags()); - } - - return convertedTags; - } - - /** - * Set the tags property: The tags property. - * - * @param tags the tags value to set. - * @return the BlobItem object itself. - */ - public BlobItem setTags(Map tags) { - convertedTags = tags; - blobItemInternal.setBlobTags(toBlobTags(tags)); - - return this; - } - - /** - * Get the versionId property: The versionId property. - * - * @return the versionId value. - */ - public String getVersionId() { - return blobItemInternal.getVersionId(); - } - - /** - * Set the versionId property: The versionId property. - * - * @param versionId the versionId value to set. - * @return the BlobItem object itself. - */ - public BlobItem setVersionId(String versionId) { - blobItemInternal.setVersionId(versionId); - return this; - } - - /** - * Get the isCurrentVersion property: The isCurrentVersion property. - * - * @return the isCurrentVersion value. - */ - public Boolean isCurrentVersion() { - return blobItemInternal.isCurrentVersion(); - } - - /** - * Set the isCurrentVersion property: The isCurrentVersion property. - * - * @param isCurrentVersion the isCurrentVersion value to set. - * @return the BlobItem object itself. - */ - public BlobItem setCurrentVersion(Boolean isCurrentVersion) { - blobItemInternal.setIsCurrentVersion(isCurrentVersion); - return this; - } - - /** - * Get the objectReplicationSourcePolicies property: The - * objectReplicationSourcePolicies property. - * - * @return the objectReplicationSourcePolicies value. - */ - public List getObjectReplicationSourcePolicies() { - if (convertedObjectReplicationSourcePolicies == null) { - convertedObjectReplicationSourcePolicies - = transformObjectReplicationMetadata(blobItemInternal.getObjectReplicationMetadata()); - } - - return convertedObjectReplicationSourcePolicies; - } - - /** - * Set the objectReplicationSourcePolicies property: The - * objectReplicationSourcePolicies property. - * - * @param objectReplicationSourcePolicies the objectReplicationSourcePolicies value - * to set. - * @return the BlobItem object itself. - */ - public BlobItem setObjectReplicationSourcePolicies(List objectReplicationSourcePolicies) { - convertedObjectReplicationSourcePolicies = objectReplicationSourcePolicies; - blobItemInternal.setObjectReplicationMetadata(toObjectReplicationMetadata(objectReplicationSourcePolicies)); - - return this; - } - - /** - * Get the hasVersionsOnly property: The HasVersionsOnly property. - * - * @return the hasVersionsOnly value. - */ - public Boolean hasVersionsOnly() { - return blobItemInternal.isHasVersionsOnly(); - } - - /** - * Set the hasVersionsOnly property: The HasVersionsOnly property. - * - * @param hasVersionsOnly the hasVersionsOnly value to set. - * @return the BlobItemInternal object itself. - */ - public BlobItem setHasVersionsOnly(Boolean hasVersionsOnly) { - blobItemInternal.setHasVersionsOnly(hasVersionsOnly); - return this; - } - - /** - * Get the isPrefix property: If blobs are named to mimic a directory hierarchy (i.e. path elements separated by a - * delimiter), this property may be used to determine if the {@code BlobItem} is a virtual directory. - * - * @return the isPrefix value. - */ - public Boolean isPrefix() { - return blobItemInternal.isPrefix() != null && blobItemInternal.isPrefix(); - } - - /** - * Set the isPrefix property: The isPrefix property. - * - * @param isPrefix the isPrefix value to set. - * @return the BlobItem object itself. - */ - public BlobItem setIsPrefix(Boolean isPrefix) { - blobItemInternal.setIsPrefix(isPrefix); - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemInternal.java new file mode 100644 index 000000000000..b37ba7921c24 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemInternal.java @@ -0,0 +1,277 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An Azure Storage Blob. + */ +@Immutable +public final class BlobItemInternal implements JsonSerializable { + /* + * The name of the blob. + */ + @Generated + private final BlobName name; + + /* + * Whether the blob is deleted. + */ + @Generated + private final boolean deleted; + + /* + * The snapshot of the blob. + */ + @Generated + private final String snapshot; + + /* + * The version id of the blob. + */ + @Generated + private String versionId; + + /* + * Whether the blob is the current version. + */ + @Generated + private Boolean isCurrentVersion; + + /* + * The properties of the blob. + */ + @Generated + private final BlobPropertiesInternal properties; + + /* + * The metadata of the blob. + */ + @Generated + private BlobMetadata metadata; + + /* + * The tags of the blob. + */ + @Generated + private BlobTags blobTags; + + /* + * The object replication metadata of the blob. + */ + @Generated + private ObjectReplicationMetadata objectReplicationMetadata; + + /* + * Whether the blog has versions only. + */ + @Generated + private Boolean hasVersionsOnly; + + /** + * Creates an instance of BlobItemInternal class. + * + * @param name the name value to set. + * @param deleted the deleted value to set. + * @param snapshot the snapshot value to set. + * @param properties the properties value to set. + */ + @Generated + private BlobItemInternal(BlobName name, boolean deleted, String snapshot, BlobPropertiesInternal properties) { + this.name = name; + this.deleted = deleted; + this.snapshot = snapshot; + this.properties = properties; + } + + /** + * Get the name property: The name of the blob. + * + * @return the name value. + */ + @Generated + public BlobName getName() { + return this.name; + } + + /** + * Get the deleted property: Whether the blob is deleted. + * + * @return the deleted value. + */ + @Generated + public boolean isDeleted() { + return this.deleted; + } + + /** + * Get the snapshot property: The snapshot of the blob. + * + * @return the snapshot value. + */ + @Generated + public String getSnapshot() { + return this.snapshot; + } + + /** + * Get the versionId property: The version id of the blob. + * + * @return the versionId value. + */ + @Generated + public String getVersionId() { + return this.versionId; + } + + /** + * Get the isCurrentVersion property: Whether the blob is the current version. + * + * @return the isCurrentVersion value. + */ + @Generated + public Boolean isCurrentVersion() { + return this.isCurrentVersion; + } + + /** + * Get the properties property: The properties of the blob. + * + * @return the properties value. + */ + @Generated + public BlobPropertiesInternal getProperties() { + return this.properties; + } + + /** + * Get the metadata property: The metadata of the blob. + * + * @return the metadata value. + */ + @Generated + public BlobMetadata getMetadata() { + return this.metadata; + } + + /** + * Get the blobTags property: The tags of the blob. + * + * @return the blobTags value. + */ + @Generated + public BlobTags getBlobTags() { + return this.blobTags; + } + + /** + * Get the objectReplicationMetadata property: The object replication metadata of the blob. + * + * @return the objectReplicationMetadata value. + */ + @Generated + public ObjectReplicationMetadata getObjectReplicationMetadata() { + return this.objectReplicationMetadata; + } + + /** + * Get the hasVersionsOnly property: Whether the blog has versions only. + * + * @return the hasVersionsOnly value. + */ + @Generated + public Boolean isHasVersionsOnly() { + return this.hasVersionsOnly; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("name", this.name); + jsonWriter.writeBooleanField("deleted", this.deleted); + jsonWriter.writeStringField("snapshot", this.snapshot); + jsonWriter.writeJsonField("properties", this.properties); + jsonWriter.writeStringField("versionId", this.versionId); + jsonWriter.writeBooleanField("isCurrentVersion", this.isCurrentVersion); + jsonWriter.writeJsonField("metadata", this.metadata); + jsonWriter.writeJsonField("blobTags", this.blobTags); + jsonWriter.writeJsonField("objectReplicationMetadata", this.objectReplicationMetadata); + jsonWriter.writeBooleanField("hasVersionsOnly", this.hasVersionsOnly); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobItemInternal from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobItemInternal if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobItemInternal. + */ + @Generated + public static BlobItemInternal fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BlobName name = null; + boolean deleted = false; + String snapshot = null; + BlobPropertiesInternal properties = null; + String versionId = null; + Boolean isCurrentVersion = null; + BlobMetadata metadata = null; + BlobTags blobTags = null; + ObjectReplicationMetadata objectReplicationMetadata = null; + Boolean hasVersionsOnly = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = BlobName.fromJson(reader); + } else if ("deleted".equals(fieldName)) { + deleted = reader.getBoolean(); + } else if ("snapshot".equals(fieldName)) { + snapshot = reader.getString(); + } else if ("properties".equals(fieldName)) { + properties = BlobPropertiesInternal.fromJson(reader); + } else if ("versionId".equals(fieldName)) { + versionId = reader.getString(); + } else if ("isCurrentVersion".equals(fieldName)) { + isCurrentVersion = reader.getNullable(JsonReader::getBoolean); + } else if ("metadata".equals(fieldName)) { + metadata = BlobMetadata.fromJson(reader); + } else if ("blobTags".equals(fieldName)) { + blobTags = BlobTags.fromJson(reader); + } else if ("objectReplicationMetadata".equals(fieldName)) { + objectReplicationMetadata = ObjectReplicationMetadata.fromJson(reader); + } else if ("hasVersionsOnly".equals(fieldName)) { + hasVersionsOnly = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + BlobItemInternal deserializedBlobItemInternal = new BlobItemInternal(name, deleted, snapshot, properties); + deserializedBlobItemInternal.versionId = versionId; + deserializedBlobItemInternal.isCurrentVersion = isCurrentVersion; + deserializedBlobItemInternal.metadata = metadata; + deserializedBlobItemInternal.blobTags = blobTags; + deserializedBlobItemInternal.objectReplicationMetadata = objectReplicationMetadata; + deserializedBlobItemInternal.hasVersionsOnly = hasVersionsOnly; + + return deserializedBlobItemInternal; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java deleted file mode 100644 index 68a6247e304f..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java +++ /dev/null @@ -1,847 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.implementation.accesshelpers.BlobItemPropertiesConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobItemPropertiesInternal; - -import java.time.OffsetDateTime; - -/** - * Properties of a blob. - */ -@Fluent -public final class BlobItemProperties { - private final BlobItemPropertiesInternal internalProperties; - - static { - BlobItemPropertiesConstructorProxy - .setAccessor(new BlobItemPropertiesConstructorProxy.BlobItemPropertiesConstructorAccessor() { - @Override - public BlobItemProperties create(BlobItemPropertiesInternal internalProperties) { - return new BlobItemProperties(internalProperties); - } - - @Override - public BlobItemPropertiesInternal getInternalProperties(BlobItemProperties properties) { - return properties.internalProperties; - } - }); - } - - private BlobItemProperties(BlobItemPropertiesInternal internalProperties) { - this.internalProperties = internalProperties; - } - - /** - * Constructs a new instance of {@link BlobItemProperties}. - */ - public BlobItemProperties() { - // Added to maintain backwards compatibility as the private constructor removes the implicit no args - // constructor. - this.internalProperties = new BlobItemPropertiesInternal(); - } - - private BlobImmutabilityPolicy convertedImmutabilityPolicy; - - /** - * Get the creationTime property: The creationTime property. - * - * @return the creationTime value. - */ - public OffsetDateTime getCreationTime() { - return internalProperties.getCreationTime(); - } - - /** - * Set the creationTime property: The creationTime property. - * - * @param creationTime the creationTime value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setCreationTime(OffsetDateTime creationTime) { - internalProperties.setCreationTime(creationTime); - return this; - } - - /** - * Get the lastModified property: The lastModified property. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - return internalProperties.getLastModified(); - } - - /** - * Set the lastModified property: The lastModified property. - * - * @param lastModified the lastModified value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setLastModified(OffsetDateTime lastModified) { - internalProperties.setLastModified(lastModified); - return this; - } - - /** - * Get the eTag property: The eTag property. - * - * @return the eTag value. - */ - public String getETag() { - return internalProperties.getETag(); - } - - /** - * Set the eTag property: The eTag property. - * - * @param eTag the eTag value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setETag(String eTag) { - internalProperties.setETag(eTag); - return this; - } - - /** - * Get the contentLength property: Size in bytes. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return internalProperties.getContentLength(); - } - - /** - * Set the contentLength property: Size in bytes. - * - * @param contentLength the contentLength value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setContentLength(Long contentLength) { - internalProperties.setContentLength(contentLength); - return this; - } - - /** - * Get the contentType property: The contentType property. - * - * @return the contentType value. - */ - public String getContentType() { - return internalProperties.getContentType(); - } - - /** - * Set the contentType property: The contentType property. - * - * @param contentType the contentType value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setContentType(String contentType) { - internalProperties.setContentType(contentType); - return this; - } - - /** - * Get the contentEncoding property: The contentEncoding property. - * - * @return the contentEncoding value. - */ - public String getContentEncoding() { - return internalProperties.getContentEncoding(); - } - - /** - * Set the contentEncoding property: The contentEncoding property. - * - * @param contentEncoding the contentEncoding value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setContentEncoding(String contentEncoding) { - internalProperties.setContentEncoding(contentEncoding); - return this; - } - - /** - * Get the contentLanguage property: The contentLanguage property. - * - * @return the contentLanguage value. - */ - public String getContentLanguage() { - return internalProperties.getContentLanguage(); - } - - /** - * Set the contentLanguage property: The contentLanguage property. - * - * @param contentLanguage the contentLanguage value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setContentLanguage(String contentLanguage) { - internalProperties.setContentLanguage(contentLanguage); - return this; - } - - /** - * Get the contentMd5 property: The contentMd5 property. - * - * @return the contentMd5 value. - */ - public byte[] getContentMd5() { - return internalProperties.getContentMd5(); - } - - /** - * Set the contentMd5 property: The contentMd5 property. - * - * @param contentMd5 the contentMd5 value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setContentMd5(byte[] contentMd5) { - internalProperties.setContentMd5(contentMd5); - return this; - } - - /** - * Get the contentDisposition property: The contentDisposition property. - * - * @return the contentDisposition value. - */ - public String getContentDisposition() { - return internalProperties.getContentDisposition(); - } - - /** - * Set the contentDisposition property: The contentDisposition property. - * - * @param contentDisposition the contentDisposition value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setContentDisposition(String contentDisposition) { - internalProperties.setContentDisposition(contentDisposition); - return this; - } - - /** - * Get the cacheControl property: The cacheControl property. - * - * @return the cacheControl value. - */ - public String getCacheControl() { - return internalProperties.getCacheControl(); - } - - /** - * Set the cacheControl property: The cacheControl property. - * - * @param cacheControl the cacheControl value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setCacheControl(String cacheControl) { - internalProperties.setCacheControl(cacheControl); - return this; - } - - /** - * Get the blobSequenceNumber property: The blobSequenceNumber property. - * - * @return the blobSequenceNumber value. - */ - public Long getBlobSequenceNumber() { - return internalProperties.getBlobSequenceNumber(); - } - - /** - * Set the blobSequenceNumber property: The blobSequenceNumber property. - * - * @param blobSequenceNumber the blobSequenceNumber value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setBlobSequenceNumber(Long blobSequenceNumber) { - internalProperties.setBlobSequenceNumber(blobSequenceNumber); - return this; - } - - /** - * Get the blobType property: Possible values include: 'BlockBlob', 'PageBlob', 'AppendBlob'. - * - * @return the blobType value. - */ - public BlobType getBlobType() { - return internalProperties.getBlobType(); - } - - /** - * Set the blobType property: Possible values include: 'BlockBlob', 'PageBlob', 'AppendBlob'. - * - * @param blobType the blobType value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setBlobType(BlobType blobType) { - internalProperties.setBlobType(blobType); - return this; - } - - /** - * Get the leaseStatus property: Possible values include: 'locked', 'unlocked'. - * - * @return the leaseStatus value. - */ - public LeaseStatusType getLeaseStatus() { - return internalProperties.getLeaseStatus(); - } - - /** - * Set the leaseStatus property: Possible values include: 'locked', 'unlocked'. - * - * @param leaseStatus the leaseStatus value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setLeaseStatus(LeaseStatusType leaseStatus) { - internalProperties.setLeaseStatus(leaseStatus); - return this; - } - - /** - * Get the leaseState property: Possible values include: 'available', 'leased', 'expired', 'breaking', 'broken'. - * - * @return the leaseState value. - */ - public LeaseStateType getLeaseState() { - return internalProperties.getLeaseState(); - } - - /** - * Set the leaseState property: Possible values include: 'available', 'leased', 'expired', 'breaking', 'broken'. - * - * @param leaseState the leaseState value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setLeaseState(LeaseStateType leaseState) { - internalProperties.setLeaseState(leaseState); - return this; - } - - /** - * Get the leaseDuration property: Possible values include: 'infinite', 'fixed'. - * - * @return the leaseDuration value. - */ - public LeaseDurationType getLeaseDuration() { - return internalProperties.getLeaseDuration(); - } - - /** - * Set the leaseDuration property: Possible values include: 'infinite', 'fixed'. - * - * @param leaseDuration the leaseDuration value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setLeaseDuration(LeaseDurationType leaseDuration) { - internalProperties.setLeaseDuration(leaseDuration); - return this; - } - - /** - * Get the copyId property: The copyId property. - * - * @return the copyId value. - */ - public String getCopyId() { - return internalProperties.getCopyId(); - } - - /** - * Set the copyId property: The copyId property. - * - * @param copyId the copyId value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setCopyId(String copyId) { - internalProperties.setCopyId(copyId); - return this; - } - - /** - * Get the copyStatus property: Possible values include: 'pending', 'success', 'aborted', 'failed'. - * - * @return the copyStatus value. - */ - public CopyStatusType getCopyStatus() { - return internalProperties.getCopyStatus(); - } - - /** - * Set the copyStatus property: Possible values include: 'pending', 'success', 'aborted', 'failed'. - * - * @param copyStatus the copyStatus value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setCopyStatus(CopyStatusType copyStatus) { - internalProperties.setCopyStatus(copyStatus); - return this; - } - - /** - * Get the copySource property: The copySource property. - * - * @return the copySource value. - */ - public String getCopySource() { - return internalProperties.getCopySource(); - } - - /** - * Set the copySource property: The copySource property. - * - * @param copySource the copySource value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setCopySource(String copySource) { - internalProperties.setCopySource(copySource); - return this; - } - - /** - * Get the copyProgress property: The copyProgress property. - * - * @return the copyProgress value. - */ - public String getCopyProgress() { - return internalProperties.getCopyProgress(); - } - - /** - * Set the copyProgress property: The copyProgress property. - * - * @param copyProgress the copyProgress value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setCopyProgress(String copyProgress) { - internalProperties.setCopyProgress(copyProgress); - return this; - } - - /** - * Get the copyCompletionTime property: The copyCompletionTime property. - * - * @return the copyCompletionTime value. - */ - public OffsetDateTime getCopyCompletionTime() { - return internalProperties.getCopyCompletionTime(); - } - - /** - * Set the copyCompletionTime property: The copyCompletionTime property. - * - * @param copyCompletionTime the copyCompletionTime value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setCopyCompletionTime(OffsetDateTime copyCompletionTime) { - internalProperties.setCopyCompletionTime(copyCompletionTime); - return this; - } - - /** - * Get the copyStatusDescription property: The copyStatusDescription property. - * - * @return the copyStatusDescription value. - */ - public String getCopyStatusDescription() { - return internalProperties.getCopyStatusDescription(); - } - - /** - * Set the copyStatusDescription property: The copyStatusDescription property. - * - * @param copyStatusDescription the copyStatusDescription value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setCopyStatusDescription(String copyStatusDescription) { - internalProperties.setCopyStatusDescription(copyStatusDescription); - return this; - } - - /** - * Get the serverEncrypted property: The serverEncrypted property. - * - * @return the serverEncrypted value. - */ - public Boolean isServerEncrypted() { - return internalProperties.isServerEncrypted(); - } - - /** - * Set the serverEncrypted property: The serverEncrypted property. - * - * @param serverEncrypted the serverEncrypted value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setServerEncrypted(Boolean serverEncrypted) { - internalProperties.setServerEncrypted(serverEncrypted); - return this; - } - - /** - * Get the incrementalCopy property: The incrementalCopy property. - * - * @return the incrementalCopy value. - */ - public Boolean isIncrementalCopy() { - return internalProperties.isIncrementalCopy(); - } - - /** - * Set the incrementalCopy property: The incrementalCopy property. - * - * @param incrementalCopy the incrementalCopy value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setIncrementalCopy(Boolean incrementalCopy) { - internalProperties.setIncrementalCopy(incrementalCopy); - return this; - } - - /** - * Get the destinationSnapshot property: The destinationSnapshot property. - * - * @return the destinationSnapshot value. - */ - public String getDestinationSnapshot() { - return internalProperties.getDestinationSnapshot(); - } - - /** - * Set the destinationSnapshot property: The destinationSnapshot property. - * - * @param destinationSnapshot the destinationSnapshot value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setDestinationSnapshot(String destinationSnapshot) { - internalProperties.setDestinationSnapshot(destinationSnapshot); - return this; - } - - /** - * Get the deletedTime property: The deletedTime property. - * - * @return the deletedTime value. - */ - public OffsetDateTime getDeletedTime() { - return internalProperties.getDeletedTime(); - } - - /** - * Set the deletedTime property: The deletedTime property. - * - * @param deletedTime the deletedTime value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setDeletedTime(OffsetDateTime deletedTime) { - internalProperties.setDeletedTime(deletedTime); - return this; - } - - /** - * Get the remainingRetentionDays property: The remainingRetentionDays property. - * - * @return the remainingRetentionDays value. - */ - public Integer getRemainingRetentionDays() { - return internalProperties.getRemainingRetentionDays(); - } - - /** - * Set the remainingRetentionDays property: The remainingRetentionDays property. - * - * @param remainingRetentionDays the remainingRetentionDays value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setRemainingRetentionDays(Integer remainingRetentionDays) { - internalProperties.setRemainingRetentionDays(remainingRetentionDays); - return this; - } - - /** - * Get the accessTier property: Possible values include: 'P4', 'P6', 'P10', 'P15', 'P20', 'P30', 'P40', 'P50', - * 'P60', 'P70', 'P80', 'Hot', 'Cool', 'Archive'. - * - * @return the accessTier value. - */ - public AccessTier getAccessTier() { - return internalProperties.getAccessTier(); - } - - /** - * Set the accessTier property: Possible values include: 'P4', 'P6', 'P10', 'P15', 'P20', 'P30', 'P40', 'P50', - * 'P60', 'P70', 'P80', 'Hot', 'Cool', 'Archive'. - * - * @param accessTier the accessTier value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setAccessTier(AccessTier accessTier) { - internalProperties.setAccessTier(accessTier); - return this; - } - - /** - * Get the accessTierInferred property: The accessTierInferred property. - * - * @return the accessTierInferred value. - */ - public Boolean isAccessTierInferred() { - return internalProperties.isAccessTierInferred(); - } - - /** - * Set the accessTierInferred property: The accessTierInferred property. - * - * @param accessTierInferred the accessTierInferred value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setAccessTierInferred(Boolean accessTierInferred) { - internalProperties.setAccessTierInferred(accessTierInferred); - return this; - } - - /** - * Get the archiveStatus property: Possible values include: 'rehydrate-pending-to-hot', - * 'rehydrate-pending-to-cool'. - * - * @return the archiveStatus value. - */ - public ArchiveStatus getArchiveStatus() { - return internalProperties.getArchiveStatus(); - } - - /** - * Set the archiveStatus property: Possible values include: 'rehydrate-pending-to-hot', - * 'rehydrate-pending-to-cool'. - * - * @param archiveStatus the archiveStatus value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setArchiveStatus(ArchiveStatus archiveStatus) { - internalProperties.setArchiveStatus(archiveStatus); - return this; - } - - /** - * Get the customerProvidedKeySha256 property: The customerProvidedKeySha256 property. - * - * @return the customerProvidedKeySha256 value. - */ - public String getCustomerProvidedKeySha256() { - return internalProperties.getCustomerProvidedKeySha256(); - } - - /** - * Set the customerProvidedKeySha256 property: The customerProvidedKeySha256 property. - * - * @param customerProvidedKeySha256 the customerProvidedKeySha256 value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setCustomerProvidedKeySha256(String customerProvidedKeySha256) { - internalProperties.setCustomerProvidedKeySha256(customerProvidedKeySha256); - return this; - } - - /** - * Get the encryptionScope property: The name of the encryption scope under which the blob is encrypted. - * - * @return the encryptionScope value. - */ - public String getEncryptionScope() { - return internalProperties.getEncryptionScope(); - } - - /** - * Set the encryptionScope property: The name of the encryption scope under which the blob is encrypted. - * - * @param encryptionScope the encryptionScope value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setEncryptionScope(String encryptionScope) { - internalProperties.setEncryptionScope(encryptionScope); - return this; - } - - /** - * Get the accessTierChangeTime property: The accessTierChangeTime property. - * - * @return the accessTierChangeTime value. - */ - public OffsetDateTime getAccessTierChangeTime() { - return internalProperties.getAccessTierChangeTime(); - } - - /** - * Set the accessTierChangeTime property: The accessTierChangeTime property. - * - * @param accessTierChangeTime the accessTierChangeTime value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setAccessTierChangeTime(OffsetDateTime accessTierChangeTime) { - internalProperties.setAccessTierChangeTime(accessTierChangeTime); - return this; - } - - /** - * Get the tagCount property: The tagCount property. - * - * @return the tagCount value. - */ - public Integer getTagCount() { - return internalProperties.getTagCount(); - } - - /** - * Set the tagCount property: The tagCount property. - * - * @param tagCount the tagCount value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setTagCount(Integer tagCount) { - internalProperties.setTagCount(tagCount); - return this; - } - - /** - * Get the rehydratePriority property: Possible values include: 'High', 'Standard'. - * - * @return the rehydratePriority value. - */ - public RehydratePriority getRehydratePriority() { - return internalProperties.getRehydratePriority(); - } - - /** - * Set the rehydratePriority property: Possible values include: 'High', 'Standard'. - * - * @param rehydratePriority the rehydratePriority value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setRehydratePriority(RehydratePriority rehydratePriority) { - internalProperties.setRehydratePriority(rehydratePriority); - return this; - } - - /** - * Get the sealed property: The sealed property. - * - * @return Whether or not the blob is sealed (marked as read only). This is only applicable for Append blobs. - */ - public Boolean isSealed() { - return internalProperties.isSealed(); - } - - /** - * Set the sealed property: The sealed property. - * - * @param sealed Whether or not the blob is sealed (marked as read only). This is only applicable for Append - * blobs. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setSealed(Boolean sealed) { - internalProperties.setIsSealed(sealed); - return this; - } - - /** - * Get the lastAccessedTime property: The lastAccessedTime property. - * - * @return the lastAccessedTime value. - */ - public OffsetDateTime getLastAccessedTime() { - return internalProperties.getLastAccessedOn(); - } - - /** - * Set the lastAccessedTime property: The lastAccessedTime property. - * - * @param lastAccessedTime the lastAccessedTime value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setLastAccessedTime(OffsetDateTime lastAccessedTime) { - internalProperties.setLastAccessedOn(lastAccessedTime); - return this; - } - - /** - * Get the expiryTime property: The Expiry-Time property. - * - * @return the expiryTime value. - */ - public OffsetDateTime getExpiryTime() { - return internalProperties.getExpiresOn(); - } - - /** - * Set the expiryTime property: The Expiry-Time property. - * - * @param expiryTime the expiryTime value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setExpiryTime(OffsetDateTime expiryTime) { - internalProperties.setExpiresOn(expiryTime); - return this; - } - - /** - * Get the immutabilityPolicy property: The ImmutabilityPolicyUntilDate and ImmutabilityPolicyMode property. - * - * @return the immutabilityPolicy value. - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - if (convertedImmutabilityPolicy == null) { - convertedImmutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(internalProperties.getImmutabilityPolicyExpiresOn()) - .setPolicyMode(internalProperties.getImmutabilityPolicyMode()); - } - - return convertedImmutabilityPolicy; - } - - /** - * Set the immutabilityPolicy property: The ImmutabilityPolicyUntilDate and ImmutabilityPolicyMode property. - * - * @param immutabilityPolicy the immutabilityPolicy value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - this.convertedImmutabilityPolicy = immutabilityPolicy; - if (immutabilityPolicy != null) { - internalProperties.setImmutabilityPolicyExpiresOn(immutabilityPolicy.getExpiryTime()); - internalProperties.setImmutabilityPolicyMode(immutabilityPolicy.getPolicyMode()); - } else { - internalProperties.setImmutabilityPolicyExpiresOn(null); - internalProperties.setImmutabilityPolicyMode(null); - } - - return this; - } - - /** - * Get the hasLegalHold property: The LegalHold property. - * - * @return the hasLegalHold value. - */ - public Boolean hasLegalHold() { - return internalProperties.isLegalHold(); - } - - /** - * Set the hasLegalHold property: The LegalHold property. - * - * @param hasLegalHold the hasLegalHold value to set. - * @return the BlobItemProperties object itself. - */ - public BlobItemProperties setHasLegalHold(Boolean hasLegalHold) { - internalProperties.setLegalHold(hasLegalHold); - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLeaseRequestConditions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLeaseRequestConditions.java deleted file mode 100644 index 5d85b00936c9..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLeaseRequestConditions.java +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.http.RequestConditions; - -import java.time.OffsetDateTime; - -/** - * This class contains values which will restrict the successful operation of a variety of lease requests to the - * conditions present. These conditions are entirely optional. The entire object or any of its properties may be set to - * null when passed to a method to indicate that those conditions are not desired. Please refer to the type of each - * field for more information on those particular access conditions. - */ -public class BlobLeaseRequestConditions extends RequestConditions { - private String tagsConditions; - - /** - * Creates a new instance of {@link BlobLeaseRequestConditions}. - */ - public BlobLeaseRequestConditions() { - } - - /** - * Optionally limit requests to resources that match the passed ETag. - * - * @param ifMatch ETag that resources must match. - * @return The updated BlobLeaseRequestConditions object. - */ - @Override - public BlobLeaseRequestConditions setIfMatch(String ifMatch) { - super.setIfMatch(ifMatch); - return this; - } - - /** - * Optionally limit requests to resources that do not match the passed ETag. - * - * @param ifNoneMatch ETag that resources must not match. - * @return The updated BlobLeaseRequestConditions object. - */ - @Override - public BlobLeaseRequestConditions setIfNoneMatch(String ifNoneMatch) { - super.setIfNoneMatch(ifNoneMatch); - return this; - } - - /** - * Optionally limit requests to resources that have only been modified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifModifiedSince The datetime that resources must have been modified since. - * @return The updated BlobLeaseRequestConditions object. - */ - @Override - public BlobLeaseRequestConditions setIfModifiedSince(OffsetDateTime ifModifiedSince) { - super.setIfModifiedSince(ifModifiedSince); - return this; - } - - /** - * Optionally limit requests to resources that have remained unmodified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifUnmodifiedSince The datetime that resources must have remained unmodified since. - * @return The updated BlobLeaseRequestConditions object. - */ - @Override - public BlobLeaseRequestConditions setIfUnmodifiedSince(OffsetDateTime ifUnmodifiedSince) { - super.setIfUnmodifiedSince(ifUnmodifiedSince); - return this; - } - - /** - * Gets the SQL statement that apply to the tags of the blob. - * - * @return The SQL statement that apply to the tags of the blob. - */ - public String getTagsConditions() { - return tagsConditions; - } - - /** - * Optionally applies the SQL statement to the tags of the blob. - * - * @param tagsConditions The SQL statement that apply to the tags of the blob. - * @return The updated BlobLeaseRequestConditions object. - */ - public BlobLeaseRequestConditions setTagsConditions(String tagsConditions) { - this.tagsConditions = tagsConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLegalHoldResult.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLegalHoldResult.java deleted file mode 100644 index 1f0dfcaaad7c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLegalHoldResult.java +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -/** - * The blob legal hold result. - */ -public interface BlobLegalHoldResult { - /** - * Gets whether a legal hold is enabled on the blob. - * - * @return whether a legal hold is enabled on the blob. - */ - boolean hasLegalHold(); -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobListDetails.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobListDetails.java deleted file mode 100644 index 060467464050..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobListDetails.java +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.BlobContainerClient; - -import java.util.ArrayList; - -/** - * This type allows users to specify additional information the service should return with each blob when listing blobs - * in a container (via a {@link BlobContainerClient} object). This type is immutable to ensure thread-safety of - * requests, so changing the details for a different listing operation requires construction of a new object. Null may - * be passed if none of the options are desirable. - */ -@Fluent -public final class BlobListDetails { - private boolean retrieveCopy; - private boolean retrieveMetadata; - private boolean retrieveTags; - private boolean retrieveSnapshots; - private boolean retrieveUncommittedBlobs; - private boolean retrieveDeletedBlobs; - private boolean retrieveVersions; - private boolean retrieveDeletedWithVersions; - private boolean retrieveImmutabilityPolicy; - private boolean retrieveLegalHold; - - /** - * Constructs an unpopulated {@link BlobListDetails}. - */ - public BlobListDetails() { - } - - /** - * Whether blob metadata related to any current or previous Copy Blob operation should be included in the response. - * - * @return a flag indicating if copy information will be returned in the listing - */ - public boolean getRetrieveCopy() { - return retrieveCopy; - } - - /** - * Whether blob metadata related to any current or previous Copy Blob operation should be included in the response. - * - * @param retrieveCopy Flag indicating whether copy information should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveCopy(boolean retrieveCopy) { - this.retrieveCopy = retrieveCopy; - return this; - } - - /** - * Whether blob metadata should be returned. - * - * @return a flag indicating if metadata will be returned in the listing - */ - public boolean getRetrieveMetadata() { - return retrieveMetadata; - } - - /** - * Whether blob metadata should be returned. - * - * @param retrieveMetadata Flag indicating whether metadata should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveMetadata(boolean retrieveMetadata) { - this.retrieveMetadata = retrieveMetadata; - return this; - } - - /** - * Whether blob tags should be returned. - * - * @return a flag indicating if tags will be returned in the listing - */ - public boolean getRetrieveTags() { - return retrieveTags; - } - - /** - * Whether blob tags should be returned. - * - * @param retrieveTags Flag indicating whether tags should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveTags(boolean retrieveTags) { - this.retrieveTags = retrieveTags; - return this; - } - - /** - * Whether snapshots should be returned. Snapshots are listed from oldest to newest. - * - * @return a flag indicating if snapshots will be returned in the listing - */ - public boolean getRetrieveSnapshots() { - return retrieveSnapshots; - } - - /** - * Whether snapshots should be returned. Snapshots are listed from oldest to newest. - * - * @param retrieveSnapshots Flag indicating whether snapshots should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveSnapshots(boolean retrieveSnapshots) { - this.retrieveSnapshots = retrieveSnapshots; - return this; - } - - /** - * Whether versions should be returned. Versions are listed from oldest to newest. - * - * @return a flag indicating if versions will be returned in the listing - */ - public boolean getRetrieveVersions() { - return retrieveVersions; - } - - /** - * Whether versions should be returned. Versions are listed from oldest to newest. - * - * @param retrieveVersions Flag indicating whether versions should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveVersions(boolean retrieveVersions) { - this.retrieveVersions = retrieveVersions; - return this; - } - - /** - * Whether blobs for which blocks have been uploaded, but which have not been committed using Put Block List, should - * be included in the response. - * - * @return a flag indicating if uncommitted blobs will be returned in the listing - */ - public boolean getRetrieveUncommittedBlobs() { - return retrieveUncommittedBlobs; - } - - /** - * Whether blobs for which blocks have been uploaded, but which have not been committed using Put Block List, should - * be included in the response. - * - * @param retrieveUncommittedBlobs Flag indicating whether uncommitted blobs should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveUncommittedBlobs(boolean retrieveUncommittedBlobs) { - this.retrieveUncommittedBlobs = retrieveUncommittedBlobs; - return this; - } - - /** - * Whether blobs which have been soft deleted should be returned. - * - * @return a flag indicating if deleted blobs will be returned in the listing - */ - public boolean getRetrieveDeletedBlobs() { - return retrieveDeletedBlobs; - } - - /** - * Whether blobs which have been soft deleted should be returned. - * - * @param retrieveDeletedBlobs Flag indicating whether deleted blobs should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveDeletedBlobs(boolean retrieveDeletedBlobs) { - this.retrieveDeletedBlobs = retrieveDeletedBlobs; - return this; - } - - /** - * Whether blobs which have been deleted with versioning. - * - * @return a flag indicating if deleted blobs with versioning will be returned in the listing - */ - public boolean getRetrieveDeletedBlobsWithVersions() { - return retrieveDeletedWithVersions; - } - - /** - * Whether blobs which have been deleted with versioning should be returned. - * - * @param retrieveDeletedWithVersions Flag indicating whether deleted blobs with versioning should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveDeletedBlobsWithVersions(boolean retrieveDeletedWithVersions) { - this.retrieveDeletedWithVersions = retrieveDeletedWithVersions; - return this; - } - - /** - * Whether immutability policy for the blob should be returned. - * - * @return a flag indicating if immutability policy for the blob will be returned in the listing - */ - public boolean getRetrieveImmutabilityPolicy() { - return retrieveImmutabilityPolicy; - } - - /** - * Whether immutability policy for the blob should be returned. - * - * @param retrieveImmutabilityPolicy Flag indicating whether immutability policy for the blob should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveImmutabilityPolicy(boolean retrieveImmutabilityPolicy) { - this.retrieveImmutabilityPolicy = retrieveImmutabilityPolicy; - return this; - } - - /** - * Whether legal hold for the blob should be returned. - * - * @return a flag indicating if legal hold for the blob will be returned in the listing - */ - public boolean getRetrieveLegalHold() { - return retrieveLegalHold; - } - - /** - * Whether legal hold for the blob should be returned. - * - * @param retrieveLegalHold Flag indicating whetherlegal hold for the blob should be returned - * @return the updated BlobListDetails object - */ - public BlobListDetails setRetrieveLegalHold(boolean retrieveLegalHold) { - this.retrieveLegalHold = retrieveLegalHold; - return this; - } - - /** - * Gets the list of flags set to true. - * - * @return a list of the flag set to true - */ - public ArrayList toList() { - ArrayList details = new ArrayList<>(); - if (this.retrieveCopy) { - details.add(ListBlobsIncludeItem.COPY); - } - if (this.retrieveDeletedBlobs) { - details.add(ListBlobsIncludeItem.DELETED); - } - if (this.retrieveMetadata) { - details.add(ListBlobsIncludeItem.METADATA); - } - if (this.retrieveTags) { - details.add(ListBlobsIncludeItem.TAGS); - } - if (this.retrieveSnapshots) { - details.add(ListBlobsIncludeItem.SNAPSHOTS); - } - if (this.retrieveUncommittedBlobs) { - details.add(ListBlobsIncludeItem.UNCOMMITTEDBLOBS); - } - if (this.retrieveVersions) { - details.add(ListBlobsIncludeItem.VERSIONS); - } - if (this.retrieveDeletedWithVersions) { - details.add(ListBlobsIncludeItem.DELETED_WITH_VERSIONS); - } - if (this.retrieveImmutabilityPolicy) { - details.add(ListBlobsIncludeItem.IMMUTABILITY_POLICY); - } - if (this.retrieveLegalHold) { - details.add(ListBlobsIncludeItem.LEGAL_HOLD); - } - return details; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobMetadata.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobMetadata.java new file mode 100644 index 000000000000..db256c54b1e7 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobMetadata.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The blob metadata. + */ +@Immutable +public final class BlobMetadata implements JsonSerializable { + /* + * Whether the blob metadata is encrypted. + */ + @Generated + private String encrypted; + + /* + * The blob metadata. + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of BlobMetadata class. + */ + @Generated + private BlobMetadata() { + } + + /** + * Get the encrypted property: Whether the blob metadata is encrypted. + * + * @return the encrypted value. + */ + @Generated + public String getEncrypted() { + return this.encrypted; + } + + /** + * Get the additionalProperties property: The blob metadata. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("encrypted", this.encrypted); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobMetadata from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobMetadata if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BlobMetadata. + */ + @Generated + public static BlobMetadata fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BlobMetadata deserializedBlobMetadata = new BlobMetadata(); + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("encrypted".equals(fieldName)) { + deserializedBlobMetadata.encrypted = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + deserializedBlobMetadata.additionalProperties = additionalProperties; + + return deserializedBlobMetadata; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobMetrics.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobMetrics.java deleted file mode 100644 index 01a83b7f6f16..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobMetrics.java +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * a summary of request statistics grouped by API in hour or minute aggregates for blobs. - */ -@Fluent -public final class BlobMetrics implements XmlSerializable { - /* - * The version of Storage Analytics to configure. - */ - private String version; - - /* - * Indicates whether metrics are enabled for the Blob service. - */ - private boolean enabled; - - /* - * Indicates whether metrics should generate summary statistics for called API operations. - */ - private Boolean includeApis; - - /* - * the retention policy which determines how long the associated data should persist - */ - private BlobRetentionPolicy retentionPolicy; - - /** - * Creates an instance of BlobMetrics class. - */ - public BlobMetrics() { - } - - /** - * Get the version property: The version of Storage Analytics to configure. - * - * @return the version value. - */ - public String getVersion() { - return this.version; - } - - /** - * Set the version property: The version of Storage Analytics to configure. - * - * @param version the version value to set. - * @return the BlobMetrics object itself. - */ - public BlobMetrics setVersion(String version) { - this.version = version; - return this; - } - - /** - * Get the enabled property: Indicates whether metrics are enabled for the Blob service. - * - * @return the enabled value. - */ - public boolean isEnabled() { - return this.enabled; - } - - /** - * Set the enabled property: Indicates whether metrics are enabled for the Blob service. - * - * @param enabled the enabled value to set. - * @return the BlobMetrics object itself. - */ - public BlobMetrics setEnabled(boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Get the includeApis property: Indicates whether metrics should generate summary statistics for called API - * operations. - * - * @return the includeApis value. - */ - public Boolean isIncludeApis() { - return this.includeApis; - } - - /** - * Set the includeApis property: Indicates whether metrics should generate summary statistics for called API - * operations. - * - * @param includeApis the includeApis value to set. - * @return the BlobMetrics object itself. - */ - public BlobMetrics setIncludeApis(Boolean includeApis) { - this.includeApis = includeApis; - return this; - } - - /** - * Get the retentionPolicy property: the retention policy which determines how long the associated data should - * persist. - * - * @return the retentionPolicy value. - */ - public BlobRetentionPolicy getRetentionPolicy() { - return this.retentionPolicy; - } - - /** - * Set the retentionPolicy property: the retention policy which determines how long the associated data should - * persist. - * - * @param retentionPolicy the retentionPolicy value to set. - * @return the BlobMetrics object itself. - */ - public BlobMetrics setRetentionPolicy(BlobRetentionPolicy retentionPolicy) { - this.retentionPolicy = retentionPolicy; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobMetrics" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Version", this.version); - xmlWriter.writeBooleanElement("Enabled", this.enabled); - xmlWriter.writeBooleanElement("IncludeAPIs", this.includeApis); - xmlWriter.writeXml(this.retentionPolicy, "RetentionPolicy"); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobMetrics from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobMetrics if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobMetrics. - */ - public static BlobMetrics fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobMetrics from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobMetrics if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobMetrics. - */ - public static BlobMetrics fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobMetrics" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobMetrics deserializedBlobMetrics = new BlobMetrics(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Version".equals(elementName.getLocalPart())) { - deserializedBlobMetrics.version = reader.getStringElement(); - } else if ("Enabled".equals(elementName.getLocalPart())) { - deserializedBlobMetrics.enabled = reader.getBooleanElement(); - } else if ("IncludeAPIs".equals(elementName.getLocalPart())) { - deserializedBlobMetrics.includeApis = reader.getNullableElement(Boolean::parseBoolean); - } else if ("RetentionPolicy".equals(elementName.getLocalPart())) { - deserializedBlobMetrics.retentionPolicy = BlobRetentionPolicy.fromXml(reader, "RetentionPolicy"); - } else { - reader.skipElement(); - } - } - - return deserializedBlobMetrics; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobName.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobName.java new file mode 100644 index 000000000000..6e7b2ffa9fd7 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobName.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a blob name. + */ +@Immutable +public final class BlobName implements JsonSerializable { + /* + * Whether the blob name is encoded. + */ + @Generated + private final boolean encoded; + + /* + * The blob name. + */ + @Generated + private final String content; + + /** + * Creates an instance of BlobName class. + * + * @param encoded the encoded value to set. + * @param content the content value to set. + */ + @Generated + private BlobName(boolean encoded, String content) { + this.encoded = encoded; + this.content = content; + } + + /** + * Get the encoded property: Whether the blob name is encoded. + * + * @return the encoded value. + */ + @Generated + public boolean isEncoded() { + return this.encoded; + } + + /** + * Get the content property: The blob name. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("encoded", this.encoded); + jsonWriter.writeStringField("content", this.content); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobName from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobName if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobName. + */ + @Generated + public static BlobName fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean encoded = false; + String content = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("encoded".equals(fieldName)) { + encoded = reader.getBoolean(); + } else if ("content".equals(fieldName)) { + content = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new BlobName(encoded, content); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobPrefix.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobPrefix.java index 6ee8ae5579da..cb11e389a0f6 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobPrefix.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobPrefix.java @@ -1,105 +1,83 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** The BlobPrefix model. */ -@Fluent -public final class BlobPrefix implements XmlSerializable { +/** + * Represents a blob prefix. + */ +@Immutable +public final class BlobPrefix implements JsonSerializable { /* - * The Name property. + * The blob name. */ - private String name; + @Generated + private final BlobName name; /** - * Creates an instance of BlobPrefix. + * Creates an instance of BlobPrefix class. + * + * @param name the name value to set. */ - public BlobPrefix() { + @Generated + private BlobPrefix(BlobName name) { + this.name = name; } /** - * Get the name property: The Name property. - * + * Get the name property: The blob name. + * * @return the name value. */ - public String getName() { + @Generated + public BlobName getName() { return this.name; } /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the BlobPrefix object itself. + * {@inheritDoc} */ - public BlobPrefix setName(String name) { - this.name = name; - return this; - } - + @Generated @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobPrefix" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeString(this.name); - return xmlWriter.writeEndElement(); + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("name", this.name); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of BlobPrefix from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobPrefix if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws IllegalStateException If the deserialized XML object was missing any required properties. - * @throws XMLStreamException If an error occurs while reading the BlobPrefix. + * Reads an instance of BlobPrefix from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobPrefix if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobPrefix. */ - public static BlobPrefix fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } + @Generated + public static BlobPrefix fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BlobName name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - /** - * Reads an instance of BlobPrefix from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobPrefix if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws IllegalStateException If the deserialized XML object was missing any required properties. - * @throws XMLStreamException If an error occurs while reading the BlobPrefix. - */ - public static BlobPrefix fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobPrefix" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobPrefix deserializedBlobPrefix = new BlobPrefix(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedBlobPrefix.name = reader.getStringElement(); + if ("name".equals(fieldName)) { + name = BlobName.fromJson(reader); } else { - reader.skipElement(); + reader.skipChildren(); } } - - return deserializedBlobPrefix; + return new BlobPrefix(name); }); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java deleted file mode 100644 index b62ecc33861a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java +++ /dev/null @@ -1,864 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.implementation.accesshelpers.BlobPropertiesConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobPropertiesInternal; -import com.azure.storage.blob.implementation.models.BlobPropertiesInternalConstructorProperties; -import com.azure.storage.blob.implementation.util.ModelHelper; - -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * This class contains the response information returned from the service when getting blob properties. - */ -@Immutable -public final class BlobProperties { - private final BlobPropertiesInternal internalProperties; - - static { - BlobPropertiesConstructorProxy - .setAccessor(new BlobPropertiesConstructorProxy.BlobPropertiesConstructorAccessor() { - @Override - public BlobProperties create(BlobPropertiesInternal internalProperties) { - return new BlobProperties(internalProperties); - } - }); - } - - private BlobProperties(BlobPropertiesInternal internalProperties) { - this.internalProperties = internalProperties; - } - - /** - * Constructs a {@link BlobProperties}. - * - * @param creationTime Creation time of the blob. - * @param lastModified Datetime when the blob was last modified. - * @param eTag ETag of the blob. - * @param blobSize Size of the blob. - * @param contentType Content type specified for the blob. - * @param contentMd5 Content MD5 specified for the blob. - * @param contentEncoding Content encoding specified for the blob. - * @param contentDisposition Content disposition specified for the blob. - * @param contentLanguage Content language specified for the blob. - * @param cacheControl Cache control specified for the blob. - * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob - * pass {@code null}. - * @param blobType Type of the blob. - * @param leaseStatus Status of the lease on the blob. - * @param leaseState State of the lease on the blob. - * @param leaseDuration Type of lease on the blob. - * @param copyId Identifier of the last copy operation performed on the blob. - * @param copyStatus Status of the last copy operation performed on the blob. - * @param copySource Source of the last copy operation performed on the blob. - * @param copyProgress Progress of the last copy operation performed on the blob. - * @param copyCompletionTime Datetime when the last copy operation on the blob completed. - * @param copyStatusDescription Description of the last copy operation on the blob. - * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. - * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. - * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. - * @param accessTier Access tier of the blob. - * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the - * blob. - * @param archiveStatus Archive status of the blob. - * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the - * server. - * @param accessTierChangeTime Datetime when the access tier of the blob last changed. - * @param metadata Metadata associated with the blob. - * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob pass - * {@code null}. - */ - public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime lastModified, final String eTag, - final long blobSize, final String contentType, final byte[] contentMd5, final String contentEncoding, - final String contentDisposition, final String contentLanguage, final String cacheControl, - final Long blobSequenceNumber, final BlobType blobType, final LeaseStatusType leaseStatus, - final LeaseStateType leaseState, final LeaseDurationType leaseDuration, final String copyId, - final CopyStatusType copyStatus, final String copySource, final String copyProgress, - final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, - final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, - final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, - final OffsetDateTime accessTierChangeTime, final Map metadata, - final Integer committedBlockCount) { - this(creationTime, lastModified, eTag, blobSize, contentType, contentMd5, contentEncoding, contentDisposition, - contentLanguage, cacheControl, blobSequenceNumber, blobType, leaseStatus, leaseState, leaseDuration, copyId, - copyStatus, copySource, copyProgress, copyCompletionTime, copyStatusDescription, isServerEncrypted, - isIncrementalCopy, copyDestinationSnapshot, accessTier, isAccessTierInferred, archiveStatus, - encryptionKeySha256, null, accessTierChangeTime, metadata, committedBlockCount, null, null, null, null, - null); - } - - /** - * Constructs a {@link BlobProperties}. - * - * @param creationTime Creation time of the blob. - * @param lastModified Datetime when the blob was last modified. - * @param eTag ETag of the blob. - * @param blobSize Size of the blob. - * @param contentType Content type specified for the blob. - * @param contentMd5 Content MD5 specified for the blob. - * @param contentEncoding Content encoding specified for the blob. - * @param contentDisposition Content disposition specified for the blob. - * @param contentLanguage Content language specified for the blob. - * @param cacheControl Cache control specified for the blob. - * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob - * pass {@code null}. - * @param blobType Type of the blob. - * @param leaseStatus Status of the lease on the blob. - * @param leaseState State of the lease on the blob. - * @param leaseDuration Type of lease on the blob. - * @param copyId Identifier of the last copy operation performed on the blob. - * @param copyStatus Status of the last copy operation performed on the blob. - * @param copySource Source of the last copy operation performed on the blob. - * @param copyProgress Progress of the last copy operation performed on the blob. - * @param copyCompletionTime Datetime when the last copy operation on the blob completed. - * @param copyStatusDescription Description of the last copy operation on the blob. - * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. - * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. - * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. - * @param accessTier Access tier of the blob. - * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the - * blob. - * @param archiveStatus Archive status of the blob. - * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the - * server. - * @param encryptionScope The name of the encryption scope under which the blob is encrypted. - * @param accessTierChangeTime Datetime when the access tier of the blob last changed. - * @param metadata Metadata associated with the blob. - * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob pass - * {@code null}. - * @param versionId The version identifier of the blob. - * @param isCurrentVersion Flag indicating if version identifier points to current version of the blob. - * @param tagCount Number of tags associated with the blob. - * @param objectReplicationStatus The object replication status map to parse. - * @param rehydratePriority The rehydrate priority - * @param isSealed Whether the blob is sealed. - */ - public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime lastModified, final String eTag, - final long blobSize, final String contentType, final byte[] contentMd5, final String contentEncoding, - final String contentDisposition, final String contentLanguage, final String cacheControl, - final Long blobSequenceNumber, final BlobType blobType, final LeaseStatusType leaseStatus, - final LeaseStateType leaseState, final LeaseDurationType leaseDuration, final String copyId, - final CopyStatusType copyStatus, final String copySource, final String copyProgress, - final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, - final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, - final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, - final String encryptionScope, final OffsetDateTime accessTierChangeTime, final Map metadata, - final Integer committedBlockCount, final String versionId, final Boolean isCurrentVersion, final Long tagCount, - Map objectReplicationStatus, final String rehydratePriority, final Boolean isSealed) { - this(creationTime, lastModified, eTag, blobSize, contentType, contentMd5, contentEncoding, contentDisposition, - contentLanguage, cacheControl, blobSequenceNumber, blobType, leaseStatus, leaseState, leaseDuration, copyId, - copyStatus, copySource, copyProgress, copyCompletionTime, copyStatusDescription, isServerEncrypted, - isIncrementalCopy, copyDestinationSnapshot, accessTier, isAccessTierInferred, archiveStatus, - encryptionKeySha256, encryptionScope, accessTierChangeTime, metadata, committedBlockCount, tagCount, - versionId, isCurrentVersion, ModelHelper.getObjectReplicationSourcePolicies(objectReplicationStatus), - ModelHelper.getObjectReplicationDestinationPolicyId(objectReplicationStatus), - RehydratePriority.fromString(rehydratePriority), isSealed, null, null); - } - - /** - * Constructs a {@link BlobProperties}. - * - * @param creationTime Creation time of the blob. - * @param lastModified Datetime when the blob was last modified. - * @param eTag ETag of the blob. - * @param blobSize Size of the blob. - * @param contentType Content type specified for the blob. - * @param contentMd5 Content MD5 specified for the blob. - * @param contentEncoding Content encoding specified for the blob. - * @param contentDisposition Content disposition specified for the blob. - * @param contentLanguage Content language specified for the blob. - * @param cacheControl Cache control specified for the blob. - * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob - * pass {@code null}. - * @param blobType Type of the blob. - * @param leaseStatus Status of the lease on the blob. - * @param leaseState State of the lease on the blob. - * @param leaseDuration Type of lease on the blob. - * @param copyId Identifier of the last copy operation performed on the blob. - * @param copyStatus Status of the last copy operation performed on the blob. - * @param copySource Source of the last copy operation performed on the blob. - * @param copyProgress Progress of the last copy operation performed on the blob. - * @param copyCompletionTime Datetime when the last copy operation on the blob completed. - * @param copyStatusDescription Description of the last copy operation on the blob. - * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. - * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. - * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. - * @param accessTier Access tier of the blob. - * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the - * blob. - * @param archiveStatus Archive status of the blob. - * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the - * server. - * @param encryptionScope The name of the encryption scope under which the blob is encrypted. - * @param accessTierChangeTime Datetime when the access tier of the blob last changed. - * @param metadata Metadata associated with the blob. - * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob pass - * {@code null}. - * @param versionId The version identifier of the blob. - * @param isCurrentVersion Flag indicating if version identifier points to current version of the blob. - * @param tagCount Number of tags associated with the blob. - * @param objectReplicationSourcePolicies The already parsed object replication policies. - * @param objectReplicationDestinationPolicyId The policy id on the destination blob. - */ - public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime lastModified, final String eTag, - final long blobSize, final String contentType, final byte[] contentMd5, final String contentEncoding, - final String contentDisposition, final String contentLanguage, final String cacheControl, - final Long blobSequenceNumber, final BlobType blobType, final LeaseStatusType leaseStatus, - final LeaseStateType leaseState, final LeaseDurationType leaseDuration, final String copyId, - final CopyStatusType copyStatus, final String copySource, final String copyProgress, - final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, - final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, - final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, - String encryptionScope, final OffsetDateTime accessTierChangeTime, final Map metadata, - final Integer committedBlockCount, final Long tagCount, final String versionId, final Boolean isCurrentVersion, - List objectReplicationSourcePolicies, String objectReplicationDestinationPolicyId) { - this(creationTime, lastModified, eTag, blobSize, contentType, contentMd5, contentEncoding, contentDisposition, - contentLanguage, cacheControl, blobSequenceNumber, blobType, leaseStatus, leaseState, leaseDuration, copyId, - copyStatus, copySource, copyProgress, copyCompletionTime, copyStatusDescription, isServerEncrypted, - isIncrementalCopy, copyDestinationSnapshot, accessTier, isAccessTierInferred, archiveStatus, - encryptionKeySha256, encryptionScope, accessTierChangeTime, metadata, committedBlockCount, tagCount, - versionId, isCurrentVersion, objectReplicationSourcePolicies, objectReplicationDestinationPolicyId, null, - null, null, null); - } - - /** - * Constructs a {@link BlobProperties}. - * - * @param creationTime Creation time of the blob. - * @param lastModified Datetime when the blob was last modified. - * @param eTag ETag of the blob. - * @param blobSize Size of the blob. - * @param contentType Content type specified for the blob. - * @param contentMd5 Content MD5 specified for the blob. - * @param contentEncoding Content encoding specified for the blob. - * @param contentDisposition Content disposition specified for the blob. - * @param contentLanguage Content language specified for the blob. - * @param cacheControl Cache control specified for the blob. - * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob - * pass {@code null}. - * @param blobType Type of the blob. - * @param leaseStatus Status of the lease on the blob. - * @param leaseState State of the lease on the blob. - * @param leaseDuration Type of lease on the blob. - * @param copyId Identifier of the last copy operation performed on the blob. - * @param copyStatus Status of the last copy operation performed on the blob. - * @param copySource Source of the last copy operation performed on the blob. - * @param copyProgress Progress of the last copy operation performed on the blob. - * @param copyCompletionTime Datetime when the last copy operation on the blob completed. - * @param copyStatusDescription Description of the last copy operation on the blob. - * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. - * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. - * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. - * @param accessTier Access tier of the blob. - * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the - * blob. - * @param archiveStatus Archive status of the blob. - * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the - * server. - * @param encryptionScope The name of the encryption scope under which the blob is encrypted. - * @param accessTierChangeTime Datetime when the access tier of the blob last changed. - * @param metadata Metadata associated with the blob. - * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob pass - * {@code null}. - * @param versionId The version identifier of the blob. - * @param isCurrentVersion Flag indicating if version identifier points to current version of the blob. - * @param tagCount Number of tags associated with the blob. - * @param objectReplicationSourcePolicies The already parsed object replication policies. - * @param objectReplicationDestinationPolicyId The policy id on the destination blob. - * @param rehydratePriority The rehydrate priority - * @param isSealed Whether the blob is sealed. - * @param lastAccessedTime The date and time the blob was read or written to. - * @param expiresOn The time when the blob is going to expire. - */ - public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime lastModified, final String eTag, - final long blobSize, final String contentType, final byte[] contentMd5, final String contentEncoding, - final String contentDisposition, final String contentLanguage, final String cacheControl, - final Long blobSequenceNumber, final BlobType blobType, final LeaseStatusType leaseStatus, - final LeaseStateType leaseState, final LeaseDurationType leaseDuration, final String copyId, - final CopyStatusType copyStatus, final String copySource, final String copyProgress, - final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, - final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, - final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, - final String encryptionScope, final OffsetDateTime accessTierChangeTime, final Map metadata, - final Integer committedBlockCount, final Long tagCount, final String versionId, final Boolean isCurrentVersion, - final List objectReplicationSourcePolicies, - final String objectReplicationDestinationPolicyId, final RehydratePriority rehydratePriority, - final Boolean isSealed, final OffsetDateTime lastAccessedTime, final OffsetDateTime expiresOn) { - this(creationTime, lastModified, eTag, blobSize, contentType, contentMd5, contentEncoding, contentDisposition, - contentLanguage, cacheControl, blobSequenceNumber, blobType, leaseStatus, leaseState, leaseDuration, copyId, - copyStatus, copySource, copyProgress, copyCompletionTime, copyStatusDescription, isServerEncrypted, - isIncrementalCopy, copyDestinationSnapshot, accessTier, isAccessTierInferred, archiveStatus, - encryptionKeySha256, encryptionScope, accessTierChangeTime, metadata, committedBlockCount, tagCount, - versionId, isCurrentVersion, objectReplicationSourcePolicies, objectReplicationDestinationPolicyId, - rehydratePriority, isSealed, lastAccessedTime, expiresOn, null, false); - } - - /** - * Constructs a {@link BlobProperties}. - * - * @param creationTime Creation time of the blob. - * @param lastModified Datetime when the blob was last modified. - * @param eTag ETag of the blob. - * @param blobSize Size of the blob. - * @param contentType Content type specified for the blob. - * @param contentMd5 Content MD5 specified for the blob. - * @param contentEncoding Content encoding specified for the blob. - * @param contentDisposition Content disposition specified for the blob. - * @param contentLanguage Content language specified for the blob. - * @param cacheControl Cache control specified for the blob. - * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob - * pass {@code null}. - * @param blobType Type of the blob. - * @param leaseStatus Status of the lease on the blob. - * @param leaseState State of the lease on the blob. - * @param leaseDuration Type of lease on the blob. - * @param copyId Identifier of the last copy operation performed on the blob. - * @param copyStatus Status of the last copy operation performed on the blob. - * @param copySource Source of the last copy operation performed on the blob. - * @param copyProgress Progress of the last copy operation performed on the blob. - * @param copyCompletionTime Datetime when the last copy operation on the blob completed. - * @param copyStatusDescription Description of the last copy operation on the blob. - * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. - * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. - * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. - * @param accessTier Access tier of the blob. - * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the - * blob. - * @param archiveStatus Archive status of the blob. - * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the - * server. - * @param encryptionScope The name of the encryption scope under which the blob is encrypted. - * @param accessTierChangeTime Datetime when the access tier of the blob last changed. - * @param metadata Metadata associated with the blob. - * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob pass - * {@code null}. - * @param versionId The version identifier of the blob. - * @param isCurrentVersion Flag indicating if version identifier points to current version of the blob. - * @param tagCount Number of tags associated with the blob. - * @param objectReplicationSourcePolicies The already parsed object replication policies. - * @param objectReplicationDestinationPolicyId The policy id on the destination blob. - * @param rehydratePriority The rehydrate priority - * @param isSealed Whether the blob is sealed. - * @param lastAccessedTime The date and time the blob was read or written to. - * @param expiresOn The time when the blob is going to expire. - * @param immutabilityPolicy The immutability policy of the blob. - * @param hasLegalHold Whether the blob has a legal hold. - */ - public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime lastModified, final String eTag, - final long blobSize, final String contentType, final byte[] contentMd5, final String contentEncoding, - final String contentDisposition, final String contentLanguage, final String cacheControl, - final Long blobSequenceNumber, final BlobType blobType, final LeaseStatusType leaseStatus, - final LeaseStateType leaseState, final LeaseDurationType leaseDuration, final String copyId, - final CopyStatusType copyStatus, final String copySource, final String copyProgress, - final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, - final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, - final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, - final String encryptionScope, final OffsetDateTime accessTierChangeTime, final Map metadata, - final Integer committedBlockCount, final Long tagCount, final String versionId, final Boolean isCurrentVersion, - final List objectReplicationSourcePolicies, - final String objectReplicationDestinationPolicyId, final RehydratePriority rehydratePriority, - final Boolean isSealed, final OffsetDateTime lastAccessedTime, final OffsetDateTime expiresOn, - BlobImmutabilityPolicy immutabilityPolicy, Boolean hasLegalHold) { - this(creationTime, lastModified, eTag, blobSize, contentType, contentMd5, contentEncoding, contentDisposition, - contentLanguage, cacheControl, blobSequenceNumber, blobType, leaseStatus, leaseState, leaseDuration, copyId, - copyStatus, copySource, copyProgress, copyCompletionTime, copyStatusDescription, isServerEncrypted, - isIncrementalCopy, copyDestinationSnapshot, accessTier, isAccessTierInferred, archiveStatus, - encryptionKeySha256, encryptionScope, accessTierChangeTime, metadata, committedBlockCount, tagCount, - versionId, isCurrentVersion, objectReplicationSourcePolicies, objectReplicationDestinationPolicyId, - rehydratePriority, isSealed, lastAccessedTime, expiresOn, immutabilityPolicy, hasLegalHold, null); - } - - /** - * Constructs a {@link BlobProperties}. - * - * @param creationTime Creation time of the blob. - * @param lastModified Datetime when the blob was last modified. - * @param eTag ETag of the blob. - * @param blobSize Size of the blob. - * @param contentType Content type specified for the blob. - * @param contentMd5 Content MD5 specified for the blob. - * @param contentEncoding Content encoding specified for the blob. - * @param contentDisposition Content disposition specified for the blob. - * @param contentLanguage Content language specified for the blob. - * @param cacheControl Cache control specified for the blob. - * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob - * pass {@code null}. - * @param blobType Type of the blob. - * @param leaseStatus Status of the lease on the blob. - * @param leaseState State of the lease on the blob. - * @param leaseDuration Type of lease on the blob. - * @param copyId Identifier of the last copy operation performed on the blob. - * @param copyStatus Status of the last copy operation performed on the blob. - * @param copySource Source of the last copy operation performed on the blob. - * @param copyProgress Progress of the last copy operation performed on the blob. - * @param copyCompletionTime Datetime when the last copy operation on the blob completed. - * @param copyStatusDescription Description of the last copy operation on the blob. - * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. - * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. - * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. - * @param accessTier Access tier of the blob. - * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the - * blob. - * @param archiveStatus Archive status of the blob. - * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the - * server. - * @param encryptionScope The name of the encryption scope under which the blob is encrypted. - * @param accessTierChangeTime Datetime when the access tier of the blob last changed. - * @param metadata Metadata associated with the blob. - * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob pass - * {@code null}. - * @param versionId The version identifier of the blob. - * @param isCurrentVersion Flag indicating if version identifier points to current version of the blob. - * @param tagCount Number of tags associated with the blob. - * @param objectReplicationSourcePolicies The already parsed object replication policies. - * @param objectReplicationDestinationPolicyId The policy id on the destination blob. - * @param rehydratePriority The rehydrate priority - * @param isSealed Whether the blob is sealed. - * @param lastAccessedTime The date and time the blob was read or written to. - * @param expiresOn The time when the blob is going to expire. - * @param immutabilityPolicy The immutability policy of the blob. - * @param hasLegalHold Whether the blob has a legal hold. - * @param requestId The request id. - */ - public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime lastModified, final String eTag, - final long blobSize, final String contentType, final byte[] contentMd5, final String contentEncoding, - final String contentDisposition, final String contentLanguage, final String cacheControl, - final Long blobSequenceNumber, final BlobType blobType, final LeaseStatusType leaseStatus, - final LeaseStateType leaseState, final LeaseDurationType leaseDuration, final String copyId, - final CopyStatusType copyStatus, final String copySource, final String copyProgress, - final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, - final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, - final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, - final String encryptionScope, final OffsetDateTime accessTierChangeTime, final Map metadata, - final Integer committedBlockCount, final Long tagCount, final String versionId, final Boolean isCurrentVersion, - final List objectReplicationSourcePolicies, - final String objectReplicationDestinationPolicyId, final RehydratePriority rehydratePriority, - final Boolean isSealed, final OffsetDateTime lastAccessedTime, final OffsetDateTime expiresOn, - BlobImmutabilityPolicy immutabilityPolicy, Boolean hasLegalHold, String requestId) { - this(new BlobPropertiesInternalConstructorProperties(creationTime, lastModified, eTag, blobSize, contentType, - contentMd5, contentEncoding, contentDisposition, contentLanguage, cacheControl, blobSequenceNumber, - blobType, leaseStatus, leaseState, leaseDuration, copyId, copyStatus, copySource, copyProgress, - copyCompletionTime, copyStatusDescription, isServerEncrypted, isIncrementalCopy, copyDestinationSnapshot, - accessTier, isAccessTierInferred, archiveStatus, encryptionKeySha256, encryptionScope, accessTierChangeTime, - metadata, committedBlockCount, tagCount, versionId, isCurrentVersion, objectReplicationSourcePolicies, - objectReplicationDestinationPolicyId, rehydratePriority, isSealed, lastAccessedTime, expiresOn, - immutabilityPolicy, hasLegalHold, requestId)); - } - - /** - * Gets the time when the blob was created. - * - * @return the time when the blob was created - */ - public OffsetDateTime getCreationTime() { - return internalProperties.getCreationTime(); - } - - /** - * Gets the time when the blob was last modified. - * - * @return the time when the blob was last modified - */ - public OffsetDateTime getLastModified() { - return internalProperties.getLastModified(); - } - - /** - * Gets the eTag of the blob. - * - * @return the eTag of the blob - */ - public String getETag() { - return internalProperties.getETag(); - } - - /** - * Gets the size of the blob in bytes. - * - * @return the size of the blob in bytes - */ - public long getBlobSize() { - return internalProperties.getBlobSize(); - } - - /** - * Gets the content type of the blob. - * - * @return the content type of the blob - */ - public String getContentType() { - return internalProperties.getContentType(); - } - - /** - * Gets the MD5 of the blob's content. - * - * @return the MD5 of the blob's content - */ - public byte[] getContentMd5() { - return CoreUtils.clone(internalProperties.getContentMd5()); - } - - /** - * Gets the content encoding of the blob. - * - * @return the content encoding of the blob - */ - public String getContentEncoding() { - return internalProperties.getContentEncoding(); - } - - /** - * Gets the content disposition of the blob. - * - * @return the content disposition of the blob - */ - public String getContentDisposition() { - return internalProperties.getContentDisposition(); - } - - /** - * Gets the content language of the blob. - * - * @return the content language of the blob - */ - public String getContentLanguage() { - return internalProperties.getContentLanguage(); - } - - /** - * Gets the cache control of the blob. - * - * @return the cache control of the blob - */ - public String getCacheControl() { - return internalProperties.getCacheControl(); - } - - /** - * Gets the current sequence number of the page blob. This is only returned for page blobs. - * - * @return the current sequence number of the page blob. This is only returned for page blobs. - */ - public Long getBlobSequenceNumber() { - return internalProperties.getBlobSequenceNumber(); - } - - /** - * Gets the type of the blob. - * - * @return the type of the blob - */ - public BlobType getBlobType() { - return internalProperties.getBlobType(); - } - - /** - * Gets the lease status of the blob. - * - * @return the lease status of the blob - */ - public LeaseStatusType getLeaseStatus() { - return internalProperties.getLeaseStatus(); - } - - /** - * Gets the lease state of the blob. - * - * @return the lease state of the blob - */ - public LeaseStateType getLeaseState() { - return internalProperties.getLeaseState(); - } - - /** - * Gets the lease duration of the blob, if the blob is leased. - * - * @return the lease duration if the blob is leased - */ - public LeaseDurationType getLeaseDuration() { - return internalProperties.getLeaseDuration(); - } - - /** - * Gets the identifier of the last copy operation. - * - * @return the identifier of the last copy operation. If this blob hasn't been the target of a copy operation or has - * been modified since this won't be set. - */ - public String getCopyId() { - return internalProperties.getCopyId(); - } - - /** - * Gets the status of the last copy operation. - * - * @return the status of the last copy operation. If this blob hasn't been the target of a copy operation or has - * been modified since this won't be set. - */ - public CopyStatusType getCopyStatus() { - return internalProperties.getCopyStatus(); - } - - /** - * Gets the source blob URL from the last copy operation. - * - * @return the source blob URL from the last copy operation. If this blob hasn't been the target of a copy operation - * or has been modified since this won't be set. - */ - public String getCopySource() { - return internalProperties.getCopySource(); - } - - /** - * Gets the progress of the last copy operation. - * - * @return the number of bytes copied and total bytes in the source from the last copy operation (bytes copied/total - * bytes). If this blob hasn't been the target of a copy operation or has been modified since this won't be set. - */ - public String getCopyProgress() { - return internalProperties.getCopyProgress(); - } - - /** - * Gets the completion time of the last copy operation. - * - * @return the completion time of the last copy operation. If this blob hasn't been the target of a copy operation - * or has been modified since this won't be set. - */ - public OffsetDateTime getCopyCompletionTime() { - return internalProperties.getCopyCompletionTime(); - } - - /** - * Gets the description of the last copy failure. - * - * @return the description of the last copy failure, this is set when the {@link #getCopyStatus() getCopyStatus} is - * {@link CopyStatusType#FAILED failed} or {@link CopyStatusType#ABORTED aborted}. If this blob hasn't been the - * target of a copy operation or has been modified since this won't be set. - */ - public String getCopyStatusDescription() { - return internalProperties.getCopyStatusDescription(); - } - - /** - * Gets the status of the blob being encrypted on the server. - * - * @return the status of the blob being encrypted on the server - */ - public Boolean isServerEncrypted() { - return internalProperties.isServerEncrypted(); - } - - /** - * Gets the status of the blob being an incremental copy blob. - * - * @return the status of the blob being an incremental copy blob - */ - public Boolean isIncrementalCopy() { - return internalProperties.isIncrementalCopy(); - } - - /** - * Gets the snapshot time of the last successful incremental copy snapshot for this blob. - * - * @return the snapshot time of the last successful incremental copy snapshot for this blob. If this blob isn't an - * incremental copy blob or incremental copy snapshot or {@link #getCopyStatus() getCopyStatus} isn't {@link - * CopyStatusType#SUCCESS success} this won't be set. - */ - public String getCopyDestinationSnapshot() { - return internalProperties.getCopyDestinationSnapshot(); - } - - /** - * Gets the access tier of the blob. - * - * @return the tier of the blob. This is only set for Page blobs on a premium storage account or for Block blobs on - * blob storage or general purpose V2 account. - */ - public AccessTier getAccessTier() { - return internalProperties.getAccessTier(); - } - - /** - * Gets the status of the tier being inferred for the blob. - * - * @return the status of the tier being inferred for the blob. This is only set for Page blobs on a premium storage - * account or for Block blobs on blob storage or general purpose V2 account. - */ - public Boolean isAccessTierInferred() { - return internalProperties.isAccessTierInferred(); - } - - /** - * Gets the archive status of the blob. - * - * @return the archive status of the blob. This is only for blobs on a blob storage and general purpose v2 account. - */ - public ArchiveStatus getArchiveStatus() { - return internalProperties.getArchiveStatus(); - } - - /** - * Gets the SHA256 of the customer provided encryption key used to encrypt the blob on the server. - * - * @return the key used to encrypt the blob - */ - public String getEncryptionKeySha256() { - return internalProperties.getEncryptionKeySha256(); - } - - /** - * Gets the name of the encryption scope under which the blob is encrypted. - * - * @return The name of the encryption scope under which the blob is encrypted. - */ - public String getEncryptionScope() { - return internalProperties.getEncryptionScope(); - } - - /** - * Gets the time when the access tier for the blob was last changed. - * - * @return the time when the access tier for the blob was last changed - */ - public OffsetDateTime getAccessTierChangeTime() { - return internalProperties.getAccessTierChangeTime(); - } - - /** - * Gets the metadata associated with this blob. - * - * @return the metadata associated with this blob - */ - public Map getMetadata() { - return internalProperties.getMetadata(); - } - - /** - * Gets the number of committed blocks in the blob. This is only returned for Append blobs. - * - * @return the number of committed blocks in the blob. This is only returned for Append blobs. - */ - public Integer getCommittedBlockCount() { - return internalProperties.getCommittedBlockCount(); - } - - /** - * Gets the number of tags associated with the blob. - * - * @return The number of tags associated with the blob. - */ - public Long getTagCount() { - return internalProperties.getTagCount(); - } - - /** - * Gets the version identifier of the blob. - * - * @return the version identifier the blob. - */ - public String getVersionId() { - return internalProperties.getVersionId(); - } - - /** - * Gets the flag indicating whether version identifier points to current version of the blob. - * - * @return the flag indicating whether version identifier points to current version of the blob. - */ - public Boolean isCurrentVersion() { - return internalProperties.isCurrentVersion(); - } - - /** - * Gets a {@link List} that contains information on the object replication policies associated with this blob and - * the status of the replication for each policy. Only available when the blob is the source of object replication. - * - * @return a {@link List} that contains information on the object replication policies associated with this blob and - * the status of the replication for each policy. Only available when the blob is the source of object replication. - */ - public List getObjectReplicationSourcePolicies() { - return Collections.unmodifiableList(internalProperties.getObjectReplicationSourcePolicies()); - } - - /** - * Gets a string that identifies the Object Replication Policy which made this blob the destination of a copy. - * - * @return a string that identifies the Object Replication Policy which made this blob the destination of a copy. - */ - public String getObjectReplicationDestinationPolicyId() { - return this.internalProperties.getObjectReplicationDestinationPolicyId(); - } - - /** - * Gets the {@link RehydratePriority} of the blob if it is in RehydratePending state. - * - * @return The {@link RehydratePriority} of the blob if it is in RehydratePending state. - */ - public RehydratePriority getRehydratePriority() { - return internalProperties.getRehydratePriority(); - } - - /** - * Gets the flag indicating whether this blob has been sealed (marked as read only). This is only returned for - * Append blobs. - * @return the flag indicating whether this blob has been sealed (marked as read only). This is only returned for - * Append blobs. - */ - public Boolean isSealed() { - return internalProperties.isSealed(); - } - - /** - * Gets the date and time the blob was last read or written to. - * - * @return The date and time the blob was last read or written to. - */ - public OffsetDateTime getLastAccessedTime() { - return internalProperties.getLastAccessedTime(); - } - - /** - * Gets the time when the blob is going to expire. - * - * @return the time when the blob is going to expire. - */ - public OffsetDateTime getExpiresOn() { - return internalProperties.getExpiresOn(); - } - - /** - * Gets the immutability policy of the blob. - * - * @return the immutability policy. - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return internalProperties.getImmutabilityPolicy(); - } - - /** - * Gets the legal hold status of the blob. - * - * @return whether the blob has a legal hold. - */ - public Boolean hasLegalHold() { - return internalProperties.hasLegalHold(); - } - - /** - * Gets the request id. - * - * @return the x-ms-request id header value. - */ - public String getRequestId() { - return internalProperties.getRequestId(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobPropertiesInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobPropertiesInternal.java new file mode 100644 index 000000000000..08a1a048681e --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobPropertiesInternal.java @@ -0,0 +1,948 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * The properties of a blob. + */ +@Immutable +public final class BlobPropertiesInternal implements JsonSerializable { + /* + * The date-time the blob was created in RFC1123 format. + */ + @Generated + private DateTimeRfc1123 creationTime; + + /* + * The date-time the blob was last modified in RFC1123 format. + */ + @Generated + private final DateTimeRfc1123 lastModified; + + /* + * The blog ETag. + */ + @Generated + private final String eTag; + + /* + * The content length of the blob. + */ + @Generated + private Long contentLength; + + /* + * The content type of the blob. + */ + @Generated + private String contentType; + + /* + * The content encoding of the blob. + */ + @Generated + private String contentEncoding; + + /* + * The content language of the blob. + */ + @Generated + private String contentLanguage; + + /* + * The content MD5 of the blob. + */ + @Generated + private byte[] contentMd5; + + /* + * The content disposition of the blob. + */ + @Generated + private String contentDisposition; + + /* + * The cache control of the blob. + */ + @Generated + private String cacheControl; + + /* + * The sequence number of the blob. + */ + @Generated + private Long blobSequenceNumber; + + /* + * The blob type. + */ + @Generated + private BlobType blobType; + + /* + * The lease status of the blob. + */ + @Generated + private LeaseStatus leaseStatus; + + /* + * The lease state of the blob. + */ + @Generated + private LeaseState leaseState; + + /* + * The lease duration of the blob. + */ + @Generated + private LeaseDuration leaseDuration; + + /* + * The copy ID of the blob. + */ + @Generated + private String copyId; + + /* + * The copy status of the blob. + */ + @Generated + private CopyStatus copyStatus; + + /* + * The copy source of the blob. + */ + @Generated + private String copySource; + + /* + * The copy progress of the blob. + */ + @Generated + private String copyProgress; + + /* + * The copy completion time of the blob. + */ + @Generated + private DateTimeRfc1123 copyCompletionTime; + + /* + * The copy status description of the blob. + */ + @Generated + private String copyStatusDescription; + + /* + * Whether the blog is encrypted on the server. + */ + @Generated + private Boolean serverEncrypted; + + /* + * Whether the blog is incremental copy. + */ + @Generated + private Boolean incrementalCopy; + + /* + * The name of the destination snapshot. + */ + @Generated + private String destinationSnapshot; + + /* + * The time the blob was deleted. + */ + @Generated + private DateTimeRfc1123 deletedTime; + + /* + * The remaining retention days of the blob. + */ + @Generated + private Integer remainingRetentionDays; + + /* + * The access tier of the blob. + */ + @Generated + private AccessTier accessTier; + + /* + * Whether the access tier is inferred. + */ + @Generated + private Boolean accessTierInferred; + + /* + * The archive status of the blob. + */ + @Generated + private ArchiveStatus archiveStatus; + + /* + * Customer provided key sha256 + */ + @Generated + private String customerProvidedKeySha256; + + /* + * The encryption scope of the blob. + */ + @Generated + private String encryptionScope; + + /* + * The access tier change time of the blob. + */ + @Generated + private DateTimeRfc1123 accessTierChangeTime; + + /* + * The number of tags for the blob. + */ + @Generated + private Integer tagCount; + + /* + * The expire time of the blob. + */ + @Generated + private DateTimeRfc1123 expiresOn; + + /* + * Whether the blob is sealed. + */ + @Generated + private Boolean isSealed; + + /* + * The rehydrate priority of the blob. + */ + @Generated + private RehydratePriority rehydratePriority; + + /* + * The last access time of the blob. + */ + @Generated + private DateTimeRfc1123 lastAccessedOn; + + /* + * The immutability policy until time of the blob. + */ + @Generated + private DateTimeRfc1123 immutabilityPolicyExpiresOn; + + /* + * The immutability policy mode of the blob. + */ + @Generated + private BlobImmutabilityPolicyMode immutabilityPolicyMode; + + /* + * Whether the blob is under legal hold. + */ + @Generated + private Boolean legalHold; + + /** + * Creates an instance of BlobPropertiesInternal class. + * + * @param lastModified the lastModified value to set. + * @param eTag the eTag value to set. + */ + @Generated + private BlobPropertiesInternal(OffsetDateTime lastModified, String eTag) { + if (lastModified == null) { + this.lastModified = null; + } else { + this.lastModified = new DateTimeRfc1123(lastModified); + } + this.eTag = eTag; + } + + /** + * Get the creationTime property: The date-time the blob was created in RFC1123 format. + * + * @return the creationTime value. + */ + @Generated + public OffsetDateTime getCreationTime() { + if (this.creationTime == null) { + return null; + } + return this.creationTime.getDateTime(); + } + + /** + * Get the lastModified property: The date-time the blob was last modified in RFC1123 format. + * + * @return the lastModified value. + */ + @Generated + public OffsetDateTime getLastModified() { + if (this.lastModified == null) { + return null; + } + return this.lastModified.getDateTime(); + } + + /** + * Get the eTag property: The blog ETag. + * + * @return the eTag value. + */ + @Generated + public String getETag() { + return this.eTag; + } + + /** + * Get the contentLength property: The content length of the blob. + * + * @return the contentLength value. + */ + @Generated + public Long getContentLength() { + return this.contentLength; + } + + /** + * Get the contentType property: The content type of the blob. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Get the contentEncoding property: The content encoding of the blob. + * + * @return the contentEncoding value. + */ + @Generated + public String getContentEncoding() { + return this.contentEncoding; + } + + /** + * Get the contentLanguage property: The content language of the blob. + * + * @return the contentLanguage value. + */ + @Generated + public String getContentLanguage() { + return this.contentLanguage; + } + + /** + * Get the contentMd5 property: The content MD5 of the blob. + * + * @return the contentMd5 value. + */ + @Generated + public byte[] getContentMd5() { + return CoreUtils.clone(this.contentMd5); + } + + /** + * Get the contentDisposition property: The content disposition of the blob. + * + * @return the contentDisposition value. + */ + @Generated + public String getContentDisposition() { + return this.contentDisposition; + } + + /** + * Get the cacheControl property: The cache control of the blob. + * + * @return the cacheControl value. + */ + @Generated + public String getCacheControl() { + return this.cacheControl; + } + + /** + * Get the blobSequenceNumber property: The sequence number of the blob. + * + * @return the blobSequenceNumber value. + */ + @Generated + public Long getBlobSequenceNumber() { + return this.blobSequenceNumber; + } + + /** + * Get the blobType property: The blob type. + * + * @return the blobType value. + */ + @Generated + public BlobType getBlobType() { + return this.blobType; + } + + /** + * Get the leaseStatus property: The lease status of the blob. + * + * @return the leaseStatus value. + */ + @Generated + public LeaseStatus getLeaseStatus() { + return this.leaseStatus; + } + + /** + * Get the leaseState property: The lease state of the blob. + * + * @return the leaseState value. + */ + @Generated + public LeaseState getLeaseState() { + return this.leaseState; + } + + /** + * Get the leaseDuration property: The lease duration of the blob. + * + * @return the leaseDuration value. + */ + @Generated + public LeaseDuration getLeaseDuration() { + return this.leaseDuration; + } + + /** + * Get the copyId property: The copy ID of the blob. + * + * @return the copyId value. + */ + @Generated + public String getCopyId() { + return this.copyId; + } + + /** + * Get the copyStatus property: The copy status of the blob. + * + * @return the copyStatus value. + */ + @Generated + public CopyStatus getCopyStatus() { + return this.copyStatus; + } + + /** + * Get the copySource property: The copy source of the blob. + * + * @return the copySource value. + */ + @Generated + public String getCopySource() { + return this.copySource; + } + + /** + * Get the copyProgress property: The copy progress of the blob. + * + * @return the copyProgress value. + */ + @Generated + public String getCopyProgress() { + return this.copyProgress; + } + + /** + * Get the copyCompletionTime property: The copy completion time of the blob. + * + * @return the copyCompletionTime value. + */ + @Generated + public OffsetDateTime getCopyCompletionTime() { + if (this.copyCompletionTime == null) { + return null; + } + return this.copyCompletionTime.getDateTime(); + } + + /** + * Get the copyStatusDescription property: The copy status description of the blob. + * + * @return the copyStatusDescription value. + */ + @Generated + public String getCopyStatusDescription() { + return this.copyStatusDescription; + } + + /** + * Get the serverEncrypted property: Whether the blog is encrypted on the server. + * + * @return the serverEncrypted value. + */ + @Generated + public Boolean isServerEncrypted() { + return this.serverEncrypted; + } + + /** + * Get the incrementalCopy property: Whether the blog is incremental copy. + * + * @return the incrementalCopy value. + */ + @Generated + public Boolean isIncrementalCopy() { + return this.incrementalCopy; + } + + /** + * Get the destinationSnapshot property: The name of the destination snapshot. + * + * @return the destinationSnapshot value. + */ + @Generated + public String getDestinationSnapshot() { + return this.destinationSnapshot; + } + + /** + * Get the deletedTime property: The time the blob was deleted. + * + * @return the deletedTime value. + */ + @Generated + public OffsetDateTime getDeletedTime() { + if (this.deletedTime == null) { + return null; + } + return this.deletedTime.getDateTime(); + } + + /** + * Get the remainingRetentionDays property: The remaining retention days of the blob. + * + * @return the remainingRetentionDays value. + */ + @Generated + public Integer getRemainingRetentionDays() { + return this.remainingRetentionDays; + } + + /** + * Get the accessTier property: The access tier of the blob. + * + * @return the accessTier value. + */ + @Generated + public AccessTier getAccessTier() { + return this.accessTier; + } + + /** + * Get the accessTierInferred property: Whether the access tier is inferred. + * + * @return the accessTierInferred value. + */ + @Generated + public Boolean isAccessTierInferred() { + return this.accessTierInferred; + } + + /** + * Get the archiveStatus property: The archive status of the blob. + * + * @return the archiveStatus value. + */ + @Generated + public ArchiveStatus getArchiveStatus() { + return this.archiveStatus; + } + + /** + * Get the customerProvidedKeySha256 property: Customer provided key sha256. + * + * @return the customerProvidedKeySha256 value. + */ + @Generated + public String getCustomerProvidedKeySha256() { + return this.customerProvidedKeySha256; + } + + /** + * Get the encryptionScope property: The encryption scope of the blob. + * + * @return the encryptionScope value. + */ + @Generated + public String getEncryptionScope() { + return this.encryptionScope; + } + + /** + * Get the accessTierChangeTime property: The access tier change time of the blob. + * + * @return the accessTierChangeTime value. + */ + @Generated + public OffsetDateTime getAccessTierChangeTime() { + if (this.accessTierChangeTime == null) { + return null; + } + return this.accessTierChangeTime.getDateTime(); + } + + /** + * Get the tagCount property: The number of tags for the blob. + * + * @return the tagCount value. + */ + @Generated + public Integer getTagCount() { + return this.tagCount; + } + + /** + * Get the expiresOn property: The expire time of the blob. + * + * @return the expiresOn value. + */ + @Generated + public OffsetDateTime getExpiresOn() { + if (this.expiresOn == null) { + return null; + } + return this.expiresOn.getDateTime(); + } + + /** + * Get the isSealed property: Whether the blob is sealed. + * + * @return the isSealed value. + */ + @Generated + public Boolean isSealed() { + return this.isSealed; + } + + /** + * Get the rehydratePriority property: The rehydrate priority of the blob. + * + * @return the rehydratePriority value. + */ + @Generated + public RehydratePriority getRehydratePriority() { + return this.rehydratePriority; + } + + /** + * Get the lastAccessedOn property: The last access time of the blob. + * + * @return the lastAccessedOn value. + */ + @Generated + public OffsetDateTime getLastAccessedOn() { + if (this.lastAccessedOn == null) { + return null; + } + return this.lastAccessedOn.getDateTime(); + } + + /** + * Get the immutabilityPolicyExpiresOn property: The immutability policy until time of the blob. + * + * @return the immutabilityPolicyExpiresOn value. + */ + @Generated + public OffsetDateTime getImmutabilityPolicyExpiresOn() { + if (this.immutabilityPolicyExpiresOn == null) { + return null; + } + return this.immutabilityPolicyExpiresOn.getDateTime(); + } + + /** + * Get the immutabilityPolicyMode property: The immutability policy mode of the blob. + * + * @return the immutabilityPolicyMode value. + */ + @Generated + public BlobImmutabilityPolicyMode getImmutabilityPolicyMode() { + return this.immutabilityPolicyMode; + } + + /** + * Get the legalHold property: Whether the blob is under legal hold. + * + * @return the legalHold value. + */ + @Generated + public Boolean isLegalHold() { + return this.legalHold; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("lastModified", Objects.toString(this.lastModified, null)); + jsonWriter.writeStringField("eTag", this.eTag); + jsonWriter.writeStringField("creationTime", Objects.toString(this.creationTime, null)); + jsonWriter.writeNumberField("contentLength", this.contentLength); + jsonWriter.writeStringField("contentType", this.contentType); + jsonWriter.writeStringField("contentEncoding", this.contentEncoding); + jsonWriter.writeStringField("contentLanguage", this.contentLanguage); + jsonWriter.writeBinaryField("contentMd5", this.contentMd5); + jsonWriter.writeStringField("contentDisposition", this.contentDisposition); + jsonWriter.writeStringField("cacheControl", this.cacheControl); + jsonWriter.writeNumberField("blobSequenceNumber", this.blobSequenceNumber); + jsonWriter.writeStringField("blobType", this.blobType == null ? null : this.blobType.toString()); + jsonWriter.writeStringField("leaseStatus", this.leaseStatus == null ? null : this.leaseStatus.toString()); + jsonWriter.writeStringField("leaseState", this.leaseState == null ? null : this.leaseState.toString()); + jsonWriter.writeStringField("leaseDuration", this.leaseDuration == null ? null : this.leaseDuration.toString()); + jsonWriter.writeStringField("copyId", this.copyId); + jsonWriter.writeStringField("copyStatus", this.copyStatus == null ? null : this.copyStatus.toString()); + jsonWriter.writeStringField("copySource", this.copySource); + jsonWriter.writeStringField("copyProgress", this.copyProgress); + jsonWriter.writeStringField("copyCompletionTime", Objects.toString(this.copyCompletionTime, null)); + jsonWriter.writeStringField("copyStatusDescription", this.copyStatusDescription); + jsonWriter.writeBooleanField("serverEncrypted", this.serverEncrypted); + jsonWriter.writeBooleanField("incrementalCopy", this.incrementalCopy); + jsonWriter.writeStringField("destinationSnapshot", this.destinationSnapshot); + jsonWriter.writeStringField("deletedTime", Objects.toString(this.deletedTime, null)); + jsonWriter.writeNumberField("remainingRetentionDays", this.remainingRetentionDays); + jsonWriter.writeStringField("accessTier", this.accessTier == null ? null : this.accessTier.toString()); + jsonWriter.writeBooleanField("accessTierInferred", this.accessTierInferred); + jsonWriter.writeStringField("archiveStatus", this.archiveStatus == null ? null : this.archiveStatus.toString()); + jsonWriter.writeStringField("customerProvidedKeySha256", this.customerProvidedKeySha256); + jsonWriter.writeStringField("encryptionScope", this.encryptionScope); + jsonWriter.writeStringField("accessTierChangeTime", Objects.toString(this.accessTierChangeTime, null)); + jsonWriter.writeNumberField("tagCount", this.tagCount); + jsonWriter.writeStringField("expiryTime", Objects.toString(this.expiresOn, null)); + jsonWriter.writeBooleanField("sealed", this.isSealed); + jsonWriter.writeStringField("rehydratePriority", + this.rehydratePriority == null ? null : this.rehydratePriority.toString()); + jsonWriter.writeStringField("lastAccessTime", Objects.toString(this.lastAccessedOn, null)); + jsonWriter.writeStringField("immutabilityPolicyUntilDate", + Objects.toString(this.immutabilityPolicyExpiresOn, null)); + jsonWriter.writeStringField("immutabilityPolicyMode", + this.immutabilityPolicyMode == null ? null : this.immutabilityPolicyMode.toString()); + jsonWriter.writeBooleanField("legalHold", this.legalHold); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobPropertiesInternal from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobPropertiesInternal if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobPropertiesInternal. + */ + @Generated + public static BlobPropertiesInternal fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime lastModified = null; + String eTag = null; + DateTimeRfc1123 creationTime = null; + Long contentLength = null; + String contentType = null; + String contentEncoding = null; + String contentLanguage = null; + byte[] contentMd5 = null; + String contentDisposition = null; + String cacheControl = null; + Long blobSequenceNumber = null; + BlobType blobType = null; + LeaseStatus leaseStatus = null; + LeaseState leaseState = null; + LeaseDuration leaseDuration = null; + String copyId = null; + CopyStatus copyStatus = null; + String copySource = null; + String copyProgress = null; + DateTimeRfc1123 copyCompletionTime = null; + String copyStatusDescription = null; + Boolean serverEncrypted = null; + Boolean incrementalCopy = null; + String destinationSnapshot = null; + DateTimeRfc1123 deletedTime = null; + Integer remainingRetentionDays = null; + AccessTier accessTier = null; + Boolean accessTierInferred = null; + ArchiveStatus archiveStatus = null; + String customerProvidedKeySha256 = null; + String encryptionScope = null; + DateTimeRfc1123 accessTierChangeTime = null; + Integer tagCount = null; + DateTimeRfc1123 expiresOn = null; + Boolean isSealed = null; + RehydratePriority rehydratePriority = null; + DateTimeRfc1123 lastAccessedOn = null; + DateTimeRfc1123 immutabilityPolicyExpiresOn = null; + BlobImmutabilityPolicyMode immutabilityPolicyMode = null; + Boolean legalHold = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("lastModified".equals(fieldName)) { + DateTimeRfc1123 lastModifiedHolder + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + if (lastModifiedHolder != null) { + lastModified = lastModifiedHolder.getDateTime(); + } + } else if ("eTag".equals(fieldName)) { + eTag = reader.getString(); + } else if ("creationTime".equals(fieldName)) { + creationTime = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + } else if ("contentLength".equals(fieldName)) { + contentLength = reader.getNullable(JsonReader::getLong); + } else if ("contentType".equals(fieldName)) { + contentType = reader.getString(); + } else if ("contentEncoding".equals(fieldName)) { + contentEncoding = reader.getString(); + } else if ("contentLanguage".equals(fieldName)) { + contentLanguage = reader.getString(); + } else if ("contentMd5".equals(fieldName)) { + contentMd5 = reader.getBinary(); + } else if ("contentDisposition".equals(fieldName)) { + contentDisposition = reader.getString(); + } else if ("cacheControl".equals(fieldName)) { + cacheControl = reader.getString(); + } else if ("blobSequenceNumber".equals(fieldName)) { + blobSequenceNumber = reader.getNullable(JsonReader::getLong); + } else if ("blobType".equals(fieldName)) { + blobType = BlobType.fromString(reader.getString()); + } else if ("leaseStatus".equals(fieldName)) { + leaseStatus = LeaseStatus.fromString(reader.getString()); + } else if ("leaseState".equals(fieldName)) { + leaseState = LeaseState.fromString(reader.getString()); + } else if ("leaseDuration".equals(fieldName)) { + leaseDuration = LeaseDuration.fromString(reader.getString()); + } else if ("copyId".equals(fieldName)) { + copyId = reader.getString(); + } else if ("copyStatus".equals(fieldName)) { + copyStatus = CopyStatus.fromString(reader.getString()); + } else if ("copySource".equals(fieldName)) { + copySource = reader.getString(); + } else if ("copyProgress".equals(fieldName)) { + copyProgress = reader.getString(); + } else if ("copyCompletionTime".equals(fieldName)) { + copyCompletionTime + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + } else if ("copyStatusDescription".equals(fieldName)) { + copyStatusDescription = reader.getString(); + } else if ("serverEncrypted".equals(fieldName)) { + serverEncrypted = reader.getNullable(JsonReader::getBoolean); + } else if ("incrementalCopy".equals(fieldName)) { + incrementalCopy = reader.getNullable(JsonReader::getBoolean); + } else if ("destinationSnapshot".equals(fieldName)) { + destinationSnapshot = reader.getString(); + } else if ("deletedTime".equals(fieldName)) { + deletedTime = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + } else if ("remainingRetentionDays".equals(fieldName)) { + remainingRetentionDays = reader.getNullable(JsonReader::getInt); + } else if ("accessTier".equals(fieldName)) { + accessTier = AccessTier.fromString(reader.getString()); + } else if ("accessTierInferred".equals(fieldName)) { + accessTierInferred = reader.getNullable(JsonReader::getBoolean); + } else if ("archiveStatus".equals(fieldName)) { + archiveStatus = ArchiveStatus.fromString(reader.getString()); + } else if ("customerProvidedKeySha256".equals(fieldName)) { + customerProvidedKeySha256 = reader.getString(); + } else if ("encryptionScope".equals(fieldName)) { + encryptionScope = reader.getString(); + } else if ("accessTierChangeTime".equals(fieldName)) { + accessTierChangeTime + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + } else if ("tagCount".equals(fieldName)) { + tagCount = reader.getNullable(JsonReader::getInt); + } else if ("expiryTime".equals(fieldName)) { + expiresOn = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + } else if ("sealed".equals(fieldName)) { + isSealed = reader.getNullable(JsonReader::getBoolean); + } else if ("rehydratePriority".equals(fieldName)) { + rehydratePriority = RehydratePriority.fromString(reader.getString()); + } else if ("lastAccessTime".equals(fieldName)) { + lastAccessedOn + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + } else if ("immutabilityPolicyUntilDate".equals(fieldName)) { + immutabilityPolicyExpiresOn + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + } else if ("immutabilityPolicyMode".equals(fieldName)) { + immutabilityPolicyMode = BlobImmutabilityPolicyMode.fromString(reader.getString()); + } else if ("legalHold".equals(fieldName)) { + legalHold = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + BlobPropertiesInternal deserializedBlobPropertiesInternal = new BlobPropertiesInternal(lastModified, eTag); + deserializedBlobPropertiesInternal.creationTime = creationTime; + deserializedBlobPropertiesInternal.contentLength = contentLength; + deserializedBlobPropertiesInternal.contentType = contentType; + deserializedBlobPropertiesInternal.contentEncoding = contentEncoding; + deserializedBlobPropertiesInternal.contentLanguage = contentLanguage; + deserializedBlobPropertiesInternal.contentMd5 = contentMd5; + deserializedBlobPropertiesInternal.contentDisposition = contentDisposition; + deserializedBlobPropertiesInternal.cacheControl = cacheControl; + deserializedBlobPropertiesInternal.blobSequenceNumber = blobSequenceNumber; + deserializedBlobPropertiesInternal.blobType = blobType; + deserializedBlobPropertiesInternal.leaseStatus = leaseStatus; + deserializedBlobPropertiesInternal.leaseState = leaseState; + deserializedBlobPropertiesInternal.leaseDuration = leaseDuration; + deserializedBlobPropertiesInternal.copyId = copyId; + deserializedBlobPropertiesInternal.copyStatus = copyStatus; + deserializedBlobPropertiesInternal.copySource = copySource; + deserializedBlobPropertiesInternal.copyProgress = copyProgress; + deserializedBlobPropertiesInternal.copyCompletionTime = copyCompletionTime; + deserializedBlobPropertiesInternal.copyStatusDescription = copyStatusDescription; + deserializedBlobPropertiesInternal.serverEncrypted = serverEncrypted; + deserializedBlobPropertiesInternal.incrementalCopy = incrementalCopy; + deserializedBlobPropertiesInternal.destinationSnapshot = destinationSnapshot; + deserializedBlobPropertiesInternal.deletedTime = deletedTime; + deserializedBlobPropertiesInternal.remainingRetentionDays = remainingRetentionDays; + deserializedBlobPropertiesInternal.accessTier = accessTier; + deserializedBlobPropertiesInternal.accessTierInferred = accessTierInferred; + deserializedBlobPropertiesInternal.archiveStatus = archiveStatus; + deserializedBlobPropertiesInternal.customerProvidedKeySha256 = customerProvidedKeySha256; + deserializedBlobPropertiesInternal.encryptionScope = encryptionScope; + deserializedBlobPropertiesInternal.accessTierChangeTime = accessTierChangeTime; + deserializedBlobPropertiesInternal.tagCount = tagCount; + deserializedBlobPropertiesInternal.expiresOn = expiresOn; + deserializedBlobPropertiesInternal.isSealed = isSealed; + deserializedBlobPropertiesInternal.rehydratePriority = rehydratePriority; + deserializedBlobPropertiesInternal.lastAccessedOn = lastAccessedOn; + deserializedBlobPropertiesInternal.immutabilityPolicyExpiresOn = immutabilityPolicyExpiresOn; + deserializedBlobPropertiesInternal.immutabilityPolicyMode = immutabilityPolicyMode; + deserializedBlobPropertiesInternal.legalHold = legalHold; + + return deserializedBlobPropertiesInternal; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowField.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowField.java deleted file mode 100644 index ab5fef25091c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowField.java +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.common.implementation.StorageImplUtils; - -/** - * Defines an arrow field for a blob quick query request. - */ -@Fluent -public class BlobQueryArrowField { - private String name; - private Integer precision; - private Integer scale; - private final BlobQueryArrowFieldType type; - - /** - * Creates a new instance of {@link BlobQueryArrowField}. - * - * @param type {@link BlobQueryArrowFieldType} - */ - public BlobQueryArrowField(BlobQueryArrowFieldType type) { - StorageImplUtils.assertNotNull("type", type); - this.type = type; - } - - /** - * Sets the name of the field. - * - * @param name The name of the field. - * @return The updated options. - */ - public BlobQueryArrowField setName(String name) { - this.name = name; - return this; - } - - /** - * Sets the precision of the field. Required if type is {@link BlobQueryArrowFieldType#DECIMAL}. - * - * @param precision The precision of the field. Required if type is {@link BlobQueryArrowFieldType#DECIMAL} - * @return The updated options. - */ - public BlobQueryArrowField setPrecision(Integer precision) { - this.precision = precision; - return this; - } - - /** - * Sets the scale of the field. Required if type is {@link BlobQueryArrowFieldType#DECIMAL}. - * - * @param scale The scale of the field. Required if type is {@link BlobQueryArrowFieldType#DECIMAL} - * @return The updated options. - */ - public BlobQueryArrowField setScale(Integer scale) { - this.scale = scale; - return this; - } - - /** - * Gets the name. - * - * @return The name. - */ - public String getName() { - return name; - } - - /** - * Gets the precision. - * - * @return The precision. - */ - public Integer getPrecision() { - return precision; - } - - /** - * Gets the scale. - * - * @return The scale. - */ - public Integer getScale() { - return scale; - } - - /** - * Gets the {@link BlobQueryArrowFieldType}. - * - * @return {@link BlobQueryArrowFieldType} - */ - public BlobQueryArrowFieldType getType() { - return type; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowFieldType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowFieldType.java deleted file mode 100644 index 27fc17d5be8b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowFieldType.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -/** - * Defines values for BlobQueryArrowFieldType. - */ -public enum BlobQueryArrowFieldType { - - /** - * Enum value int64. - */ - INT64("int64"), - - /** - * Enum value bool. - */ - BOOL("bool"), - - /** - * Enum value timestamp[ms]. - */ - TIMESTAMP("timestamp[ms]"), - - /** - * Enum value string. - */ - STRING("string"), - - /** - * Enum value double. - */ - DOUBLE("double"), - - /** - * Enum value decimal. - */ - DECIMAL("decimal"); - - /** - * The actual serialized value for a BlobQueryArrowFieldType instance. - */ - private final String value; - - BlobQueryArrowFieldType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a BlobQueryArrowFieldType instance. - * - * @param value the serialized value to parse. - * @return the parsed BlobQueryArrowFieldType object, or null if unable to parse. - */ - public static BlobQueryArrowFieldType fromString(String value) { - BlobQueryArrowFieldType[] items = BlobQueryArrowFieldType.values(); - for (BlobQueryArrowFieldType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowSerialization.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowSerialization.java deleted file mode 100644 index 66f921a3f9e1..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryArrowSerialization.java +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import java.util.Collections; -import java.util.List; - -/** - * Defines the output arrow serialization for a blob quick query request. - */ -public class BlobQueryArrowSerialization implements BlobQuerySerialization { - private List schema; - - /** - * Creates a new instance of {@link BlobQueryArrowSerialization}. - */ - public BlobQueryArrowSerialization() { - } - - /** - * Gets the arrow fields. - * - * @return the arrow fields. - */ - public List getSchema() { - return schema == null ? null : Collections.unmodifiableList(schema); - } - - /** - * Sets the arrow fields. - * - * @param schema the arrow fields. - * @return the updated BlobQueryArrowSerialization object. - */ - public BlobQueryArrowSerialization setSchema(List schema) { - this.schema = schema == null ? null : Collections.unmodifiableList(schema); - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryAsyncResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryAsyncResponse.java deleted file mode 100644 index 030102bee2f5..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryAsyncResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.rest.ResponseBase; -import reactor.core.publisher.Flux; - -import java.nio.ByteBuffer; - -/** - * This class contains the response information returned from the server when querying a blob. - */ -public final class BlobQueryAsyncResponse extends ResponseBase> { - /** - * Constructs a {@link BlobQueryAsyncResponse}. - * - * @param request Request sent to the service. - * @param statusCode Response status code returned by the service. - * @param headers Raw headers returned in the response. - * @param value Stream of download data being returned by the service. - * @param deserializedHeaders Headers deserialized into an object. - */ - public BlobQueryAsyncResponse(HttpRequest request, int statusCode, HttpHeaders headers, Flux value, - BlobQueryHeaders deserializedHeaders) { - super(request, statusCode, headers, value, deserializedHeaders); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryDelimitedSerialization.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryDelimitedSerialization.java deleted file mode 100644 index d1dc568d581d..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryDelimitedSerialization.java +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -/** - * Defines the input or output delimited (CSV) serialization for a blob quick query request. - */ -public class BlobQueryDelimitedSerialization implements BlobQuerySerialization { - private char columnSeparator; - private char fieldQuote; - private char escapeChar; - private boolean headersPresent; - private char recordSeparator; - - /** - * Creates a new instance of {@link BlobQueryDelimitedSerialization}. - */ - public BlobQueryDelimitedSerialization() { - } - - /** - * Gets the column separator. - * @return the column separator. - */ - public char getColumnSeparator() { - return columnSeparator; - } - - /** - * Sets the column separator. - * @param columnSeparator the column separator. - * @return the updated BlobQuickQueryDelimitedSerialization object. - */ - public BlobQueryDelimitedSerialization setColumnSeparator(char columnSeparator) { - this.columnSeparator = columnSeparator; - return this; - } - - /** - * Gets the field quote. - * @return the field quote. - */ - public char getFieldQuote() { - return fieldQuote; - } - - /** - * Sets the field quote. - * @param fieldQuote the field quote. - * @return the updated BlobQuickQueryDelimitedSerialization object. - */ - public BlobQueryDelimitedSerialization setFieldQuote(char fieldQuote) { - this.fieldQuote = fieldQuote; - return this; - } - - /** - * Gets the escape character. - * @return the escape character. - */ - public char getEscapeChar() { - return escapeChar; - } - - /** - * Sets the escape character. - * @param escapeChar the escape character. - * @return the updated BlobQuickQueryDelimitedSerialization object. - */ - public BlobQueryDelimitedSerialization setEscapeChar(char escapeChar) { - this.escapeChar = escapeChar; - return this; - } - - /** - * Gets whether or not headers are present. - * @return Whether or not headers are present. - */ - public boolean isHeadersPresent() { - return headersPresent; - } - - /** - * Sets whether or not headers are present. - * @param headersPresent Whether or not headers are present. - * @return the updated BlobQuickQueryDelimitedSerialization object. - */ - public BlobQueryDelimitedSerialization setHeadersPresent(boolean headersPresent) { - this.headersPresent = headersPresent; - return this; - } - - /** - * Gets the record separator. - * - * @return the record separator. - */ - public char getRecordSeparator() { - return recordSeparator; - } - - /** - * Sets the record separator. - * @param recordSeparator the record separator. - * @return the updated BlobQueryDelimitedSerialization object. - */ - public BlobQueryDelimitedSerialization setRecordSeparator(char recordSeparator) { - this.recordSeparator = recordSeparator; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryError.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryError.java deleted file mode 100644 index 0c9341950e5b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryError.java +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -/** - * Defines a blob query error that can be returned on parsing a blob query request. - */ -public class BlobQueryError { - - private final boolean fatal; - private final String name; - private final String description; - private final long position; - - /** - * Creates a new BlobQueryError object. - * @param fatal Whether the error is fatal. - * @param name The name of the error. - * @param description A description of the error. - * @param position The blob offset at which the error occurred. - */ - public BlobQueryError(boolean fatal, String name, String description, long position) { - this.fatal = fatal; - this.name = name; - this.description = description; - this.position = position; - } - - /** - * Whether the error is fatal. If true, this error prevents further query processing. More result data may be - * returned, but there is no guarantee that all the original data will be processed. If false, this error does not - * prevent further query processing. - * - * @return Whether the error is fatal. - */ - public boolean isFatal() { - return fatal; - } - - /** - * Gets the name of the error. - * - * @return The name of the error. - */ - public String getName() { - return name; - } - - /** - * Gets a description of the error. - * - * @return A description of the error. - */ - public String getDescription() { - return description; - } - - /** - * Gets the blob offset at which the error occurred. - * - * @return The blob offset at which the error occurred. - */ - public long getPosition() { - return position; - } - - @Override - public String toString() { - return String.format("QueryError. fatality = %b, name = %s, description = %s, position (in source) = %d.", - this.fatal, this.name, this.description, this.position); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryHeaders.java deleted file mode 100644 index 2b235727b5a8..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryHeaders.java +++ /dev/null @@ -1,880 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpHeaders; -import com.azure.storage.blob.implementation.accesshelpers.BlobQueryHeadersConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobsQueryHeaders; - -import java.time.OffsetDateTime; -import java.util.Map; - -/** - * Defines headers for Query operation. - */ -@Fluent -public final class BlobQueryHeaders { - private final BlobsQueryHeaders internalHeaders; - - static { - BlobQueryHeadersConstructorProxy.setAccessor(BlobQueryHeaders::new); - } - - /* - * The errorCode property. - */ - private String errorCode; - - private BlobQueryHeaders(BlobsQueryHeaders internalHeaders) { - this.internalHeaders = internalHeaders; - } - - /** - * Constructs a new instance of {@link BlobQueryHeaders}. - */ - public BlobQueryHeaders() { - // Added to maintain backwards compatibility as the private constructor removes the implicit no args constructor - this.internalHeaders = new BlobsQueryHeaders(new HttpHeaders()); - } - - /** - * Get the lastModified property: Returns the date and time the container - * was last modified. Any operation that modifies the blob, including an - * update of the blob's metadata or properties, changes the last-modified - * time of the blob. - * - * @return the lastModified value. - */ - public OffsetDateTime getLastModified() { - return internalHeaders.getLastModified(); - } - - /** - * Set the lastModified property: Returns the date and time the container - * was last modified. Any operation that modifies the blob, including an - * update of the blob's metadata or properties, changes the last-modified - * time of the blob. - * - * @param lastModified the lastModified value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setLastModified(OffsetDateTime lastModified) { - internalHeaders.setLastModified(lastModified); - return this; - } - - /** - * Get the metadata property: The metadata property. - * - * @return the metadata value. - */ - public Map getMetadata() { - return internalHeaders.getXMsMeta(); - } - - /** - * Set the metadata property: The metadata property. - * - * @param metadata the metadata value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setMetadata(Map metadata) { - internalHeaders.setXMsMeta(metadata); - return this; - } - - /** - * Get the contentLength property: The number of bytes present in the - * response body. - * - * @return the contentLength value. - */ - public Long getContentLength() { - return internalHeaders.getContentLength(); - } - - /** - * Set the contentLength property: The number of bytes present in the - * response body. - * - * @param contentLength the contentLength value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setContentLength(Long contentLength) { - internalHeaders.setContentLength(contentLength); - return this; - } - - /** - * Get the contentType property: The media type of the body of the - * response. For Download Blob this is 'application/octet-stream'. - * - * @return the contentType value. - */ - public String getContentType() { - return internalHeaders.getContentType(); - } - - /** - * Set the contentType property: The media type of the body of the - * response. For Download Blob this is 'application/octet-stream'. - * - * @param contentType the contentType value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setContentType(String contentType) { - internalHeaders.setContentType(contentType); - return this; - } - - /** - * Get the contentRange property: Indicates the range of bytes returned in - * the event that the client requested a subset of the blob by setting the - * 'Range' request header. - * - * @return the contentRange value. - */ - public String getContentRange() { - return internalHeaders.getContentRange(); - } - - /** - * Set the contentRange property: Indicates the range of bytes returned in - * the event that the client requested a subset of the blob by setting the - * 'Range' request header. - * - * @param contentRange the contentRange value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setContentRange(String contentRange) { - internalHeaders.setContentRange(contentRange); - return this; - } - - /** - * Get the eTag property: The ETag contains a value that you can use to - * perform operations conditionally. If the request version is 2011-08-18 - * or newer, the ETag value will be in quotes. - * - * @return the eTag value. - */ - public String getETag() { - return internalHeaders.getETag(); - } - - /** - * Set the eTag property: The ETag contains a value that you can use to - * perform operations conditionally. If the request version is 2011-08-18 - * or newer, the ETag value will be in quotes. - * - * @param eTag the eTag value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setETag(String eTag) { - internalHeaders.setETag(eTag); - return this; - } - - /** - * Get the contentMd5 property: If the blob has an MD5 hash and this - * operation is to read the full blob, this response header is returned so - * that the client can check for message content integrity. - * - * @return the contentMd5 value. - */ - public byte[] getContentMd5() { - return internalHeaders.getContentMD5(); - } - - /** - * Set the contentMd5 property: If the blob has an MD5 hash and this - * operation is to read the full blob, this response header is returned so - * that the client can check for message content integrity. - * - * @param contentMd5 the contentMd5 value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setContentMd5(byte[] contentMd5) { - internalHeaders.setContentMD5(contentMd5); - return this; - } - - /** - * Get the contentEncoding property: This header returns the value that was - * specified for the Content-Encoding request header. - * - * @return the contentEncoding value. - */ - public String getContentEncoding() { - return internalHeaders.getContentEncoding(); - } - - /** - * Set the contentEncoding property: This header returns the value that was - * specified for the Content-Encoding request header. - * - * @param contentEncoding the contentEncoding value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setContentEncoding(String contentEncoding) { - internalHeaders.setContentEncoding(contentEncoding); - return this; - } - - /** - * Get the cacheControl property: This header is returned if it was - * previously specified for the blob. - * - * @return the cacheControl value. - */ - public String getCacheControl() { - return internalHeaders.getCacheControl(); - } - - /** - * Set the cacheControl property: This header is returned if it was - * previously specified for the blob. - * - * @param cacheControl the cacheControl value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setCacheControl(String cacheControl) { - internalHeaders.setCacheControl(cacheControl); - return this; - } - - /** - * Get the contentDisposition property: This header returns the value that - * was specified for the 'x-ms-blob-content-disposition' header. The - * Content-Disposition response header field conveys additional information - * about how to process the response payload, and also can be used to - * attach additional metadata. For example, if set to attachment, it - * indicates that the user-agent should not display the response, but - * instead show a Save As dialog with a filename other than the blob name - * specified. - * - * @return the contentDisposition value. - */ - public String getContentDisposition() { - return internalHeaders.getContentDisposition(); - } - - /** - * Set the contentDisposition property: This header returns the value that - * was specified for the 'x-ms-blob-content-disposition' header. The - * Content-Disposition response header field conveys additional information - * about how to process the response payload, and also can be used to - * attach additional metadata. For example, if set to attachment, it - * indicates that the user-agent should not display the response, but - * instead show a Save As dialog with a filename other than the blob name - * specified. - * - * @param contentDisposition the contentDisposition value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setContentDisposition(String contentDisposition) { - internalHeaders.setContentDisposition(contentDisposition); - return this; - } - - /** - * Get the contentLanguage property: This header returns the value that was - * specified for the Content-Language request header. - * - * @return the contentLanguage value. - */ - public String getContentLanguage() { - return internalHeaders.getContentLanguage(); - } - - /** - * Set the contentLanguage property: This header returns the value that was - * specified for the Content-Language request header. - * - * @param contentLanguage the contentLanguage value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setContentLanguage(String contentLanguage) { - internalHeaders.setContentLanguage(contentLanguage); - return this; - } - - /** - * Get the blobSequenceNumber property: The current sequence number for a - * page blob. This header is not returned for block blobs or append blobs. - * - * @return the blobSequenceNumber value. - */ - public Long getBlobSequenceNumber() { - return internalHeaders.getXMsBlobSequenceNumber(); - } - - /** - * Set the blobSequenceNumber property: The current sequence number for a - * page blob. This header is not returned for block blobs or append blobs. - * - * @param blobSequenceNumber the blobSequenceNumber value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setBlobSequenceNumber(Long blobSequenceNumber) { - internalHeaders.setXMsBlobSequenceNumber(blobSequenceNumber); - return this; - } - - /** - * Get the blobType property: The blob's type. Possible values include: - * 'BlockBlob', 'PageBlob', 'AppendBlob'. - * - * @return the blobType value. - */ - public BlobType getBlobType() { - return internalHeaders.getXMsBlobType(); - } - - /** - * Set the blobType property: The blob's type. Possible values include: - * 'BlockBlob', 'PageBlob', 'AppendBlob'. - * - * @param blobType the blobType value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setBlobType(BlobType blobType) { - internalHeaders.setXMsBlobType(blobType); - return this; - } - - /** - * Get the copyCompletionTime property: Conclusion time of the last - * attempted Copy Blob operation where this blob was the destination blob. - * This value can specify the time of a completed, aborted, or failed copy - * attempt. This header does not appear if a copy is pending, if this blob - * has never been the destination in a Copy Blob operation, or if this blob - * has been modified after a concluded Copy Blob operation using Set Blob - * Properties, Put Blob, or Put Block List. - * - * @return the copyCompletionTime value. - */ - public OffsetDateTime getCopyCompletionTime() { - return internalHeaders.getXMsCopyCompletionTime(); - } - - /** - * Set the copyCompletionTime property: Conclusion time of the last - * attempted Copy Blob operation where this blob was the destination blob. - * This value can specify the time of a completed, aborted, or failed copy - * attempt. This header does not appear if a copy is pending, if this blob - * has never been the destination in a Copy Blob operation, or if this blob - * has been modified after a concluded Copy Blob operation using Set Blob - * Properties, Put Blob, or Put Block List. - * - * @param copyCompletionTime the copyCompletionTime value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setCopyCompletionTime(OffsetDateTime copyCompletionTime) { - internalHeaders.setXMsCopyCompletionTime(copyCompletionTime); - return this; - } - - /** - * Get the copyStatusDescription property: Only appears when - * x-ms-copy-status is failed or pending. Describes the cause of the last - * fatal or non-fatal copy operation failure. This header does not appear - * if this blob has never been the destination in a Copy Blob operation, or - * if this blob has been modified after a concluded Copy Blob operation - * using Set Blob Properties, Put Blob, or Put Block List. - * - * @return the copyStatusDescription value. - */ - public String getCopyStatusDescription() { - return internalHeaders.getXMsCopyStatusDescription(); - } - - /** - * Set the copyStatusDescription property: Only appears when - * x-ms-copy-status is failed or pending. Describes the cause of the last - * fatal or non-fatal copy operation failure. This header does not appear - * if this blob has never been the destination in a Copy Blob operation, or - * if this blob has been modified after a concluded Copy Blob operation - * using Set Blob Properties, Put Blob, or Put Block List. - * - * @param copyStatusDescription the copyStatusDescription value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setCopyStatusDescription(String copyStatusDescription) { - internalHeaders.setXMsCopyStatusDescription(copyStatusDescription); - return this; - } - - /** - * Get the copyId property: String identifier for this copy operation. Use - * with Get Blob Properties to check the status of this copy operation, or - * pass to Abort Copy Blob to abort a pending copy. - * - * @return the copyId value. - */ - public String getCopyId() { - return internalHeaders.getXMsCopyId(); - } - - /** - * Set the copyId property: String identifier for this copy operation. Use - * with Get Blob Properties to check the status of this copy operation, or - * pass to Abort Copy Blob to abort a pending copy. - * - * @param copyId the copyId value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setCopyId(String copyId) { - internalHeaders.setXMsCopyId(copyId); - return this; - } - - /** - * Get the copyProgress property: Contains the number of bytes copied and - * the total bytes in the source in the last attempted Copy Blob operation - * where this blob was the destination blob. Can show between 0 and - * Content-Length bytes copied. This header does not appear if this blob - * has never been the destination in a Copy Blob operation, or if this blob - * has been modified after a concluded Copy Blob operation using Set Blob - * Properties, Put Blob, or Put Block List. - * - * @return the copyProgress value. - */ - public String getCopyProgress() { - return internalHeaders.getXMsCopyProgress(); - } - - /** - * Set the copyProgress property: Contains the number of bytes copied and - * the total bytes in the source in the last attempted Copy Blob operation - * where this blob was the destination blob. Can show between 0 and - * Content-Length bytes copied. This header does not appear if this blob - * has never been the destination in a Copy Blob operation, or if this blob - * has been modified after a concluded Copy Blob operation using Set Blob - * Properties, Put Blob, or Put Block List. - * - * @param copyProgress the copyProgress value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setCopyProgress(String copyProgress) { - internalHeaders.setXMsCopyProgress(copyProgress); - return this; - } - - /** - * Get the copySource property: URL up to 2 KB in length that specifies the - * source blob or file used in the last attempted Copy Blob operation where - * this blob was the destination blob. This header does not appear if this - * blob has never been the destination in a Copy Blob operation, or if this - * blob has been modified after a concluded Copy Blob operation using Set - * Blob Properties, Put Blob, or Put Block List. - * - * @return the copySource value. - */ - public String getCopySource() { - return internalHeaders.getXMsCopySource(); - } - - /** - * Set the copySource property: URL up to 2 KB in length that specifies the - * source blob or file used in the last attempted Copy Blob operation where - * this blob was the destination blob. This header does not appear if this - * blob has never been the destination in a Copy Blob operation, or if this - * blob has been modified after a concluded Copy Blob operation using Set - * Blob Properties, Put Blob, or Put Block List. - * - * @param copySource the copySource value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setCopySource(String copySource) { - internalHeaders.setXMsCopySource(copySource); - return this; - } - - /** - * Get the copyStatus property: State of the copy operation identified by - * x-ms-copy-id. Possible values include: 'pending', 'success', 'aborted', - * 'failed'. - * - * @return the copyStatus value. - */ - public CopyStatusType getCopyStatus() { - return internalHeaders.getXMsCopyStatus(); - } - - /** - * Set the copyStatus property: State of the copy operation identified by - * x-ms-copy-id. Possible values include: 'pending', 'success', 'aborted', - * 'failed'. - * - * @param copyStatus the copyStatus value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setCopyStatus(CopyStatusType copyStatus) { - internalHeaders.setXMsCopyStatus(copyStatus); - return this; - } - - /** - * Get the leaseDuration property: When a blob is leased, specifies whether - * the lease is of infinite or fixed duration. Possible values include: - * 'infinite', 'fixed'. - * - * @return the leaseDuration value. - */ - public LeaseDurationType getLeaseDuration() { - return internalHeaders.getXMsLeaseDuration(); - } - - /** - * Set the leaseDuration property: When a blob is leased, specifies whether - * the lease is of infinite or fixed duration. Possible values include: - * 'infinite', 'fixed'. - * - * @param leaseDuration the leaseDuration value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setLeaseDuration(LeaseDurationType leaseDuration) { - internalHeaders.setXMsLeaseDuration(leaseDuration); - return this; - } - - /** - * Get the leaseState property: Lease state of the blob. Possible values - * include: 'available', 'leased', 'expired', 'breaking', 'broken'. - * - * @return the leaseState value. - */ - public LeaseStateType getLeaseState() { - return internalHeaders.getXMsLeaseState(); - } - - /** - * Set the leaseState property: Lease state of the blob. Possible values - * include: 'available', 'leased', 'expired', 'breaking', 'broken'. - * - * @param leaseState the leaseState value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setLeaseState(LeaseStateType leaseState) { - internalHeaders.setXMsLeaseState(leaseState); - return this; - } - - /** - * Get the leaseStatus property: The current lease status of the blob. - * Possible values include: 'locked', 'unlocked'. - * - * @return the leaseStatus value. - */ - public LeaseStatusType getLeaseStatus() { - return internalHeaders.getXMsLeaseStatus(); - } - - /** - * Set the leaseStatus property: The current lease status of the blob. - * Possible values include: 'locked', 'unlocked'. - * - * @param leaseStatus the leaseStatus value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setLeaseStatus(LeaseStatusType leaseStatus) { - internalHeaders.setXMsLeaseStatus(leaseStatus); - return this; - } - - /** - * Get the clientRequestId property: If a client request id header is sent - * in the request, this header will be present in the response with the - * same value. - * - * @return the clientRequestId value. - */ - public String getClientRequestId() { - return internalHeaders.getXMsClientRequestId(); - } - - /** - * Set the clientRequestId property: If a client request id header is sent - * in the request, this header will be present in the response with the - * same value. - * - * @param clientRequestId the clientRequestId value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setClientRequestId(String clientRequestId) { - internalHeaders.setXMsClientRequestId(clientRequestId); - return this; - } - - /** - * Get the requestId property: This header uniquely identifies the request - * that was made and can be used for troubleshooting the request. - * - * @return the requestId value. - */ - public String getRequestId() { - return internalHeaders.getXMsRequestId(); - } - - /** - * Set the requestId property: This header uniquely identifies the request - * that was made and can be used for troubleshooting the request. - * - * @param requestId the requestId value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setRequestId(String requestId) { - internalHeaders.setXMsRequestId(requestId); - return this; - } - - /** - * Get the version property: Indicates the version of the Blob service used - * to execute the request. This header is returned for requests made - * against version 2009-09-19 and above. - * - * @return the version value. - */ - public String getVersion() { - return internalHeaders.getXMsVersion(); - } - - /** - * Set the version property: Indicates the version of the Blob service used - * to execute the request. This header is returned for requests made - * against version 2009-09-19 and above. - * - * @param version the version value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setVersion(String version) { - internalHeaders.setXMsVersion(version); - return this; - } - - /** - * Get the acceptRanges property: Indicates that the service supports - * requests for partial blob content. - * - * @return the acceptRanges value. - */ - public String getAcceptRanges() { - return internalHeaders.getAcceptRanges(); - } - - /** - * Set the acceptRanges property: Indicates that the service supports - * requests for partial blob content. - * - * @param acceptRanges the acceptRanges value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setAcceptRanges(String acceptRanges) { - internalHeaders.setAcceptRanges(acceptRanges); - return this; - } - - /** - * Get the dateProperty property: UTC date/time value generated by the - * service that indicates the time at which the response was initiated. - * - * @return the dateProperty value. - */ - public OffsetDateTime getDateProperty() { - return internalHeaders.getDate(); - } - - /** - * Set the dateProperty property: UTC date/time value generated by the - * service that indicates the time at which the response was initiated. - * - * @param dateProperty the dateProperty value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setDateProperty(OffsetDateTime dateProperty) { - internalHeaders.setDate(dateProperty); - return this; - } - - /** - * Get the blobCommittedBlockCount property: The number of committed blocks - * present in the blob. This header is returned only for append blobs. - * - * @return the blobCommittedBlockCount value. - */ - public Integer getBlobCommittedBlockCount() { - return internalHeaders.getXMsBlobCommittedBlockCount(); - } - - /** - * Set the blobCommittedBlockCount property: The number of committed blocks - * present in the blob. This header is returned only for append blobs. - * - * @param blobCommittedBlockCount the blobCommittedBlockCount value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setBlobCommittedBlockCount(Integer blobCommittedBlockCount) { - internalHeaders.setXMsBlobCommittedBlockCount(blobCommittedBlockCount); - return this; - } - - /** - * Get the serverEncrypted property: The value of this header is set to - * true if the blob data and application metadata are completely encrypted - * using the specified algorithm. Otherwise, the value is set to false - * (when the blob is unencrypted, or if only parts of the blob/application - * metadata are encrypted). - * - * @return the serverEncrypted value. - */ - public Boolean isServerEncrypted() { - return internalHeaders.isXMsServerEncrypted(); - } - - /** - * Set the serverEncrypted property: The value of this header is set to - * true if the blob data and application metadata are completely encrypted - * using the specified algorithm. Otherwise, the value is set to false - * (when the blob is unencrypted, or if only parts of the blob/application - * metadata are encrypted). - * - * @param serverEncrypted the serverEncrypted value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setServerEncrypted(Boolean serverEncrypted) { - internalHeaders.setXMsServerEncrypted(serverEncrypted); - return this; - } - - /** - * Get the encryptionKeySha256 property: The SHA-256 hash of the encryption - * key used to encrypt the blob. This header is only returned when the blob - * was encrypted with a customer-provided key. - * - * @return the encryptionKeySha256 value. - */ - public String getEncryptionKeySha256() { - return internalHeaders.getXMsEncryptionKeySha256(); - } - - /** - * Set the encryptionKeySha256 property: The SHA-256 hash of the encryption - * key used to encrypt the blob. This header is only returned when the blob - * was encrypted with a customer-provided key. - * - * @param encryptionKeySha256 the encryptionKeySha256 value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setEncryptionKeySha256(String encryptionKeySha256) { - internalHeaders.setXMsEncryptionKeySha256(encryptionKeySha256); - return this; - } - - /** - * Get the encryptionScope property: Returns the name of the encryption - * scope used to encrypt the blob contents and application metadata. Note - * that the absence of this header implies use of the default account - * encryption scope. - * - * @return the encryptionScope value. - */ - public String getEncryptionScope() { - return internalHeaders.getXMsEncryptionScope(); - } - - /** - * Set the encryptionScope property: Returns the name of the encryption - * scope used to encrypt the blob contents and application metadata. Note - * that the absence of this header implies use of the default account - * encryption scope. - * - * @param encryptionScope the encryptionScope value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setEncryptionScope(String encryptionScope) { - internalHeaders.setXMsEncryptionScope(encryptionScope); - return this; - } - - /** - * Get the blobContentMd5 property: If the blob has a MD5 hash, and if - * request contains range header (Range or x-ms-range), this response - * header is returned with the value of the whole blob's MD5 value. This - * value may or may not be equal to the value returned in Content-MD5 - * header, with the latter calculated from the requested range. - * - * @return the blobContentMd5 value. - */ - public byte[] getBlobContentMd5() { - return internalHeaders.getXMsBlobContentMd5(); - } - - /** - * Set the blobContentMd5 property: If the blob has a MD5 hash, and if - * request contains range header (Range or x-ms-range), this response - * header is returned with the value of the whole blob's MD5 value. This - * value may or may not be equal to the value returned in Content-MD5 - * header, with the latter calculated from the requested range. - * - * @param blobContentMd5 the blobContentMd5 value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setBlobContentMd5(byte[] blobContentMd5) { - internalHeaders.setXMsBlobContentMd5(blobContentMd5); - return this; - } - - /** - * Get the contentCrc64 property: If the request is to read a specified - * range and the x-ms-range-get-content-crc64 is set to true, then the - * request returns a crc64 for the range, as long as the range size is less - * than or equal to 4 MB. If both x-ms-range-get-content-crc64 and - * x-ms-range-get-content-md5 is specified in the same request, it will - * fail with 400(Bad Request). - * - * @return the contentCrc64 value. - */ - public byte[] getContentCrc64() { - return internalHeaders.getXMsContentCrc64(); - } - - /** - * Set the contentCrc64 property: If the request is to read a specified - * range and the x-ms-range-get-content-crc64 is set to true, then the - * request returns a crc64 for the range, as long as the range size is less - * than or equal to 4 MB. If both x-ms-range-get-content-crc64 and - * x-ms-range-get-content-md5 is specified in the same request, it will - * fail with 400(Bad Request). - * - * @param contentCrc64 the contentCrc64 value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setContentCrc64(byte[] contentCrc64) { - internalHeaders.setXMsContentCrc64(contentCrc64); - return this; - } - - /** - * Get the errorCode property: The errorCode property. - * - * @return the errorCode value. - */ - public String getErrorCode() { - return this.errorCode; - } - - /** - * Set the errorCode property: The errorCode property. - * - * @param errorCode the errorCode value to set. - * @return the BlobQueryHeaders object itself. - */ - public BlobQueryHeaders setErrorCode(String errorCode) { - this.errorCode = errorCode; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryJsonSerialization.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryJsonSerialization.java deleted file mode 100644 index 7e354ce730b2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryJsonSerialization.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -/** - * Defines the input or output JSON serialization for a blob quick query request. - */ -public class BlobQueryJsonSerialization implements BlobQuerySerialization { - private char recordSeparator; - - /** - * Creates a new instance of {@link BlobQueryJsonSerialization}. - */ - public BlobQueryJsonSerialization() { - } - - /** - * Gets the record separator. - * - * @return the record separator. - */ - public char getRecordSeparator() { - return recordSeparator; - } - - /** - * Sets the record separator. - * @param recordSeparator the record separator. - * @return the updated BlobQueryJsonSerialization object. - */ - public BlobQueryJsonSerialization setRecordSeparator(char recordSeparator) { - this.recordSeparator = recordSeparator; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryParquetSerialization.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryParquetSerialization.java deleted file mode 100644 index 5064bbf09f79..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryParquetSerialization.java +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -/** - * Defines the input parquet serialization for a blob quick query request. - */ -public final class BlobQueryParquetSerialization implements BlobQuerySerialization { - /** - * Creates a new instance of {@link BlobQueryParquetSerialization}. - */ - public BlobQueryParquetSerialization() { - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryProgress.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryProgress.java deleted file mode 100644 index 56bc23a73d2a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryProgress.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -/** - * Defines a blob query error that can be returned on parsing a blob query request. - */ -public class BlobQueryProgress { - private final long bytesScanned; - private final long totalBytes; - - /** - * Creates a new BlobQueryProgress object. - * @param bytesScanned The number of bytes scanned so far. - * @param totalBytes The total number of bytes in the blob. - */ - public BlobQueryProgress(long bytesScanned, long totalBytes) { - this.bytesScanned = bytesScanned; - this.totalBytes = totalBytes; - } - - /** - * Gets the number of bytes scanned so far. - * - * @return The number of bytes scanned so far. - */ - public long getBytesScanned() { - return bytesScanned; - } - - /** - * Gets the total number of bytes in the blob. - * - * @return The total number of bytes in the blob. - */ - public long getTotalBytes() { - return totalBytes; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryResponse.java deleted file mode 100644 index 9d9f06bfb6d1..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQueryResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.http.rest.ResponseBase; - -/** - * This class contains the response information return from the server when querying a blob. - */ -public final class BlobQueryResponse extends ResponseBase { - /** - * Constructs a {@link BlobQueryResponse}. - * - * @param response Response returned from the service. - */ - public BlobQueryResponse(BlobQueryAsyncResponse response) { - super(response.getRequest(), response.getStatusCode(), response.getHeaders(), null, - response.getDeserializedHeaders()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQuerySerialization.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQuerySerialization.java deleted file mode 100644 index fe0771d2fdfe..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobQuerySerialization.java +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -/** - * Defines the input and output serialization for a blob quick query request. - * either {@link BlobQueryJsonSerialization}, {@link BlobQueryDelimitedSerialization}, - * {@link BlobQueryArrowSerialization}, or {@link BlobQueryParquetSerialization}. - *

- * Note: {@link BlobQueryParquetSerialization} can only be used as an input and - * {@link BlobQueryArrowSerialization} can only be used as an output. - *

- */ -public interface BlobQuerySerialization { -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRange.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRange.java deleted file mode 100644 index 74a6cb52fe55..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRange.java +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; - -import java.util.Locale; - -/** - * This is a representation of a range of bytes on a blob, typically used during a download operation. This type is - * immutable to ensure thread-safety of requests, so changing the values for a different operation requires construction - * of a new object. Passing null as a BlobRange value will default to the entire range of the blob. - */ -@Immutable -public final class BlobRange { - private static final String RANGE_HEADER_FORMAT = "bytes=%d-%d"; - private static final String BEGIN_RANGE_HEADER_FORMAT = "bytes=%d-"; - - private final long offset; - private final Long count; - - /** - * Specifies the download operation to start from the offset position (zero-based) and download the rest of the - * entire blob to the end. - * - * @param offset the zero-based position to start downloading - * @throws IllegalArgumentException If {@code offset} is less than {@code 0}. - */ - public BlobRange(long offset) { - this(offset, null); - } - - /** - * Specifies the download operation to start from the offset position (zero-based) and download the count number of - * bytes. - * - * @param offset the zero-based position to start downloading - * @param count the number of bytes to download - * @throws IllegalArgumentException If {@code offset} or {@code count} is less than {@code 0}. - */ - public BlobRange(long offset, Long count) { - if (offset < 0) { - throw new IllegalArgumentException("BlobRange offset must be greater than or equal to 0."); - } - this.offset = offset; - - if (count != null && count < 0) { - throw new IllegalArgumentException("BlobRange count must be greater than or equal to 0 if specified."); - } - this.count = count; - } - - /** - * The start of the range. Must be greater than or equal to 0. - * - * @return the offset for the range - */ - public long getOffset() { - return offset; - } - - /** - * How many bytes to include in the range. Must be greater than or equal to 0 if specified. - * - * @return the number bytes to include in the range - */ - public Long getCount() { - return count; - } - - /** - * Gets a string compliant the format of the Azure Storage x-ms-range and Range headers. - * - * @return A string compliant with the format of the Azure Storage x-ms-range and Range headers. - */ - @Override - public String toString() { - if (this.count != null) { - long rangeEnd = this.offset + this.count - 1; - return String.format(Locale.ROOT, RANGE_HEADER_FORMAT, this.offset, rangeEnd); - } - - return String.format(Locale.ROOT, BEGIN_RANGE_HEADER_FORMAT, this.offset); - } - - /** - * Gets a string compliant with the format of the Azure Storage x-ms-range and Range headers if {@code count} isn't - * {@code null} or {@code offset} isn't 0, otherwise null. - * - * @return {@link BlobRange#toString()} if {@code count} isn't {@code null} or {@code offset} isn't 0, otherwise - * null. - */ - public String toHeaderValue() { - // The default values of a BlobRange - if (this.offset == 0 && this.count == null) { - return null; - } - return this.toString(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRequestConditions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRequestConditions.java deleted file mode 100644 index 8921d19823bb..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRequestConditions.java +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; - -import java.time.OffsetDateTime; - -/** - * This class contains values which will restrict the successful operation of a variety of requests to the conditions - * present. These conditions are entirely optional. The entire object or any of its properties may be set to null when - * passed to a method to indicate that those conditions are not desired. Please refer to the type of each field for more - * information on those particular access conditions. - */ -@Fluent -public class BlobRequestConditions extends BlobLeaseRequestConditions { - private String leaseId; - - /** - * Creates a new instance of {@link BlobRequestConditions}. - */ - public BlobRequestConditions() { - } - - /** - * Optionally limit requests to resources that match the passed ETag. - * - * @param ifMatch ETag that resources must match. - * @return The updated BlobRequestConditions object. - */ - @Override - public BlobRequestConditions setIfMatch(String ifMatch) { - super.setIfMatch(ifMatch); - return this; - } - - /** - * Optionally limit requests to resources that do not match the passed ETag. - * - * @param ifNoneMatch ETag that resources must not match. - * @return The updated BlobRequestConditions object. - */ - @Override - public BlobRequestConditions setIfNoneMatch(String ifNoneMatch) { - super.setIfNoneMatch(ifNoneMatch); - return this; - } - - /** - * Optionally limit requests to resources that have only been modified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifModifiedSince The datetime that resources must have been modified since. - * @return The updated BlobRequestConditions object. - */ - @Override - public BlobRequestConditions setIfModifiedSince(OffsetDateTime ifModifiedSince) { - super.setIfModifiedSince(ifModifiedSince); - return this; - } - - /** - * Optionally limit requests to resources that have remained unmodified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifUnmodifiedSince The datetime that resources must have remained unmodified since. - * @return The updated BlobRequestConditions object. - */ - @Override - public BlobRequestConditions setIfUnmodifiedSince(OffsetDateTime ifUnmodifiedSince) { - super.setIfUnmodifiedSince(ifUnmodifiedSince); - return this; - } - - /** - * Optionally applies the SQL statement to the tags of the blob. - * - * @param tagsConditions The SQL statement that apply to the tags of the blob. - * @return The updated BlobRequestConditions object. - */ - @Override - public BlobRequestConditions setTagsConditions(String tagsConditions) { - super.setTagsConditions(tagsConditions); - return this; - } - - /** - * Gets the lease ID that blobs and containers must match. - * - * @return The lease ID that blobs and containers must match. - */ - public String getLeaseId() { - return leaseId; - } - - /** - * Optionally limits requests to blobs and containers that match the lease ID. - * - * @param leaseId Lease ID that blobs and containers must match. - * @return The updated BlobRequestConditions object. - */ - public BlobRequestConditions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRetentionPolicy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRetentionPolicy.java deleted file mode 100644 index 1e8640c1b857..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobRetentionPolicy.java +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * the retention policy which determines how long the associated data should persist. - */ -@Fluent -public final class BlobRetentionPolicy implements XmlSerializable { - /* - * Indicates whether a retention policy is enabled for the storage service - */ - private boolean enabled; - - /* - * Indicates the number of days that metrics or logging or soft-deleted data should be retained. All data older than - * this value will be deleted - */ - private Integer days; - - /** - * Creates an instance of BlobRetentionPolicy class. - */ - public BlobRetentionPolicy() { - } - - /** - * Get the enabled property: Indicates whether a retention policy is enabled for the storage service. - * - * @return the enabled value. - */ - public boolean isEnabled() { - return this.enabled; - } - - /** - * Set the enabled property: Indicates whether a retention policy is enabled for the storage service. - * - * @param enabled the enabled value to set. - * @return the BlobRetentionPolicy object itself. - */ - public BlobRetentionPolicy setEnabled(boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Get the days property: Indicates the number of days that metrics or logging or soft-deleted data should be - * retained. All data older than this value will be deleted. - * - * @return the days value. - */ - public Integer getDays() { - return this.days; - } - - /** - * Set the days property: Indicates the number of days that metrics or logging or soft-deleted data should be - * retained. All data older than this value will be deleted. - * - * @param days the days value to set. - * @return the BlobRetentionPolicy object itself. - */ - public BlobRetentionPolicy setDays(Integer days) { - this.days = days; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobRetentionPolicy" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeBooleanElement("Enabled", this.enabled); - xmlWriter.writeNumberElement("Days", this.days); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobRetentionPolicy from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobRetentionPolicy if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobRetentionPolicy. - */ - public static BlobRetentionPolicy fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobRetentionPolicy from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobRetentionPolicy if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobRetentionPolicy. - */ - public static BlobRetentionPolicy fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName - = CoreUtils.isNullOrEmpty(rootElementName) ? "BlobRetentionPolicy" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobRetentionPolicy deserializedBlobRetentionPolicy = new BlobRetentionPolicy(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Enabled".equals(elementName.getLocalPart())) { - deserializedBlobRetentionPolicy.enabled = reader.getBooleanElement(); - } else if ("Days".equals(elementName.getLocalPart())) { - deserializedBlobRetentionPolicy.days = reader.getNullableElement(Integer::parseInt); - } else { - reader.skipElement(); - } - } - - return deserializedBlobRetentionPolicy; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobSeekableByteChannelReadResult.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobSeekableByteChannelReadResult.java deleted file mode 100644 index 4c3d29b159c6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobSeekableByteChannelReadResult.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import java.nio.channels.SeekableByteChannel; - -/** - * Contains the results of opening a {@link SeekableByteChannel} to read from a blob. - */ -public final class BlobSeekableByteChannelReadResult { - private final SeekableByteChannel channel; - private final BlobProperties properties; - - /** - * Creates a new instance of {@link BlobSeekableByteChannelReadResult}. - * - * @param channel Channel to read the target blob. - * @param properties Blob properties of the target blob. - */ - public BlobSeekableByteChannelReadResult(SeekableByteChannel channel, BlobProperties properties) { - this.channel = channel; - this.properties = properties; - } - - /** - * Gets the channel to read the target blob. - * - * @return Channel to read the target blob. - */ - public SeekableByteChannel getChannel() { - return channel; - } - - /** - * Gets the blob properties of the target blob. - * - * @return Blob properties of the target blob. - */ - public BlobProperties getProperties() { - return properties; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobServiceProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobServiceProperties.java deleted file mode 100644 index 002e94c211c4..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobServiceProperties.java +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; -import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Storage Service Properties. - */ -@Fluent -public final class BlobServiceProperties implements XmlSerializable { - /* - * Azure Analytics Logging settings. - */ - private BlobAnalyticsLogging logging; - - /* - * a summary of request statistics grouped by API in hour or minute aggregates for blobs - */ - private BlobMetrics hourMetrics; - - /* - * a summary of request statistics grouped by API in hour or minute aggregates for blobs - */ - private BlobMetrics minuteMetrics; - - /* - * The set of CORS rules. - */ - private List cors; - - /* - * The default version to use for requests to the Blob service if an incoming request's version is not specified. - * Possible values include version 2008-10-27 and all more recent versions - */ - private String defaultServiceVersion; - - /* - * the retention policy which determines how long the associated data should persist - */ - private BlobRetentionPolicy deleteRetentionPolicy; - - /* - * The properties that enable an account to host a static website - */ - private StaticWebsite staticWebsite; - - /** - * Creates an instance of BlobServiceProperties class. - */ - public BlobServiceProperties() { - } - - /** - * Get the logging property: Azure Analytics Logging settings. - * - * @return the logging value. - */ - public BlobAnalyticsLogging getLogging() { - return this.logging; - } - - /** - * Set the logging property: Azure Analytics Logging settings. - * - * @param logging the logging value to set. - * @return the BlobServiceProperties object itself. - */ - public BlobServiceProperties setLogging(BlobAnalyticsLogging logging) { - this.logging = logging; - return this; - } - - /** - * Get the hourMetrics property: a summary of request statistics grouped by API in hour or minute aggregates for - * blobs. - * - * @return the hourMetrics value. - */ - public BlobMetrics getHourMetrics() { - return this.hourMetrics; - } - - /** - * Set the hourMetrics property: a summary of request statistics grouped by API in hour or minute aggregates for - * blobs. - * - * @param hourMetrics the hourMetrics value to set. - * @return the BlobServiceProperties object itself. - */ - public BlobServiceProperties setHourMetrics(BlobMetrics hourMetrics) { - this.hourMetrics = hourMetrics; - return this; - } - - /** - * Get the minuteMetrics property: a summary of request statistics grouped by API in hour or minute aggregates for - * blobs. - * - * @return the minuteMetrics value. - */ - public BlobMetrics getMinuteMetrics() { - return this.minuteMetrics; - } - - /** - * Set the minuteMetrics property: a summary of request statistics grouped by API in hour or minute aggregates for - * blobs. - * - * @param minuteMetrics the minuteMetrics value to set. - * @return the BlobServiceProperties object itself. - */ - public BlobServiceProperties setMinuteMetrics(BlobMetrics minuteMetrics) { - this.minuteMetrics = minuteMetrics; - return this; - } - - /** - * Get the cors property: The set of CORS rules. - * - * @return the cors value. - */ - public List getCors() { - if (this.cors == null) { - this.cors = new ArrayList<>(); - } - return this.cors; - } - - /** - * Set the cors property: The set of CORS rules. - * - * @param cors the cors value to set. - * @return the BlobServiceProperties object itself. - */ - public BlobServiceProperties setCors(List cors) { - this.cors = cors; - return this; - } - - /** - * Get the defaultServiceVersion property: The default version to use for requests to the Blob service if an - * incoming request's version is not specified. Possible values include version 2008-10-27 and all more recent - * versions. - * - * @return the defaultServiceVersion value. - */ - public String getDefaultServiceVersion() { - return this.defaultServiceVersion; - } - - /** - * Set the defaultServiceVersion property: The default version to use for requests to the Blob service if an - * incoming request's version is not specified. Possible values include version 2008-10-27 and all more recent - * versions. - * - * @param defaultServiceVersion the defaultServiceVersion value to set. - * @return the BlobServiceProperties object itself. - */ - public BlobServiceProperties setDefaultServiceVersion(String defaultServiceVersion) { - this.defaultServiceVersion = defaultServiceVersion; - return this; - } - - /** - * Get the deleteRetentionPolicy property: the retention policy which determines how long the associated data should - * persist. - * - * @return the deleteRetentionPolicy value. - */ - public BlobRetentionPolicy getDeleteRetentionPolicy() { - return this.deleteRetentionPolicy; - } - - /** - * Set the deleteRetentionPolicy property: the retention policy which determines how long the associated data should - * persist. - * - * @param deleteRetentionPolicy the deleteRetentionPolicy value to set. - * @return the BlobServiceProperties object itself. - */ - public BlobServiceProperties setDeleteRetentionPolicy(BlobRetentionPolicy deleteRetentionPolicy) { - this.deleteRetentionPolicy = deleteRetentionPolicy; - return this; - } - - /** - * Get the staticWebsite property: The properties that enable an account to host a static website. - * - * @return the staticWebsite value. - */ - public StaticWebsite getStaticWebsite() { - return this.staticWebsite; - } - - /** - * Set the staticWebsite property: The properties that enable an account to host a static website. - * - * @param staticWebsite the staticWebsite value to set. - * @return the BlobServiceProperties object itself. - */ - public BlobServiceProperties setStaticWebsite(StaticWebsite staticWebsite) { - this.staticWebsite = staticWebsite; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "StorageServiceProperties" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.logging, "Logging"); - xmlWriter.writeXml(this.hourMetrics, "HourMetrics"); - xmlWriter.writeXml(this.minuteMetrics, "MinuteMetrics"); - if (this.cors != null) { - xmlWriter.writeStartElement("Cors"); - for (BlobCorsRule element : this.cors) { - xmlWriter.writeXml(element, "CorsRule"); - } - xmlWriter.writeEndElement(); - } - xmlWriter.writeStringElement("DefaultServiceVersion", this.defaultServiceVersion); - xmlWriter.writeXml(this.deleteRetentionPolicy, "DeleteRetentionPolicy"); - xmlWriter.writeXml(this.staticWebsite, "StaticWebsite"); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobServiceProperties from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobServiceProperties if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobServiceProperties. - */ - public static BlobServiceProperties fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobServiceProperties from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobServiceProperties if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobServiceProperties. - */ - public static BlobServiceProperties fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName - = CoreUtils.isNullOrEmpty(rootElementName) ? "StorageServiceProperties" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobServiceProperties deserializedBlobServiceProperties = new BlobServiceProperties(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Logging".equals(elementName.getLocalPart())) { - deserializedBlobServiceProperties.logging = BlobAnalyticsLogging.fromXml(reader, "Logging"); - } else if ("HourMetrics".equals(elementName.getLocalPart())) { - deserializedBlobServiceProperties.hourMetrics = BlobMetrics.fromXml(reader, "HourMetrics"); - } else if ("MinuteMetrics".equals(elementName.getLocalPart())) { - deserializedBlobServiceProperties.minuteMetrics = BlobMetrics.fromXml(reader, "MinuteMetrics"); - } else if ("Cors".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - elementName = reader.getElementName(); - if ("CorsRule".equals(elementName.getLocalPart())) { - if (deserializedBlobServiceProperties.cors == null) { - deserializedBlobServiceProperties.cors = new ArrayList<>(); - } - deserializedBlobServiceProperties.cors.add(BlobCorsRule.fromXml(reader, "CorsRule")); - } else { - reader.skipElement(); - } - } - } else if ("DefaultServiceVersion".equals(elementName.getLocalPart())) { - deserializedBlobServiceProperties.defaultServiceVersion = reader.getStringElement(); - } else if ("DeleteRetentionPolicy".equals(elementName.getLocalPart())) { - deserializedBlobServiceProperties.deleteRetentionPolicy - = BlobRetentionPolicy.fromXml(reader, "DeleteRetentionPolicy"); - } else if ("StaticWebsite".equals(elementName.getLocalPart())) { - deserializedBlobServiceProperties.staticWebsite = StaticWebsite.fromXml(reader, "StaticWebsite"); - } else { - reader.skipElement(); - } - } - - return deserializedBlobServiceProperties; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobServiceStatistics.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobServiceStatistics.java deleted file mode 100644 index dd9cf49cd1ba..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobServiceStatistics.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Stats for the storage service. - */ -@Fluent -public final class BlobServiceStatistics implements XmlSerializable { - /* - * Geo-Replication information for the Secondary Storage Service - */ - private GeoReplication geoReplication; - - /** - * Creates an instance of BlobServiceStatistics class. - */ - public BlobServiceStatistics() { - } - - /** - * Get the geoReplication property: Geo-Replication information for the Secondary Storage Service. - * - * @return the geoReplication value. - */ - public GeoReplication getGeoReplication() { - return this.geoReplication; - } - - /** - * Set the geoReplication property: Geo-Replication information for the Secondary Storage Service. - * - * @param geoReplication the geoReplication value to set. - * @return the BlobServiceStatistics object itself. - */ - public BlobServiceStatistics setGeoReplication(GeoReplication geoReplication) { - this.geoReplication = geoReplication; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "StorageServiceStats" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.geoReplication, "GeoReplication"); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobServiceStatistics from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobServiceStatistics if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobServiceStatistics. - */ - public static BlobServiceStatistics fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobServiceStatistics from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobServiceStatistics if the XmlReader was pointing to an instance of it, or null if it - * was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobServiceStatistics. - */ - public static BlobServiceStatistics fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName - = CoreUtils.isNullOrEmpty(rootElementName) ? "StorageServiceStats" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobServiceStatistics deserializedBlobServiceStatistics = new BlobServiceStatistics(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("GeoReplication".equals(elementName.getLocalPart())) { - deserializedBlobServiceStatistics.geoReplication = GeoReplication.fromXml(reader, "GeoReplication"); - } else { - reader.skipElement(); - } - } - - return deserializedBlobServiceStatistics; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobSignedIdentifier.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobSignedIdentifier.java deleted file mode 100644 index 0394a51fc322..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobSignedIdentifier.java +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * signed identifier. - */ -@Fluent -public final class BlobSignedIdentifier implements XmlSerializable { - /* - * a unique id - */ - private String id; - - /* - * An Access policy - */ - private BlobAccessPolicy accessPolicy; - - /** - * Creates an instance of BlobSignedIdentifier class. - */ - public BlobSignedIdentifier() { - } - - /** - * Get the id property: a unique id. - * - * @return the id value. - */ - public String getId() { - return this.id; - } - - /** - * Set the id property: a unique id. - * - * @param id the id value to set. - * @return the BlobSignedIdentifier object itself. - */ - public BlobSignedIdentifier setId(String id) { - this.id = id; - return this; - } - - /** - * Get the accessPolicy property: An Access policy. - * - * @return the accessPolicy value. - */ - public BlobAccessPolicy getAccessPolicy() { - return this.accessPolicy; - } - - /** - * Set the accessPolicy property: An Access policy. - * - * @param accessPolicy the accessPolicy value to set. - * @return the BlobSignedIdentifier object itself. - */ - public BlobSignedIdentifier setAccessPolicy(BlobAccessPolicy accessPolicy) { - this.accessPolicy = accessPolicy; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "SignedIdentifier" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Id", this.id); - xmlWriter.writeXml(this.accessPolicy, "AccessPolicy"); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlobSignedIdentifier from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlobSignedIdentifier if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobSignedIdentifier. - */ - public static BlobSignedIdentifier fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlobSignedIdentifier from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlobSignedIdentifier if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlobSignedIdentifier. - */ - public static BlobSignedIdentifier fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "SignedIdentifier" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlobSignedIdentifier deserializedBlobSignedIdentifier = new BlobSignedIdentifier(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Id".equals(elementName.getLocalPart())) { - deserializedBlobSignedIdentifier.id = reader.getStringElement(); - } else if ("AccessPolicy".equals(elementName.getLocalPart())) { - deserializedBlobSignedIdentifier.accessPolicy = BlobAccessPolicy.fromXml(reader, "AccessPolicy"); - } else { - reader.skipElement(); - } - } - - return deserializedBlobSignedIdentifier; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobStorageException.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobStorageException.java deleted file mode 100644 index 18206a4618ec..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobStorageException.java +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpResponse; -import com.azure.storage.common.implementation.StorageImplUtils; - -import static com.azure.storage.common.implementation.Constants.HeaderConstants.ERROR_CODE_HEADER_NAME; - -/** - * A {@code BlobStorageException} is thrown whenever Azure Storage successfully returns an error code that is not - * 200-level. Users can inspect the status code and error code to determine the cause of the error response. The - * exception message may also contain more detailed information depending on the type of error. The user may also - * inspect the raw HTTP response or call toString to get the full payload of the error response if present. Note that - * even some expected "errors" will be thrown as a {@code BlobStorageException}. For example, some users may perform a - * getProperties request on an entity to determine whether it exists or not. If it does not exists, an exception will be - * thrown even though this may be considered an expected indication of absence in this case. - * - *

Sample Code

- *

For more samples, please see the sample - * file

- */ -public final class BlobStorageException extends HttpResponseException { - /** - * Constructs a {@code BlobStorageException}. - * - * @param message the exception message or the response content if a message is not available. - * @param response the HTTP response. - * @param value the error code of the exception. - */ - public BlobStorageException(String message, HttpResponse response, Object value) { - super(StorageImplUtils.convertStorageExceptionMessage(message, response), response, value); - } - - /** - * Gets the error code returned by the service. - * - * @return The error code returned by the service. - */ - public BlobErrorCode getErrorCode() { - return BlobErrorCode.fromString(super.getResponse().getHeaders().getValue(ERROR_CODE_HEADER_NAME)); - } - - /** - * Gets the message returned by the service. - * - * @return The message returned by the service. - */ - public String getServiceMessage() { - return super.getMessage(); - } - - /** - * Gets the status code on the response. - * - * @return The status code on the response. - */ - public int getStatusCode() { - return super.getResponse().getStatusCode(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobTag.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobTag.java new file mode 100644 index 000000000000..2f26304bbece --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobTag.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The blob tags. + */ +@Immutable +public final class BlobTag implements JsonSerializable { + /* + * The key of the tag. + */ + @Generated + private final String key; + + /* + * The value of the tag. + */ + @Generated + private final String value; + + /** + * Creates an instance of BlobTag class. + * + * @param key the key value to set. + * @param value the value value to set. + */ + @Generated + public BlobTag(String key, String value) { + this.key = key; + this.value = value; + } + + /** + * Get the key property: The key of the tag. + * + * @return the key value. + */ + @Generated + public String getKey() { + return this.key; + } + + /** + * Get the value property: The value of the tag. + * + * @return the value value. + */ + @Generated + public String getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("key", this.key); + jsonWriter.writeStringField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobTag from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobTag if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobTag. + */ + @Generated + public static BlobTag fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String key = null; + String value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("key".equals(fieldName)) { + key = reader.getString(); + } else if ("value".equals(fieldName)) { + value = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new BlobTag(key, value); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobTags.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobTags.java new file mode 100644 index 000000000000..f43c3174ad56 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobTags.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents blob tags. + */ +@Immutable +public final class BlobTags implements JsonSerializable { + /* + * Represents the blob tags. + */ + @Generated + private final List blobTagSet; + + /** + * Creates an instance of BlobTags class. + * + * @param blobTagSet the blobTagSet value to set. + */ + @Generated + public BlobTags(List blobTagSet) { + this.blobTagSet = blobTagSet; + } + + /** + * Get the blobTagSet property: Represents the blob tags. + * + * @return the blobTagSet value. + */ + @Generated + public List getBlobTagSet() { + return this.blobTagSet; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("blobTagSet", this.blobTagSet, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobTags from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobTags if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobTags. + */ + @Generated + public static BlobTags fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List blobTagSet = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blobTagSet".equals(fieldName)) { + blobTagSet = reader.readArray(reader1 -> BlobTag.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new BlobTags(blobTagSet); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobType.java index 8e4447a018fd..1d60b9fcbe5b 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobType.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobType.java @@ -1,61 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + /** - * Defines values for BlobType. + * The blob type. */ -public enum BlobType { +public final class BlobType extends ExpandableStringEnum { /** - * Enum value BlockBlob. + * The blob is a block blob. */ - BLOCK_BLOB("BlockBlob"), + @Generated + public static final BlobType BLOCK_BLOB = fromString("BlockBlob"); /** - * Enum value PageBlob. + * The blob is a page blob. */ - PAGE_BLOB("PageBlob"), + @Generated + public static final BlobType PAGE_BLOB = fromString("PageBlob"); /** - * Enum value AppendBlob. + * The blob is an append blob. */ - APPEND_BLOB("AppendBlob"); + @Generated + public static final BlobType APPEND_BLOB = fromString("AppendBlob"); /** - * The actual serialized value for a BlobType instance. + * Creates a new instance of BlobType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. */ - private final String value; - - BlobType(String value) { - this.value = value; + @Generated + @Deprecated + public BlobType() { } /** - * Parses a serialized value to a BlobType instance. + * Creates or finds a BlobType from its string representation. * - * @param value the serialized value to parse. - * @return the parsed BlobType object, or null if unable to parse. + * @param name a name to look for. + * @return the corresponding BlobType. */ - public static BlobType fromString(String value) { - if (value == null) { - return null; - } - BlobType[] items = BlobType.values(); - for (BlobType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; + @Generated + public static BlobType fromString(String name) { + return fromString(name, BlobType.class); } /** - * {@inheritDoc} + * Gets known BlobType values. + * + * @return known BlobType values. */ - @Override - public String toString() { - return this.value; + @Generated + public static Collection values() { + return values(BlobType.class); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Block.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Block.java index b4c2982fc6e7..7fcbc6378d0b 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Block.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Block.java @@ -1,42 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * Represents a single block in a block blob. It describes the block's ID and size. */ -@Fluent -public final class Block implements XmlSerializable { +@Immutable +public final class Block implements JsonSerializable { /* * The base64 encoded block ID. */ - private String name; + @Generated + private final String name; /* * The block size in bytes. */ - private long sizeLong; - - /* - * The SizeInt property. - */ - private int sizeInt; + @Generated + private final long size; /** * Creates an instance of Block class. + * + * @param name the name value to set. + * @param size the size value to set. */ - public Block() { + @Generated + private Block(String name, long size) { + this.name = name; + this.size = size; } /** @@ -44,123 +46,60 @@ public Block() { * * @return the name value. */ + @Generated public String getName() { return this.name; } /** - * Set the name property: The base64 encoded block ID. - * - * @param name the name value to set. - * @return the Block object itself. - */ - public Block setName(String name) { - this.name = name; - return this; - } - - /** - * Get the sizeLong property: The block size in bytes. - * - * @return the sizeLong value. - */ - public long getSizeLong() { - return this.sizeLong; - } - - /** - * Set the sizeLong property: The block size in bytes. + * Get the size property: The block size in bytes. * - * @param sizeLong the sizeLong value to set. - * @return the Block object itself. + * @return the size value. */ - public Block setSizeLong(long sizeLong) { - this.sizeLong = sizeLong; - return this; + @Generated + public long getSize() { + return this.size; } /** - * Get the sizeInt property: The SizeInt property. - * - * @return the sizeInt value. - * @deprecated Use {@link #getSizeLong()} + * {@inheritDoc} */ - @Deprecated - public int getSize() { - int returnValue = this.sizeInt; - return (int) this.sizeLong; // return returnValue; - } - - /** - * Set the sizeInt property: The SizeInt property. - * - * @param sizeInt the sizeInt value to set. - * @return the Block object itself. - * @deprecated Use {@link #setSizeLong(long)} - */ - @Deprecated - public Block setSize(int sizeInt) { - this.sizeInt = sizeInt; - Block returnValue = this; - return returnValue.setSizeLong((long) sizeInt); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - + @Generated @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Block" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Name", this.name); - xmlWriter.writeLongElement("Size", this.sizeLong); - xmlWriter.writeIntElement("SizeInt", this.sizeInt); - return xmlWriter.writeEndElement(); + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeLongField("size", this.size); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of Block from the XmlReader. + * Reads an instance of Block from the JsonReader. * - * @param xmlReader The XmlReader being read. - * @return An instance of Block if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the Block. + * @param jsonReader The JsonReader being read. + * @return An instance of Block if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Block. */ - public static Block fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of Block from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of Block if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the Block. - */ - public static Block fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "Block" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - Block deserializedBlock = new Block(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedBlock.name = reader.getStringElement(); - } else if ("Size".equals(elementName.getLocalPart())) { - deserializedBlock.sizeLong = reader.getLongElement(); - } else if ("SizeInt".equals(elementName.getLocalPart())) { - deserializedBlock.sizeInt = reader.getIntElement(); + @Generated + public static Block fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + long size = 0L; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("size".equals(fieldName)) { + size = reader.getLong(); } else { - reader.skipElement(); + reader.skipChildren(); } } - - return deserializedBlock; + return new Block(name, size); }); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockBlobItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockBlobItem.java deleted file mode 100644 index bdad9c963208..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockBlobItem.java +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; -import com.azure.core.util.CoreUtils; - -import java.time.OffsetDateTime; - -/** - * This class contains the properties about a block blob. - */ -@Immutable -public class BlockBlobItem { - private final String eTag; - private final OffsetDateTime lastModified; - private final byte[] contentMd5; - private final Boolean isServerEncrypted; - private final String encryptionKeySha256; - private final String encryptionScope; - private final String versionId; - - /** - * Constructs a {@link BlockBlobItem}. - * - * @param eTag ETag of the block blob. - * @param lastModified Last modified time of the block blob. - * @param contentMd5 Content MD5 of the block blob. - * @param isServerEncrypted Flag indicating if the block blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the block blob. - * @deprecated Use {@link #BlockBlobItem(String, OffsetDateTime, byte[], Boolean, String, String, String)} instead. - */ - @Deprecated - public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final boolean isServerEncrypted, final String encryptionKeySha256) { - this(eTag, lastModified, contentMd5, isServerEncrypted, encryptionKeySha256, null); - } - - /** - * Constructs a {@link BlockBlobItem}. - * - * @param eTag ETag of the block blob. - * @param lastModified Last modified time of the block blob. - * @param contentMd5 Content MD5 of the block blob. - * @param isServerEncrypted Flag indicating if the block blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the block blob. - * @param encryptionScope The encryption scope used to encrypt the block blob. - * @deprecated Use {@link #BlockBlobItem(String, OffsetDateTime, byte[], Boolean, String, String, String)} instead. - */ - @Deprecated - public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope) { - this(eTag, lastModified, contentMd5, isServerEncrypted, encryptionKeySha256, encryptionScope, null); - } - - /** - * Constructs a {@link BlockBlobItem}. - * - * @param eTag ETag of the block blob. - * @param lastModified Last modified time of the block blob. - * @param contentMd5 Content MD5 of the block blob. - * @param isServerEncrypted Flag indicating if the block blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the block blob. - * @param encryptionScope The encryption scope used to encrypt the block blob. - * @param versionId The version identifier of the block blob. - * @deprecated Use {@link #BlockBlobItem(String, OffsetDateTime, byte[], Boolean, String, String, String)} instead. - */ - @Deprecated - public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope, - final String versionId) { - this(eTag, lastModified, contentMd5, (Boolean) isServerEncrypted, encryptionKeySha256, encryptionScope, - versionId); - } - - /** - * Constructs a {@link BlockBlobItem}. - * - * @param eTag ETag of the block blob. - * @param lastModified Last modified time of the block blob. - * @param contentMd5 Content MD5 of the block blob. - * @param isServerEncrypted Flag indicating if the block blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the block blob. - * @param encryptionScope The encryption scope used to encrypt the block blob. - * @param versionId The version identifier of the block blob. - */ - public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final Boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope, - final String versionId) { - this.eTag = eTag; - this.lastModified = lastModified; - this.contentMd5 = CoreUtils.clone(contentMd5); - this.isServerEncrypted = isServerEncrypted; - this.encryptionKeySha256 = encryptionKeySha256; - this.encryptionScope = encryptionScope; - this.versionId = versionId; - } - - /** - * Gets the eTag of the block blob. - * - * @return the eTag of the block blob - */ - public String getETag() { - return eTag; - } - - /** - * Gets the last time the block blob was modified. - * - * @return the last time the block blob was modified - */ - public OffsetDateTime getLastModified() { - return lastModified; - } - - /** - * Gets the encryption status of the block blob on the server. - * - * @return the encryption status of the block blob on the server - */ - public Boolean isServerEncrypted() { - return isServerEncrypted; - } - - /** - * Gets the key used to encrypt the block blob. - * - * @return the key used to encrypt the block blob - */ - public String getEncryptionKeySha256() { - return encryptionKeySha256; - } - - /** - * Gets the encryption scope used to encrypt the block blob. - * - * @return the encryption scope used to encrypt the block blob - */ - public String getEncryptionScope() { - return encryptionScope; - } - - /** - * Gets the MD5 of the block blob's content. - * - * @return the MD5 of the block blob's comment - */ - public byte[] getContentMd5() { - return CoreUtils.clone(contentMd5); - } - - /** - * Gets the version identifier of the block blob. - * - * @return the version identifier of the block blob - */ - public String getVersionId() { - return versionId; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockList.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockList.java index ff7995e60a42..327e250474ea 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockList.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockList.java @@ -1,168 +1,100 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; /** - * The BlockList model. + * Contains the committed and uncommitted blocks in a block blob. */ -@Fluent -public final class BlockList implements XmlSerializable { +@Immutable +public final class BlockList implements JsonSerializable { /* - * The CommittedBlocks property. + * The list of committed blocks. */ + @Generated private List committedBlocks; /* - * The UncommittedBlocks property. + * The list of uncommitted blocks. */ + @Generated private List uncommittedBlocks; /** * Creates an instance of BlockList class. */ - public BlockList() { + @Generated + private BlockList() { } /** - * Get the committedBlocks property: The CommittedBlocks property. + * Get the committedBlocks property: The list of committed blocks. * * @return the committedBlocks value. */ + @Generated public List getCommittedBlocks() { - if (this.committedBlocks == null) { - this.committedBlocks = new ArrayList<>(); - } return this.committedBlocks; } /** - * Set the committedBlocks property: The CommittedBlocks property. - * - * @param committedBlocks the committedBlocks value to set. - * @return the BlockList object itself. - */ - public BlockList setCommittedBlocks(List committedBlocks) { - this.committedBlocks = committedBlocks; - return this; - } - - /** - * Get the uncommittedBlocks property: The UncommittedBlocks property. + * Get the uncommittedBlocks property: The list of uncommitted blocks. * * @return the uncommittedBlocks value. */ + @Generated public List getUncommittedBlocks() { - if (this.uncommittedBlocks == null) { - this.uncommittedBlocks = new ArrayList<>(); - } return this.uncommittedBlocks; } /** - * Set the uncommittedBlocks property: The UncommittedBlocks property. - * - * @param uncommittedBlocks the uncommittedBlocks value to set. - * @return the BlockList object itself. + * {@inheritDoc} */ - public BlockList setUncommittedBlocks(List uncommittedBlocks) { - this.uncommittedBlocks = uncommittedBlocks; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - + @Generated @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlockList" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (this.committedBlocks != null) { - xmlWriter.writeStartElement("CommittedBlocks"); - for (Block element : this.committedBlocks) { - xmlWriter.writeXml(element, "Block"); - } - xmlWriter.writeEndElement(); - } - if (this.uncommittedBlocks != null) { - xmlWriter.writeStartElement("UncommittedBlocks"); - for (Block element : this.uncommittedBlocks) { - xmlWriter.writeXml(element, "Block"); - } - xmlWriter.writeEndElement(); - } - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlockList from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlockList if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the BlockList. - */ - public static BlockList fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("committedBlocks", this.committedBlocks, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("uncommittedBlocks", this.uncommittedBlocks, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of BlockList from the XmlReader. + * Reads an instance of BlockList from the JsonReader. * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlockList if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the BlockList. + * @param jsonReader The JsonReader being read. + * @return An instance of BlockList if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the BlockList. */ - public static BlockList fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlockList" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { + @Generated + public static BlockList fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { BlockList deserializedBlockList = new BlockList(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("CommittedBlocks".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - elementName = reader.getElementName(); - if ("Block".equals(elementName.getLocalPart())) { - if (deserializedBlockList.committedBlocks == null) { - deserializedBlockList.committedBlocks = new ArrayList<>(); - } - deserializedBlockList.committedBlocks.add(Block.fromXml(reader, "Block")); - } else { - reader.skipElement(); - } - } - } else if ("UncommittedBlocks".equals(elementName.getLocalPart())) { - while (reader.nextElement() != XmlToken.END_ELEMENT) { - elementName = reader.getElementName(); - if ("Block".equals(elementName.getLocalPart())) { - if (deserializedBlockList.uncommittedBlocks == null) { - deserializedBlockList.uncommittedBlocks = new ArrayList<>(); - } - deserializedBlockList.uncommittedBlocks.add(Block.fromXml(reader, "Block")); - } else { - reader.skipElement(); - } - } + if ("committedBlocks".equals(fieldName)) { + List committedBlocks = reader.readArray(reader1 -> Block.fromJson(reader1)); + deserializedBlockList.committedBlocks = committedBlocks; + } else if ("uncommittedBlocks".equals(fieldName)) { + List uncommittedBlocks = reader.readArray(reader1 -> Block.fromJson(reader1)); + deserializedBlockList.uncommittedBlocks = uncommittedBlocks; } else { - reader.skipElement(); + reader.skipChildren(); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockListType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockListType.java index 1169afc1805a..5e2340d15ff1 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockListType.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockListType.java @@ -1,61 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + /** - * Defines values for BlockListType. + * The block list types. */ -public enum BlockListType { +public final class BlockListType extends ExpandableStringEnum { /** - * Enum value committed. + * The list of committed blocks. */ - COMMITTED("committed"), + @Generated + public static final BlockListType COMMITTED = fromString("committed"); /** - * Enum value uncommitted. + * The list of uncommitted blocks. */ - UNCOMMITTED("uncommitted"), + @Generated + public static final BlockListType UNCOMMITTED = fromString("uncommitted"); /** - * Enum value all. + * Both lists together. */ - ALL("all"); + @Generated + public static final BlockListType ALL = fromString("all"); /** - * The actual serialized value for a BlockListType instance. + * Creates a new instance of BlockListType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. */ - private final String value; - - BlockListType(String value) { - this.value = value; + @Generated + @Deprecated + public BlockListType() { } /** - * Parses a serialized value to a BlockListType instance. + * Creates or finds a BlockListType from its string representation. * - * @param value the serialized value to parse. - * @return the parsed BlockListType object, or null if unable to parse. + * @param name a name to look for. + * @return the corresponding BlockListType. */ - public static BlockListType fromString(String value) { - if (value == null) { - return null; - } - BlockListType[] items = BlockListType.values(); - for (BlockListType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; + @Generated + public static BlockListType fromString(String name) { + return fromString(name, BlockListType.class); } /** - * {@inheritDoc} + * Gets known BlockListType values. + * + * @return known BlockListType values. */ - @Override - public String toString() { - return this.value; + @Generated + public static Collection values() { + return values(BlockListType.class); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockLookupList.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockLookupList.java index fc4ce4ac83f3..2960295479f7 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockLookupList.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlockLookupList.java @@ -1,170 +1,154 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; /** - * The BlockLookupList model. + * The Block lookup list. */ @Fluent -public final class BlockLookupList implements XmlSerializable { +public final class BlockLookupList implements JsonSerializable { /* - * The Committed property. + * The committed blocks */ - private List committed = new ArrayList<>(); + @Generated + private List committed; /* - * The Uncommitted property. + * The uncommitted blocks */ - private List uncommitted = new ArrayList<>(); + @Generated + private List uncommitted; /* - * The Latest property. + * The latest blocks */ - private List latest = new ArrayList<>(); + @Generated + private List latest; /** * Creates an instance of BlockLookupList class. */ + @Generated public BlockLookupList() { } /** - * Get the committed property: The Committed property. + * Get the committed property: The committed blocks. * * @return the committed value. */ + @Generated public List getCommitted() { return this.committed; } /** - * Set the committed property: The Committed property. + * Set the committed property: The committed blocks. * * @param committed the committed value to set. * @return the BlockLookupList object itself. */ + @Generated public BlockLookupList setCommitted(List committed) { this.committed = committed; return this; } /** - * Get the uncommitted property: The Uncommitted property. + * Get the uncommitted property: The uncommitted blocks. * * @return the uncommitted value. */ + @Generated public List getUncommitted() { return this.uncommitted; } /** - * Set the uncommitted property: The Uncommitted property. + * Set the uncommitted property: The uncommitted blocks. * * @param uncommitted the uncommitted value to set. * @return the BlockLookupList object itself. */ + @Generated public BlockLookupList setUncommitted(List uncommitted) { this.uncommitted = uncommitted; return this; } /** - * Get the latest property: The Latest property. + * Get the latest property: The latest blocks. * * @return the latest value. */ + @Generated public List getLatest() { return this.latest; } /** - * Set the latest property: The Latest property. + * Set the latest property: The latest blocks. * * @param latest the latest value to set. * @return the BlockLookupList object itself. */ + @Generated public BlockLookupList setLatest(List latest) { this.latest = latest; return this; } - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlockList" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (this.committed != null) { - for (String element : this.committed) { - xmlWriter.writeStringElement("Committed", element); - } - } - if (this.uncommitted != null) { - for (String element : this.uncommitted) { - xmlWriter.writeStringElement("Uncommitted", element); - } - } - if (this.latest != null) { - for (String element : this.latest) { - xmlWriter.writeStringElement("Latest", element); - } - } - return xmlWriter.writeEndElement(); - } - /** - * Reads an instance of BlockLookupList from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlockLookupList if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlockLookupList. + * {@inheritDoc} */ - public static BlockLookupList fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("committed", this.committed, (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("uncommitted", this.uncommitted, (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("latest", this.latest, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of BlockLookupList from the XmlReader. + * Reads an instance of BlockLookupList from the JsonReader. * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlockLookupList if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlockLookupList. + * @param jsonReader The JsonReader being read. + * @return An instance of BlockLookupList if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BlockLookupList. */ - public static BlockLookupList fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "BlockList" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { + @Generated + public static BlockLookupList fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { BlockLookupList deserializedBlockLookupList = new BlockLookupList(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Committed".equals(elementName.getLocalPart())) { - deserializedBlockLookupList.committed.add(reader.getStringElement()); - } else if ("Uncommitted".equals(elementName.getLocalPart())) { - deserializedBlockLookupList.uncommitted.add(reader.getStringElement()); - } else if ("Latest".equals(elementName.getLocalPart())) { - deserializedBlockLookupList.latest.add(reader.getStringElement()); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("committed".equals(fieldName)) { + List committed = reader.readArray(reader1 -> reader1.getString()); + deserializedBlockLookupList.committed = committed; + } else if ("uncommitted".equals(fieldName)) { + List uncommitted = reader.readArray(reader1 -> reader1.getString()); + deserializedBlockLookupList.uncommitted = uncommitted; + } else if ("latest".equals(fieldName)) { + List latest = reader.readArray(reader1 -> reader1.getString()); + deserializedBlockLookupList.latest = latest; } else { - reader.skipElement(); + reader.skipChildren(); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ClearRange.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ClearRange.java index b2a28444a9a8..c7e341c7fb20 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ClearRange.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ClearRange.java @@ -1,132 +1,105 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** - * The ClearRange model. + * The clear range. */ -@Fluent -public final class ClearRange implements XmlSerializable { +@Immutable +public final class ClearRange implements JsonSerializable { /* - * The Start property. + * The start of the byte range. */ - private long start; + @Generated + private final long start; /* - * The End property. + * The end of the byte range. */ - private long end; + @Generated + private final long end; /** * Creates an instance of ClearRange class. + * + * @param start the start value to set. + * @param end the end value to set. */ - public ClearRange() { + @Generated + private ClearRange(long start, long end) { + this.start = start; + this.end = end; } /** - * Get the start property: The Start property. + * Get the start property: The start of the byte range. * * @return the start value. */ + @Generated public long getStart() { return this.start; } /** - * Set the start property: The Start property. - * - * @param start the start value to set. - * @return the ClearRange object itself. - */ - public ClearRange setStart(long start) { - this.start = start; - return this; - } - - /** - * Get the end property: The End property. + * Get the end property: The end of the byte range. * * @return the end value. */ + @Generated public long getEnd() { return this.end; } /** - * Set the end property: The End property. - * - * @param end the end value to set. - * @return the ClearRange object itself. + * {@inheritDoc} */ - public ClearRange setEnd(long end) { - this.end = end; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - + @Generated @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "ClearRange" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeLongElement("Start", this.start); - xmlWriter.writeLongElement("End", this.end); - return xmlWriter.writeEndElement(); + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeLongField("start", this.start); + jsonWriter.writeLongField("end", this.end); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of ClearRange from the XmlReader. + * Reads an instance of ClearRange from the JsonReader. * - * @param xmlReader The XmlReader being read. - * @return An instance of ClearRange if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the ClearRange. + * @param jsonReader The JsonReader being read. + * @return An instance of ClearRange if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ClearRange. */ - public static ClearRange fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of ClearRange from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of ClearRange if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the ClearRange. - */ - public static ClearRange fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "ClearRange" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - ClearRange deserializedClearRange = new ClearRange(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); + @Generated + public static ClearRange fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + long start = 0L; + long end = 0L; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("Start".equals(elementName.getLocalPart())) { - deserializedClearRange.start = reader.getLongElement(); - } else if ("End".equals(elementName.getLocalPart())) { - deserializedClearRange.end = reader.getLongElement(); + if ("start".equals(fieldName)) { + start = reader.getLong(); + } else if ("end".equals(fieldName)) { + end = reader.getLong(); } else { - reader.skipElement(); + reader.skipChildren(); } } - - return deserializedClearRange; + return new ClearRange(start, end); }); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ConsistentReadControl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ConsistentReadControl.java deleted file mode 100644 index c1ee6f998cfd..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ConsistentReadControl.java +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.storage.blob.BlobClient; - -/** - * Defines values to indicate what strategy the SDK should use when reading from a blob to ensure the view of the data - * is consistent and not changed during the read. - * {@link #NONE} - * {@link #ETAG} - * {@link #VERSION_ID} - */ -public enum ConsistentReadControl { - /** - * No consistent read control. The client will honor user provided {@link BlobRequestConditions#getIfMatch()} and - * {@link BlobClient#getVersionId()}. - */ - NONE, - - /** - * Default value. Consistent read control based on eTag. - * If {@link BlobRequestConditions#getIfMatch()} is set, the client will honor this value. - * Otherwise, {@link BlobRequestConditions#getIfMatch()} is set to the latest eTag. - * Note: Modification of the base blob will result in an {@code IOException} or a {@code BlobStorageException} if - * eTag is the only form of consistent read control being employed. - */ - ETAG, - - /** - * Consistent control based on versionId. Note: Versioning must be supported by the account to use this value. - * If {@link BlobClient#getVersionId()} is set, the client will honor this value. - * Otherwise, {@link BlobClient#getVersionId()} is set to the latest versionId. - * Note: Modification of the base blob will not result in an {@code Exception} and allow you to continue reading the - * entirety of the appropriate version of the blob determined at the time of opening the {@code InputStream} but it - * may no longer be the latest data. - */ - VERSION_ID -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ContainerItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ContainerItem.java new file mode 100644 index 000000000000..883ab4b6213b --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ContainerItem.java @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * An Azure Storage container. + */ +@Immutable +public final class ContainerItem implements JsonSerializable { + /* + * The name of the container. + */ + @Generated + private final String name; + + /* + * Whether the container is deleted. + */ + @Generated + private Boolean delete; + + /* + * The version of the container. + */ + @Generated + private String version; + + /* + * The properties of the container. + */ + @Generated + private final ContainerProperties properties; + + /* + * The metadata of the container. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of ContainerItem class. + * + * @param name the name value to set. + * @param properties the properties value to set. + */ + @Generated + private ContainerItem(String name, ContainerProperties properties) { + this.name = name; + this.properties = properties; + } + + /** + * Get the name property: The name of the container. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the delete property: Whether the container is deleted. + * + * @return the delete value. + */ + @Generated + public Boolean isDelete() { + return this.delete; + } + + /** + * Get the version property: The version of the container. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * Get the properties property: The properties of the container. + * + * @return the properties value. + */ + @Generated + public ContainerProperties getProperties() { + return this.properties; + } + + /** + * Get the metadata property: The metadata of the container. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("properties", this.properties); + jsonWriter.writeBooleanField("delete", this.delete); + jsonWriter.writeStringField("version", this.version); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ContainerItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ContainerItem if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ContainerItem. + */ + @Generated + public static ContainerItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + ContainerProperties properties = null; + Boolean delete = null; + String version = null; + Map metadata = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("properties".equals(fieldName)) { + properties = ContainerProperties.fromJson(reader); + } else if ("delete".equals(fieldName)) { + delete = reader.getNullable(JsonReader::getBoolean); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + ContainerItem deserializedContainerItem = new ContainerItem(name, properties); + deserializedContainerItem.delete = delete; + deserializedContainerItem.version = version; + deserializedContainerItem.metadata = metadata; + + return deserializedContainerItem; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ContainerProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ContainerProperties.java new file mode 100644 index 000000000000..b05c14bfd064 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ContainerProperties.java @@ -0,0 +1,357 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * The properties of a container. + */ +@Immutable +public final class ContainerProperties implements JsonSerializable { + /* + * The date-time the container was last modified in RFC1123 format. + */ + @Generated + private final DateTimeRfc1123 lastModified; + + /* + * The ETag of the container. + */ + @Generated + private final String eTag; + + /* + * The lease status of the container. + */ + @Generated + private LeaseStatus leaseStatus; + + /* + * The lease state of the container. + */ + @Generated + private LeaseState leaseState; + + /* + * The lease duration of the container. + */ + @Generated + private LeaseDuration leaseDuration; + + /* + * The public access type of the container. + */ + @Generated + private PublicAccessType publicAccess; + + /* + * Whether it has an immutability policy. + */ + @Generated + private Boolean hasImmutabilityPolicy; + + /* + * The has legal hold status of the container. + */ + @Generated + private Boolean hasLegalHold; + + /* + * The default encryption scope of the container. + */ + @Generated + private String defaultEncryptionScope; + + /* + * Whether to prevent encryption scope override. + */ + @Generated + private Boolean preventEncryptionScopeOverride; + + /* + * The deleted time of the container. + */ + @Generated + private DateTimeRfc1123 deletedTime; + + /* + * The remaining retention days of the container. + */ + @Generated + private Integer remainingRetentionDays; + + /* + * Whether immutable storage with versioning is enabled. + */ + @Generated + private Boolean isImmutableStorageWithVersioningEnabled; + + /** + * Creates an instance of ContainerProperties class. + * + * @param lastModified the lastModified value to set. + * @param eTag the eTag value to set. + */ + @Generated + private ContainerProperties(OffsetDateTime lastModified, String eTag) { + if (lastModified == null) { + this.lastModified = null; + } else { + this.lastModified = new DateTimeRfc1123(lastModified); + } + this.eTag = eTag; + } + + /** + * Get the lastModified property: The date-time the container was last modified in RFC1123 format. + * + * @return the lastModified value. + */ + @Generated + public OffsetDateTime getLastModified() { + if (this.lastModified == null) { + return null; + } + return this.lastModified.getDateTime(); + } + + /** + * Get the eTag property: The ETag of the container. + * + * @return the eTag value. + */ + @Generated + public String getETag() { + return this.eTag; + } + + /** + * Get the leaseStatus property: The lease status of the container. + * + * @return the leaseStatus value. + */ + @Generated + public LeaseStatus getLeaseStatus() { + return this.leaseStatus; + } + + /** + * Get the leaseState property: The lease state of the container. + * + * @return the leaseState value. + */ + @Generated + public LeaseState getLeaseState() { + return this.leaseState; + } + + /** + * Get the leaseDuration property: The lease duration of the container. + * + * @return the leaseDuration value. + */ + @Generated + public LeaseDuration getLeaseDuration() { + return this.leaseDuration; + } + + /** + * Get the publicAccess property: The public access type of the container. + * + * @return the publicAccess value. + */ + @Generated + public PublicAccessType getPublicAccess() { + return this.publicAccess; + } + + /** + * Get the hasImmutabilityPolicy property: Whether it has an immutability policy. + * + * @return the hasImmutabilityPolicy value. + */ + @Generated + public Boolean isHasImmutabilityPolicy() { + return this.hasImmutabilityPolicy; + } + + /** + * Get the hasLegalHold property: The has legal hold status of the container. + * + * @return the hasLegalHold value. + */ + @Generated + public Boolean isHasLegalHold() { + return this.hasLegalHold; + } + + /** + * Get the defaultEncryptionScope property: The default encryption scope of the container. + * + * @return the defaultEncryptionScope value. + */ + @Generated + public String getDefaultEncryptionScope() { + return this.defaultEncryptionScope; + } + + /** + * Get the preventEncryptionScopeOverride property: Whether to prevent encryption scope override. + * + * @return the preventEncryptionScopeOverride value. + */ + @Generated + public Boolean isPreventEncryptionScopeOverride() { + return this.preventEncryptionScopeOverride; + } + + /** + * Get the deletedTime property: The deleted time of the container. + * + * @return the deletedTime value. + */ + @Generated + public OffsetDateTime getDeletedTime() { + if (this.deletedTime == null) { + return null; + } + return this.deletedTime.getDateTime(); + } + + /** + * Get the remainingRetentionDays property: The remaining retention days of the container. + * + * @return the remainingRetentionDays value. + */ + @Generated + public Integer getRemainingRetentionDays() { + return this.remainingRetentionDays; + } + + /** + * Get the isImmutableStorageWithVersioningEnabled property: Whether immutable storage with versioning is enabled. + * + * @return the isImmutableStorageWithVersioningEnabled value. + */ + @Generated + public Boolean isImmutableStorageWithVersioningEnabled() { + return this.isImmutableStorageWithVersioningEnabled; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("lastModified", Objects.toString(this.lastModified, null)); + jsonWriter.writeStringField("eTag", this.eTag); + jsonWriter.writeStringField("leaseStatus", this.leaseStatus == null ? null : this.leaseStatus.toString()); + jsonWriter.writeStringField("leaseState", this.leaseState == null ? null : this.leaseState.toString()); + jsonWriter.writeStringField("leaseDuration", this.leaseDuration == null ? null : this.leaseDuration.toString()); + jsonWriter.writeStringField("publicAccess", this.publicAccess == null ? null : this.publicAccess.toString()); + jsonWriter.writeBooleanField("hasImmutabilityPolicy", this.hasImmutabilityPolicy); + jsonWriter.writeBooleanField("hasLegalHold", this.hasLegalHold); + jsonWriter.writeStringField("defaultEncryptionScope", this.defaultEncryptionScope); + jsonWriter.writeBooleanField("denyEncryptionScopeOverride", this.preventEncryptionScopeOverride); + jsonWriter.writeStringField("deletedTime", Objects.toString(this.deletedTime, null)); + jsonWriter.writeNumberField("remainingRetentionDays", this.remainingRetentionDays); + jsonWriter.writeBooleanField("immutableStorageWithVersioningEnabled", + this.isImmutableStorageWithVersioningEnabled); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ContainerProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ContainerProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ContainerProperties. + */ + @Generated + public static ContainerProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime lastModified = null; + String eTag = null; + LeaseStatus leaseStatus = null; + LeaseState leaseState = null; + LeaseDuration leaseDuration = null; + PublicAccessType publicAccess = null; + Boolean hasImmutabilityPolicy = null; + Boolean hasLegalHold = null; + String defaultEncryptionScope = null; + Boolean preventEncryptionScopeOverride = null; + DateTimeRfc1123 deletedTime = null; + Integer remainingRetentionDays = null; + Boolean isImmutableStorageWithVersioningEnabled = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("lastModified".equals(fieldName)) { + DateTimeRfc1123 lastModifiedHolder + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + if (lastModifiedHolder != null) { + lastModified = lastModifiedHolder.getDateTime(); + } + } else if ("eTag".equals(fieldName)) { + eTag = reader.getString(); + } else if ("leaseStatus".equals(fieldName)) { + leaseStatus = LeaseStatus.fromString(reader.getString()); + } else if ("leaseState".equals(fieldName)) { + leaseState = LeaseState.fromString(reader.getString()); + } else if ("leaseDuration".equals(fieldName)) { + leaseDuration = LeaseDuration.fromString(reader.getString()); + } else if ("publicAccess".equals(fieldName)) { + publicAccess = PublicAccessType.fromString(reader.getString()); + } else if ("hasImmutabilityPolicy".equals(fieldName)) { + hasImmutabilityPolicy = reader.getNullable(JsonReader::getBoolean); + } else if ("hasLegalHold".equals(fieldName)) { + hasLegalHold = reader.getNullable(JsonReader::getBoolean); + } else if ("defaultEncryptionScope".equals(fieldName)) { + defaultEncryptionScope = reader.getString(); + } else if ("denyEncryptionScopeOverride".equals(fieldName)) { + preventEncryptionScopeOverride = reader.getNullable(JsonReader::getBoolean); + } else if ("deletedTime".equals(fieldName)) { + deletedTime = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + } else if ("remainingRetentionDays".equals(fieldName)) { + remainingRetentionDays = reader.getNullable(JsonReader::getInt); + } else if ("immutableStorageWithVersioningEnabled".equals(fieldName)) { + isImmutableStorageWithVersioningEnabled = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + ContainerProperties deserializedContainerProperties = new ContainerProperties(lastModified, eTag); + deserializedContainerProperties.leaseStatus = leaseStatus; + deserializedContainerProperties.leaseState = leaseState; + deserializedContainerProperties.leaseDuration = leaseDuration; + deserializedContainerProperties.publicAccess = publicAccess; + deserializedContainerProperties.hasImmutabilityPolicy = hasImmutabilityPolicy; + deserializedContainerProperties.hasLegalHold = hasLegalHold; + deserializedContainerProperties.defaultEncryptionScope = defaultEncryptionScope; + deserializedContainerProperties.preventEncryptionScopeOverride = preventEncryptionScopeOverride; + deserializedContainerProperties.deletedTime = deletedTime; + deserializedContainerProperties.remainingRetentionDays = remainingRetentionDays; + deserializedContainerProperties.isImmutableStorageWithVersioningEnabled + = isImmutableStorageWithVersioningEnabled; + + return deserializedContainerProperties; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CopyStatus.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CopyStatus.java new file mode 100644 index 000000000000..bbed950bf1a9 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CopyStatus.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The copy status. + */ +public final class CopyStatus extends ExpandableStringEnum { + /** + * The copy operation is pending. + */ + @Generated + public static final CopyStatus PENDING = fromString("pending"); + + /** + * The copy operation succeeded. + */ + @Generated + public static final CopyStatus SUCCESS = fromString("success"); + + /** + * The copy operation failed. + */ + @Generated + public static final CopyStatus FAILED = fromString("failed"); + + /** + * The copy operation is aborted. + */ + @Generated + public static final CopyStatus ABORTED = fromString("aborted"); + + /** + * Creates a new instance of CopyStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public CopyStatus() { + } + + /** + * Creates or finds a CopyStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding CopyStatus. + */ + @Generated + public static CopyStatus fromString(String name) { + return fromString(name, CopyStatus.class); + } + + /** + * Gets known CopyStatus values. + * + * @return known CopyStatus values. + */ + @Generated + public static Collection values() { + return values(CopyStatus.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CopyStatusType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CopyStatusType.java deleted file mode 100644 index 7ff46019be09..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CopyStatusType.java +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -/** - * Defines values for CopyStatusType. - */ -public enum CopyStatusType { - /** - * Enum value pending. - */ - PENDING("pending"), - - /** - * Enum value success. - */ - SUCCESS("success"), - - /** - * Enum value aborted. - */ - ABORTED("aborted"), - - /** - * Enum value failed. - */ - FAILED("failed"); - - /** - * The actual serialized value for a CopyStatusType instance. - */ - private final String value; - - CopyStatusType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a CopyStatusType instance. - * - * @param value the serialized value to parse. - * @return the parsed CopyStatusType object, or null if unable to parse. - */ - public static CopyStatusType fromString(String value) { - if (value == null) { - return null; - } - CopyStatusType[] items = CopyStatusType.values(); - for (CopyStatusType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CorsRule.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CorsRule.java new file mode 100644 index 000000000000..54c6276eb81a --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CorsRule.java @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * CORS is an HTTP feature that enables a web application running under one domain to access resources in another + * domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page from + * calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs + * in another domain. + */ +@Immutable +public final class CorsRule implements JsonSerializable { + /* + * The allowed origins. + */ + @Generated + private final String allowedOrigins; + + /* + * The allowed methods. + */ + @Generated + private final String allowedMethods; + + /* + * The allowed headers. + */ + @Generated + private final String allowedHeaders; + + /* + * The exposed headers. + */ + @Generated + private final String exposedHeaders; + + /* + * The maximum age in seconds. + */ + @Generated + private final int maxAgeInSeconds; + + /** + * Creates an instance of CorsRule class. + * + * @param allowedOrigins the allowedOrigins value to set. + * @param allowedMethods the allowedMethods value to set. + * @param allowedHeaders the allowedHeaders value to set. + * @param exposedHeaders the exposedHeaders value to set. + * @param maxAgeInSeconds the maxAgeInSeconds value to set. + */ + @Generated + public CorsRule(String allowedOrigins, String allowedMethods, String allowedHeaders, String exposedHeaders, + int maxAgeInSeconds) { + this.allowedOrigins = allowedOrigins; + this.allowedMethods = allowedMethods; + this.allowedHeaders = allowedHeaders; + this.exposedHeaders = exposedHeaders; + this.maxAgeInSeconds = maxAgeInSeconds; + } + + /** + * Get the allowedOrigins property: The allowed origins. + * + * @return the allowedOrigins value. + */ + @Generated + public String getAllowedOrigins() { + return this.allowedOrigins; + } + + /** + * Get the allowedMethods property: The allowed methods. + * + * @return the allowedMethods value. + */ + @Generated + public String getAllowedMethods() { + return this.allowedMethods; + } + + /** + * Get the allowedHeaders property: The allowed headers. + * + * @return the allowedHeaders value. + */ + @Generated + public String getAllowedHeaders() { + return this.allowedHeaders; + } + + /** + * Get the exposedHeaders property: The exposed headers. + * + * @return the exposedHeaders value. + */ + @Generated + public String getExposedHeaders() { + return this.exposedHeaders; + } + + /** + * Get the maxAgeInSeconds property: The maximum age in seconds. + * + * @return the maxAgeInSeconds value. + */ + @Generated + public int getMaxAgeInSeconds() { + return this.maxAgeInSeconds; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("allowedOrigins", this.allowedOrigins); + jsonWriter.writeStringField("allowedMethods", this.allowedMethods); + jsonWriter.writeStringField("allowedHeaders", this.allowedHeaders); + jsonWriter.writeStringField("exposedHeaders", this.exposedHeaders); + jsonWriter.writeIntField("maxAgeInSeconds", this.maxAgeInSeconds); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CorsRule from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CorsRule if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CorsRule. + */ + @Generated + public static CorsRule fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String allowedOrigins = null; + String allowedMethods = null; + String allowedHeaders = null; + String exposedHeaders = null; + int maxAgeInSeconds = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("allowedOrigins".equals(fieldName)) { + allowedOrigins = reader.getString(); + } else if ("allowedMethods".equals(fieldName)) { + allowedMethods = reader.getString(); + } else if ("allowedHeaders".equals(fieldName)) { + allowedHeaders = reader.getString(); + } else if ("exposedHeaders".equals(fieldName)) { + exposedHeaders = reader.getString(); + } else if ("maxAgeInSeconds".equals(fieldName)) { + maxAgeInSeconds = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new CorsRule(allowedOrigins, allowedMethods, allowedHeaders, exposedHeaders, maxAgeInSeconds); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CpkInfo.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CpkInfo.java deleted file mode 100644 index 8014447a6386..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CpkInfo.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; - -/** - * Parameter group. - */ -@Fluent -public final class CpkInfo { - /* - * Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, - * encryption is performed with the root account encryption key. For more information, see Encryption at Rest for - * Azure Storage Services. - */ - private String encryptionKey; - - /* - * The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. - */ - private String encryptionKeySha256; - - /* - * The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be - * provided if the x-ms-encryption-key header is provided. - */ - private EncryptionAlgorithmType encryptionAlgorithm; - - /** - * Creates an instance of CpkInfo class. - */ - public CpkInfo() { - } - - /** - * Get the encryptionKey property: Optional. Specifies the encryption key to use to encrypt the data provided in the - * request. If not specified, encryption is performed with the root account encryption key. For more information, - * see Encryption at Rest for Azure Storage Services. - * - * @return the encryptionKey value. - */ - public String getEncryptionKey() { - return this.encryptionKey; - } - - /** - * Set the encryptionKey property: Optional. Specifies the encryption key to use to encrypt the data provided in the - * request. If not specified, encryption is performed with the root account encryption key. For more information, - * see Encryption at Rest for Azure Storage Services. - * - * @param encryptionKey the encryptionKey value to set. - * @return the CpkInfo object itself. - */ - public CpkInfo setEncryptionKey(String encryptionKey) { - this.encryptionKey = encryptionKey; - return this; - } - - /** - * Get the encryptionKeySha256 property: The SHA-256 hash of the provided encryption key. Must be provided if the - * x-ms-encryption-key header is provided. - * - * @return the encryptionKeySha256 value. - */ - public String getEncryptionKeySha256() { - return this.encryptionKeySha256; - } - - /** - * Set the encryptionKeySha256 property: The SHA-256 hash of the provided encryption key. Must be provided if the - * x-ms-encryption-key header is provided. - * - * @param encryptionKeySha256 the encryptionKeySha256 value to set. - * @return the CpkInfo object itself. - */ - public CpkInfo setEncryptionKeySha256(String encryptionKeySha256) { - this.encryptionKeySha256 = encryptionKeySha256; - return this; - } - - /** - * Get the encryptionAlgorithm property: The algorithm used to produce the encryption key hash. Currently, the only - * accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. - * - * @return the encryptionAlgorithm value. - */ - public EncryptionAlgorithmType getEncryptionAlgorithm() { - return this.encryptionAlgorithm; - } - - /** - * Set the encryptionAlgorithm property: The algorithm used to produce the encryption key hash. Currently, the only - * accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. - * - * @param encryptionAlgorithm the encryptionAlgorithm value to set. - * @return the CpkInfo object itself. - */ - public CpkInfo setEncryptionAlgorithm(EncryptionAlgorithmType encryptionAlgorithm) { - this.encryptionAlgorithm = encryptionAlgorithm; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CustomerProvidedKey.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CustomerProvidedKey.java deleted file mode 100644 index 4ba057f47555..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/CustomerProvidedKey.java +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; -import com.azure.core.util.logging.ClientLogger; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Base64; - -/** - * Contains the customer provided key information used to encrypt a blob's content on the server. - */ -@Immutable -public class CustomerProvidedKey { - private static final ClientLogger LOGGER = new ClientLogger(CustomerProvidedKey.class); - - /** - * Base64 encoded string of the encryption key. - */ - private final String key; - - /** - * Base64 encoded string of the encryption key's SHA256 hash. - */ - private final String keySha256; - - /** - * The algorithm for Azure Blob Storage to encrypt with. - * Azure Blob Storage only offers AES256 encryption. - */ - private final EncryptionAlgorithmType encryptionAlgorithm = EncryptionAlgorithmType.AES256; - - /** - * Creates a new wrapper for a client provided key. - * - * @param key The encryption key encoded as a base64 string. - * @throws RuntimeException If "SHA-256" cannot be found. - */ - public CustomerProvidedKey(String key) { - - this.key = key; - - MessageDigest sha256; - try { - sha256 = MessageDigest.getInstance("SHA-256"); - } catch (NoSuchAlgorithmException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - byte[] keyhash = sha256.digest(Base64.getDecoder().decode(key)); - this.keySha256 = Base64.getEncoder().encodeToString(keyhash); - } - - /** - * Creates a new wrapper for a client provided key. - * - * @param key The encryption key bytes. - * - * @throws RuntimeException If "SHA-256" cannot be found. - */ - public CustomerProvidedKey(byte[] key) { - - this.key = Base64.getEncoder().encodeToString(key); - - MessageDigest sha256; - try { - sha256 = MessageDigest.getInstance("SHA-256"); - } catch (NoSuchAlgorithmException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - byte[] keyhash = sha256.digest(key); - this.keySha256 = Base64.getEncoder().encodeToString(keyhash); - } - - /** - * Gets the encryption key. - * - * @return A base64 encoded string of the encryption key. - */ - public String getKey() { - return key; - } - - /** - * Gets the encryption key's hash. - * - * @return A base64 encoded string of the encryption key hash. - */ - public String getKeySha256() { - return keySha256; - } - - /** - * Gets the algorithm to use this key with. - * - * @return A label for the encryption algorithm, as understood by Azure Storage. - */ - public EncryptionAlgorithmType getEncryptionAlgorithm() { - return encryptionAlgorithm; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DeleteSnapshotsOptionType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DeleteSnapshotsOptionType.java index d0905a9f3e02..2450613d0236 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DeleteSnapshotsOptionType.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DeleteSnapshotsOptionType.java @@ -1,56 +1,57 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + /** - * Defines values for DeleteSnapshotsOptionType. + * The delete snapshots option type. */ -public enum DeleteSnapshotsOptionType { +public final class DeleteSnapshotsOptionType extends ExpandableStringEnum { /** - * Enum value include. + * The delete snapshots include option is only. */ - INCLUDE("include"), + @Generated + public static final DeleteSnapshotsOptionType ONLY = fromString("only"); /** - * Enum value only. + * The delete snapshots include option is include. */ - ONLY("only"); + @Generated + public static final DeleteSnapshotsOptionType INCLUDE = fromString("include"); /** - * The actual serialized value for a DeleteSnapshotsOptionType instance. + * Creates a new instance of DeleteSnapshotsOptionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. */ - private final String value; - - DeleteSnapshotsOptionType(String value) { - this.value = value; + @Generated + @Deprecated + public DeleteSnapshotsOptionType() { } /** - * Parses a serialized value to a DeleteSnapshotsOptionType instance. + * Creates or finds a DeleteSnapshotsOptionType from its string representation. * - * @param value the serialized value to parse. - * @return the parsed DeleteSnapshotsOptionType object, or null if unable to parse. + * @param name a name to look for. + * @return the corresponding DeleteSnapshotsOptionType. */ - public static DeleteSnapshotsOptionType fromString(String value) { - if (value == null) { - return null; - } - DeleteSnapshotsOptionType[] items = DeleteSnapshotsOptionType.values(); - for (DeleteSnapshotsOptionType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; + @Generated + public static DeleteSnapshotsOptionType fromString(String name) { + return fromString(name, DeleteSnapshotsOptionType.class); } /** - * {@inheritDoc} + * Gets known DeleteSnapshotsOptionType values. + * + * @return known DeleteSnapshotsOptionType values. */ - @Override - public String toString() { - return this.value; + @Generated + public static Collection values() { + return values(DeleteSnapshotsOptionType.class); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DelimitedTextConfiguration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DelimitedTextConfiguration.java similarity index 53% rename from sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DelimitedTextConfiguration.java rename to sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DelimitedTextConfiguration.java index c7cccd42c60e..9a556ad95fc8 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DelimitedTextConfiguration.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DelimitedTextConfiguration.java @@ -1,51 +1,56 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.storage.blob.implementation.models; +package com.azure.storage.blob.models; import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** - * Groups the settings used for interpreting the blob data if the blob is delimited text formatted. + * Represents the delimited text configuration. */ @Fluent -public final class DelimitedTextConfiguration implements XmlSerializable { +public final class DelimitedTextConfiguration implements JsonSerializable { /* * The string used to separate columns. */ + @Generated private String columnSeparator; /* * The string used to quote a specific field. */ + @Generated private String fieldQuote; /* * The string used to separate records. */ + @Generated private String recordSeparator; /* - * The string used as an escape character. + * The string used to escape a quote character in a field. */ + @Generated private String escapeChar; /* * Represents whether the data has headers. */ + @Generated private Boolean headersPresent; /** * Creates an instance of DelimitedTextConfiguration class. */ + @Generated public DelimitedTextConfiguration() { } @@ -54,6 +59,7 @@ public DelimitedTextConfiguration() { * * @return the columnSeparator value. */ + @Generated public String getColumnSeparator() { return this.columnSeparator; } @@ -64,6 +70,7 @@ public String getColumnSeparator() { * @param columnSeparator the columnSeparator value to set. * @return the DelimitedTextConfiguration object itself. */ + @Generated public DelimitedTextConfiguration setColumnSeparator(String columnSeparator) { this.columnSeparator = columnSeparator; return this; @@ -74,6 +81,7 @@ public DelimitedTextConfiguration setColumnSeparator(String columnSeparator) { * * @return the fieldQuote value. */ + @Generated public String getFieldQuote() { return this.fieldQuote; } @@ -84,6 +92,7 @@ public String getFieldQuote() { * @param fieldQuote the fieldQuote value to set. * @return the DelimitedTextConfiguration object itself. */ + @Generated public DelimitedTextConfiguration setFieldQuote(String fieldQuote) { this.fieldQuote = fieldQuote; return this; @@ -94,6 +103,7 @@ public DelimitedTextConfiguration setFieldQuote(String fieldQuote) { * * @return the recordSeparator value. */ + @Generated public String getRecordSeparator() { return this.recordSeparator; } @@ -104,26 +114,29 @@ public String getRecordSeparator() { * @param recordSeparator the recordSeparator value to set. * @return the DelimitedTextConfiguration object itself. */ + @Generated public DelimitedTextConfiguration setRecordSeparator(String recordSeparator) { this.recordSeparator = recordSeparator; return this; } /** - * Get the escapeChar property: The string used as an escape character. + * Get the escapeChar property: The string used to escape a quote character in a field. * * @return the escapeChar value. */ + @Generated public String getEscapeChar() { return this.escapeChar; } /** - * Set the escapeChar property: The string used as an escape character. + * Set the escapeChar property: The string used to escape a quote character in a field. * * @param escapeChar the escapeChar value to set. * @return the DelimitedTextConfiguration object itself. */ + @Generated public DelimitedTextConfiguration setEscapeChar(String escapeChar) { this.escapeChar = escapeChar; return this; @@ -134,6 +147,7 @@ public DelimitedTextConfiguration setEscapeChar(String escapeChar) { * * @return the headersPresent value. */ + @Generated public Boolean isHeadersPresent() { return this.headersPresent; } @@ -144,72 +158,55 @@ public Boolean isHeadersPresent() { * @param headersPresent the headersPresent value to set. * @return the DelimitedTextConfiguration object itself. */ + @Generated public DelimitedTextConfiguration setHeadersPresent(Boolean headersPresent) { this.headersPresent = headersPresent; return this; } - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "DelimitedTextConfiguration" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("ColumnSeparator", this.columnSeparator); - xmlWriter.writeStringElement("FieldQuote", this.fieldQuote); - xmlWriter.writeStringElement("RecordSeparator", this.recordSeparator); - xmlWriter.writeStringElement("EscapeChar", this.escapeChar); - xmlWriter.writeBooleanElement("HasHeaders", this.headersPresent); - return xmlWriter.writeEndElement(); - } - /** - * Reads an instance of DelimitedTextConfiguration from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of DelimitedTextConfiguration if the XmlReader was pointing to an instance of it, or null if - * it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the DelimitedTextConfiguration. + * {@inheritDoc} */ - public static DelimitedTextConfiguration fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("columnSeparator", this.columnSeparator); + jsonWriter.writeStringField("fieldQuote", this.fieldQuote); + jsonWriter.writeStringField("recordSeparator", this.recordSeparator); + jsonWriter.writeStringField("escapeChar", this.escapeChar); + jsonWriter.writeBooleanField("headersPresent", this.headersPresent); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of DelimitedTextConfiguration from the XmlReader. + * Reads an instance of DelimitedTextConfiguration from the JsonReader. * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of DelimitedTextConfiguration if the XmlReader was pointing to an instance of it, or null if - * it was pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the DelimitedTextConfiguration. - */ - public static DelimitedTextConfiguration fromXml(XmlReader xmlReader, String rootElementName) - throws XMLStreamException { - String finalRootElementName - = CoreUtils.isNullOrEmpty(rootElementName) ? "DelimitedTextConfiguration" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { + * @param jsonReader The JsonReader being read. + * @return An instance of DelimitedTextConfiguration if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the DelimitedTextConfiguration. + */ + @Generated + public static DelimitedTextConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { DelimitedTextConfiguration deserializedDelimitedTextConfiguration = new DelimitedTextConfiguration(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("ColumnSeparator".equals(elementName.getLocalPart())) { - deserializedDelimitedTextConfiguration.columnSeparator = reader.getStringElement(); - } else if ("FieldQuote".equals(elementName.getLocalPart())) { - deserializedDelimitedTextConfiguration.fieldQuote = reader.getStringElement(); - } else if ("RecordSeparator".equals(elementName.getLocalPart())) { - deserializedDelimitedTextConfiguration.recordSeparator = reader.getStringElement(); - } else if ("EscapeChar".equals(elementName.getLocalPart())) { - deserializedDelimitedTextConfiguration.escapeChar = reader.getStringElement(); - } else if ("HasHeaders".equals(elementName.getLocalPart())) { - deserializedDelimitedTextConfiguration.headersPresent - = reader.getNullableElement(Boolean::parseBoolean); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("columnSeparator".equals(fieldName)) { + deserializedDelimitedTextConfiguration.columnSeparator = reader.getString(); + } else if ("fieldQuote".equals(fieldName)) { + deserializedDelimitedTextConfiguration.fieldQuote = reader.getString(); + } else if ("recordSeparator".equals(fieldName)) { + deserializedDelimitedTextConfiguration.recordSeparator = reader.getString(); + } else if ("escapeChar".equals(fieldName)) { + deserializedDelimitedTextConfiguration.escapeChar = reader.getString(); + } else if ("headersPresent".equals(fieldName)) { + deserializedDelimitedTextConfiguration.headersPresent = reader.getNullable(JsonReader::getBoolean); } else { - reader.skipElement(); + reader.skipChildren(); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DownloadRetryOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DownloadRetryOptions.java deleted file mode 100644 index 7ca94e8f3771..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/DownloadRetryOptions.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.logging.ClientLogger; - -import java.util.Locale; - -/** - * This class contains the configuration options used to download from the blob service using smart retries, starting - * from a checkpoint, rather than starting over from the beginning. - */ -@Fluent -public final class DownloadRetryOptions { - private static final String PARAMETER_NOT_IN_RANGE = "The value of the parameter '%s' should be between %s and %s."; - - private static final ClientLogger LOGGER = new ClientLogger(DownloadRetryOptions.class); - - /* - * We use "retry" here because by the time the user passes this type, the initial request, or try, has already been - * issued and returned. This is in contrast to the retry policy options, which includes the initial try in its - * count, thus the difference in verbiage. - */ - private int maxRetryRequests = 5; - - /** - * Creates a new instance of {@link DownloadRetryOptions}. - */ - public DownloadRetryOptions() { - } - - /** - * Specifies the maximum number of additional HTTP Get requests that will be made while reading the data from a - * response body. - * - * @return the maximum number of retries to attempt before the request finally fails - */ - public int getMaxRetryRequests() { - return maxRetryRequests; - } - - /** - * Specifies the maximum number of additional HTTP Get requests that will be made while reading the data from a - * response body. - * - * @param maxRetryRequests The number of retries to attempt before the request finally fails - * @return the updated DownloadRetryOptions object - * @throws IllegalArgumentException If {@code maxRetryRequests} is less than 0 - */ - public DownloadRetryOptions setMaxRetryRequests(int maxRetryRequests) { - if (maxRetryRequests < 0) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException( - String.format(Locale.ROOT, PARAMETER_NOT_IN_RANGE, "options.maxRetryRequests", 0, Integer.MAX_VALUE))); - } - - this.maxRetryRequests = maxRetryRequests; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/EncryptionAlgorithmType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/EncryptionAlgorithmType.java index 182cc57063a7..59cd6463ec6c 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/EncryptionAlgorithmType.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/EncryptionAlgorithmType.java @@ -1,51 +1,52 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + /** - * Defines values for EncryptionAlgorithmType. + * The algorithm used to produce the encryption key hash. Currently, the only accepted value is \"AES256\". Must be + * provided if the x-ms-encryption-key header is provided. */ -public enum EncryptionAlgorithmType { +public final class EncryptionAlgorithmType extends ExpandableStringEnum { /** - * Enum value AES256. + * The AES256 encryption algorithm. */ - AES256("AES256"); + @Generated + public static final EncryptionAlgorithmType AES256 = fromString("AES256"); /** - * The actual serialized value for a EncryptionAlgorithmType instance. + * Creates a new instance of EncryptionAlgorithmType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. */ - private final String value; - - EncryptionAlgorithmType(String value) { - this.value = value; + @Generated + @Deprecated + public EncryptionAlgorithmType() { } /** - * Parses a serialized value to a EncryptionAlgorithmType instance. + * Creates or finds a EncryptionAlgorithmType from its string representation. * - * @param value the serialized value to parse. - * @return the parsed EncryptionAlgorithmType object, or null if unable to parse. + * @param name a name to look for. + * @return the corresponding EncryptionAlgorithmType. */ - public static EncryptionAlgorithmType fromString(String value) { - if (value == null) { - return null; - } - EncryptionAlgorithmType[] items = EncryptionAlgorithmType.values(); - for (EncryptionAlgorithmType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; + @Generated + public static EncryptionAlgorithmType fromString(String name) { + return fromString(name, EncryptionAlgorithmType.class); } /** - * {@inheritDoc} + * Gets known EncryptionAlgorithmType values. + * + * @return known EncryptionAlgorithmType values. */ - @Override - public String toString() { - return this.value; + @Generated + public static Collection values() { + return values(EncryptionAlgorithmType.class); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobItem.java new file mode 100644 index 000000000000..1eda7683508f --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobItem.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The filter blob item. + */ +@Immutable +public final class FilterBlobItem implements JsonSerializable { + /* + * The name of the blob. + */ + @Generated + private final String name; + + /* + * The properties of the blob. + */ + @Generated + private final String containerName; + + /* + * The metadata of the blob. + */ + @Generated + private BlobTags tags; + + /* + * The version ID of the blob. + */ + @Generated + private String versionId; + + /* + * Whether it is the current version of the blob + */ + @Generated + private Boolean isCurrentVersion; + + /** + * Creates an instance of FilterBlobItem class. + * + * @param name the name value to set. + * @param containerName the containerName value to set. + */ + @Generated + private FilterBlobItem(String name, String containerName) { + this.name = name; + this.containerName = containerName; + } + + /** + * Get the name property: The name of the blob. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the containerName property: The properties of the blob. + * + * @return the containerName value. + */ + @Generated + public String getContainerName() { + return this.containerName; + } + + /** + * Get the tags property: The metadata of the blob. + * + * @return the tags value. + */ + @Generated + public BlobTags getTags() { + return this.tags; + } + + /** + * Get the versionId property: The version ID of the blob. + * + * @return the versionId value. + */ + @Generated + public String getVersionId() { + return this.versionId; + } + + /** + * Get the isCurrentVersion property: Whether it is the current version of the blob. + * + * @return the isCurrentVersion value. + */ + @Generated + public Boolean isCurrentVersion() { + return this.isCurrentVersion; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("containerName", this.containerName); + jsonWriter.writeJsonField("tags", this.tags); + jsonWriter.writeStringField("versionId", this.versionId); + jsonWriter.writeBooleanField("isCurrentVersion", this.isCurrentVersion); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FilterBlobItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FilterBlobItem if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FilterBlobItem. + */ + @Generated + public static FilterBlobItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String containerName = null; + BlobTags tags = null; + String versionId = null; + Boolean isCurrentVersion = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("containerName".equals(fieldName)) { + containerName = reader.getString(); + } else if ("tags".equals(fieldName)) { + tags = BlobTags.fromJson(reader); + } else if ("versionId".equals(fieldName)) { + versionId = reader.getString(); + } else if ("isCurrentVersion".equals(fieldName)) { + isCurrentVersion = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + FilterBlobItem deserializedFilterBlobItem = new FilterBlobItem(name, containerName); + deserializedFilterBlobItem.tags = tags; + deserializedFilterBlobItem.versionId = versionId; + deserializedFilterBlobItem.isCurrentVersion = isCurrentVersion; + + return deserializedFilterBlobItem; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobSegment.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobSegment.java new file mode 100644 index 000000000000..f862a2147d54 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobSegment.java @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The result of a Filter Blobs API call. + */ +@Immutable +public final class FilterBlobSegment implements JsonSerializable { + /* + * The service endpoint. + */ + @Generated + private final String serviceEndpoint; + + /* + * The filter for the blobs. + */ + @Generated + private final String where; + + /* + * The blob segment. + */ + @Generated + private final List blobs; + + /* + * The next marker of the blobs. + */ + @Generated + private String nextMarker; + + /** + * Creates an instance of FilterBlobSegment class. + * + * @param serviceEndpoint the serviceEndpoint value to set. + * @param where the where value to set. + * @param blobs the blobs value to set. + */ + @Generated + private FilterBlobSegment(String serviceEndpoint, String where, List blobs) { + this.serviceEndpoint = serviceEndpoint; + this.where = where; + this.blobs = blobs; + } + + /** + * Get the serviceEndpoint property: The service endpoint. + * + * @return the serviceEndpoint value. + */ + @Generated + public String getServiceEndpoint() { + return this.serviceEndpoint; + } + + /** + * Get the where property: The filter for the blobs. + * + * @return the where value. + */ + @Generated + public String getWhere() { + return this.where; + } + + /** + * Get the blobs property: The blob segment. + * + * @return the blobs value. + */ + @Generated + public List getBlobs() { + return this.blobs; + } + + /** + * Get the nextMarker property: The next marker of the blobs. + * + * @return the nextMarker value. + */ + @Generated + public String getNextMarker() { + return this.nextMarker; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("serviceEndpoint", this.serviceEndpoint); + jsonWriter.writeStringField("where", this.where); + jsonWriter.writeArrayField("blobs", this.blobs, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextMarker", this.nextMarker); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FilterBlobSegment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FilterBlobSegment if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FilterBlobSegment. + */ + @Generated + public static FilterBlobSegment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String serviceEndpoint = null; + String where = null; + List blobs = null; + String nextMarker = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("serviceEndpoint".equals(fieldName)) { + serviceEndpoint = reader.getString(); + } else if ("where".equals(fieldName)) { + where = reader.getString(); + } else if ("blobs".equals(fieldName)) { + blobs = reader.readArray(reader1 -> FilterBlobItem.fromJson(reader1)); + } else if ("nextMarker".equals(fieldName)) { + nextMarker = reader.getString(); + } else { + reader.skipChildren(); + } + } + FilterBlobSegment deserializedFilterBlobSegment = new FilterBlobSegment(serviceEndpoint, where, blobs); + deserializedFilterBlobSegment.nextMarker = nextMarker; + + return deserializedFilterBlobSegment; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobsIncludeItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobsIncludeItem.java new file mode 100644 index 000000000000..2d1aea8d8878 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/FilterBlobsIncludeItem.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The filter blobs includes. + */ +public final class FilterBlobsIncludeItem extends ExpandableStringEnum { + /** + * The filter includes no versions. + */ + @Generated + public static final FilterBlobsIncludeItem NONE = fromString("none"); + + /** + * The filter includes n versions. + */ + @Generated + public static final FilterBlobsIncludeItem VERSIONS = fromString("versions"); + + /** + * Creates a new instance of FilterBlobsIncludeItem value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public FilterBlobsIncludeItem() { + } + + /** + * Creates or finds a FilterBlobsIncludeItem from its string representation. + * + * @param name a name to look for. + * @return the corresponding FilterBlobsIncludeItem. + */ + @Generated + public static FilterBlobsIncludeItem fromString(String name) { + return fromString(name, FilterBlobsIncludeItem.class); + } + + /** + * Gets known FilterBlobsIncludeItem values. + * + * @return known FilterBlobsIncludeItem values. + */ + @Generated + public static Collection values() { + return values(FilterBlobsIncludeItem.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplication.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplication.java index 4740f534d303..851642234c6a 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplication.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplication.java @@ -1,41 +1,52 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.core.util.DateTimeRfc1123; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.time.OffsetDateTime; import java.util.Objects; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; /** * Geo-Replication information for the Secondary Storage Service. */ -@Fluent -public final class GeoReplication implements XmlSerializable { +@Immutable +public final class GeoReplication implements JsonSerializable { /* * The status of the secondary location */ - private GeoReplicationStatus status; + @Generated + private final GeoReplicationStatusType status; /* * A GMT date/time value, to the second. All primary writes preceding this value are guaranteed to be available for * read operations at the secondary. Primary writes after this point in time may or may not be available for reads. */ - private DateTimeRfc1123 lastSyncTime; + @Generated + private final DateTimeRfc1123 lastSyncTime; /** * Creates an instance of GeoReplication class. + * + * @param status the status value to set. + * @param lastSyncTime the lastSyncTime value to set. */ - public GeoReplication() { + @Generated + private GeoReplication(GeoReplicationStatusType status, OffsetDateTime lastSyncTime) { + this.status = status; + if (lastSyncTime == null) { + this.lastSyncTime = null; + } else { + this.lastSyncTime = new DateTimeRfc1123(lastSyncTime); + } } /** @@ -43,21 +54,11 @@ public GeoReplication() { * * @return the status value. */ - public GeoReplicationStatus getStatus() { + @Generated + public GeoReplicationStatusType getStatus() { return this.status; } - /** - * Set the status property: The status of the secondary location. - * - * @param status the status value to set. - * @return the GeoReplication object itself. - */ - public GeoReplication setStatus(GeoReplicationStatus status) { - this.status = status; - return this; - } - /** * Get the lastSyncTime property: A GMT date/time value, to the second. All primary writes preceding this value are * guaranteed to be available for read operations at the secondary. Primary writes after this point in time may or @@ -65,6 +66,7 @@ public GeoReplication setStatus(GeoReplicationStatus status) { * * @return the lastSyncTime value. */ + @Generated public OffsetDateTime getLastSyncTime() { if (this.lastSyncTime == null) { return null; @@ -73,75 +75,48 @@ public OffsetDateTime getLastSyncTime() { } /** - * Set the lastSyncTime property: A GMT date/time value, to the second. All primary writes preceding this value are - * guaranteed to be available for read operations at the secondary. Primary writes after this point in time may or - * may not be available for reads. - * - * @param lastSyncTime the lastSyncTime value to set. - * @return the GeoReplication object itself. + * {@inheritDoc} */ - public GeoReplication setLastSyncTime(OffsetDateTime lastSyncTime) { - if (lastSyncTime == null) { - this.lastSyncTime = null; - } else { - this.lastSyncTime = new DateTimeRfc1123(lastSyncTime); - } - return this; - } - + @Generated @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "GeoReplication" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Status", this.status == null ? null : this.status.toString()); - xmlWriter.writeStringElement("LastSyncTime", Objects.toString(this.lastSyncTime, null)); - return xmlWriter.writeEndElement(); + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeStringField("lastSyncTime", Objects.toString(this.lastSyncTime, null)); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of GeoReplication from the XmlReader. + * Reads an instance of GeoReplication from the JsonReader. * - * @param xmlReader The XmlReader being read. - * @return An instance of GeoReplication if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the GeoReplication. + * @param jsonReader The JsonReader being read. + * @return An instance of GeoReplication if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the GeoReplication. */ - public static GeoReplication fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } + @Generated + public static GeoReplication fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GeoReplicationStatusType status = null; + OffsetDateTime lastSyncTime = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - /** - * Reads an instance of GeoReplication from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of GeoReplication if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the GeoReplication. - */ - public static GeoReplication fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "GeoReplication" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - GeoReplication deserializedGeoReplication = new GeoReplication(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Status".equals(elementName.getLocalPart())) { - deserializedGeoReplication.status = GeoReplicationStatus.fromString(reader.getStringElement()); - } else if ("LastSyncTime".equals(elementName.getLocalPart())) { - deserializedGeoReplication.lastSyncTime = reader.getNullableElement(DateTimeRfc1123::new); + if ("status".equals(fieldName)) { + status = GeoReplicationStatusType.fromString(reader.getString()); + } else if ("lastSyncTime".equals(fieldName)) { + DateTimeRfc1123 lastSyncTimeHolder + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + if (lastSyncTimeHolder != null) { + lastSyncTime = lastSyncTimeHolder.getDateTime(); + } } else { - reader.skipElement(); + reader.skipChildren(); } } - - return deserializedGeoReplication; + return new GeoReplication(status, lastSyncTime); }); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplicationStatus.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplicationStatus.java deleted file mode 100644 index e64825b6e7f8..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplicationStatus.java +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.util.ExpandableStringEnum; -import java.util.Collection; - -/** - * The status of the secondary location. - */ -public final class GeoReplicationStatus extends ExpandableStringEnum { - /** - * Static value live for GeoReplicationStatus. - */ - public static final GeoReplicationStatus LIVE = fromString("live"); - - /** - * Static value bootstrap for GeoReplicationStatus. - */ - public static final GeoReplicationStatus BOOTSTRAP = fromString("bootstrap"); - - /** - * Static value unavailable for GeoReplicationStatus. - */ - public static final GeoReplicationStatus UNAVAILABLE = fromString("unavailable"); - - /** - * Creates a new instance of GeoReplicationStatus value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Deprecated - public GeoReplicationStatus() { - } - - /** - * Creates or finds a GeoReplicationStatus from its string representation. - * - * @param name a name to look for. - * @return the corresponding GeoReplicationStatus. - */ - public static GeoReplicationStatus fromString(String name) { - return fromString(name, GeoReplicationStatus.class); - } - - /** - * Gets known GeoReplicationStatus values. - * - * @return known GeoReplicationStatus values. - */ - public static Collection values() { - return values(GeoReplicationStatus.class); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplicationStatusType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplicationStatusType.java new file mode 100644 index 000000000000..f8796245a7df --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/GeoReplicationStatusType.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The geo replication status. + */ +public final class GeoReplicationStatusType extends ExpandableStringEnum { + /** + * The geo replication is live. + */ + @Generated + public static final GeoReplicationStatusType LIVE = fromString("live"); + + /** + * The geo replication is bootstrap. + */ + @Generated + public static final GeoReplicationStatusType BOOTSTRAP = fromString("bootstrap"); + + /** + * The geo replication is unavailable. + */ + @Generated + public static final GeoReplicationStatusType UNAVAILABLE = fromString("unavailable"); + + /** + * Creates a new instance of GeoReplicationStatusType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public GeoReplicationStatusType() { + } + + /** + * Creates or finds a GeoReplicationStatusType from its string representation. + * + * @param name a name to look for. + * @return the corresponding GeoReplicationStatusType. + */ + @Generated + public static GeoReplicationStatusType fromString(String name) { + return fromString(name, GeoReplicationStatusType.class); + } + + /** + * Gets known GeoReplicationStatusType values. + * + * @return known GeoReplicationStatusType values. + */ + @Generated + public static Collection values() { + return values(GeoReplicationStatusType.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/JsonTextConfiguration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/JsonTextConfiguration.java new file mode 100644 index 000000000000..70ddbadfab91 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/JsonTextConfiguration.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the JSON text configuration. + */ +@Fluent +public final class JsonTextConfiguration implements JsonSerializable { + /* + * The string used to separate records. + */ + @Generated + private String recordSeparator; + + /** + * Creates an instance of JsonTextConfiguration class. + */ + @Generated + public JsonTextConfiguration() { + } + + /** + * Get the recordSeparator property: The string used to separate records. + * + * @return the recordSeparator value. + */ + @Generated + public String getRecordSeparator() { + return this.recordSeparator; + } + + /** + * Set the recordSeparator property: The string used to separate records. + * + * @param recordSeparator the recordSeparator value to set. + * @return the JsonTextConfiguration object itself. + */ + @Generated + public JsonTextConfiguration setRecordSeparator(String recordSeparator) { + this.recordSeparator = recordSeparator; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("recordSeparator", this.recordSeparator); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JsonTextConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JsonTextConfiguration if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the JsonTextConfiguration. + */ + @Generated + public static JsonTextConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + JsonTextConfiguration deserializedJsonTextConfiguration = new JsonTextConfiguration(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("recordSeparator".equals(fieldName)) { + deserializedJsonTextConfiguration.recordSeparator = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedJsonTextConfiguration; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/KeyInfo.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/KeyInfo.java deleted file mode 100644 index 76b695738e98..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/KeyInfo.java +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * Key information. - */ -@Fluent -public final class KeyInfo implements XmlSerializable { - /* - * The date-time the key is active in ISO 8601 UTC time - */ - private String start; - - /* - * The date-time the key expires in ISO 8601 UTC time - */ - private String expiry; - - /** - * Creates an instance of KeyInfo class. - */ - public KeyInfo() { - } - - /** - * Get the start property: The date-time the key is active in ISO 8601 UTC time. - * - * @return the start value. - */ - public String getStart() { - return this.start; - } - - /** - * Set the start property: The date-time the key is active in ISO 8601 UTC time. - * - * @param start the start value to set. - * @return the KeyInfo object itself. - */ - public KeyInfo setStart(String start) { - this.start = start; - return this; - } - - /** - * Get the expiry property: The date-time the key expires in ISO 8601 UTC time. - * - * @return the expiry value. - */ - public String getExpiry() { - return this.expiry; - } - - /** - * Set the expiry property: The date-time the key expires in ISO 8601 UTC time. - * - * @param expiry the expiry value to set. - * @return the KeyInfo object itself. - */ - public KeyInfo setExpiry(String expiry) { - this.expiry = expiry; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "KeyInfo" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("Start", this.start); - xmlWriter.writeStringElement("Expiry", this.expiry); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of KeyInfo from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of KeyInfo if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the KeyInfo. - */ - public static KeyInfo fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of KeyInfo from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of KeyInfo if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the KeyInfo. - */ - public static KeyInfo fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "KeyInfo" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - KeyInfo deserializedKeyInfo = new KeyInfo(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Start".equals(elementName.getLocalPart())) { - deserializedKeyInfo.start = reader.getStringElement(); - } else if ("Expiry".equals(elementName.getLocalPart())) { - deserializedKeyInfo.expiry = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedKeyInfo; - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseDuration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseDuration.java new file mode 100644 index 000000000000..f0ff4a67404f --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseDuration.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The lease duration. + */ +public final class LeaseDuration extends ExpandableStringEnum { + /** + * The lease is of infinite duration. + */ + @Generated + public static final LeaseDuration INFINITE = fromString("infinite"); + + /** + * The lease is of fixed duration. + */ + @Generated + public static final LeaseDuration FIXED = fromString("fixed"); + + /** + * Creates a new instance of LeaseDuration value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public LeaseDuration() { + } + + /** + * Creates or finds a LeaseDuration from its string representation. + * + * @param name a name to look for. + * @return the corresponding LeaseDuration. + */ + @Generated + public static LeaseDuration fromString(String name) { + return fromString(name, LeaseDuration.class); + } + + /** + * Gets known LeaseDuration values. + * + * @return known LeaseDuration values. + */ + @Generated + public static Collection values() { + return values(LeaseDuration.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseDurationType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseDurationType.java deleted file mode 100644 index ce5ac31938a7..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseDurationType.java +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -/** - * Defines values for LeaseDurationType. - */ -public enum LeaseDurationType { - /** - * Enum value infinite. - */ - INFINITE("infinite"), - - /** - * Enum value fixed. - */ - FIXED("fixed"); - - /** - * The actual serialized value for a LeaseDurationType instance. - */ - private final String value; - - LeaseDurationType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a LeaseDurationType instance. - * - * @param value the serialized value to parse. - * @return the parsed LeaseDurationType object, or null if unable to parse. - */ - public static LeaseDurationType fromString(String value) { - if (value == null) { - return null; - } - LeaseDurationType[] items = LeaseDurationType.values(); - for (LeaseDurationType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseState.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseState.java new file mode 100644 index 000000000000..9b9e55926db3 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseState.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The lease state. + */ +public final class LeaseState extends ExpandableStringEnum { + /** + * The lease is available. + */ + @Generated + public static final LeaseState AVAILABLE = fromString("available"); + + /** + * The lease is currently leased. + */ + @Generated + public static final LeaseState LEASED = fromString("leased"); + + /** + * The lease is expired. + */ + @Generated + public static final LeaseState EXPIRED = fromString("expired"); + + /** + * The lease is breaking. + */ + @Generated + public static final LeaseState BREAKING = fromString("breaking"); + + /** + * The lease is broken. + */ + @Generated + public static final LeaseState BROKEN = fromString("broken"); + + /** + * Creates a new instance of LeaseState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public LeaseState() { + } + + /** + * Creates or finds a LeaseState from its string representation. + * + * @param name a name to look for. + * @return the corresponding LeaseState. + */ + @Generated + public static LeaseState fromString(String name) { + return fromString(name, LeaseState.class); + } + + /** + * Gets known LeaseState values. + * + * @return known LeaseState values. + */ + @Generated + public static Collection values() { + return values(LeaseState.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStateType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStateType.java deleted file mode 100644 index c76a09b519fb..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStateType.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -/** - * Defines values for LeaseStateType. - */ -public enum LeaseStateType { - /** - * Enum value available. - */ - AVAILABLE("available"), - - /** - * Enum value leased. - */ - LEASED("leased"), - - /** - * Enum value expired. - */ - EXPIRED("expired"), - - /** - * Enum value breaking. - */ - BREAKING("breaking"), - - /** - * Enum value broken. - */ - BROKEN("broken"); - - /** - * The actual serialized value for a LeaseStateType instance. - */ - private final String value; - - LeaseStateType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a LeaseStateType instance. - * - * @param value the serialized value to parse. - * @return the parsed LeaseStateType object, or null if unable to parse. - */ - public static LeaseStateType fromString(String value) { - if (value == null) { - return null; - } - LeaseStateType[] items = LeaseStateType.values(); - for (LeaseStateType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStatus.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStatus.java new file mode 100644 index 000000000000..706f4665744b --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStatus.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The lease status. + */ +public final class LeaseStatus extends ExpandableStringEnum { + /** + * The lease is unlocked. + */ + @Generated + public static final LeaseStatus UNLOCKED = fromString("unlocked"); + + /** + * The lease is locked. + */ + @Generated + public static final LeaseStatus LOCKED = fromString("locked"); + + /** + * Creates a new instance of LeaseStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public LeaseStatus() { + } + + /** + * Creates or finds a LeaseStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding LeaseStatus. + */ + @Generated + public static LeaseStatus fromString(String name) { + return fromString(name, LeaseStatus.class); + } + + /** + * Gets known LeaseStatus values. + * + * @return known LeaseStatus values. + */ + @Generated + public static Collection values() { + return values(LeaseStatus.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStatusType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStatusType.java deleted file mode 100644 index 2de9c2c87362..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/LeaseStatusType.java +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -/** - * Defines values for LeaseStatusType. - */ -public enum LeaseStatusType { - /** - * Enum value locked. - */ - LOCKED("locked"), - - /** - * Enum value unlocked. - */ - UNLOCKED("unlocked"); - - /** - * The actual serialized value for a LeaseStatusType instance. - */ - private final String value; - - LeaseStatusType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a LeaseStatusType instance. - * - * @param value the serialized value to parse. - * @return the parsed LeaseStatusType object, or null if unable to parse. - */ - public static LeaseStatusType fromString(String value) { - if (value == null) { - return null; - } - LeaseStatusType[] items = LeaseStatusType.values(); - for (LeaseStatusType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobContainersIncludeType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobContainersIncludeType.java deleted file mode 100644 index 9615a6ce401b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobContainersIncludeType.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -/** - * Defines values for ListBlobContainersIncludeType. - */ -public enum ListBlobContainersIncludeType { - /** - * Enum value metadata. - */ - METADATA("metadata"), - - /** - * Enum value deleted. - */ - DELETED("deleted"), - - /** - * Enum value system. - */ - SYSTEM("system"); - - /** - * The actual serialized value for a ListBlobContainersIncludeType instance. - */ - private final String value; - - ListBlobContainersIncludeType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ListBlobContainersIncludeType instance. - * - * @param value the serialized value to parse. - * @return the parsed ListBlobContainersIncludeType object, or null if unable to parse. - */ - public static ListBlobContainersIncludeType fromString(String value) { - if (value == null) { - return null; - } - ListBlobContainersIncludeType[] items = ListBlobContainersIncludeType.values(); - for (ListBlobContainersIncludeType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobContainersOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobContainersOptions.java deleted file mode 100644 index 801b0eb87358..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobContainersOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobServiceClient; - -/** - * Defines options available to configure the behavior of a call to listContainersSegment on a {@link BlobServiceClient} - * object. See the constructor for details on each of the options. Null may be passed in place of an object of this type - * if no options are desirable. - */ -@Fluent -public final class ListBlobContainersOptions { - private static final ClientLogger LOGGER = new ClientLogger(ListBlobContainersOptions.class); - - private BlobContainerListDetails details; - private String prefix; - private Integer maxResultsPerPage; - - /** - * Constructs an unpopulated {@link ListBlobContainersOptions}. - */ - public ListBlobContainersOptions() { - this.details = new BlobContainerListDetails(); - } - - /** - * Gets the details for listing specific containers. - * - * @return the details for listing specific containers - */ - public BlobContainerListDetails getDetails() { - return details; - } - - /** - * Sets the details for listing specific containers. - * - * @param details The details for listing specific containers - * @return the updated ListBlobContainersOptions object - */ - public ListBlobContainersOptions setDetails(BlobContainerListDetails details) { - this.details = details; - return this; - } - - /** - * Filters the results to return only blobs whose names begin with the specified prefix. - * - * @return the prefix a container must start with to be returned - */ - public String getPrefix() { - return prefix; - } - - /** - * Filters the results to return only blobs whose names begin with the specified prefix. - * - * @param prefix The prefix that a container must match to be returned - * @return the updated ListBlobContainersOptions object - */ - public ListBlobContainersOptions setPrefix(String prefix) { - this.prefix = prefix; - return this; - } - - /** - * Specifies the maximum number of blobs to return, including all BlobPrefix elements. If the request does not - * specify maxResultsPerPage or specifies a value greater than 5,000, the server will return up to 5,000 items. - * - * @return the number of containers to be returned in a single response - */ - public Integer getMaxResultsPerPage() { - return maxResultsPerPage; - } - - /** - * Specifies the maximum number of blobs to return, including all BlobPrefix elements. If the request does not - * specify maxResultsPerPage or specifies a value greater than 5,000, the server will return up to 5,000 items. - * - * @param maxResultsPerPage The number of containers to return in a single response - * @return the updated ListBlobContainersOptions object - * @throws IllegalArgumentException If {@code maxResultsPerPage} is less than or equal to {@code 0}. - */ - public ListBlobContainersOptions setMaxResultsPerPage(Integer maxResultsPerPage) { - if (maxResultsPerPage != null && maxResultsPerPage <= 0) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("MaxResultsPerPage must be greater than 0.")); - } - this.maxResultsPerPage = maxResultsPerPage; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsFlatSegmentResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsFlatSegmentResponse.java new file mode 100644 index 000000000000..c7ead17b6eac --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsFlatSegmentResponse.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An enumeration of blobs. + */ +@Immutable +public final class ListBlobsFlatSegmentResponse implements JsonSerializable { + /* + * The service endpoint. + */ + @Generated + private final String serviceEndpoint; + + /* + * The container name. + */ + @Generated + private final String containerName; + + /* + * The prefix of the blobs. + */ + @Generated + private String prefix; + + /* + * The marker of the blobs. + */ + @Generated + private String marker; + + /* + * The max results of the blobs. + */ + @Generated + private Integer maxResults; + + /* + * The blob segment. + */ + @Generated + private final BlobFlatListSegment segment; + + /* + * The next marker of the blobs. + */ + @Generated + private String nextMarker; + + /** + * Creates an instance of ListBlobsFlatSegmentResponse class. + * + * @param serviceEndpoint the serviceEndpoint value to set. + * @param containerName the containerName value to set. + * @param segment the segment value to set. + */ + @Generated + private ListBlobsFlatSegmentResponse(String serviceEndpoint, String containerName, BlobFlatListSegment segment) { + this.serviceEndpoint = serviceEndpoint; + this.containerName = containerName; + this.segment = segment; + } + + /** + * Get the serviceEndpoint property: The service endpoint. + * + * @return the serviceEndpoint value. + */ + @Generated + public String getServiceEndpoint() { + return this.serviceEndpoint; + } + + /** + * Get the containerName property: The container name. + * + * @return the containerName value. + */ + @Generated + public String getContainerName() { + return this.containerName; + } + + /** + * Get the prefix property: The prefix of the blobs. + * + * @return the prefix value. + */ + @Generated + public String getPrefix() { + return this.prefix; + } + + /** + * Get the marker property: The marker of the blobs. + * + * @return the marker value. + */ + @Generated + public String getMarker() { + return this.marker; + } + + /** + * Get the maxResults property: The max results of the blobs. + * + * @return the maxResults value. + */ + @Generated + public Integer getMaxResults() { + return this.maxResults; + } + + /** + * Get the segment property: The blob segment. + * + * @return the segment value. + */ + @Generated + public BlobFlatListSegment getSegment() { + return this.segment; + } + + /** + * Get the nextMarker property: The next marker of the blobs. + * + * @return the nextMarker value. + */ + @Generated + public String getNextMarker() { + return this.nextMarker; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("serviceEndpoint", this.serviceEndpoint); + jsonWriter.writeStringField("containerName", this.containerName); + jsonWriter.writeJsonField("segment", this.segment); + jsonWriter.writeStringField("prefix", this.prefix); + jsonWriter.writeStringField("marker", this.marker); + jsonWriter.writeNumberField("maxResults", this.maxResults); + jsonWriter.writeStringField("nextMarker", this.nextMarker); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ListBlobsFlatSegmentResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ListBlobsFlatSegmentResponse if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ListBlobsFlatSegmentResponse. + */ + @Generated + public static ListBlobsFlatSegmentResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String serviceEndpoint = null; + String containerName = null; + BlobFlatListSegment segment = null; + String prefix = null; + String marker = null; + Integer maxResults = null; + String nextMarker = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("serviceEndpoint".equals(fieldName)) { + serviceEndpoint = reader.getString(); + } else if ("containerName".equals(fieldName)) { + containerName = reader.getString(); + } else if ("segment".equals(fieldName)) { + segment = BlobFlatListSegment.fromJson(reader); + } else if ("prefix".equals(fieldName)) { + prefix = reader.getString(); + } else if ("marker".equals(fieldName)) { + marker = reader.getString(); + } else if ("maxResults".equals(fieldName)) { + maxResults = reader.getNullable(JsonReader::getInt); + } else if ("nextMarker".equals(fieldName)) { + nextMarker = reader.getString(); + } else { + reader.skipChildren(); + } + } + ListBlobsFlatSegmentResponse deserializedListBlobsFlatSegmentResponse + = new ListBlobsFlatSegmentResponse(serviceEndpoint, containerName, segment); + deserializedListBlobsFlatSegmentResponse.prefix = prefix; + deserializedListBlobsFlatSegmentResponse.marker = marker; + deserializedListBlobsFlatSegmentResponse.maxResults = maxResults; + deserializedListBlobsFlatSegmentResponse.nextMarker = nextMarker; + + return deserializedListBlobsFlatSegmentResponse; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsHierarchySegmentResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsHierarchySegmentResponse.java new file mode 100644 index 000000000000..7eb9aab9befc --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsHierarchySegmentResponse.java @@ -0,0 +1,236 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An enumeration of blobs. + */ +@Immutable +public final class ListBlobsHierarchySegmentResponse implements JsonSerializable { + /* + * The service endpoint. + */ + @Generated + private final String serviceEndpoint; + + /* + * The container name. + */ + @Generated + private final String containerName; + + /* + * The delimiter of the blobs. + */ + @Generated + private String delimiter; + + /* + * The prefix of the blobs. + */ + @Generated + private String prefix; + + /* + * The marker of the blobs. + */ + @Generated + private String marker; + + /* + * The max results of the blobs. + */ + @Generated + private Integer maxResults; + + /* + * The blob segment. + */ + @Generated + private final BlobHierarchyListSegment segment; + + /* + * The next marker of the blobs. + */ + @Generated + private String nextMarker; + + /** + * Creates an instance of ListBlobsHierarchySegmentResponse class. + * + * @param serviceEndpoint the serviceEndpoint value to set. + * @param containerName the containerName value to set. + * @param segment the segment value to set. + */ + @Generated + private ListBlobsHierarchySegmentResponse(String serviceEndpoint, String containerName, + BlobHierarchyListSegment segment) { + this.serviceEndpoint = serviceEndpoint; + this.containerName = containerName; + this.segment = segment; + } + + /** + * Get the serviceEndpoint property: The service endpoint. + * + * @return the serviceEndpoint value. + */ + @Generated + public String getServiceEndpoint() { + return this.serviceEndpoint; + } + + /** + * Get the containerName property: The container name. + * + * @return the containerName value. + */ + @Generated + public String getContainerName() { + return this.containerName; + } + + /** + * Get the delimiter property: The delimiter of the blobs. + * + * @return the delimiter value. + */ + @Generated + public String getDelimiter() { + return this.delimiter; + } + + /** + * Get the prefix property: The prefix of the blobs. + * + * @return the prefix value. + */ + @Generated + public String getPrefix() { + return this.prefix; + } + + /** + * Get the marker property: The marker of the blobs. + * + * @return the marker value. + */ + @Generated + public String getMarker() { + return this.marker; + } + + /** + * Get the maxResults property: The max results of the blobs. + * + * @return the maxResults value. + */ + @Generated + public Integer getMaxResults() { + return this.maxResults; + } + + /** + * Get the segment property: The blob segment. + * + * @return the segment value. + */ + @Generated + public BlobHierarchyListSegment getSegment() { + return this.segment; + } + + /** + * Get the nextMarker property: The next marker of the blobs. + * + * @return the nextMarker value. + */ + @Generated + public String getNextMarker() { + return this.nextMarker; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("serviceEndpoint", this.serviceEndpoint); + jsonWriter.writeStringField("containerName", this.containerName); + jsonWriter.writeJsonField("segment", this.segment); + jsonWriter.writeStringField("delimiter", this.delimiter); + jsonWriter.writeStringField("prefix", this.prefix); + jsonWriter.writeStringField("marker", this.marker); + jsonWriter.writeNumberField("maxResults", this.maxResults); + jsonWriter.writeStringField("nextMarker", this.nextMarker); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ListBlobsHierarchySegmentResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ListBlobsHierarchySegmentResponse if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ListBlobsHierarchySegmentResponse. + */ + @Generated + public static ListBlobsHierarchySegmentResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String serviceEndpoint = null; + String containerName = null; + BlobHierarchyListSegment segment = null; + String delimiter = null; + String prefix = null; + String marker = null; + Integer maxResults = null; + String nextMarker = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("serviceEndpoint".equals(fieldName)) { + serviceEndpoint = reader.getString(); + } else if ("containerName".equals(fieldName)) { + containerName = reader.getString(); + } else if ("segment".equals(fieldName)) { + segment = BlobHierarchyListSegment.fromJson(reader); + } else if ("delimiter".equals(fieldName)) { + delimiter = reader.getString(); + } else if ("prefix".equals(fieldName)) { + prefix = reader.getString(); + } else if ("marker".equals(fieldName)) { + marker = reader.getString(); + } else if ("maxResults".equals(fieldName)) { + maxResults = reader.getNullable(JsonReader::getInt); + } else if ("nextMarker".equals(fieldName)) { + nextMarker = reader.getString(); + } else { + reader.skipChildren(); + } + } + ListBlobsHierarchySegmentResponse deserializedListBlobsHierarchySegmentResponse + = new ListBlobsHierarchySegmentResponse(serviceEndpoint, containerName, segment); + deserializedListBlobsHierarchySegmentResponse.delimiter = delimiter; + deserializedListBlobsHierarchySegmentResponse.prefix = prefix; + deserializedListBlobsHierarchySegmentResponse.marker = marker; + deserializedListBlobsHierarchySegmentResponse.maxResults = maxResults; + deserializedListBlobsHierarchySegmentResponse.nextMarker = nextMarker; + + return deserializedListBlobsHierarchySegmentResponse; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsIncludeItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsIncludeItem.java index 975ec377007b..31b0bf91d7a8 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsIncludeItem.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsIncludeItem.java @@ -1,96 +1,105 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + /** - * Defines values for ListBlobsIncludeItem. + * The list blob includes parameter values. */ -public enum ListBlobsIncludeItem { +public final class ListBlobsIncludeItem extends ExpandableStringEnum { /** - * Enum value copy. + * The include copies. */ - COPY("copy"), + @Generated + public static final ListBlobsIncludeItem COPY = fromString("copy"); /** - * Enum value deleted. + * The include deleted blobs. */ - DELETED("deleted"), + @Generated + public static final ListBlobsIncludeItem DELETED = fromString("deleted"); /** - * Enum value metadata. + * The include metadata. */ - METADATA("metadata"), + @Generated + public static final ListBlobsIncludeItem METADATA = fromString("metadata"); /** - * Enum value snapshots. + * The include snapshots. */ - SNAPSHOTS("snapshots"), + @Generated + public static final ListBlobsIncludeItem SNAPSHOTS = fromString("snapshots"); /** - * Enum value uncommittedblobs. + * The include uncommitted blobs. */ - UNCOMMITTEDBLOBS("uncommittedblobs"), + @Generated + public static final ListBlobsIncludeItem UNCOMMITTED_BLOBS = fromString("uncommittedblobs"); /** - * Enum value versions. + * The include versions. */ - VERSIONS("versions"), + @Generated + public static final ListBlobsIncludeItem VERSIONS = fromString("versions"); /** - * Enum value tags. + * The include tags. */ - TAGS("tags"), + @Generated + public static final ListBlobsIncludeItem TAGS = fromString("tags"); /** - * Enum value immutabilitypolicy. + * The include immutable policy. */ - IMMUTABILITY_POLICY("immutabilitypolicy"), + @Generated + public static final ListBlobsIncludeItem IMMUTABILITY_POLICY = fromString("immutabilitypolicy"); /** - * Enum value legalhold. + * The include legal hold. */ - LEGAL_HOLD("legalhold"), + @Generated + public static final ListBlobsIncludeItem LEGAL_HOLD = fromString("legalhold"); /** - * Enum value deletedwithversions. + * The include deleted with versions. */ - DELETED_WITH_VERSIONS("deletedwithversions"); + @Generated + public static final ListBlobsIncludeItem DELETED_WITH_VERSIONS = fromString("deletedwithversions"); /** - * The actual serialized value for a ListBlobsIncludeItem instance. + * Creates a new instance of ListBlobsIncludeItem value. + * + * @deprecated Use the {@link #fromString(String)} factory method. */ - private final String value; - - ListBlobsIncludeItem(String value) { - this.value = value; + @Generated + @Deprecated + public ListBlobsIncludeItem() { } /** - * Parses a serialized value to a ListBlobsIncludeItem instance. + * Creates or finds a ListBlobsIncludeItem from its string representation. * - * @param value the serialized value to parse. - * @return the parsed ListBlobsIncludeItem object, or null if unable to parse. + * @param name a name to look for. + * @return the corresponding ListBlobsIncludeItem. */ - public static ListBlobsIncludeItem fromString(String value) { - if (value == null) { - return null; - } - ListBlobsIncludeItem[] items = ListBlobsIncludeItem.values(); - for (ListBlobsIncludeItem item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; + @Generated + public static ListBlobsIncludeItem fromString(String name) { + return fromString(name, ListBlobsIncludeItem.class); } /** - * {@inheritDoc} + * Gets known ListBlobsIncludeItem values. + * + * @return known ListBlobsIncludeItem values. */ - @Override - public String toString() { - return this.value; + @Generated + public static Collection values() { + return values(ListBlobsIncludeItem.class); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsOptions.java deleted file mode 100644 index d33edff1afa5..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobContainerClient; - -/** - * Defines options available to configure the behavior of a call to listBlobsFlatSegment on a {@link - * BlobContainerClient} object. See the constructor for details on each of the options. - */ -@Fluent -public final class ListBlobsOptions { - private static final ClientLogger LOGGER = new ClientLogger(ListBlobsOptions.class); - - private BlobListDetails details; - private String prefix; - private Integer maxResultsPerPage; - - /** - * Constructs an unpopulated {@link ListBlobsOptions}. - */ - public ListBlobsOptions() { - this.details = new BlobListDetails(); - } - - /** - * Gets the details for listing specific blobs. - * - * @return the details for listing specific blobs - */ - public BlobListDetails getDetails() { - return details; - } - - /** - * Sets the details for listing specific blobs. - * - * @param details The details for listing specific blobs - * @return the updated ListBlobsOptions object - */ - public ListBlobsOptions setDetails(BlobListDetails details) { - this.details = details; - return this; - } - - /** - * Filters the results to return only blobs whose names begin with the specified prefix. May be null to return all - * blobs. - * - * @return the prefix that a blob must match to be returned in the listing - */ - public String getPrefix() { - return prefix; - } - - /** - * Filters the results to return only blobs whose names begin with the specified prefix. May be null to return all - * blobs. - * - * @param prefix A prefix that a blob must match to be returned - * @return the updated ListBlobsOptions object - */ - public ListBlobsOptions setPrefix(String prefix) { - this.prefix = prefix; - return this; - } - - /** - * Specifies the maximum number of blobs to return, including all BlobPrefix elements. If the request does not - * specify maxResultsPerPage or specifies a value greater than 5,000, the server will return up to 5,000 items. - * - * @return the number of blobs that will be returned in a single response - */ - public Integer getMaxResultsPerPage() { - return maxResultsPerPage; - } - - /** - * Specifies the maximum number of blobs to return, including all BlobPrefix elements. If the request does not - * specify maxResultsPerPage or specifies a value greater than 5,000, the server will return up to 5,000 items. - * - * @param maxResultsPerPage The number of blobs to returned in a single response - * @return the updated ListBlobsOptions object - * @throws IllegalArgumentException If {@code maxResultsPerPage} is less than or equal to {@code 0}. - */ - public ListBlobsOptions setMaxResultsPerPage(Integer maxResultsPerPage) { - if (maxResultsPerPage != null && maxResultsPerPage <= 0) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("MaxResultsPerPage must be greater than 0.")); - } - this.maxResultsPerPage = maxResultsPerPage; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListContainersIncludeType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListContainersIncludeType.java new file mode 100644 index 000000000000..f0ef4de73fc6 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListContainersIncludeType.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Include this parameter to specify that the container's metadata be returned as part of the response body. + */ +public final class ListContainersIncludeType extends ExpandableStringEnum { + /** + * Include metadata. + */ + @Generated + public static final ListContainersIncludeType METADATA = fromString("metadata"); + + /** + * Include deleted. + */ + @Generated + public static final ListContainersIncludeType DELETED = fromString("deleted"); + + /** + * Include system. + */ + @Generated + public static final ListContainersIncludeType SYSTEM = fromString("system"); + + /** + * Creates a new instance of ListContainersIncludeType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ListContainersIncludeType() { + } + + /** + * Creates or finds a ListContainersIncludeType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ListContainersIncludeType. + */ + @Generated + public static ListContainersIncludeType fromString(String name) { + return fromString(name, ListContainersIncludeType.class); + } + + /** + * Gets known ListContainersIncludeType values. + * + * @return known ListContainersIncludeType values. + */ + @Generated + public static Collection values() { + return values(ListContainersIncludeType.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListContainersSegmentResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListContainersSegmentResponse.java new file mode 100644 index 000000000000..dda93c35c347 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListContainersSegmentResponse.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The list container segment response. + */ +@Immutable +public final class ListContainersSegmentResponse implements JsonSerializable { + /* + * The service endpoint. + */ + @Generated + private final String serviceEndpoint; + + /* + * The prefix of the containers. + */ + @Generated + private String prefix; + + /* + * The marker of the containers. + */ + @Generated + private String marker; + + /* + * The max results of the containers. + */ + @Generated + private Integer maxResults; + + /* + * The container segment. + */ + @Generated + private final List containerItems; + + /* + * The next marker of the containers. + */ + @Generated + private String nextMarker; + + /** + * Creates an instance of ListContainersSegmentResponse class. + * + * @param serviceEndpoint the serviceEndpoint value to set. + * @param containerItems the containerItems value to set. + */ + @Generated + private ListContainersSegmentResponse(String serviceEndpoint, List containerItems) { + this.serviceEndpoint = serviceEndpoint; + this.containerItems = containerItems; + } + + /** + * Get the serviceEndpoint property: The service endpoint. + * + * @return the serviceEndpoint value. + */ + @Generated + public String getServiceEndpoint() { + return this.serviceEndpoint; + } + + /** + * Get the prefix property: The prefix of the containers. + * + * @return the prefix value. + */ + @Generated + public String getPrefix() { + return this.prefix; + } + + /** + * Get the marker property: The marker of the containers. + * + * @return the marker value. + */ + @Generated + public String getMarker() { + return this.marker; + } + + /** + * Get the maxResults property: The max results of the containers. + * + * @return the maxResults value. + */ + @Generated + public Integer getMaxResults() { + return this.maxResults; + } + + /** + * Get the containerItems property: The container segment. + * + * @return the containerItems value. + */ + @Generated + public List getContainerItems() { + return this.containerItems; + } + + /** + * Get the nextMarker property: The next marker of the containers. + * + * @return the nextMarker value. + */ + @Generated + public String getNextMarker() { + return this.nextMarker; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("serviceEndpoint", this.serviceEndpoint); + jsonWriter.writeArrayField("containerItems", this.containerItems, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("prefix", this.prefix); + jsonWriter.writeStringField("marker", this.marker); + jsonWriter.writeNumberField("maxResults", this.maxResults); + jsonWriter.writeStringField("NextMarker", this.nextMarker); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ListContainersSegmentResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ListContainersSegmentResponse if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ListContainersSegmentResponse. + */ + @Generated + public static ListContainersSegmentResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String serviceEndpoint = null; + List containerItems = null; + String prefix = null; + String marker = null; + Integer maxResults = null; + String nextMarker = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("serviceEndpoint".equals(fieldName)) { + serviceEndpoint = reader.getString(); + } else if ("containerItems".equals(fieldName)) { + containerItems = reader.readArray(reader1 -> ContainerItem.fromJson(reader1)); + } else if ("prefix".equals(fieldName)) { + prefix = reader.getString(); + } else if ("marker".equals(fieldName)) { + marker = reader.getString(); + } else if ("maxResults".equals(fieldName)) { + maxResults = reader.getNullable(JsonReader::getInt); + } else if ("NextMarker".equals(fieldName)) { + nextMarker = reader.getString(); + } else { + reader.skipChildren(); + } + } + ListContainersSegmentResponse deserializedListContainersSegmentResponse + = new ListContainersSegmentResponse(serviceEndpoint, containerItems); + deserializedListContainersSegmentResponse.prefix = prefix; + deserializedListContainersSegmentResponse.marker = marker; + deserializedListContainersSegmentResponse.maxResults = maxResults; + deserializedListContainersSegmentResponse.nextMarker = nextMarker; + + return deserializedListContainersSegmentResponse; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Logging.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Logging.java new file mode 100644 index 000000000000..bcda9da4b339 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Logging.java @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Azure Analytics Logging settings. + */ +@Immutable +public final class Logging implements JsonSerializable { + /* + * The version of the logging properties. + */ + @Generated + private final String version; + + /* + * Whether delete operation is logged. + */ + @Generated + private final boolean delete; + + /* + * Whether read operation is logged. + */ + @Generated + private final boolean read; + + /* + * Whether write operation is logged. + */ + @Generated + private final boolean write; + + /* + * The retention policy of the logs. + */ + @Generated + private final RetentionPolicy retentionPolicy; + + /** + * Creates an instance of Logging class. + * + * @param version the version value to set. + * @param delete the delete value to set. + * @param read the read value to set. + * @param write the write value to set. + * @param retentionPolicy the retentionPolicy value to set. + */ + @Generated + public Logging(String version, boolean delete, boolean read, boolean write, RetentionPolicy retentionPolicy) { + this.version = version; + this.delete = delete; + this.read = read; + this.write = write; + this.retentionPolicy = retentionPolicy; + } + + /** + * Get the version property: The version of the logging properties. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * Get the delete property: Whether delete operation is logged. + * + * @return the delete value. + */ + @Generated + public boolean isDelete() { + return this.delete; + } + + /** + * Get the read property: Whether read operation is logged. + * + * @return the read value. + */ + @Generated + public boolean isRead() { + return this.read; + } + + /** + * Get the write property: Whether write operation is logged. + * + * @return the write value. + */ + @Generated + public boolean isWrite() { + return this.write; + } + + /** + * Get the retentionPolicy property: The retention policy of the logs. + * + * @return the retentionPolicy value. + */ + @Generated + public RetentionPolicy getRetentionPolicy() { + return this.retentionPolicy; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("version", this.version); + jsonWriter.writeBooleanField("delete", this.delete); + jsonWriter.writeBooleanField("read", this.read); + jsonWriter.writeBooleanField("write", this.write); + jsonWriter.writeJsonField("retentionPolicy", this.retentionPolicy); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Logging from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Logging if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Logging. + */ + @Generated + public static Logging fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String version = null; + boolean delete = false; + boolean read = false; + boolean write = false; + RetentionPolicy retentionPolicy = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("delete".equals(fieldName)) { + delete = reader.getBoolean(); + } else if ("read".equals(fieldName)) { + read = reader.getBoolean(); + } else if ("write".equals(fieldName)) { + write = reader.getBoolean(); + } else if ("retentionPolicy".equals(fieldName)) { + retentionPolicy = RetentionPolicy.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new Logging(version, delete, read, write, retentionPolicy); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Metrics.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Metrics.java new file mode 100644 index 000000000000..003e1efd7bef --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/Metrics.java @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The metrics properties. + */ +@Fluent +public final class Metrics implements JsonSerializable { + /* + * The version of the metrics properties. + */ + @Generated + private String version; + + /* + * Whether it is enabled. + */ + @Generated + private final boolean enabled; + + /* + * Whether to include API in the metrics. + */ + @Generated + private Boolean includeApis; + + /* + * The retention policy of the metrics. + */ + @Generated + private RetentionPolicy retentionPolicy; + + /** + * Creates an instance of Metrics class. + * + * @param enabled the enabled value to set. + */ + @Generated + public Metrics(boolean enabled) { + this.enabled = enabled; + } + + /** + * Get the version property: The version of the metrics properties. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * Set the version property: The version of the metrics properties. + * + * @param version the version value to set. + * @return the Metrics object itself. + */ + @Generated + public Metrics setVersion(String version) { + this.version = version; + return this; + } + + /** + * Get the enabled property: Whether it is enabled. + * + * @return the enabled value. + */ + @Generated + public boolean isEnabled() { + return this.enabled; + } + + /** + * Get the includeApis property: Whether to include API in the metrics. + * + * @return the includeApis value. + */ + @Generated + public Boolean isIncludeApis() { + return this.includeApis; + } + + /** + * Set the includeApis property: Whether to include API in the metrics. + * + * @param includeApis the includeApis value to set. + * @return the Metrics object itself. + */ + @Generated + public Metrics setIncludeApis(Boolean includeApis) { + this.includeApis = includeApis; + return this; + } + + /** + * Get the retentionPolicy property: The retention policy of the metrics. + * + * @return the retentionPolicy value. + */ + @Generated + public RetentionPolicy getRetentionPolicy() { + return this.retentionPolicy; + } + + /** + * Set the retentionPolicy property: The retention policy of the metrics. + * + * @param retentionPolicy the retentionPolicy value to set. + * @return the Metrics object itself. + */ + @Generated + public Metrics setRetentionPolicy(RetentionPolicy retentionPolicy) { + this.retentionPolicy = retentionPolicy; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeStringField("version", this.version); + jsonWriter.writeBooleanField("includeApis", this.includeApis); + jsonWriter.writeJsonField("retentionPolicy", this.retentionPolicy); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Metrics from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Metrics if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Metrics. + */ + @Generated + public static Metrics fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean enabled = false; + String version = null; + Boolean includeApis = null; + RetentionPolicy retentionPolicy = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("enabled".equals(fieldName)) { + enabled = reader.getBoolean(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("includeApis".equals(fieldName)) { + includeApis = reader.getNullable(JsonReader::getBoolean); + } else if ("retentionPolicy".equals(fieldName)) { + retentionPolicy = RetentionPolicy.fromJson(reader); + } else { + reader.skipChildren(); + } + } + Metrics deserializedMetrics = new Metrics(enabled); + deserializedMetrics.version = version; + deserializedMetrics.includeApis = includeApis; + deserializedMetrics.retentionPolicy = retentionPolicy; + + return deserializedMetrics; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationMetadata.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationMetadata.java new file mode 100644 index 000000000000..c11cb5c56a99 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationMetadata.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The object replication metadata. + */ +@Immutable +public final class ObjectReplicationMetadata implements JsonSerializable { + /* + * The object replication metadata. + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of ObjectReplicationMetadata class. + */ + @Generated + private ObjectReplicationMetadata() { + } + + /** + * Get the additionalProperties property: The object replication metadata. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ObjectReplicationMetadata from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ObjectReplicationMetadata if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ObjectReplicationMetadata. + */ + @Generated + public static ObjectReplicationMetadata fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ObjectReplicationMetadata deserializedObjectReplicationMetadata = new ObjectReplicationMetadata(); + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + deserializedObjectReplicationMetadata.additionalProperties = additionalProperties; + + return deserializedObjectReplicationMetadata; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationPolicy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationPolicy.java deleted file mode 100644 index 8e6ee7f57afc..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationPolicy.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * A type that contains information about an object replication policy on a source blob. - */ -@Immutable -public class ObjectReplicationPolicy { - private final String policyId; - private final List objectReplicationRules; - - /** - * Constructs a new ObjectReplicationPolicy object. - * @param policyId The policy id - * @param rules A {@code List} of rules associated with this policy to the status of the replication associated - * with that rule. - */ - public ObjectReplicationPolicy(String policyId, List rules) { - this.policyId = policyId; - this.objectReplicationRules = Collections.unmodifiableList(new ArrayList<>(rules)); - } - - /** - * Gets the policy id. - * - * @return The policy id. - */ - public String getPolicyId() { - return policyId; - } - - /** - * Gets the rules associated with this policy to the status of the replication associated with that rule. - * - * @return The rules associated with this policy to the status of the replication associated with that rule. - */ - public List getRules() { - return this.objectReplicationRules; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationRule.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationRule.java deleted file mode 100644 index a803757f919d..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationRule.java +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -/** - * A type that contains information about an object replication rule on a source blob. - */ -public class ObjectReplicationRule { - private final String ruleId; - private final ObjectReplicationStatus status; - - /** - * Constructs a new ObjectReplicationRule object. - * @param ruleId The rule id. - * @param status The {@link ObjectReplicationStatus} - */ - public ObjectReplicationRule(String ruleId, ObjectReplicationStatus status) { - this.ruleId = ruleId; - this.status = status; - } - - /** - * Gets the rule id. - * - * @return The rule id. - */ - public String getRuleId() { - return ruleId; - } - - /** - * Gets the {@link ObjectReplicationStatus} - * - * @return The {@link ObjectReplicationStatus} - */ - public ObjectReplicationStatus getStatus() { - return status; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationStatus.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationStatus.java deleted file mode 100644 index 295f98c9b328..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ObjectReplicationStatus.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.util.ExpandableStringEnum; - -import java.util.Collection; - -/** - * Defines values for ObjectReplicationStatus. - */ -public final class ObjectReplicationStatus extends ExpandableStringEnum { - /** - * Static value completed for ObjectReplicationStatus. - */ - public static final ObjectReplicationStatus COMPLETE = fromString("complete"); - - /** - * Static value failed for ObjectReplicationStatus. - */ - public static final ObjectReplicationStatus FAILED = fromString("failed"); - - /** - * Creates a new instance of {@link ObjectReplicationStatus} with no string value. - * - * @deprecated Use {@link #fromString(String)} instead. - */ - @Deprecated - public ObjectReplicationStatus() { - } - - /** - * Creates or finds a ObjectReplicationStatus from its string representation. - * - * @param name a name to look for. - * @return the corresponding ObjectReplicationStatus. - */ - public static ObjectReplicationStatus fromString(String name) { - return fromString(name, ObjectReplicationStatus.class); - } - - /** - * Gets known ObjectReplicationStatus values. - * - * @return known ObjectReplicationStatus values. - */ - public static Collection values() { - return values(ObjectReplicationStatus.class); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobCopyIncrementalRequestConditions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobCopyIncrementalRequestConditions.java deleted file mode 100644 index 6f74ecd26131..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobCopyIncrementalRequestConditions.java +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.http.RequestConditions; - -import java.time.OffsetDateTime; - -/** - * This class contains values which will restrict the successful operation of a variety of blob requests to the - * conditions present on the destination blob. These conditions are entirely optional. The entire object or any of its - * properties may be set to null when passed to a method to indicate that those conditions are not desired. Please - * refer to the type of each field for more information on those particular access conditions. - */ -public class PageBlobCopyIncrementalRequestConditions extends RequestConditions { - private String tagsConditions; - - /** - * Creates a new instance of {@link PageBlobCopyIncrementalRequestConditions}. - */ - public PageBlobCopyIncrementalRequestConditions() { - } - - /** - * Optionally limit requests to resources that match the passed ETag. - * - * @param ifMatch ETag that resources must match. - * @return The updated BlobDestinationRequestConditions object. - */ - @Override - public PageBlobCopyIncrementalRequestConditions setIfMatch(String ifMatch) { - super.setIfMatch(ifMatch); - return this; - } - - /** - * Optionally limit requests to resources that do not match the passed ETag. - * - * @param ifNoneMatch ETag that resources must not match. - * @return The updated BlobDestinationRequestConditions object. - */ - @Override - public PageBlobCopyIncrementalRequestConditions setIfNoneMatch(String ifNoneMatch) { - super.setIfNoneMatch(ifNoneMatch); - return this; - } - - /** - * Optionally limit requests to resources that have only been modified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifModifiedSince The datetime that resources must have been modified since. - * @return The updated BlobDestinationRequestConditions object. - */ - @Override - public PageBlobCopyIncrementalRequestConditions setIfModifiedSince(OffsetDateTime ifModifiedSince) { - super.setIfModifiedSince(ifModifiedSince); - return this; - } - - /** - * Optionally limit requests to resources that have remained unmodified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifUnmodifiedSince The datetime that resources must have remained unmodified since. - * @return The updated BlobDestinationRequestConditions object. - */ - @Override - public PageBlobCopyIncrementalRequestConditions setIfUnmodifiedSince(OffsetDateTime ifUnmodifiedSince) { - super.setIfUnmodifiedSince(ifUnmodifiedSince); - return this; - } - - /** - * Gets the SQL statement that apply to the tags of the blob. - * - * @return The SQL statement that apply to the tags of the blob. - */ - public String getTagsConditions() { - return tagsConditions; - } - - /** - * Optionally applies the SQL statement to the tags of the blob. - * - * @param tagsConditions The SQL statement that apply to the tags of the blob. - * @return The updated BlobDestinationRequestConditions object. - */ - public PageBlobCopyIncrementalRequestConditions setTagsConditions(String tagsConditions) { - this.tagsConditions = tagsConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobItem.java deleted file mode 100644 index ef127458a57a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobItem.java +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; -import com.azure.core.util.CoreUtils; - -import java.time.OffsetDateTime; - -/** - * This class contains the properties about a page blob. - */ -@Immutable -public class PageBlobItem { - private final String eTag; - private final OffsetDateTime lastModified; - private final byte[] contentMd5; - private final Boolean isServerEncrypted; - private final String encryptionKeySha256; - private final String encryptionScope; - private final Long blobSequenceNumber; - private final String versionId; - - /** - * Constructs a {@link PageBlobItem}. - * - * @param eTag ETag of the page blob. - * @param lastModified Last modified time of the page blob. - * @param contentMd5 Content MD5 of the page blob. - * @param isServerEncrypted Flag indicating if the page blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the page blob. - * @param blobSequenceNumber The current sequence number for the page blob. - */ - public PageBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final Boolean isServerEncrypted, final String encryptionKeySha256, final Long blobSequenceNumber) { - this(eTag, lastModified, contentMd5, isServerEncrypted, encryptionKeySha256, null, blobSequenceNumber); - } - - /** - * Constructs a {@link PageBlobItem}. - * - * @param eTag ETag of the page blob. - * @param lastModified Last modified time of the page blob. - * @param contentMd5 Content MD5 of the page blob. - * @param isServerEncrypted Flag indicating if the page blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the page blob. - * @param encryptionScope The encryption scope used to encrypt the page blob. - * @param blobSequenceNumber The current sequence number for the page blob. - */ - public PageBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final Boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope, - final Long blobSequenceNumber) { - this(eTag, lastModified, contentMd5, isServerEncrypted, encryptionKeySha256, encryptionScope, - blobSequenceNumber, null); - } - - /** - * Constructs a {@link PageBlobItem}. - * - * @param eTag ETag of the page blob. - * @param lastModified Last modified time of the page blob. - * @param contentMd5 Content MD5 of the page blob. - * @param isServerEncrypted Flag indicating if the page blob is encrypted on the server. - * @param encryptionKeySha256 The encryption key used to encrypt the page blob. - * @param encryptionScope The encryption scope used to encrypt the page blob. - * @param blobSequenceNumber The current sequence number for the page blob. - * @param versionId The version identifier of the page blob. - */ - public PageBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, - final Boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope, - final Long blobSequenceNumber, final String versionId) { - this.eTag = eTag; - this.lastModified = lastModified; - this.contentMd5 = CoreUtils.clone(contentMd5); - this.isServerEncrypted = isServerEncrypted; - this.encryptionKeySha256 = encryptionKeySha256; - this.encryptionScope = encryptionScope; - this.blobSequenceNumber = blobSequenceNumber; - this.versionId = versionId; - } - - /** - * Gets the eTag of the page blob. - * - * @return the eTag of the page blob - */ - public String getETag() { - return eTag; - } - - /** - * Gets the time this page blob was last modified. - * - * @return the time this page blob was last modified - */ - public OffsetDateTime getLastModified() { - return lastModified; - } - - /** - * Gets the encryption status of the page blob on the server. - * - * @return the encryption status of the page blob on the server - */ - public Boolean isServerEncrypted() { - return isServerEncrypted; - } - - /** - * Gets the key used to encrypt the page blob. - * - * @return the key used to encrypt the page blob - */ - public String getEncryptionKeySha256() { - return encryptionKeySha256; - } - - /** - * Gets the encryption scope used to encrypt the page blob. - * - * @return the encryption scope used to encrypt the page blob - */ - public String getEncryptionScope() { - return encryptionScope; - } - - /** - * Gets the MD5 of the page blob's content. - * - * @return the MD5 of the page blob's content - */ - public byte[] getContentMd5() { - return CoreUtils.clone(contentMd5); - } - - /** - * Gets the current sequence number of the page blob. - * - * @return the current sequence number of the page blob - */ - public Long getBlobSequenceNumber() { - return blobSequenceNumber; - } - - /** - * Gets the version identifier of the page blob. - * - * @return the version identifier of the page blob - */ - public String getVersionId() { - return versionId; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobRequestConditions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobRequestConditions.java deleted file mode 100644 index 356005a9d244..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageBlobRequestConditions.java +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; - -import java.time.OffsetDateTime; - -/** - * This class contains values that restrict the successful completion of PageBlob operations to certain conditions. - * It may be set to null if no access conditions are desired. - *

- * Please refer to the request header section - * here for more conceptual information. - */ -@Fluent -public final class PageBlobRequestConditions extends BlobRequestConditions { - private Long ifSequenceNumberLessThanOrEqualTo; - private Long ifSequenceNumberLessThan; - private Long ifSequenceNumberEqualTo; - - /** - * Creates a new instance of {@link PageBlobRequestConditions}. - */ - public PageBlobRequestConditions() { - } - - /** - * Optionally limit requests to resources that match the passed ETag. - * - * @param ifMatch ETag that resources must match. - * @return The updated PageBlobRequestConditions object. - */ - @Override - public PageBlobRequestConditions setIfMatch(String ifMatch) { - super.setIfMatch(ifMatch); - return this; - } - - /** - * Optionally limit requests to resources that do not match the passed ETag. - * - * @param ifNoneMatch ETag that resources must not match. - * @return The updated PageBlobRequestConditions object. - */ - @Override - public PageBlobRequestConditions setIfNoneMatch(String ifNoneMatch) { - super.setIfNoneMatch(ifNoneMatch); - return this; - } - - /** - * Optionally limit requests to resources that have only been modified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifModifiedSince The datetime that resources must have been modified since. - * @return The updated PageBlobRequestConditions object. - */ - @Override - public PageBlobRequestConditions setIfModifiedSince(OffsetDateTime ifModifiedSince) { - super.setIfModifiedSince(ifModifiedSince); - return this; - } - - /** - * Optionally limit requests to resources that have remained unmodified since the passed - * {@link OffsetDateTime datetime}. - * - * @param ifUnmodifiedSince The datetime that resources must have remained unmodified since. - * @return The updated PageBlobRequestConditions object. - */ - @Override - public PageBlobRequestConditions setIfUnmodifiedSince(OffsetDateTime ifUnmodifiedSince) { - super.setIfUnmodifiedSince(ifUnmodifiedSince); - return this; - } - - /** - * Optionally limits requests to blobs and containers that match the lease ID. - * - * @param leaseId Lease ID that blobs and containers must match. - * @return The updated PageBlobRequestConditions object. - */ - @Override - public PageBlobRequestConditions setLeaseId(String leaseId) { - super.setLeaseId(leaseId); - return this; - } - - /** - * Optionally applies the SQL statement to the tags of the blob. - * - * @param tagsConditions The SQL statement that apply to the tags of the blob. - * @return The updated BlobRequestConditions object. - */ - @Override - public PageBlobRequestConditions setTagsConditions(String tagsConditions) { - super.setTagsConditions(tagsConditions); - return this; - } - - /** - * Gets the value that the page blob's sequence number must be less than or equal to. - * - * @return The value the sequence number must be less than or equal to. - */ - public Long getIfSequenceNumberLessThanOrEqualTo() { - return ifSequenceNumberLessThanOrEqualTo; - } - - /** - * Sets the value that the page blob's sequence number must be less than or equal to. - * - * @param ifSequenceNumberLessThanOrEqualTo The value the sequence number must be less than or equal to. - * @return The updated PageBlobRequestConditions object. - */ - public PageBlobRequestConditions setIfSequenceNumberLessThanOrEqualTo(Long ifSequenceNumberLessThanOrEqualTo) { - this.ifSequenceNumberLessThanOrEqualTo = ifSequenceNumberLessThanOrEqualTo; - return this; - } - - /** - * Gets the value that the page blob's sequence number must be less than. - * - * @return The value the sequence number must be less than. - */ - public Long getIfSequenceNumberLessThan() { - return ifSequenceNumberLessThan; - } - - /** - * Sets the value that the page blob's sequence number must be less than. - * - * @param ifSequenceNumberLessThan The value the sequence number must be less than. - * @return The updated PageBlobRequestConditions object. - */ - public PageBlobRequestConditions setIfSequenceNumberLessThan(Long ifSequenceNumberLessThan) { - this.ifSequenceNumberLessThan = ifSequenceNumberLessThan; - return this; - } - - /** - * Gets the value that the page blob's sequence number must be equal to. - * - * @return The value the sequence number must be equal to. - */ - public Long getIfSequenceNumberEqualTo() { - return ifSequenceNumberEqualTo; - } - - /** - * Sets the value that the page blob's sequence number must be less equal to. - * - * @param ifSequenceNumberEqualTo The value the sequence number must be equal to. - * @return The updated PageBlobRequestConditions object. - */ - public PageBlobRequestConditions setIfSequenceNumberEqualTo(Long ifSequenceNumberEqualTo) { - this.ifSequenceNumberEqualTo = ifSequenceNumberEqualTo; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageList.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageList.java index 94039eb2dbba..030a3a85417c 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageList.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageList.java @@ -1,183 +1,120 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.storage.blob.models; -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.implementation.models.PageListHelper; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.util.ArrayList; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; /** - * the list of pages. + * Represents a page list. */ -@Fluent -public final class PageList implements XmlSerializable { - - static { - PageListHelper.setAccessor(new PageListHelper.PageListAccessor() { - - @Override - public String getNextMarker(PageList pageList) { - return pageList.getNextMarker(); - } - - @Override - public PageList setNextMarker(PageList pageList, String marker) { - return pageList.setNextMarker(marker); - } - }); - } - +@Immutable +public final class PageList implements JsonSerializable { /* - * The PageRange property. + * The page ranges. */ - private List pageRange = new ArrayList<>(); + @Generated + private List pageRange; /* - * The ClearRange property. + * The clear ranges. */ - private List clearRange = new ArrayList<>(); + @Generated + private List clearRange; /* - * The NextMarker property. + * The next marker. */ + @Generated private String nextMarker; /** * Creates an instance of PageList class. */ - public PageList() { + @Generated + private PageList() { } /** - * Get the pageRange property: The PageRange property. - * + * Get the pageRange property: The page ranges. + * * @return the pageRange value. */ + @Generated public List getPageRange() { return this.pageRange; } /** - * Set the pageRange property: The PageRange property. - * - * @param pageRange the pageRange value to set. - * @return the PageList object itself. - */ - public PageList setPageRange(List pageRange) { - this.pageRange = pageRange; - return this; - } - - /** - * Get the clearRange property: The ClearRange property. - * + * Get the clearRange property: The clear ranges. + * * @return the clearRange value. */ + @Generated public List getClearRange() { return this.clearRange; } /** - * Set the clearRange property: The ClearRange property. - * - * @param clearRange the clearRange value to set. - * @return the PageList object itself. - */ - public PageList setClearRange(List clearRange) { - this.clearRange = clearRange; - return this; - } - - /** - * Get the nextMarker property: The NextMarker property. - * + * Get the nextMarker property: The next marker. + * * @return the nextMarker value. */ - private String getNextMarker() { + @Generated + public String getNextMarker() { return this.nextMarker; } /** - * Set the nextMarker property: The NextMarker property. - * - * @param nextMarker the nextMarker value to set. - * @return the PageList object itself. + * {@inheritDoc} */ - private PageList setNextMarker(String nextMarker) { - this.nextMarker = nextMarker; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - + @Generated @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "PageList" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - if (this.pageRange != null) { - for (PageRange element : this.pageRange) { - xmlWriter.writeXml(element, "PageRange"); - } - } - if (this.clearRange != null) { - for (ClearRange element : this.clearRange) { - xmlWriter.writeXml(element, "ClearRange"); - } - } - xmlWriter.writeStringElement("NextMarker", this.nextMarker); - return xmlWriter.writeEndElement(); + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("pageRange", this.pageRange, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("clearRange", this.clearRange, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextMarker", this.nextMarker); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of PageList from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of PageList if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the PageList. + * Reads an instance of PageList from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PageList if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the PageList. */ - public static PageList fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of PageList from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of PageList if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the PageList. - */ - public static PageList fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "PageList" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { + @Generated + public static PageList fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { PageList deserializedPageList = new PageList(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - if ("PageRange".equals(elementName.getLocalPart())) { - deserializedPageList.pageRange.add(PageRange.fromXml(reader, "PageRange")); - } else if ("ClearRange".equals(elementName.getLocalPart())) { - deserializedPageList.clearRange.add(ClearRange.fromXml(reader, "ClearRange")); - } else if ("NextMarker".equals(elementName.getLocalPart())) { - deserializedPageList.nextMarker = reader.getStringElement(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("pageRange".equals(fieldName)) { + List pageRange = reader.readArray(reader1 -> PageRange.fromJson(reader1)); + deserializedPageList.pageRange = pageRange; + } else if ("clearRange".equals(fieldName)) { + List clearRange = reader.readArray(reader1 -> ClearRange.fromJson(reader1)); + deserializedPageList.clearRange = clearRange; + } else if ("nextMarker".equals(fieldName)) { + deserializedPageList.nextMarker = reader.getString(); } else { - reader.skipElement(); + reader.skipChildren(); } } + return deserializedPageList; }); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageRange.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageRange.java index 06678ff05c6a..8bbe9d3e79c1 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageRange.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageRange.java @@ -1,132 +1,105 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** - * The PageRange model. + * The page range. */ -@Fluent -public final class PageRange implements XmlSerializable { +@Immutable +public final class PageRange implements JsonSerializable { /* - * The Start property. + * The start of the byte range. */ - private long start; + @Generated + private final long start; /* - * The End property. + * The end of the byte range. */ - private long end; + @Generated + private final long end; /** * Creates an instance of PageRange class. + * + * @param start the start value to set. + * @param end the end value to set. */ - public PageRange() { + @Generated + private PageRange(long start, long end) { + this.start = start; + this.end = end; } /** - * Get the start property: The Start property. + * Get the start property: The start of the byte range. * * @return the start value. */ + @Generated public long getStart() { return this.start; } /** - * Set the start property: The Start property. - * - * @param start the start value to set. - * @return the PageRange object itself. - */ - public PageRange setStart(long start) { - this.start = start; - return this; - } - - /** - * Get the end property: The End property. + * Get the end property: The end of the byte range. * * @return the end value. */ + @Generated public long getEnd() { return this.end; } /** - * Set the end property: The End property. - * - * @param end the end value to set. - * @return the PageRange object itself. + * {@inheritDoc} */ - public PageRange setEnd(long end) { - this.end = end; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - + @Generated @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "PageRange" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeLongElement("Start", this.start); - xmlWriter.writeLongElement("End", this.end); - return xmlWriter.writeEndElement(); + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeLongField("start", this.start); + jsonWriter.writeLongField("end", this.end); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of PageRange from the XmlReader. + * Reads an instance of PageRange from the JsonReader. * - * @param xmlReader The XmlReader being read. - * @return An instance of PageRange if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the PageRange. + * @param jsonReader The JsonReader being read. + * @return An instance of PageRange if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PageRange. */ - public static PageRange fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of PageRange from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of PageRange if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the PageRange. - */ - public static PageRange fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "PageRange" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - PageRange deserializedPageRange = new PageRange(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); + @Generated + public static PageRange fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + long start = 0L; + long end = 0L; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); - if ("Start".equals(elementName.getLocalPart())) { - deserializedPageRange.start = reader.getLongElement(); - } else if ("End".equals(elementName.getLocalPart())) { - deserializedPageRange.end = reader.getLongElement(); + if ("start".equals(fieldName)) { + start = reader.getLong(); + } else if ("end".equals(fieldName)) { + end = reader.getLong(); } else { - reader.skipElement(); + reader.skipChildren(); } } - - return deserializedPageRange; + return new PageRange(start, end); }); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageRangeItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageRangeItem.java deleted file mode 100644 index c91823cf857b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PageRangeItem.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; -import com.azure.core.http.HttpRange; -import com.azure.storage.blob.specialized.PageBlobClient; - -/** - * Represents a page range on a page blob returned by {@link PageBlobClient#listPageRanges(BlobRange)}. - */ -@Immutable -public final class PageRangeItem { - private final HttpRange range; - private final boolean isClear; - - /** - * Creates a new {@code PageRangeItem}. - * - * @param range The {@link HttpRange}. - * @param isClear Whether the bytes are cleared. - */ - public PageRangeItem(HttpRange range, boolean isClear) { - this.range = range; - this.isClear = isClear; - } - - /** - * Gets the range property. - * - * @return The range property. - */ - public HttpRange getRange() { - return range; - } - - /** - * Gets whether the range is cleared. - * - * @return Whether the range is cleared. - */ - public boolean isClear() { - return this.isClear; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParallelTransferOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParallelTransferOptions.java deleted file mode 100644 index 77f7841c945d..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParallelTransferOptions.java +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.ProgressListener; -import com.azure.storage.blob.ProgressReceiver; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.common.implementation.StorageImplUtils; - -/** - * This class contains configuration used to parallelize data transfer operations. Note that not all values are used - * by every method which accepts this type. Please refer to the javadoc on specific methods for these cases. - */ -@Fluent -public final class ParallelTransferOptions { - - private Long blockSize; - private Integer maxConcurrency; - private ProgressReceiver progressReceiver; - private Long maxSingleUploadSize; - - /** - * Creates a new {@link ParallelTransferOptions}. - */ - public ParallelTransferOptions() { - } - - /** - * Creates a new {@link ParallelTransferOptions} with default parameters applied. - * - * @param blockSize The block size. - * For upload, The block size is the size of each block that will be staged. This value also determines the number - * of requests that need to be made. If block size is large, upload will make fewer network calls, but each - * individual call will send more data and will therefore take longer. This parameter also determines the size - * that each buffer uses when buffering is required and consequently amount of memory consumed by such methods may - * be up to blockSize * numBuffers. - * @param maxConcurrency For buffered upload only, the number of buffers is the maximum number of buffers this - * method should allocate. Memory will be allocated lazily as needed. Must be at least two. Typically, the larger - * the number of buffers, the more parallel, and thus faster, the upload portion of this operation will be. - * The amount of memory consumed by methods using this value may be up to blockSize * numBuffers. - * @param progressReceiver {@link ProgressReceiver} - * @deprecated Use fluent interface to set properties instead. - */ - @Deprecated - public ParallelTransferOptions(Integer blockSize, Integer maxConcurrency, ProgressReceiver progressReceiver) { - this(blockSize, maxConcurrency, progressReceiver, null); - } - - /** - * Creates a new {@link ParallelTransferOptions} with default parameters applied. - * - * @param blockSize The block size. - * For upload, The block size is the size of each block that will be staged. This value also determines the number - * of requests that need to be made. If block size is large, upload will make fewer network calls, but each - * individual call will send more data and will therefore take longer. This parameter also determines the size - * that each buffer uses when buffering is required and consequently amount of memory consumed by such methods may - * be up to blockSize * maxConcurrency. - * @param maxConcurrency The maximum number of parallel requests that will be issued at any given time as a part of - * a single parallel transfer. This value applies per api. For example, if two calls to uploadFromFile are made at - * the same time, and each specifies a maxConcurrency of 5, there may be up to 10 outstanding, concurrent requests, - * up to 5 for each of the upload operations. For buffered uploads only, the maximum number of buffers to be - * allocated as part of the transfer will be {@code maxConcurrency + 1}. In those cases, memory will be allocated - * lazily as needed. The amount of memory consumed by methods which buffer may be up to blockSize * maxConcurrency. - * In general, upload methods which do not accept a length parameter must perform some buffering. - * @param progressReceiver {@link ProgressReceiver} - * @param maxSingleUploadSize If the size of the data is less than or equal to this value, it will be uploaded in a - * single put rather than broken up into chunks. If the data is uploaded in a single shot, the block size will be - * ignored. Some constraints to consider are that more requests cost more, but several small or mid-sized requests - * may sometimes perform better. In the case of buffered upload, up to this amount of data may be buffered before - * any data is sent. Must be greater than 0. May be null to accept default behavior, which is the maximum value the - * service accepts for uploading in a single requests and is represented by - * {@link BlockBlobAsyncClient#MAX_UPLOAD_BLOB_BYTES}. - * @deprecated Use fluent interface to set properties instead. - */ - @Deprecated - public ParallelTransferOptions(Integer blockSize, Integer maxConcurrency, ProgressReceiver progressReceiver, - Integer maxSingleUploadSize) { - this.setBlockSizeLong(blockSize == null ? null : Long.valueOf(blockSize)); - this.setMaxConcurrency(maxConcurrency); - this.setProgressReceiver(progressReceiver); - this.setMaxSingleUploadSizeLong(maxSingleUploadSize == null ? null : Long.valueOf(maxSingleUploadSize)); - } - - /** - * Gets the block size (chunk size) to transfer at a time. - * @return The block size. - * @deprecated Use {@link #getBlockSizeLong()}. - */ - @Deprecated - public Integer getBlockSize() { - return this.blockSize == null ? null : Math.toIntExact(this.blockSize); - } - - /** - * Gets the block size (chunk size) to transfer at a time. - * @return The block size. - */ - public Long getBlockSizeLong() { - return this.blockSize; - } - - /** - * Sets the block size (chunk size) to transfer at a time. - * For upload, The block size is the size of each block that will be staged. This value also determines the number - * of requests that need to be made. If block size is large, upload will make fewer network calls, but each - * individual call will send more data and will therefore take longer. This parameter also determines the size - * that each buffer uses when buffering is required and consequently amount of memory consumed by such methods may - * be up to blockSize * numBuffers. - * - * @param blockSize The block size. - * @return The ParallelTransferOptions object itself. - */ - public ParallelTransferOptions setBlockSizeLong(Long blockSize) { - if (blockSize != null) { - StorageImplUtils.assertInBounds("blockSize", blockSize, 1, BlockBlobAsyncClient.MAX_STAGE_BLOCK_BYTES_LONG); - } - this.blockSize = blockSize; - return this; - } - - /** - * Gets the number of buffers being used for a transfer operation. - * @return The number of buffers. - * @deprecated Use {@link #getMaxConcurrency()} - */ - @Deprecated - public Integer getNumBuffers() { - return this.maxConcurrency; - } - - /** - * Gets the Progress receiver for parallel reporting - * @return The progress reporter - * @deprecated Use {@link #getProgressListener()} - */ - @Deprecated - public ProgressReceiver getProgressReceiver() { - return this.progressReceiver; - } - - /** - * Sets the {@link ProgressReceiver}. - * - * @param progressReceiver The {@link ProgressReceiver}. - * @return The ParallelTransferOptions object itself. - * @deprecated Use {@link #setProgressListener(ProgressListener)} - */ - @Deprecated - public ParallelTransferOptions setProgressReceiver(ProgressReceiver progressReceiver) { - this.progressReceiver = progressReceiver; - return this; - } - - /** - * Sets the {@link ProgressReceiver}. - * - * @param progressListener The {@link ProgressListener}. - * @return The ParallelTransferOptions object itself. - */ - public ParallelTransferOptions setProgressListener(ProgressListener progressListener) { - this.progressReceiver = progressListener == null ? null : progressListener::handleProgress; - return this; - } - - /** - * Gets the Progress listener for parallel reporting - * @return The progress listener - */ - public ProgressListener getProgressListener() { - return this.progressReceiver; - } - - /** - * Gets the value above which the upload will be broken into blocks and parallelized. - * @return The threshold value. - * @deprecated Use {@link #getMaxSingleUploadSizeLong()}. - */ - @Deprecated - public Integer getMaxSingleUploadSize() { - return this.maxSingleUploadSize == null ? null : Math.toIntExact(this.maxSingleUploadSize); - } - - /** - * Gets the value above which the upload will be broken into blocks and parallelized. - * @return The threshold value. - */ - public Long getMaxSingleUploadSizeLong() { - return this.maxSingleUploadSize; - } - - /** - * If the size of the data is less than or equal to this value, it will be uploaded in a - * single put rather than broken up into chunks. If the data is uploaded in a single shot, the block size will be - * ignored. Some constraints to consider are that more requests cost more, but several small or mid-sized requests - * may sometimes perform better. In the case of buffered upload, up to this amount of data may be buffered before - * any data is sent. Must be greater than 0. May be null to accept default behavior, which is the maximum value the - * service accepts for uploading in a single requests and is represented by - * {@link BlockBlobAsyncClient#MAX_UPLOAD_BLOB_BYTES_LONG}. - * - * @param maxSingleUploadSize The threshold value. - * @return The ParallelTransferOptions object itself. - */ - public ParallelTransferOptions setMaxSingleUploadSizeLong(Long maxSingleUploadSize) { - if (maxSingleUploadSize != null) { - StorageImplUtils.assertInBounds("maxSingleUploadSize", maxSingleUploadSize, 1, - BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES_LONG); - } - this.maxSingleUploadSize = maxSingleUploadSize; - return this; - } - - /** - * The maximum number of parallel requests that will be issued at any given time as a part of - * a single parallel transfer. This value applies per api. For example, if two calls to uploadFromFile are made at - * the same time, and each specifies a maxConcurrency of 5, there may be up to 10 outstanding, concurrent requests, - * up to 5 for each of the upload operations. For buffered uploads only, the maximum number of buffers to be - * allocated as part of the transfer will be {@code maxConcurrency + 1}. In those cases, memory will be allocated - * lazily as needed. The amount of memory consumed by methods which buffer may be up to blockSize * maxConcurrency. - * In general, upload methods which do not accept a length parameter must perform some buffering. - * @return The max concurrency value. - */ - public Integer getMaxConcurrency() { - return this.maxConcurrency; - } - - /** - * Sets the maximum number of parallel requests that will be issued at any given time as a part of - * a single parallel transfer. This value applies per api. For example, if two calls to uploadFromFile are made at - * the same time, and each specifies a maxConcurrency of 5, there may be up to 10 outstanding, concurrent requests, - * up to 5 for each of the upload operations. For buffered uploads only, the maximum number of buffers to be - * allocated as part of the transfer will be {@code maxConcurrency + 1}. In those cases, memory will be allocated - * lazily as needed. The amount of memory consumed by methods which buffer may be up to blockSize * maxConcurrency. - * In general, upload methods which do not accept a length parameter must perform some buffering. - * - * @param maxConcurrency The maximum number of parallel requests that will be issued at any given time as a part of - * a single parallel transfer. This value applies per api. For example, if two calls to uploadFromFile are made at - * the same time, and each specifies a maxConcurrency of 5, there may be up to 10 outstanding, concurrent requests, - * up to 5 for each of the upload operations. For buffered uploads only, the maximum number of buffers to be - * allocated as part of the transfer will be {@code maxConcurrency + 1}. In those cases, memory will be allocated - * lazily as needed. The amount of memory consumed by methods which buffer may be up to blockSize * maxConcurrency. - * In general, upload methods which do not accept a length parameter must perform some buffering. - * @return The ParallelTransferOptions object itself. - */ - public ParallelTransferOptions setMaxConcurrency(Integer maxConcurrency) { - if (maxConcurrency != null) { - StorageImplUtils.assertInBounds("numBuffers", maxConcurrency, 1, Integer.MAX_VALUE); - } - this.maxConcurrency = maxConcurrency; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParquetConfiguration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParquetConfiguration.java new file mode 100644 index 000000000000..3065f51a6cc4 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParquetConfiguration.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Represents the Parquet configuration. + */ +@Fluent +public final class ParquetConfiguration implements JsonSerializable { + /* + * Represents the Parquet configuration. + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of ParquetConfiguration class. + */ + @Generated + public ParquetConfiguration() { + } + + /** + * Get the additionalProperties property: Represents the Parquet configuration. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Represents the Parquet configuration. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ParquetConfiguration object itself. + */ + @Generated + public ParquetConfiguration setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ParquetConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ParquetConfiguration if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the ParquetConfiguration. + */ + @Generated + public static ParquetConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ParquetConfiguration deserializedParquetConfiguration = new ParquetConfiguration(); + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + deserializedParquetConfiguration.additionalProperties = additionalProperties; + + return deserializedParquetConfiguration; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PathRenameMode.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PathRenameMode.java deleted file mode 100644 index 864ec9e3a73c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PathRenameMode.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -/** Defines values for PathRenameMode. */ -public enum PathRenameMode { - /** Enum value legacy. */ - LEGACY("legacy"), - - /** Enum value posix. */ - POSIX("posix"); - - /** The actual serialized value for a PathRenameMode instance. */ - private final String value; - - PathRenameMode(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a PathRenameMode instance. - * - * @param value the serialized value to parse. - * @return the parsed PathRenameMode object, or null if unable to parse. - */ - public static PathRenameMode fromString(String value) { - PathRenameMode[] items = PathRenameMode.values(); - for (PathRenameMode item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PremiumPageBlobAccessTier.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PremiumPageBlobAccessTier.java similarity index 69% rename from sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PremiumPageBlobAccessTier.java rename to sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PremiumPageBlobAccessTier.java index 95d832fa9faf..ebacfffaa4de 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/PremiumPageBlobAccessTier.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PremiumPageBlobAccessTier.java @@ -1,69 +1,81 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.storage.blob.implementation.models; +package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; /** - * Defines values for PremiumPageBlobAccessTier. + * The premium page blob access tier types. */ public final class PremiumPageBlobAccessTier extends ExpandableStringEnum { /** - * Static value P4 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P4. */ + @Generated public static final PremiumPageBlobAccessTier P4 = fromString("P4"); /** - * Static value P6 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P6. */ + @Generated public static final PremiumPageBlobAccessTier P6 = fromString("P6"); /** - * Static value P10 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P10. */ + @Generated public static final PremiumPageBlobAccessTier P10 = fromString("P10"); /** - * Static value P15 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P15. */ + @Generated public static final PremiumPageBlobAccessTier P15 = fromString("P15"); /** - * Static value P20 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P20. */ + @Generated public static final PremiumPageBlobAccessTier P20 = fromString("P20"); /** - * Static value P30 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P30. */ + @Generated public static final PremiumPageBlobAccessTier P30 = fromString("P30"); /** - * Static value P40 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P40. */ + @Generated public static final PremiumPageBlobAccessTier P40 = fromString("P40"); /** - * Static value P50 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P50. */ + @Generated public static final PremiumPageBlobAccessTier P50 = fromString("P50"); /** - * Static value P60 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P60. */ + @Generated public static final PremiumPageBlobAccessTier P60 = fromString("P60"); /** - * Static value P70 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P70. */ + @Generated public static final PremiumPageBlobAccessTier P70 = fromString("P70"); /** - * Static value P80 for PremiumPageBlobAccessTier. + * The premium page blob access tier is P80. */ + @Generated public static final PremiumPageBlobAccessTier P80 = fromString("P80"); /** @@ -71,6 +83,7 @@ public final class PremiumPageBlobAccessTier extends ExpandableStringEnum values() { return values(PremiumPageBlobAccessTier.class); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PublicAccessType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PublicAccessType.java index af78698cce78..2e0c81ebe013 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PublicAccessType.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/PublicAccessType.java @@ -1,31 +1,35 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; /** - * Defines values for PublicAccessType. + * The public access types. */ public final class PublicAccessType extends ExpandableStringEnum { /** - * Static value container for PublicAccessType. + * Blob access. */ - public static final PublicAccessType CONTAINER = fromString("container"); + @Generated + public static final PublicAccessType BLOB = fromString("blob"); /** - * Static value blob for PublicAccessType. + * Container access. */ - public static final PublicAccessType BLOB = fromString("blob"); + @Generated + public static final PublicAccessType CONTAINER = fromString("container"); /** * Creates a new instance of PublicAccessType value. * * @deprecated Use the {@link #fromString(String)} factory method. */ + @Generated @Deprecated public PublicAccessType() { } @@ -36,6 +40,7 @@ public PublicAccessType() { * @param name a name to look for. * @return the corresponding PublicAccessType. */ + @Generated public static PublicAccessType fromString(String name) { return fromString(name, PublicAccessType.class); } @@ -45,6 +50,7 @@ public static PublicAccessType fromString(String name) { * * @return known PublicAccessType values. */ + @Generated public static Collection values() { return values(PublicAccessType.class); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryFormat.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryFormat.java new file mode 100644 index 000000000000..5eb1dae1c946 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryFormat.java @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The query format settings. + */ +@Fluent +public final class QueryFormat implements JsonSerializable { + /* + * The query type. + */ + @Generated + private final QueryType type; + + /* + * The delimited text configuration. + */ + @Generated + private DelimitedTextConfiguration delimitedTextConfiguration; + + /* + * The JSON text configuration. + */ + @Generated + private JsonTextConfiguration jsonTextConfiguration; + + /* + * The Apache Arrow configuration. + */ + @Generated + private ArrowConfiguration arrowConfiguration; + + /* + * The Parquet configuration. + */ + @Generated + private ParquetConfiguration parquetTextConfiguration; + + /** + * Creates an instance of QueryFormat class. + * + * @param type the type value to set. + */ + @Generated + public QueryFormat(QueryType type) { + this.type = type; + } + + /** + * Get the type property: The query type. + * + * @return the type value. + */ + @Generated + public QueryType getType() { + return this.type; + } + + /** + * Get the delimitedTextConfiguration property: The delimited text configuration. + * + * @return the delimitedTextConfiguration value. + */ + @Generated + public DelimitedTextConfiguration getDelimitedTextConfiguration() { + return this.delimitedTextConfiguration; + } + + /** + * Set the delimitedTextConfiguration property: The delimited text configuration. + * + * @param delimitedTextConfiguration the delimitedTextConfiguration value to set. + * @return the QueryFormat object itself. + */ + @Generated + public QueryFormat setDelimitedTextConfiguration(DelimitedTextConfiguration delimitedTextConfiguration) { + this.delimitedTextConfiguration = delimitedTextConfiguration; + return this; + } + + /** + * Get the jsonTextConfiguration property: The JSON text configuration. + * + * @return the jsonTextConfiguration value. + */ + @Generated + public JsonTextConfiguration getJsonTextConfiguration() { + return this.jsonTextConfiguration; + } + + /** + * Set the jsonTextConfiguration property: The JSON text configuration. + * + * @param jsonTextConfiguration the jsonTextConfiguration value to set. + * @return the QueryFormat object itself. + */ + @Generated + public QueryFormat setJsonTextConfiguration(JsonTextConfiguration jsonTextConfiguration) { + this.jsonTextConfiguration = jsonTextConfiguration; + return this; + } + + /** + * Get the arrowConfiguration property: The Apache Arrow configuration. + * + * @return the arrowConfiguration value. + */ + @Generated + public ArrowConfiguration getArrowConfiguration() { + return this.arrowConfiguration; + } + + /** + * Set the arrowConfiguration property: The Apache Arrow configuration. + * + * @param arrowConfiguration the arrowConfiguration value to set. + * @return the QueryFormat object itself. + */ + @Generated + public QueryFormat setArrowConfiguration(ArrowConfiguration arrowConfiguration) { + this.arrowConfiguration = arrowConfiguration; + return this; + } + + /** + * Get the parquetTextConfiguration property: The Parquet configuration. + * + * @return the parquetTextConfiguration value. + */ + @Generated + public ParquetConfiguration getParquetTextConfiguration() { + return this.parquetTextConfiguration; + } + + /** + * Set the parquetTextConfiguration property: The Parquet configuration. + * + * @param parquetTextConfiguration the parquetTextConfiguration value to set. + * @return the QueryFormat object itself. + */ + @Generated + public QueryFormat setParquetTextConfiguration(ParquetConfiguration parquetTextConfiguration) { + this.parquetTextConfiguration = parquetTextConfiguration; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeJsonField("delimitedTextConfiguration", this.delimitedTextConfiguration); + jsonWriter.writeJsonField("jsonTextConfiguration", this.jsonTextConfiguration); + jsonWriter.writeJsonField("arrowConfiguration", this.arrowConfiguration); + jsonWriter.writeJsonField("parquetTextConfiguration", this.parquetTextConfiguration); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of QueryFormat from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of QueryFormat if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the QueryFormat. + */ + @Generated + public static QueryFormat fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + QueryType type = null; + DelimitedTextConfiguration delimitedTextConfiguration = null; + JsonTextConfiguration jsonTextConfiguration = null; + ArrowConfiguration arrowConfiguration = null; + ParquetConfiguration parquetTextConfiguration = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + type = QueryType.fromString(reader.getString()); + } else if ("delimitedTextConfiguration".equals(fieldName)) { + delimitedTextConfiguration = DelimitedTextConfiguration.fromJson(reader); + } else if ("jsonTextConfiguration".equals(fieldName)) { + jsonTextConfiguration = JsonTextConfiguration.fromJson(reader); + } else if ("arrowConfiguration".equals(fieldName)) { + arrowConfiguration = ArrowConfiguration.fromJson(reader); + } else if ("parquetTextConfiguration".equals(fieldName)) { + parquetTextConfiguration = ParquetConfiguration.fromJson(reader); + } else { + reader.skipChildren(); + } + } + QueryFormat deserializedQueryFormat = new QueryFormat(type); + deserializedQueryFormat.delimitedTextConfiguration = delimitedTextConfiguration; + deserializedQueryFormat.jsonTextConfiguration = jsonTextConfiguration; + deserializedQueryFormat.arrowConfiguration = arrowConfiguration; + deserializedQueryFormat.parquetTextConfiguration = parquetTextConfiguration; + + return deserializedQueryFormat; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryRequest.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryRequest.java new file mode 100644 index 000000000000..03c110950e0f --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryRequest.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Groups the set of query request settings. + */ +@Fluent +public final class QueryRequest implements JsonSerializable { + /* + * Required. The type of the provided query expression. + */ + @Generated + private final QueryRequestType queryType; + + /* + * The query expression in SQL. The maximum size of the query expression is 256KiB. + */ + @Generated + private final String expression; + + /* + * The input serialization settings. + */ + @Generated + private QuerySerialization inputSerialization; + + /* + * The output serialization settings. + */ + @Generated + private QuerySerialization outputSerialization; + + /** + * Creates an instance of QueryRequest class. + * + * @param queryType the queryType value to set. + * @param expression the expression value to set. + */ + @Generated + public QueryRequest(QueryRequestType queryType, String expression) { + this.queryType = queryType; + this.expression = expression; + } + + /** + * Get the queryType property: Required. The type of the provided query expression. + * + * @return the queryType value. + */ + @Generated + public QueryRequestType getQueryType() { + return this.queryType; + } + + /** + * Get the expression property: The query expression in SQL. The maximum size of the query expression is 256KiB. + * + * @return the expression value. + */ + @Generated + public String getExpression() { + return this.expression; + } + + /** + * Get the inputSerialization property: The input serialization settings. + * + * @return the inputSerialization value. + */ + @Generated + public QuerySerialization getInputSerialization() { + return this.inputSerialization; + } + + /** + * Set the inputSerialization property: The input serialization settings. + * + * @param inputSerialization the inputSerialization value to set. + * @return the QueryRequest object itself. + */ + @Generated + public QueryRequest setInputSerialization(QuerySerialization inputSerialization) { + this.inputSerialization = inputSerialization; + return this; + } + + /** + * Get the outputSerialization property: The output serialization settings. + * + * @return the outputSerialization value. + */ + @Generated + public QuerySerialization getOutputSerialization() { + return this.outputSerialization; + } + + /** + * Set the outputSerialization property: The output serialization settings. + * + * @param outputSerialization the outputSerialization value to set. + * @return the QueryRequest object itself. + */ + @Generated + public QueryRequest setOutputSerialization(QuerySerialization outputSerialization) { + this.outputSerialization = outputSerialization; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("queryType", this.queryType == null ? null : this.queryType.toString()); + jsonWriter.writeStringField("expression", this.expression); + jsonWriter.writeJsonField("inputSerialization", this.inputSerialization); + jsonWriter.writeJsonField("outputSerialization", this.outputSerialization); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of QueryRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of QueryRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the QueryRequest. + */ + @Generated + public static QueryRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + QueryRequestType queryType = null; + String expression = null; + QuerySerialization inputSerialization = null; + QuerySerialization outputSerialization = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("queryType".equals(fieldName)) { + queryType = QueryRequestType.fromString(reader.getString()); + } else if ("expression".equals(fieldName)) { + expression = reader.getString(); + } else if ("inputSerialization".equals(fieldName)) { + inputSerialization = QuerySerialization.fromJson(reader); + } else if ("outputSerialization".equals(fieldName)) { + outputSerialization = QuerySerialization.fromJson(reader); + } else { + reader.skipChildren(); + } + } + QueryRequest deserializedQueryRequest = new QueryRequest(queryType, expression); + deserializedQueryRequest.inputSerialization = inputSerialization; + deserializedQueryRequest.outputSerialization = outputSerialization; + + return deserializedQueryRequest; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryRequestType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryRequestType.java new file mode 100644 index 000000000000..ef82400de226 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryRequestType.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The query request, note only SQL supported. + */ +public final class QueryRequestType extends ExpandableStringEnum { + /** + * The SQL request query type. + */ + @Generated + public static final QueryRequestType SQL = fromString("SQL"); + + /** + * Creates a new instance of QueryRequestType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public QueryRequestType() { + } + + /** + * Creates or finds a QueryRequestType from its string representation. + * + * @param name a name to look for. + * @return the corresponding QueryRequestType. + */ + @Generated + public static QueryRequestType fromString(String name) { + return fromString(name, QueryRequestType.class); + } + + /** + * Gets known QueryRequestType values. + * + * @return known QueryRequestType values. + */ + @Generated + public static Collection values() { + return values(QueryRequestType.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QuerySerialization.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QuerySerialization.java new file mode 100644 index 000000000000..96cd23eb2eb9 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QuerySerialization.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The query serialization settings. + */ +@Immutable +public final class QuerySerialization implements JsonSerializable { + /* + * The query format. + */ + @Generated + private final QueryFormat format; + + /** + * Creates an instance of QuerySerialization class. + * + * @param format the format value to set. + */ + @Generated + public QuerySerialization(QueryFormat format) { + this.format = format; + } + + /** + * Get the format property: The query format. + * + * @return the format value. + */ + @Generated + public QueryFormat getFormat() { + return this.format; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("format", this.format); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of QuerySerialization from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of QuerySerialization if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the QuerySerialization. + */ + @Generated + public static QuerySerialization fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + QueryFormat format = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("format".equals(fieldName)) { + format = QueryFormat.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new QuerySerialization(format); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryType.java new file mode 100644 index 000000000000..e1a955f3079b --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/QueryType.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The query format type. + */ +public final class QueryType extends ExpandableStringEnum { + /** + * The query format type is delimited. + */ + @Generated + public static final QueryType DELIMITED = fromString("delimited"); + + /** + * The query format type is JSON. + */ + @Generated + public static final QueryType JSON = fromString("json"); + + /** + * The query format type is Apache Arrow. + */ + @Generated + public static final QueryType ARROW = fromString("arrow"); + + /** + * The query format type is Parquet. + */ + @Generated + public static final QueryType PARQUET = fromString("parquet"); + + /** + * Creates a new instance of QueryType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public QueryType() { + } + + /** + * Creates or finds a QueryType from its string representation. + * + * @param name a name to look for. + * @return the corresponding QueryType. + */ + @Generated + public static QueryType fromString(String name) { + return fromString(name, QueryType.class); + } + + /** + * Gets known QueryType values. + * + * @return known QueryType values. + */ + @Generated + public static Collection values() { + return values(QueryType.class); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/RehydratePriority.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/RehydratePriority.java index 69d05855c046..1ca8f00478c8 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/RehydratePriority.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/RehydratePriority.java @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; @@ -13,13 +14,15 @@ */ public final class RehydratePriority extends ExpandableStringEnum { /** - * Static value High for RehydratePriority. + * The rehydrate priority is high. */ + @Generated public static final RehydratePriority HIGH = fromString("High"); /** - * Static value Standard for RehydratePriority. + * The rehydrate priority is standard. */ + @Generated public static final RehydratePriority STANDARD = fromString("Standard"); /** @@ -27,6 +30,7 @@ public final class RehydratePriority extends ExpandableStringEnum values() { return values(RehydratePriority.class); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/RetentionPolicy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/RetentionPolicy.java new file mode 100644 index 000000000000..835669d674e2 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/RetentionPolicy.java @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The retention policy. + */ +@Fluent +public final class RetentionPolicy implements JsonSerializable { + /* + * Whether to enable the retention policy. + */ + @Generated + private final boolean enabled; + + /* + * The number of days to retain the logs. + */ + @Generated + private Integer days; + + /* + * Whether to allow permanent delete. + */ + @Generated + private Boolean allowPermanentDelete; + + /** + * Creates an instance of RetentionPolicy class. + * + * @param enabled the enabled value to set. + */ + @Generated + public RetentionPolicy(boolean enabled) { + this.enabled = enabled; + } + + /** + * Get the enabled property: Whether to enable the retention policy. + * + * @return the enabled value. + */ + @Generated + public boolean isEnabled() { + return this.enabled; + } + + /** + * Get the days property: The number of days to retain the logs. + * + * @return the days value. + */ + @Generated + public Integer getDays() { + return this.days; + } + + /** + * Set the days property: The number of days to retain the logs. + * + * @param days the days value to set. + * @return the RetentionPolicy object itself. + */ + @Generated + public RetentionPolicy setDays(Integer days) { + this.days = days; + return this; + } + + /** + * Get the allowPermanentDelete property: Whether to allow permanent delete. + * + * @return the allowPermanentDelete value. + */ + @Generated + public Boolean isAllowPermanentDelete() { + return this.allowPermanentDelete; + } + + /** + * Set the allowPermanentDelete property: Whether to allow permanent delete. + * + * @param allowPermanentDelete the allowPermanentDelete value to set. + * @return the RetentionPolicy object itself. + */ + @Generated + public RetentionPolicy setAllowPermanentDelete(Boolean allowPermanentDelete) { + this.allowPermanentDelete = allowPermanentDelete; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeNumberField("days", this.days); + jsonWriter.writeBooleanField("allowPermanentDelete", this.allowPermanentDelete); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RetentionPolicy from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RetentionPolicy if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RetentionPolicy. + */ + @Generated + public static RetentionPolicy fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean enabled = false; + Integer days = null; + Boolean allowPermanentDelete = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("enabled".equals(fieldName)) { + enabled = reader.getBoolean(); + } else if ("days".equals(fieldName)) { + days = reader.getNullable(JsonReader::getInt); + } else if ("allowPermanentDelete".equals(fieldName)) { + allowPermanentDelete = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + RetentionPolicy deserializedRetentionPolicy = new RetentionPolicy(enabled); + deserializedRetentionPolicy.days = days; + deserializedRetentionPolicy.allowPermanentDelete = allowPermanentDelete; + + return deserializedRetentionPolicy; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SequenceNumberActionType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SequenceNumberActionType.java index b53fe1e30289..f53f70a0be68 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SequenceNumberActionType.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SequenceNumberActionType.java @@ -1,61 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + /** - * Defines values for SequenceNumberActionType. + * The sequence number actions. */ -public enum SequenceNumberActionType { +public final class SequenceNumberActionType extends ExpandableStringEnum { /** - * Enum value max. + * Increment the sequence number. */ - MAX("max"), + @Generated + public static final SequenceNumberActionType INCREMENT = fromString("increment"); /** - * Enum value update. + * Set the maximum for the sequence number. */ - UPDATE("update"), + @Generated + public static final SequenceNumberActionType MAX = fromString("max"); /** - * Enum value increment. + * Update the sequence number. */ - INCREMENT("increment"); + @Generated + public static final SequenceNumberActionType UPDATE = fromString("update"); /** - * The actual serialized value for a SequenceNumberActionType instance. + * Creates a new instance of SequenceNumberActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. */ - private final String value; - - SequenceNumberActionType(String value) { - this.value = value; + @Generated + @Deprecated + public SequenceNumberActionType() { } /** - * Parses a serialized value to a SequenceNumberActionType instance. + * Creates or finds a SequenceNumberActionType from its string representation. * - * @param value the serialized value to parse. - * @return the parsed SequenceNumberActionType object, or null if unable to parse. + * @param name a name to look for. + * @return the corresponding SequenceNumberActionType. */ - public static SequenceNumberActionType fromString(String value) { - if (value == null) { - return null; - } - SequenceNumberActionType[] items = SequenceNumberActionType.values(); - for (SequenceNumberActionType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; + @Generated + public static SequenceNumberActionType fromString(String name) { + return fromString(name, SequenceNumberActionType.class); } /** - * {@inheritDoc} + * Gets known SequenceNumberActionType values. + * + * @return known SequenceNumberActionType values. */ - @Override - public String toString() { - return this.value; + @Generated + public static Collection values() { + return values(SequenceNumberActionType.class); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SetPropertiesOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SetPropertiesOptions.java new file mode 100644 index 000000000000..96b4fa438bc6 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SetPropertiesOptions.java @@ -0,0 +1,252 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import java.util.List; + +/** + * Options for setProperties API. + */ +@Fluent +public final class SetPropertiesOptions { + /* + * The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. + */ + @Generated + private Integer timeout; + + /* + * The logging properties. + */ + @Generated + private Logging logging; + + /* + * The hour metrics properties. + */ + @Generated + private Metrics hourMetrics; + + /* + * The minute metrics properties. + */ + @Generated + private Metrics minuteMetrics; + + /* + * The CORS properties. + */ + @Generated + private List cors; + + /* + * The default service version. + */ + @Generated + private String defaultServiceVersion; + + /* + * The delete retention policy. + */ + @Generated + private RetentionPolicy deleteRetentionPolicy; + + /* + * The static website properties. + */ + @Generated + private StaticWebsite staticWebsite; + + /** + * Creates an instance of SetPropertiesOptions class. + */ + @Generated + public SetPropertiesOptions() { + } + + /** + * Get the timeout property: The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * + * @return the timeout value. + */ + @Generated + public Integer getTimeout() { + return this.timeout; + } + + /** + * Set the timeout property: The timeout parameter is expressed in seconds. For more information, see <a + * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting + * Timeouts for Blob Service Operations.</a>. + * + * @param timeout the timeout value to set. + * @return the SetPropertiesOptions object itself. + */ + @Generated + public SetPropertiesOptions setTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + + /** + * Get the logging property: The logging properties. + * + * @return the logging value. + */ + @Generated + public Logging getLogging() { + return this.logging; + } + + /** + * Set the logging property: The logging properties. + * + * @param logging the logging value to set. + * @return the SetPropertiesOptions object itself. + */ + @Generated + public SetPropertiesOptions setLogging(Logging logging) { + this.logging = logging; + return this; + } + + /** + * Get the hourMetrics property: The hour metrics properties. + * + * @return the hourMetrics value. + */ + @Generated + public Metrics getHourMetrics() { + return this.hourMetrics; + } + + /** + * Set the hourMetrics property: The hour metrics properties. + * + * @param hourMetrics the hourMetrics value to set. + * @return the SetPropertiesOptions object itself. + */ + @Generated + public SetPropertiesOptions setHourMetrics(Metrics hourMetrics) { + this.hourMetrics = hourMetrics; + return this; + } + + /** + * Get the minuteMetrics property: The minute metrics properties. + * + * @return the minuteMetrics value. + */ + @Generated + public Metrics getMinuteMetrics() { + return this.minuteMetrics; + } + + /** + * Set the minuteMetrics property: The minute metrics properties. + * + * @param minuteMetrics the minuteMetrics value to set. + * @return the SetPropertiesOptions object itself. + */ + @Generated + public SetPropertiesOptions setMinuteMetrics(Metrics minuteMetrics) { + this.minuteMetrics = minuteMetrics; + return this; + } + + /** + * Get the cors property: The CORS properties. + * + * @return the cors value. + */ + @Generated + public List getCors() { + return this.cors; + } + + /** + * Set the cors property: The CORS properties. + * + * @param cors the cors value to set. + * @return the SetPropertiesOptions object itself. + */ + @Generated + public SetPropertiesOptions setCors(List cors) { + this.cors = cors; + return this; + } + + /** + * Get the defaultServiceVersion property: The default service version. + * + * @return the defaultServiceVersion value. + */ + @Generated + public String getDefaultServiceVersion() { + return this.defaultServiceVersion; + } + + /** + * Set the defaultServiceVersion property: The default service version. + * + * @param defaultServiceVersion the defaultServiceVersion value to set. + * @return the SetPropertiesOptions object itself. + */ + @Generated + public SetPropertiesOptions setDefaultServiceVersion(String defaultServiceVersion) { + this.defaultServiceVersion = defaultServiceVersion; + return this; + } + + /** + * Get the deleteRetentionPolicy property: The delete retention policy. + * + * @return the deleteRetentionPolicy value. + */ + @Generated + public RetentionPolicy getDeleteRetentionPolicy() { + return this.deleteRetentionPolicy; + } + + /** + * Set the deleteRetentionPolicy property: The delete retention policy. + * + * @param deleteRetentionPolicy the deleteRetentionPolicy value to set. + * @return the SetPropertiesOptions object itself. + */ + @Generated + public SetPropertiesOptions setDeleteRetentionPolicy(RetentionPolicy deleteRetentionPolicy) { + this.deleteRetentionPolicy = deleteRetentionPolicy; + return this; + } + + /** + * Get the staticWebsite property: The static website properties. + * + * @return the staticWebsite value. + */ + @Generated + public StaticWebsite getStaticWebsite() { + return this.staticWebsite; + } + + /** + * Set the staticWebsite property: The static website properties. + * + * @param staticWebsite the staticWebsite value to set. + * @return the SetPropertiesOptions object itself. + */ + @Generated + public SetPropertiesOptions setStaticWebsite(StaticWebsite staticWebsite) { + this.staticWebsite = staticWebsite; + return this; + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SignedIdentifier.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SignedIdentifier.java new file mode 100644 index 000000000000..e595581cf1f1 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SignedIdentifier.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The signed identifier. + */ +@Immutable +public final class SignedIdentifier implements JsonSerializable { + /* + * The unique ID for the signed identifier. + */ + @Generated + private final String id; + + /* + * The access policy for the signed identifier. + */ + @Generated + private final AccessPolicy accessPolicy; + + /** + * Creates an instance of SignedIdentifier class. + * + * @param id the id value to set. + * @param accessPolicy the accessPolicy value to set. + */ + @Generated + public SignedIdentifier(String id, AccessPolicy accessPolicy) { + this.id = id; + this.accessPolicy = accessPolicy; + } + + /** + * Get the id property: The unique ID for the signed identifier. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the accessPolicy property: The access policy for the signed identifier. + * + * @return the accessPolicy value. + */ + @Generated + public AccessPolicy getAccessPolicy() { + return this.accessPolicy; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeJsonField("accessPolicy", this.accessPolicy); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SignedIdentifier from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SignedIdentifier if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SignedIdentifier. + */ + @Generated + public static SignedIdentifier fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + AccessPolicy accessPolicy = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("accessPolicy".equals(fieldName)) { + accessPolicy = AccessPolicy.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new SignedIdentifier(id, accessPolicy); + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SkuName.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SkuName.java deleted file mode 100644 index bab2c5e601f7..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SkuName.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -/** - * Defines values for SkuName. - */ -public enum SkuName { - /** - * Enum value Standard_LRS. - */ - STANDARD_LRS("Standard_LRS"), - - /** - * Enum value Standard_GRS. - */ - STANDARD_GRS("Standard_GRS"), - - /** - * Enum value Standard_RAGRS. - */ - STANDARD_RAGRS("Standard_RAGRS"), - - /** - * Enum value Standard_ZRS. - */ - STANDARD_ZRS("Standard_ZRS"), - - /** - * Enum value Premium_LRS. - */ - PREMIUM_LRS("Premium_LRS"); - - /** - * The actual serialized value for a SkuName instance. - */ - private final String value; - - SkuName(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a SkuName instance. - * - * @param value the serialized value to parse. - * @return the parsed SkuName object, or null if unable to parse. - */ - public static SkuName fromString(String value) { - if (value == null) { - return null; - } - SkuName[] items = SkuName.values(); - for (SkuName item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StaticWebsite.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StaticWebsite.java index 106b5f99b154..714366d91c98 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StaticWebsite.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StaticWebsite.java @@ -1,47 +1,54 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * The properties that enable an account to host a static website. */ @Fluent -public final class StaticWebsite implements XmlSerializable { +public final class StaticWebsite implements JsonSerializable { /* * Indicates whether this account is hosting a static website */ - private boolean enabled; + @Generated + private final boolean enabled; /* - * The default name of the index page under each directory + * The index document. */ + @Generated private String indexDocument; /* - * The absolute path of the custom 404 page + * The error document. */ + @Generated private String errorDocument404Path; /* * Absolute path of the default index page */ + @Generated private String defaultIndexDocumentPath; /** * Creates an instance of StaticWebsite class. + * + * @param enabled the enabled value to set. */ - public StaticWebsite() { + @Generated + public StaticWebsite(boolean enabled) { + this.enabled = enabled; } /** @@ -49,56 +56,50 @@ public StaticWebsite() { * * @return the enabled value. */ + @Generated public boolean isEnabled() { return this.enabled; } /** - * Set the enabled property: Indicates whether this account is hosting a static website. - * - * @param enabled the enabled value to set. - * @return the StaticWebsite object itself. - */ - public StaticWebsite setEnabled(boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Get the indexDocument property: The default name of the index page under each directory. + * Get the indexDocument property: The index document. * * @return the indexDocument value. */ + @Generated public String getIndexDocument() { return this.indexDocument; } /** - * Set the indexDocument property: The default name of the index page under each directory. + * Set the indexDocument property: The index document. * * @param indexDocument the indexDocument value to set. * @return the StaticWebsite object itself. */ + @Generated public StaticWebsite setIndexDocument(String indexDocument) { this.indexDocument = indexDocument; return this; } /** - * Get the errorDocument404Path property: The absolute path of the custom 404 page. + * Get the errorDocument404Path property: The error document. * * @return the errorDocument404Path value. */ + @Generated public String getErrorDocument404Path() { return this.errorDocument404Path; } /** - * Set the errorDocument404Path property: The absolute path of the custom 404 page. + * Set the errorDocument404Path property: The error document. * * @param errorDocument404Path the errorDocument404Path value to set. * @return the StaticWebsite object itself. */ + @Generated public StaticWebsite setErrorDocument404Path(String errorDocument404Path) { this.errorDocument404Path = errorDocument404Path; return this; @@ -109,6 +110,7 @@ public StaticWebsite setErrorDocument404Path(String errorDocument404Path) { * * @return the defaultIndexDocumentPath value. */ + @Generated public String getDefaultIndexDocumentPath() { return this.defaultIndexDocumentPath; } @@ -119,68 +121,62 @@ public String getDefaultIndexDocumentPath() { * @param defaultIndexDocumentPath the defaultIndexDocumentPath value to set. * @return the StaticWebsite object itself. */ + @Generated public StaticWebsite setDefaultIndexDocumentPath(String defaultIndexDocumentPath) { this.defaultIndexDocumentPath = defaultIndexDocumentPath; return this; } - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "StaticWebsite" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeBooleanElement("Enabled", this.enabled); - xmlWriter.writeStringElement("IndexDocument", this.indexDocument); - xmlWriter.writeStringElement("ErrorDocument404Path", this.errorDocument404Path); - xmlWriter.writeStringElement("DefaultIndexDocumentPath", this.defaultIndexDocumentPath); - return xmlWriter.writeEndElement(); - } - /** - * Reads an instance of StaticWebsite from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of StaticWebsite if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the StaticWebsite. + * {@inheritDoc} */ - public static StaticWebsite fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeStringField("indexDocument", this.indexDocument); + jsonWriter.writeStringField("errorDocument404Path", this.errorDocument404Path); + jsonWriter.writeStringField("defaultIndexDocumentPath", this.defaultIndexDocumentPath); + return jsonWriter.writeEndObject(); } /** - * Reads an instance of StaticWebsite from the XmlReader. + * Reads an instance of StaticWebsite from the JsonReader. * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of StaticWebsite if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the StaticWebsite. + * @param jsonReader The JsonReader being read. + * @return An instance of StaticWebsite if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the StaticWebsite. */ - public static StaticWebsite fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "StaticWebsite" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - StaticWebsite deserializedStaticWebsite = new StaticWebsite(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Enabled".equals(elementName.getLocalPart())) { - deserializedStaticWebsite.enabled = reader.getBooleanElement(); - } else if ("IndexDocument".equals(elementName.getLocalPart())) { - deserializedStaticWebsite.indexDocument = reader.getStringElement(); - } else if ("ErrorDocument404Path".equals(elementName.getLocalPart())) { - deserializedStaticWebsite.errorDocument404Path = reader.getStringElement(); - } else if ("DefaultIndexDocumentPath".equals(elementName.getLocalPart())) { - deserializedStaticWebsite.defaultIndexDocumentPath = reader.getStringElement(); + @Generated + public static StaticWebsite fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean enabled = false; + String indexDocument = null; + String errorDocument404Path = null; + String defaultIndexDocumentPath = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("enabled".equals(fieldName)) { + enabled = reader.getBoolean(); + } else if ("indexDocument".equals(fieldName)) { + indexDocument = reader.getString(); + } else if ("errorDocument404Path".equals(fieldName)) { + errorDocument404Path = reader.getString(); + } else if ("defaultIndexDocumentPath".equals(fieldName)) { + defaultIndexDocumentPath = reader.getString(); } else { - reader.skipElement(); + reader.skipChildren(); } } + StaticWebsite deserializedStaticWebsite = new StaticWebsite(enabled); + deserializedStaticWebsite.indexDocument = indexDocument; + deserializedStaticWebsite.errorDocument404Path = errorDocument404Path; + deserializedStaticWebsite.defaultIndexDocumentPath = defaultIndexDocumentPath; return deserializedStaticWebsite; }); diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageAccountInfo.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageAccountInfo.java deleted file mode 100644 index 0cd3723a0cb6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageAccountInfo.java +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.models; - -import com.azure.core.annotation.Immutable; - -/** - * This class contains information about the storage account. - */ -@Immutable -public class StorageAccountInfo { - private final SkuName skuName; - private final AccountKind accountKind; - private final boolean isHnsEnabled; - - /** - * Constructs a {@link StorageAccountInfo}. - * - * @param skuName SKU of the account. - * @param accountKind Type of the account. - */ - public StorageAccountInfo(final SkuName skuName, final AccountKind accountKind) { - this.skuName = skuName; - this.accountKind = accountKind; - this.isHnsEnabled = false; - } - - /** - * Constructs a {@link StorageAccountInfo}. - * - * @param skuName SKU of the account. - * @param accountKind Type of the account. - * @param isHnsEnabled whether hierarchical namespace is enabled on the account. - */ - public StorageAccountInfo(final SkuName skuName, final AccountKind accountKind, Boolean isHnsEnabled) { - this.skuName = skuName; - this.accountKind = accountKind; - this.isHnsEnabled = isHnsEnabled != null && isHnsEnabled; - } - - /** - * Gets the SKU of the account. - * - * @return the SKU of the account. - */ - public SkuName getSkuName() { - return skuName; - } - - /** - * Gets the information of the type of the account. - * - * @return the type of the account. - */ - public AccountKind getAccountKind() { - return accountKind; - } - - /** - * Specifies whether hierarchical namespace is enabled on the account. - * - * @return whether hierarchical namespace is enabled on the account. - */ - public boolean isHierarchicalNamespaceEnabled() { - return isHnsEnabled; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageServiceProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageServiceProperties.java new file mode 100644 index 000000000000..11acd90f15b0 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageServiceProperties.java @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The service properties. + */ +@Immutable +public final class StorageServiceProperties implements JsonSerializable { + /* + * The logging properties. + */ + @Generated + private Logging logging; + + /* + * The hour metrics properties. + */ + @Generated + private Metrics hourMetrics; + + /* + * The minute metrics properties. + */ + @Generated + private Metrics minuteMetrics; + + /* + * The CORS properties. + */ + @Generated + private List cors; + + /* + * The default service version. + */ + @Generated + private String defaultServiceVersion; + + /* + * The delete retention policy. + */ + @Generated + private RetentionPolicy deleteRetentionPolicy; + + /* + * The static website properties. + */ + @Generated + private StaticWebsite staticWebsite; + + /** + * Creates an instance of StorageServiceProperties class. + */ + @Generated + private StorageServiceProperties() { + } + + /** + * Get the logging property: The logging properties. + * + * @return the logging value. + */ + @Generated + public Logging getLogging() { + return this.logging; + } + + /** + * Get the hourMetrics property: The hour metrics properties. + * + * @return the hourMetrics value. + */ + @Generated + public Metrics getHourMetrics() { + return this.hourMetrics; + } + + /** + * Get the minuteMetrics property: The minute metrics properties. + * + * @return the minuteMetrics value. + */ + @Generated + public Metrics getMinuteMetrics() { + return this.minuteMetrics; + } + + /** + * Get the cors property: The CORS properties. + * + * @return the cors value. + */ + @Generated + public List getCors() { + return this.cors; + } + + /** + * Get the defaultServiceVersion property: The default service version. + * + * @return the defaultServiceVersion value. + */ + @Generated + public String getDefaultServiceVersion() { + return this.defaultServiceVersion; + } + + /** + * Get the deleteRetentionPolicy property: The delete retention policy. + * + * @return the deleteRetentionPolicy value. + */ + @Generated + public RetentionPolicy getDeleteRetentionPolicy() { + return this.deleteRetentionPolicy; + } + + /** + * Get the staticWebsite property: The static website properties. + * + * @return the staticWebsite value. + */ + @Generated + public StaticWebsite getStaticWebsite() { + return this.staticWebsite; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("logging", this.logging); + jsonWriter.writeJsonField("hourMetrics", this.hourMetrics); + jsonWriter.writeJsonField("minuteMetrics", this.minuteMetrics); + jsonWriter.writeArrayField("cors", this.cors, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("defaultServiceVersion", this.defaultServiceVersion); + jsonWriter.writeJsonField("deleteRetentionPolicy", this.deleteRetentionPolicy); + jsonWriter.writeJsonField("staticWebsite", this.staticWebsite); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageServiceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageServiceProperties if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageServiceProperties. + */ + @Generated + public static StorageServiceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageServiceProperties deserializedStorageServiceProperties = new StorageServiceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("logging".equals(fieldName)) { + deserializedStorageServiceProperties.logging = Logging.fromJson(reader); + } else if ("hourMetrics".equals(fieldName)) { + deserializedStorageServiceProperties.hourMetrics = Metrics.fromJson(reader); + } else if ("minuteMetrics".equals(fieldName)) { + deserializedStorageServiceProperties.minuteMetrics = Metrics.fromJson(reader); + } else if ("cors".equals(fieldName)) { + List cors = reader.readArray(reader1 -> CorsRule.fromJson(reader1)); + deserializedStorageServiceProperties.cors = cors; + } else if ("defaultServiceVersion".equals(fieldName)) { + deserializedStorageServiceProperties.defaultServiceVersion = reader.getString(); + } else if ("deleteRetentionPolicy".equals(fieldName)) { + deserializedStorageServiceProperties.deleteRetentionPolicy = RetentionPolicy.fromJson(reader); + } else if ("staticWebsite".equals(fieldName)) { + deserializedStorageServiceProperties.staticWebsite = StaticWebsite.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageServiceProperties; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageServiceStats.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageServiceStats.java new file mode 100644 index 000000000000..41b7ab1d34d0 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/StorageServiceStats.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Stats for the storage service. + */ +@Immutable +public final class StorageServiceStats implements JsonSerializable { + /* + * The geo replication stats. + */ + @Generated + private GeoReplication geoReplication; + + /** + * Creates an instance of StorageServiceStats class. + */ + @Generated + private StorageServiceStats() { + } + + /** + * Get the geoReplication property: The geo replication stats. + * + * @return the geoReplication value. + */ + @Generated + public GeoReplication getGeoReplication() { + return this.geoReplication; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("geoReplication", this.geoReplication); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageServiceStats from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageServiceStats if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageServiceStats. + */ + @Generated + public static StorageServiceStats fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageServiceStats deserializedStorageServiceStats = new StorageServiceStats(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("geoReplication".equals(fieldName)) { + deserializedStorageServiceStats.geoReplication = GeoReplication.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageServiceStats; + }); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SyncCopyStatusType.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SyncCopyStatusType.java deleted file mode 100644 index 3dadcb480e62..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/SyncCopyStatusType.java +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -/** - * Defines values for SyncCopyStatusType. - */ -public enum SyncCopyStatusType { - /** - * Enum value success. - */ - SUCCESS("success"); - - /** - * The actual serialized value for a SyncCopyStatusType instance. - */ - private final String value; - - SyncCopyStatusType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a SyncCopyStatusType instance. - * - * @param value the serialized value to parse. - * @return the parsed SyncCopyStatusType object, or null if unable to parse. - */ - public static SyncCopyStatusType fromString(String value) { - SyncCopyStatusType[] items = SyncCopyStatusType.values(); - for (SyncCopyStatusType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/TaggedBlobItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/TaggedBlobItem.java deleted file mode 100644 index f0e53c7158c2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/TaggedBlobItem.java +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.storage.blob.models; - -import java.util.Collections; -import java.util.Map; - -/** - * Blob info from a Filter Blobs API call. - */ -public final class TaggedBlobItem { - - /** - * Constructor to create a new TaggedBlobItem - * @param containerName The container name - * @param name The blob name - */ - public TaggedBlobItem(String containerName, String name) { - this(containerName, name, Collections.emptyMap()); - } - - /** - * Constructor to create a new TaggedBlobItem - * @param containerName The container name - * @param name The blob name - * @param tags The blob tags - */ - public TaggedBlobItem(String containerName, String name, Map tags) { - this.name = name; - this.containerName = containerName; - this.tags = tags; - } - - /* - * The name property. - */ - private final String name; - - /* - * The containerName property. - */ - private final String containerName; - - private final Map tags; - - /** - * Get the name property: The name property. - * - * @return the name value. - */ - public String getName() { - return this.name; - } - - /** - * Get the containerName property: The containerName property. - * - * @return the containerName value. - */ - public String getContainerName() { - return this.containerName; - } - - /** - * Get the tags property: The tags property. - * - * @return the tags value. - */ - public Map getTags() { - return this.tags; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/UserDelegationKey.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/UserDelegationKey.java index fdbf49e6510c..9ccf8a500992 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/UserDelegationKey.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/UserDelegationKey.java @@ -1,104 +1,105 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.storage.blob.models; -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import java.time.OffsetDateTime; -import java.time.format.DateTimeFormatter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; /** * A user delegation key. */ -@Fluent -public final class UserDelegationKey implements XmlSerializable { +@Immutable +public final class UserDelegationKey implements JsonSerializable { /* * The Azure Active Directory object ID in GUID format. */ - private String signedObjectId; + @Generated + private final String signedOid; /* - * The Azure Active Directory tenant ID in GUID format + * The Azure Active Directory tenant ID in GUID format. */ - private String signedTenantId; + @Generated + private final String signedTid; /* - * The date-time the key is active + * The date-time the key is active. */ - private OffsetDateTime signedStart; + @Generated + private final String signedStart; /* - * The date-time the key expires + * The date-time the key expires. */ - private OffsetDateTime signedExpiry; + @Generated + private final String signedExpiry; /* - * Abbreviation of the Azure Storage service that accepts the key + * Abbreviation of the Azure Storage service that accepts the key. */ - private String signedService; + @Generated + private final String signedService; /* - * The service version that created the key + * The service version that created the key. */ - private String signedVersion; + @Generated + private final String signedVersion; /* - * The key as a base64 string + * The key as a base64 string. */ - private String value; + @Generated + private final String value; /** * Creates an instance of UserDelegationKey class. - */ - public UserDelegationKey() { - } - - /** - * Get the signedObjectId property: The Azure Active Directory object ID in GUID format. - * - * @return the signedObjectId value. - */ - public String getSignedObjectId() { - return this.signedObjectId; - } - - /** - * Set the signedObjectId property: The Azure Active Directory object ID in GUID format. * - * @param signedObjectId the signedObjectId value to set. - * @return the UserDelegationKey object itself. + * @param signedOid the signedOid value to set. + * @param signedTid the signedTid value to set. + * @param signedStart the signedStart value to set. + * @param signedExpiry the signedExpiry value to set. + * @param signedService the signedService value to set. + * @param signedVersion the signedVersion value to set. + * @param value the value value to set. */ - public UserDelegationKey setSignedObjectId(String signedObjectId) { - this.signedObjectId = signedObjectId; - return this; + @Generated + private UserDelegationKey(String signedOid, String signedTid, String signedStart, String signedExpiry, + String signedService, String signedVersion, String value) { + this.signedOid = signedOid; + this.signedTid = signedTid; + this.signedStart = signedStart; + this.signedExpiry = signedExpiry; + this.signedService = signedService; + this.signedVersion = signedVersion; + this.value = value; } /** - * Get the signedTenantId property: The Azure Active Directory tenant ID in GUID format. + * Get the signedOid property: The Azure Active Directory object ID in GUID format. * - * @return the signedTenantId value. + * @return the signedOid value. */ - public String getSignedTenantId() { - return this.signedTenantId; + @Generated + public String getSignedOid() { + return this.signedOid; } /** - * Set the signedTenantId property: The Azure Active Directory tenant ID in GUID format. + * Get the signedTid property: The Azure Active Directory tenant ID in GUID format. * - * @param signedTenantId the signedTenantId value to set. - * @return the UserDelegationKey object itself. + * @return the signedTid value. */ - public UserDelegationKey setSignedTenantId(String signedTenantId) { - this.signedTenantId = signedTenantId; - return this; + @Generated + public String getSignedTid() { + return this.signedTid; } /** @@ -106,173 +107,111 @@ public UserDelegationKey setSignedTenantId(String signedTenantId) { * * @return the signedStart value. */ - public OffsetDateTime getSignedStart() { + @Generated + public String getSignedStart() { return this.signedStart; } - /** - * Set the signedStart property: The date-time the key is active. - * - * @param signedStart the signedStart value to set. - * @return the UserDelegationKey object itself. - */ - public UserDelegationKey setSignedStart(OffsetDateTime signedStart) { - this.signedStart = signedStart; - return this; - } - /** * Get the signedExpiry property: The date-time the key expires. * * @return the signedExpiry value. */ - public OffsetDateTime getSignedExpiry() { + @Generated + public String getSignedExpiry() { return this.signedExpiry; } - /** - * Set the signedExpiry property: The date-time the key expires. - * - * @param signedExpiry the signedExpiry value to set. - * @return the UserDelegationKey object itself. - */ - public UserDelegationKey setSignedExpiry(OffsetDateTime signedExpiry) { - this.signedExpiry = signedExpiry; - return this; - } - /** * Get the signedService property: Abbreviation of the Azure Storage service that accepts the key. * * @return the signedService value. */ + @Generated public String getSignedService() { return this.signedService; } - /** - * Set the signedService property: Abbreviation of the Azure Storage service that accepts the key. - * - * @param signedService the signedService value to set. - * @return the UserDelegationKey object itself. - */ - public UserDelegationKey setSignedService(String signedService) { - this.signedService = signedService; - return this; - } - /** * Get the signedVersion property: The service version that created the key. * * @return the signedVersion value. */ + @Generated public String getSignedVersion() { return this.signedVersion; } - /** - * Set the signedVersion property: The service version that created the key. - * - * @param signedVersion the signedVersion value to set. - * @return the UserDelegationKey object itself. - */ - public UserDelegationKey setSignedVersion(String signedVersion) { - this.signedVersion = signedVersion; - return this; - } - /** * Get the value property: The key as a base64 string. * * @return the value value. */ + @Generated public String getValue() { return this.value; } /** - * Set the value property: The key as a base64 string. - * - * @param value the value value to set. - * @return the UserDelegationKey object itself. + * {@inheritDoc} */ - public UserDelegationKey setValue(String value) { - this.value = value; - return this; - } - - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - + @Generated @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "UserDelegationKey" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeStringElement("SignedOid", this.signedObjectId); - xmlWriter.writeStringElement("SignedTid", this.signedTenantId); - xmlWriter.writeStringElement("SignedStart", - this.signedStart == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.signedStart)); - xmlWriter.writeStringElement("SignedExpiry", - this.signedExpiry == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.signedExpiry)); - xmlWriter.writeStringElement("SignedService", this.signedService); - xmlWriter.writeStringElement("SignedVersion", this.signedVersion); - xmlWriter.writeStringElement("Value", this.value); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of UserDelegationKey from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of UserDelegationKey if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the UserDelegationKey. - */ - public static UserDelegationKey fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of UserDelegationKey from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of UserDelegationKey if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the UserDelegationKey. - */ - public static UserDelegationKey fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "UserDelegationKey" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - UserDelegationKey deserializedUserDelegationKey = new UserDelegationKey(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("SignedOid".equals(elementName.getLocalPart())) { - deserializedUserDelegationKey.signedObjectId = reader.getStringElement(); - } else if ("SignedTid".equals(elementName.getLocalPart())) { - deserializedUserDelegationKey.signedTenantId = reader.getStringElement(); - } else if ("SignedStart".equals(elementName.getLocalPart())) { - deserializedUserDelegationKey.signedStart - = reader.getNullableElement(dateString -> CoreUtils.parseBestOffsetDateTime(dateString)); - } else if ("SignedExpiry".equals(elementName.getLocalPart())) { - deserializedUserDelegationKey.signedExpiry - = reader.getNullableElement(dateString -> CoreUtils.parseBestOffsetDateTime(dateString)); - } else if ("SignedService".equals(elementName.getLocalPart())) { - deserializedUserDelegationKey.signedService = reader.getStringElement(); - } else if ("SignedVersion".equals(elementName.getLocalPart())) { - deserializedUserDelegationKey.signedVersion = reader.getStringElement(); - } else if ("Value".equals(elementName.getLocalPart())) { - deserializedUserDelegationKey.value = reader.getStringElement(); + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("signedOid", this.signedOid); + jsonWriter.writeStringField("signedTid", this.signedTid); + jsonWriter.writeStringField("signedStart", this.signedStart); + jsonWriter.writeStringField("signedExpiry", this.signedExpiry); + jsonWriter.writeStringField("signedService", this.signedService); + jsonWriter.writeStringField("signedVersion", this.signedVersion); + jsonWriter.writeStringField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserDelegationKey from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserDelegationKey if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the UserDelegationKey. + */ + @Generated + public static UserDelegationKey fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String signedOid = null; + String signedTid = null; + String signedStart = null; + String signedExpiry = null; + String signedService = null; + String signedVersion = null; + String value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("signedOid".equals(fieldName)) { + signedOid = reader.getString(); + } else if ("signedTid".equals(fieldName)) { + signedTid = reader.getString(); + } else if ("signedStart".equals(fieldName)) { + signedStart = reader.getString(); + } else if ("signedExpiry".equals(fieldName)) { + signedExpiry = reader.getString(); + } else if ("signedService".equals(fieldName)) { + signedService = reader.getString(); + } else if ("signedVersion".equals(fieldName)) { + signedVersion = reader.getString(); + } else if ("value".equals(fieldName)) { + value = reader.getString(); } else { - reader.skipElement(); + reader.skipChildren(); } } - - return deserializedUserDelegationKey; + return new UserDelegationKey(signedOid, signedTid, signedStart, signedExpiry, signedService, signedVersion, + value); }); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/package-info.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/package-info.java index 0680e6d4bbc6..437908234203 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/package-info.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/package-info.java @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. /** - * Package containing the data models for AzureBlobStorage. - * null. + * Package containing the data models for Blob. */ package com.azure.storage.blob.models; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobAppendBlockFromUrlOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobAppendBlockFromUrlOptions.java deleted file mode 100644 index fd04ac8ee86a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobAppendBlockFromUrlOptions.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpAuthorization; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.AppendBlobRequestConditions; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; - -/** - * Extended options that may be passed when appending a block from a source URL. - */ -@Fluent -public final class AppendBlobAppendBlockFromUrlOptions { - private final String sourceUrl; - private BlobRange sourceRange; - private byte[] sourceContentMd5; - private AppendBlobRequestConditions destinationRequestConditions; - private BlobRequestConditions sourceRequestConditions; - private HttpAuthorization sourceAuthorization; - - /** - * Creates a new instance of {@link AppendBlobAppendBlockFromUrlOptions}. - * - * @param sourceUrl The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - */ - public AppendBlobAppendBlockFromUrlOptions(String sourceUrl) { - this.sourceUrl = sourceUrl; - } - - /** - * Gets the source URL to copy from. - * - * @return Source URL to copy from. - */ - public String getSourceUrl() { - return sourceUrl; - } - - /** - * Gets the range of bytes to read from the source. - * - * @return Range of bytes to read from the source. - */ - public BlobRange getSourceRange() { - return sourceRange; - } - - /** - * Sets the range of bytes to read from the source. - * - * @param sourceRange Range of bytes to read from the source. - * @return The updated options. - */ - public AppendBlobAppendBlockFromUrlOptions setSourceRange(BlobRange sourceRange) { - this.sourceRange = sourceRange; - return this; - } - - /** - * Gets the MD5 of the source content to be appended. - * - * @return MD5 of the source content to be appended. - */ - public byte[] getSourceContentMd5() { - return CoreUtils.clone(sourceContentMd5); - } - - /** - * Sets the MD5 of the source content to be appended. - * - * @param sourceContentMd5 MD5 of the source content to be appended. - * @return The updated options. - */ - public AppendBlobAppendBlockFromUrlOptions setSourceContentMd5(byte[] sourceContentMd5) { - this.sourceContentMd5 = CoreUtils.clone(sourceContentMd5); - return this; - } - - /** - * Gets the {@link AppendBlobRequestConditions} for writing to destination. - * - * @return {@link AppendBlobRequestConditions} for writing to destination. - */ - public AppendBlobRequestConditions getDestinationRequestConditions() { - return destinationRequestConditions; - } - - /** - * Sets the {@link AppendBlobRequestConditions} for writing to destination. - * - * @param destinationRequestConditions {@link AppendBlobRequestConditions} for writing to destination. - * @return The updated options. - */ - public AppendBlobAppendBlockFromUrlOptions - setDestinationRequestConditions(AppendBlobRequestConditions destinationRequestConditions) { - this.destinationRequestConditions = destinationRequestConditions; - return this; - } - - /** - * Gets the {@link BlobRequestConditions} for accessing source. - * - * @return {@link BlobRequestConditions} for accessing source. - */ - public BlobRequestConditions getSourceRequestConditions() { - return sourceRequestConditions; - } - - /** - * Sets the {@link BlobRequestConditions} for accessing source. - * - * @param sourceRequestConditions {@link BlobRequestConditions} for accessing source. - * @return The updated options. - */ - public AppendBlobAppendBlockFromUrlOptions - setSourceRequestConditions(BlobRequestConditions sourceRequestConditions) { - this.sourceRequestConditions = sourceRequestConditions; - return this; - } - - /** - * Gets the auth header for accessing source. - * - * @return auth header for accessing source. - */ - public HttpAuthorization getSourceAuthorization() { - return sourceAuthorization; - } - - /** - * Sets "Authorization" header for accessing source URL. Currently only "Bearer" authentication is accepted by - * Storage. - * - * @param sourceAuthorization auth header for accessing source. - * @return The updated options. - */ - public AppendBlobAppendBlockFromUrlOptions setSourceAuthorization(HttpAuthorization sourceAuthorization) { - this.sourceAuthorization = sourceAuthorization; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobCreateOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobCreateOptions.java deleted file mode 100644 index cfe7948e5d09..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobCreateOptions.java +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRequestConditions; - -import java.util.Map; - -/** - * Extended options that may be passed when creating an Append Blob. - */ -@Fluent -public class AppendBlobCreateOptions { - private BlobHttpHeaders headers; - private Map metadata; - private Map tags; - private BlobRequestConditions requestConditions; - private BlobImmutabilityPolicy immutabilityPolicy; - private Boolean legalHold; - - /** - * Creates a new instance of {@link AppendBlobCreateOptions}. - */ - public AppendBlobCreateOptions() { - } - - /** - * Gets the {@link BlobHttpHeaders}. - * - * @return {@link BlobHttpHeaders} - */ - public BlobHttpHeaders getHeaders() { - return headers; - } - - /** - * Sets the {@link BlobHttpHeaders}. - * - * @param headers {@link BlobHttpHeaders} - * @return The updated {@code AppendBlobCreateOptions} - */ - public AppendBlobCreateOptions setHeaders(BlobHttpHeaders headers) { - this.headers = headers; - return this; - } - - /** - * Gets the metadata to associate with the blob. - * - * @return The metadata to associate with the blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to associate with the blob. - * - * @param metadata The metadata to associate with the blob. - * @return The updated options - */ - public AppendBlobCreateOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to associate with the blob. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public AppendBlobCreateOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public AppendBlobCreateOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the immutability policy for the blob. - * - * @return {@link BlobImmutabilityPolicy} - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return immutabilityPolicy; - } - - /** - * Sets the immutability policy for the blob. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy} - * @return The updated options. - */ - public AppendBlobCreateOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - this.immutabilityPolicy = immutabilityPolicy; - return this; - } - - /** - * Gets if a legal hold should be placed on the blob. - * - * @return If a legal hold should be placed on the blob. - */ - public Boolean hasLegalHold() { - return legalHold; - } - - /** - * Sets if a legal hold should be placed on the blob. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param legalHold Indicates if a legal hold should be placed on the blob. - * @return The updated options. - */ - public AppendBlobCreateOptions setLegalHold(Boolean legalHold) { - this.legalHold = legalHold; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobSealOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobSealOptions.java deleted file mode 100644 index 736313ac31bd..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobSealOptions.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.AppendBlobRequestConditions; -import com.azure.storage.blob.models.BlobRequestConditions; - -/** - * Extended options that may be passed when sealing an Append Blob. - */ -@Fluent -public class AppendBlobSealOptions { - private AppendBlobRequestConditions requestConditions; - - /** - * Creates a new instance of {@link AppendBlobSealOptions}. - */ - public AppendBlobSealOptions() { - } - - /** - * Gets the {@link AppendBlobRequestConditions}. - * - * @return {@link AppendBlobRequestConditions} - */ - public AppendBlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link AppendBlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public AppendBlobSealOptions setRequestConditions(AppendBlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobAcquireLeaseOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobAcquireLeaseOptions.java deleted file mode 100644 index 8d7525e30cd2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobAcquireLeaseOptions.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; - -/** - * Extended options that may be passed when acquiring a lease to a blob or container. - */ -@Fluent -public class BlobAcquireLeaseOptions { - private final int duration; - private BlobLeaseRequestConditions requestConditions; - - /** - * Creates a new instance of {@link BlobAcquireLeaseOptions}. - * - * @param durationInSeconds The duration of the lease between 15 to 60 seconds or -1 for an infinite duration. - */ - public BlobAcquireLeaseOptions(int durationInSeconds) { - this.duration = durationInSeconds; - } - - /** - * Gets the duration of the lease. - * - * @return The duration of the lease between 15 to 60 seconds or -1 for an infinite duration. - */ - public int getDuration() { - return this.duration; - } - - /** - * Gets the {@link BlobLeaseRequestConditions}. - * - * @return {@link BlobLeaseRequestConditions} - */ - public BlobLeaseRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobLeaseRequestConditions}. - * - * @param requestConditions {@link BlobLeaseRequestConditions} - * @return The updated options. - */ - public BlobAcquireLeaseOptions setRequestConditions(BlobLeaseRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBeginCopyOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBeginCopyOptions.java deleted file mode 100644 index e8143f59c53c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBeginCopyOptions.java +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.time.Duration; -import java.util.Map; - -/** - * Extended options that may be passed when beginning a copy operation. - */ -@Fluent -public class BlobBeginCopyOptions { - private final String sourceUrl; - private Map metadata; - private Map tags; - private AccessTier tier; - private RehydratePriority rehydratePriority; - private BlobBeginCopySourceRequestConditions sourceRequestConditions; - private BlobRequestConditions destinationRequestConditions; - private Duration pollInterval; - private Boolean sealDestination; - private BlobImmutabilityPolicy immutabilityPolicy; - private Boolean legalHold; - - /** - * Creates a new instance of {@link BlobBeginCopyOptions}. - * - * @param sourceUrl The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - * @throws NullPointerException If {@code sourceUrl} is null. - */ - public BlobBeginCopyOptions(String sourceUrl) { - StorageImplUtils.assertNotNull("sourceUrl", sourceUrl); - this.sourceUrl = sourceUrl; - } - - /** - * Gets the source URL. - * - * @return The source URL. - */ - public String getSourceUrl() { - return this.sourceUrl; - } - - /** - * Gets the metadata to associate with the destination blob. - * - * @return The metadata to associate with the destination blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to associate with the destination blob. - * - * @param metadata The metadata to associate with the destination blob. - * @return The updated options - */ - public BlobBeginCopyOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to associate with the blob. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public BlobBeginCopyOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link AccessTier} for the destination blob. - * - * @return {@link AccessTier} for the destination blob. - */ - public AccessTier getTier() { - return tier; - } - - /** - * Sets the {@link AccessTier} for the destination blob. - * - * @param tier {@link AccessTier} for the destination blob. - * @return The updated options. - */ - public BlobBeginCopyOptions setTier(AccessTier tier) { - this.tier = tier; - return this; - } - - /** - * Gets the {@link RehydratePriority} for rehydrating the blob. - * - * @return {@link RehydratePriority} for rehydrating the blob. - */ - public RehydratePriority getRehydratePriority() { - return rehydratePriority; - } - - /** - * Sets the {@link RehydratePriority} for rehydrating the blob. - * - * @param rehydratePriority {@link RehydratePriority} for rehydrating the blob. - * @return The updated options. - */ - public BlobBeginCopyOptions setRehydratePriority(RehydratePriority rehydratePriority) { - this.rehydratePriority = rehydratePriority; - return this; - } - - /** - * Gets the {@link BlobBeginCopySourceRequestConditions} for the source. - * - * @return {@link BlobBeginCopySourceRequestConditions} for the source. - */ - public BlobBeginCopySourceRequestConditions getSourceRequestConditions() { - return sourceRequestConditions; - } - - /** - * Sets the {@link BlobBeginCopySourceRequestConditions} for the source. - * - * @param sourceRequestConditions {@link BlobBeginCopySourceRequestConditions} for the source. - * @return The updated options. - */ - public BlobBeginCopyOptions - setSourceRequestConditions(BlobBeginCopySourceRequestConditions sourceRequestConditions) { - this.sourceRequestConditions = sourceRequestConditions; - return this; - } - - /** - * Gets the {@link BlobRequestConditions} for the destination. - * - * @return {@link BlobRequestConditions} for the destination. - */ - public BlobRequestConditions getDestinationRequestConditions() { - return destinationRequestConditions; - } - - /** - * Sets the {@link BlobRequestConditions} for the destination. - * - * @param destinationRequestConditions {@link BlobRequestConditions} for the destination - * @return The updated options. - */ - public BlobBeginCopyOptions setDestinationRequestConditions(BlobRequestConditions destinationRequestConditions) { - this.destinationRequestConditions = destinationRequestConditions; - return this; - } - - /** - * Gets the duration between each poll for the copy status. - * - * @return Duration between each poll for the copy status. If none is specified, a default of one second - * is used. - */ - public Duration getPollInterval() { - return pollInterval; - } - - /** - * Sets the duration between each poll for the copy status. - * - * @param pollInterval Duration between each poll for the copy status. If none is specified, a default of one second - * is used. - * @return The updated options. - */ - public BlobBeginCopyOptions setPollInterval(Duration pollInterval) { - this.pollInterval = pollInterval; - return this; - } - - /** - * Gets whether the destination blob should be sealed (marked as read only). - *

- * Only applicable for Append Blobs. - * - * @return Whether the destination blob should be sealed (marked as read only). - */ - public Boolean isSealDestination() { - return sealDestination; - } - - /** - * Sets whether the destination blob should be sealed (marked as read only). - *

- * Only applicable for Append Blobs. - * - * @param sealDestination Whether the destination blob should be sealed (marked as read only). - * @return The updated options. - */ - public BlobBeginCopyOptions setSealDestination(Boolean sealDestination) { - this.sealDestination = sealDestination; - return this; - } - - /** - * Gets the {@link BlobImmutabilityPolicy} for the destination blob. - * - * @return {@link BlobImmutabilityPolicy} - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return immutabilityPolicy; - } - - /** - * Sets the {@link BlobImmutabilityPolicy} for the destination blob. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy} - * @return The updated options. - */ - public BlobBeginCopyOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - this.immutabilityPolicy = immutabilityPolicy; - return this; - } - - /** - * Gets if a legal hold should be placed on the blob. - * - * @return If a legal hold should be placed on the blob. - */ - public Boolean isLegalHold() { - return legalHold; - } - - /** - * Sets if a legal hold should be placed on the blob. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * @param legalHold Indicates if a legal hold should be placed on the blob. - * @return The updated options. - */ - public BlobBeginCopyOptions setLegalHold(Boolean legalHold) { - this.legalHold = legalHold; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBreakLeaseOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBreakLeaseOptions.java deleted file mode 100644 index 59aec35eda27..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBreakLeaseOptions.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; - -import java.time.Duration; - -/** - * Extended options that may be passed when breaking a lease to a blob or container. - */ -@Fluent -public class BlobBreakLeaseOptions { - private Duration breakPeriod; - private BlobLeaseRequestConditions requestConditions; - - /** - * Creates a new instance of {@link BlobBreakLeaseOptions}. - */ - public BlobBreakLeaseOptions() { - } - - /** - * Gets the break period of the lease. - * - * @return An optional duration, between 0 and 60 seconds, that the lease should continue before - * it is broken. If the break period is longer than the time remaining on the lease the remaining time on the lease - * is used. A new lease will not be available before the break period has expired, but the lease may be held for - * longer than the break period. - */ - public Duration getBreakPeriod() { - return this.breakPeriod; - } - - /** - * Sets the break period of the lease. - * - * @param breakPeriod An optional duration, between 0 and 60 seconds, that the lease should continue before - * it is broken. If the break period is longer than the time remaining on the lease the remaining time on the lease - * is used. A new lease will not be available before the break period has expired, but the lease may be held for - * longer than the break period. - * @return The updated options. - */ - public BlobBreakLeaseOptions setBreakPeriod(Duration breakPeriod) { - this.breakPeriod = breakPeriod; - return this; - } - - /** - * Gets the {@link BlobLeaseRequestConditions}. - * - * @return {@link BlobLeaseRequestConditions} - */ - public BlobLeaseRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobLeaseRequestConditions}. - * - * @param requestConditions {@link BlobLeaseRequestConditions} - * @return The updated options. - */ - public BlobBreakLeaseOptions setRequestConditions(BlobLeaseRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobChangeLeaseOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobChangeLeaseOptions.java deleted file mode 100644 index 70eae80285d3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobChangeLeaseOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; -import com.azure.storage.common.implementation.StorageImplUtils; - -/** - * Extended options that may be passed when changing a lease to a blob or container. - */ -@Fluent -public class BlobChangeLeaseOptions { - private final String proposedId; - private BlobLeaseRequestConditions requestConditions; - - /** - * Creates a new instance of {@link BlobChangeLeaseOptions}. - * - * @param proposedId A new lease ID in a valid GUID format. - * @throws NullPointerException If {@code proposedId} is null. - */ - public BlobChangeLeaseOptions(String proposedId) { - StorageImplUtils.assertNotNull("proposedId", proposedId); - this.proposedId = proposedId; - } - - /** - * Gets the proposed lease ID. - * - * @return A new lease ID in a valid GUID format. - */ - public String getProposedId() { - return this.proposedId; - } - - /** - * Gets the {@link BlobLeaseRequestConditions}. - * - * @return {@link BlobLeaseRequestConditions} - */ - public BlobLeaseRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobLeaseRequestConditions}. - * - * @param requestConditions {@link BlobLeaseRequestConditions} - * @return The updated options. - */ - public BlobChangeLeaseOptions setRequestConditions(BlobLeaseRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobContainerCreateOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobContainerCreateOptions.java deleted file mode 100644 index e2bfbdc9b662..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobContainerCreateOptions.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.PublicAccessType; - -import java.util.Map; - -/** - * Extended options that may be passed when creating a Blob Container. - */ -@Fluent -public class BlobContainerCreateOptions { - private Map metadata; - PublicAccessType publicAccessType; - - /** - * Creates a new instance of {@link BlobContainerCreateOptions}. - */ - public BlobContainerCreateOptions() { - } - - /** - * Gets the metadata to associate with the blob. - * - * @return The metadata to associate with the blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to associate with the blob. - * - * @param metadata The metadata to associate with the blob. - * @return The updated options - */ - public BlobContainerCreateOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the public access type associated with the blob. - * - * @return The public access type associated with the blob. - */ - public PublicAccessType getPublicAccessType() { - return publicAccessType; - } - - /** - * Sets the public access type to associate with the blob. - * - * @param accessType The public access type to associate with the blob. - * @return The updated options. - */ - public BlobContainerCreateOptions setPublicAccessType(PublicAccessType accessType) { - publicAccessType = accessType; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobContainerRenameOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobContainerRenameOptions.java deleted file mode 100644 index 6358f3c0eb3b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobContainerRenameOptions.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobRequestConditions; - -import java.util.Objects; - -/** - * Extended options that may be passed when renaming a blob container. - */ -@Fluent -class BlobContainerRenameOptions { - private final String destinationContainerName; - private BlobRequestConditions requestConditions; - - /** - * Creates a new instance of {@link BlobContainerRenameOptions}. - * - * @param destinationContainerName The new name of the container. - * @throws NullPointerException If {@code destinationContainerName} is null. - */ - BlobContainerRenameOptions(String destinationContainerName) { - Objects.requireNonNull(destinationContainerName); - this.destinationContainerName = destinationContainerName; - } - - /** - * Gets the new name of the container. - * - * @return The new name of the container. - */ - public String getDestinationContainerName() { - return destinationContainerName; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - * @throws UnsupportedOperationException if a condition other than lease id is set. - */ - public BlobContainerRenameOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobCopyFromUrlOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobCopyFromUrlOptions.java deleted file mode 100644 index 8aa3a25d48c1..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobCopyFromUrlOptions.java +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpAuthorization; -import com.azure.core.http.RequestConditions; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobCopySourceTagsMode; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.util.Map; - -/** - * Extended options that may be passed when copying a blob. - */ -@Fluent -public class BlobCopyFromUrlOptions { - private final String copySource; - private Map metadata; - private Map tags; - private AccessTier tier; - private RequestConditions sourceRequestConditions; - private BlobRequestConditions destinationRequestConditions; - private HttpAuthorization sourceAuthorization; - private BlobImmutabilityPolicy immutabilityPolicy; - private Boolean legalHold; - private BlobCopySourceTagsMode copySourceTags; - - /** - * Creates a new instance of {@link BlobCopyFromUrlOptions}. - * - * @param copySource The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - * @throws NullPointerException If {@code copySource} is null. - */ - public BlobCopyFromUrlOptions(String copySource) { - StorageImplUtils.assertNotNull("copySource", copySource); - this.copySource = copySource; - } - - /** - * Gets the source URL to copy from. - * - * @return The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - */ - public String getCopySource() { - return this.copySource; - } - - /** - * Gets the metadata to associate with the destination blob. - * - * @return The metadata to associate with the destination blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to associate with the destination blob. - * - * @param metadata The metadata to associate with the destination blob. - * @return The updated options - */ - public BlobCopyFromUrlOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to associate with the blob. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public BlobCopyFromUrlOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link AccessTier} for the destination blob. - * - * @return {@link AccessTier} for the destination blob. - */ - public AccessTier getTier() { - return tier; - } - - /** - * Sets the {@link AccessTier} for the destination blob. - * - * @param tier {@link AccessTier} for the destination blob. - * @return The updated options. - */ - public BlobCopyFromUrlOptions setTier(AccessTier tier) { - this.tier = tier; - return this; - } - - /** - * Gets the {@link RequestConditions} for the source. - * - * @return {@link RequestConditions} for the source. - */ - public RequestConditions getSourceRequestConditions() { - return sourceRequestConditions; - } - - /** - * Sets the {@link RequestConditions} for the source. - * - * @param sourceRequestConditions {@link RequestConditions} for the source. - * @return The updated options. - */ - public BlobCopyFromUrlOptions setSourceRequestConditions(RequestConditions sourceRequestConditions) { - this.sourceRequestConditions = sourceRequestConditions; - return this; - } - - /** - * Gets the {@link BlobRequestConditions} for the destination. - * - * @return {@link BlobRequestConditions} for the destination. - */ - public BlobRequestConditions getDestinationRequestConditions() { - return destinationRequestConditions; - } - - /** - * Sets the {@link BlobRequestConditions} for the destination. - * - * @param destinationRequestConditions {@link BlobRequestConditions} for the destination. - * @return The updated options. - */ - public BlobCopyFromUrlOptions setDestinationRequestConditions(BlobRequestConditions destinationRequestConditions) { - this.destinationRequestConditions = destinationRequestConditions; - return this; - } - - /** - * Gets "Authorization" header for accessing source URL. Currently only "Bearer" authentication is accepted by - * Storage. - * - * @return auth header for access to source. - */ - public HttpAuthorization getSourceAuthorization() { - return sourceAuthorization; - } - - /** - * Sets "Authorization" header for accessing source URL. Currently only "Bearer" authentication is accepted by - * Storage. - * - * @param sourceAuthorization auth header for access to source. - * @return The updated options. - */ - public BlobCopyFromUrlOptions setSourceAuthorization(HttpAuthorization sourceAuthorization) { - this.sourceAuthorization = sourceAuthorization; - return this; - } - - /** - * Gets the {@link BlobImmutabilityPolicy}. - * - * @return {@link BlobImmutabilityPolicy} - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return immutabilityPolicy; - } - - /** - * Sets the {@link BlobImmutabilityPolicy}. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy} - * @return The updated options. - */ - public BlobCopyFromUrlOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - this.immutabilityPolicy = immutabilityPolicy; - return this; - } - - /** - * Gets if a legal hold should be placed on the blob. - * - * @return If a legal hold should be placed on the blob. - */ - public Boolean hasLegalHold() { - return legalHold; - } - - /** - * Sets if a legal hold should be placed on the blob. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param legalHold Indicates if a legal hold should be placed on the blob. - * @return The updated options. - */ - public BlobCopyFromUrlOptions setLegalHold(Boolean legalHold) { - this.legalHold = legalHold; - return this; - } - - /** - * Gets the copy source tags mode. - * - * @return The copy source tags mode. - */ - public BlobCopySourceTagsMode getCopySourceTagsMode() { - return copySourceTags; - } - - /** - * Sets the copy source tags mode - * - * @param copySourceTags Indicates if a legal hold should be placed on the blob. - * @return The updated options. - */ - public BlobCopyFromUrlOptions setCopySourceTagsMode(BlobCopySourceTagsMode copySourceTags) { - this.copySourceTags = copySourceTags; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobDownloadToFileOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobDownloadToFileOptions.java deleted file mode 100644 index 434844645f58..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobDownloadToFileOptions.java +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.common.ParallelTransferOptions; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.nio.file.OpenOption; -import java.util.Set; - -/** - * Extended options that may be passed when downloading a blob to a file. - */ -@Fluent -public class BlobDownloadToFileOptions { - private final String filePath; - private BlobRange range; - private ParallelTransferOptions parallelTransferOptions; - private DownloadRetryOptions downloadRetryOptions; - private BlobRequestConditions requestConditions; - private boolean retrieveContentRangeMd5; - private Set openOptions; - - /** - * Constructs a {@link BlobDownloadToFileOptions}. - * - * @param filePath Path of the file to download to. - * @throws NullPointerException If {@code filePath} is null. - */ - public BlobDownloadToFileOptions(String filePath) { - StorageImplUtils.assertNotNull("filePath", filePath); - this.filePath = filePath; - } - - /** - * Gets the path of the file to download to. - * - * @return The path of the file to download to. - */ - public String getFilePath() { - return filePath; - } - - /** - * Gets the {@link BlobRange}. - * - * @return {@link BlobRange} - */ - public BlobRange getRange() { - return range; - } - - /** - * Gets the {@link ParallelTransferOptions}. - * - * @return {@link ParallelTransferOptions} - */ - public ParallelTransferOptions getParallelTransferOptions() { - return parallelTransferOptions; - } - - /** - * Gets the {@link DownloadRetryOptions}. - * - * @return {@link DownloadRetryOptions} - */ - public DownloadRetryOptions getDownloadRetryOptions() { - return downloadRetryOptions; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Gets whether the contentMD5 for the specified blob range should be returned. - * - * @return Whether the contentMD5 for the specified blob range should be returned. - */ - public boolean isRetrieveContentRangeMd5() { - return retrieveContentRangeMd5; - } - - /** - * Gets the {@link OpenOption OpenOptions} to use to configure how to open or create the file. - * - * @return {@link OpenOption OpenOptions} to use to configure how to open or create the file. - */ - public Set getOpenOptions() { - return openOptions; - } - - /** - * Sets the {@link BlobRange}. - * - * @param range {@link BlobRange} - * @return The updated options. - */ - public BlobDownloadToFileOptions setRange(BlobRange range) { - this.range = range; - return this; - } - - /** - * Sets the {@link ParallelTransferOptions}. - * - * @param parallelTransferOptions {@link ParallelTransferOptions} - * @return The updated options. - */ - public BlobDownloadToFileOptions setParallelTransferOptions(ParallelTransferOptions parallelTransferOptions) { - this.parallelTransferOptions = parallelTransferOptions; - return this; - } - - /** - * Sets the {@link DownloadRetryOptions}. - * - * @param downloadRetryOptions {@link DownloadRetryOptions} - * @return The updated options. - */ - public BlobDownloadToFileOptions setDownloadRetryOptions(DownloadRetryOptions downloadRetryOptions) { - this.downloadRetryOptions = downloadRetryOptions; - return this; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlobDownloadToFileOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Sets whether the contentMD5 for the specified blob range should be returned. - * - * @param retrieveContentRangeMd5 Whether the contentMD5 for the specified blob range should be returned. - * @return The updated options. - */ - public BlobDownloadToFileOptions setRetrieveContentRangeMd5(boolean retrieveContentRangeMd5) { - this.retrieveContentRangeMd5 = retrieveContentRangeMd5; - return this; - } - - /** - * Sets the {@link OpenOption OpenOptions} to use to configure how to open or create the file. - * - * @param openOptions {@link OpenOption OpenOptions} to use to configure how to open or create the file. - * @return The updated options. - */ - public BlobDownloadToFileOptions setOpenOptions(Set openOptions) { - this.openOptions = openOptions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobGetTagsOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobGetTagsOptions.java deleted file mode 100644 index a8e8071b2e6b..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobGetTagsOptions.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobRequestConditions; - -/** - * Extended options that may be passed when getting tags for a blob. - */ -@Fluent -public class BlobGetTagsOptions { - private BlobRequestConditions requestConditions; - - /** - * Creates a new instance of {@link BlobGetTagsOptions}. - */ - public BlobGetTagsOptions() { - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlobGetTagsOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobInputStreamOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobInputStreamOptions.java deleted file mode 100644 index d98d744f3dd3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobInputStreamOptions.java +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.ConsistentReadControl; - -/** - * Extended options that may be passed when opening a blob input stream. - */ -@Fluent -public class BlobInputStreamOptions { - private BlobRange range; - private BlobRequestConditions requestConditions; - private Integer blockSize; - private ConsistentReadControl consistentReadControl; - - /** - * Creates a new instance of {@link BlobInputStreamOptions}. - */ - public BlobInputStreamOptions() { - } - - /** - * Gets the {@link BlobRange}. - * - * @return {@link BlobRange} - */ - public BlobRange getRange() { - return range; - } - - /** - * Sets the {@link BlobRange}. - * - * @param range {@link BlobRange} - * @return The updated options. - */ - public BlobInputStreamOptions setRange(BlobRange range) { - this.range = range; - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlobInputStreamOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the size of each data chunk returned from the service. If block size is large, input stream will make - * fewer network calls, but each individual call will send more data and will therefore take longer. - * The default value is 4 MB. - * - * @return The size of each data chunk returned from the service. If block size is large, input stream will make - * fewer network calls, but each individual call will send more data and will therefore take longer. - * The default value is 4 MB. - */ - public Integer getBlockSize() { - return blockSize; - } - - /** - * Sets the size of each data chunk returned from the service. If block size is large, input stream will make - * fewer network calls, but each individual call will send more data and will therefore take longer. - * The default value is 4 MB. - * - * @param blockSize The size of each data chunk returned from the service. If block size is large, input stream - * will make fewer network calls, but each individual call will send more data and will therefore take longer. - * The default value is 4 MB. - * @return The updated options. - */ - public BlobInputStreamOptions setBlockSize(Integer blockSize) { - this.blockSize = blockSize; - return this; - } - - /** - * Gets the {@link ConsistentReadControl} Default is E-Tag. - * - * @return {@link ConsistentReadControl} Default is E-Tag. - */ - public ConsistentReadControl getConsistentReadControl() { - return consistentReadControl; - } - - /** - * Sets the {@link ConsistentReadControl} Default is E-Tag. - * - * @param consistentReadControl {@link ConsistentReadControl} Default is E-Tag. - * @return The updated options. - */ - public BlobInputStreamOptions setConsistentReadControl(ConsistentReadControl consistentReadControl) { - this.consistentReadControl = consistentReadControl; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobParallelUploadOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobParallelUploadOptions.java deleted file mode 100644 index 681ff994ae62..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobParallelUploadOptions.java +++ /dev/null @@ -1,369 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Flux; - -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.util.Map; - -/** - * Extended options that may be passed when uploading a Block Blob in parallel. - */ -@Fluent -public class BlobParallelUploadOptions { - private final Flux dataFlux; - private final InputStream dataStream; - private final Long length; - private ParallelTransferOptions parallelTransferOptions; - private BlobHttpHeaders headers; - private Map metadata; - private Map tags; - private AccessTier tier; - private BlobRequestConditions requestConditions; - private boolean computeMd5; - private Duration timeout; - private BlobImmutabilityPolicy immutabilityPolicy; - private Boolean legalHold; - - /** - * Constructs a new {@link BlobParallelUploadOptions}. - * - * @param dataFlux The data to write to the blob. Unlike other upload methods, this method does not require that - * the {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not - * expected to produce the same values across subscriptions. - * @throws NullPointerException If {@code dataFlux} is null. - */ - public BlobParallelUploadOptions(Flux dataFlux) { - StorageImplUtils.assertNotNull("dataFlux", dataFlux); - this.dataFlux = dataFlux; - this.dataStream = null; - this.length = null; - } - - /** - * Constructs a new {@link BlobParallelUploadOptions}. - *

- * Use {@link #BlobParallelUploadOptions(InputStream)} instead to supply an InputStream without knowing the exact - * length beforehand. - * - * @param dataStream The data to write to the blob. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - * @throws NullPointerException If {@code dataStream} is null. - * @deprecated length is no longer necessary; use {@link #BlobParallelUploadOptions(InputStream)} instead. - */ - @Deprecated - public BlobParallelUploadOptions(InputStream dataStream, long length) { - this(dataStream, Long.valueOf(length)); - } - - /** - * Constructs a new {@link BlobParallelUploadOptions}. - * Note: the {@link InputStream} must be closed by the caller. - * - * @param dataStream The data to write to the blob. - * @throws NullPointerException If {@code dataStream} is null. - */ - public BlobParallelUploadOptions(InputStream dataStream) { - this(dataStream, null); - } - - /** - * Common constructor for building options from InputStream. - * Note: the {@link InputStream} must be closed by the caller. - * - * @param dataStream The data to write to the blob. - * @param length Optional known length of the data, affects reactive behavior for backwards compatibility. - * @throws NullPointerException If {@code dataStream} is null. - * @throws IllegalArgumentException If {@code length} is specified and is less than 0 or greater than - * {@link Long#MAX_VALUE}. - */ - private BlobParallelUploadOptions(InputStream dataStream, Long length) { - StorageImplUtils.assertNotNull("dataStream", dataStream); - if (length != null) { - StorageImplUtils.assertInBounds("length", length, 0, Long.MAX_VALUE); - } - this.dataStream = dataStream; - this.dataFlux = null; - this.length = length; - } - - /** - * Constructs a new {@code BlobParallelUploadOptions}. - * - * @param data The data to write to the blob. - */ - public BlobParallelUploadOptions(BinaryData data) { - StorageImplUtils.assertNotNull("data", data); - this.dataFlux = Flux.just(data.toByteBuffer()); - this.dataStream = null; - this.length = data.getLength(); - } - - /** - * Gets the data source. - * - * @return The data to write to the blob. - */ - public Flux getDataFlux() { - return this.dataFlux; - } - - /** - * Gets the data source. - * - * @return The data to write to the blob. - */ - public InputStream getDataStream() { - return this.dataStream; - } - - /** - * Gets the length of the data. - * - * @return The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - * @deprecated use {@link #getOptionalLength()} to have safe access to a length that will not always exist. - */ - @Deprecated - public long getLength() { - return length; - } - - /** - * Gets the length of the data. - * - * @return The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - */ - public Long getOptionalLength() { - return length; - } - - /** - * Gets the {@link ParallelTransferOptions}. - * - * @return {@link ParallelTransferOptions} - */ - public ParallelTransferOptions getParallelTransferOptions() { - return parallelTransferOptions; - } - - /** - * Sets the {@link ParallelTransferOptions}. - * - * @param parallelTransferOptions {@link ParallelTransferOptions} - * @return The updated options. - */ - public BlobParallelUploadOptions setParallelTransferOptions(ParallelTransferOptions parallelTransferOptions) { - this.parallelTransferOptions = parallelTransferOptions; - return this; - } - - /** - * Gets the {@link BlobHttpHeaders}. - * - * @return {@link BlobHttpHeaders} - */ - public BlobHttpHeaders getHeaders() { - return headers; - } - - /** - * Sets the {@link BlobHttpHeaders}. - * - * @param headers {@link BlobHttpHeaders} - * @return The updated options - */ - public BlobParallelUploadOptions setHeaders(BlobHttpHeaders headers) { - this.headers = headers; - return this; - } - - /** - * Gets the metadata. - * - * @return The metadata to associate with the blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata. - * - * @param metadata The metadata to associate with the blob. - * @return The updated options. - */ - public BlobParallelUploadOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Get the tags. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Set the tags. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public BlobParallelUploadOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link AccessTier}. - * - * @return {@link AccessTier} - */ - public AccessTier getTier() { - return tier; - } - - /** - * Sets the {@link AccessTier}. - * - * @param tier {@link AccessTier} - * @return The updated options. - */ - public BlobParallelUploadOptions setTier(AccessTier tier) { - this.tier = tier; - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlobParallelUploadOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the computeMd5 property. - * - * @return Whether the library should calculate the md5 and send it for the service to verify. - */ - public boolean isComputeMd5() { - return computeMd5; - } - - /** - * Sets the computeMd5 property. - * - * @param computeMd5 Whether the library should calculate the md5 and send it for the service to - * verify. - * @return The updated options. - */ - public BlobParallelUploadOptions setComputeMd5(boolean computeMd5) { - this.computeMd5 = computeMd5; - return this; - } - - /** - * Gets the timeout. - * - * @return An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @deprecated Use {@link BlobClient#uploadWithResponse(BlobParallelUploadOptions, Duration, Context)} to - * specify timeout. - */ - @Deprecated - public Duration getTimeout() { - return this.timeout; - } - - /** - * Sets the timeout. - * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @return The updated options - * @deprecated Use {@link BlobClient#uploadWithResponse(BlobParallelUploadOptions, Duration, Context)} to - * specify timeout. - */ - @Deprecated - public BlobParallelUploadOptions setTimeout(Duration timeout) { - this.timeout = timeout; - return this; - } - - /** - * Gets the {@link BlobImmutabilityPolicy}. - * - * @return {@link BlobImmutabilityPolicy} - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return immutabilityPolicy; - } - - /** - * Sets the {@link BlobImmutabilityPolicy}. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy} - * @return The updated options. - */ - public BlobParallelUploadOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - this.immutabilityPolicy = immutabilityPolicy; - return this; - } - - /** - * Gets if a legal hold should be placed on the blob. - * - * @return If a legal hold should be placed on the blob. - */ - public Boolean isLegalHold() { - return legalHold; - } - - /** - * Sets if a legal hold should be placed on the blob. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param legalHold Indicates if a legal hold should be placed on the blob. - * @return The updated options. - */ - public BlobParallelUploadOptions setLegalHold(Boolean legalHold) { - this.legalHold = legalHold; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobQueryOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobQueryOptions.java deleted file mode 100644 index a74b775cc23c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobQueryOptions.java +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobQueryError; -import com.azure.storage.blob.models.BlobQueryProgress; -import com.azure.storage.blob.models.BlobQuerySerialization; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.io.OutputStream; -import java.util.function.Consumer; - -/** - * Optional parameters for Blob Query. - */ -@Fluent -public class BlobQueryOptions { - private final String expression; - private final OutputStream outputStream; - private BlobQuerySerialization inputSerialization; - private BlobQuerySerialization outputSerialization; - private BlobRequestConditions requestConditions; - private Consumer errorConsumer; - private Consumer progressConsumer; - - /** - * Constructs a {@link BlobQueryOptions}. - * - * @param expression The query expression. - * @throws NullPointerException If {@code expression} is null. - */ - public BlobQueryOptions(String expression) { - StorageImplUtils.assertNotNull("expression", expression); - this.expression = expression; - this.outputStream = null; - } - - /** - * Constructs a {@link BlobQueryOptions}. - * - * @param expression The query expression. - * @param outputStream The OutputStream where the downloaded data will be written. - * @throws NullPointerException If {@code expression} or {@code outputStream} is null. - */ - public BlobQueryOptions(String expression, OutputStream outputStream) { - StorageImplUtils.assertNotNull("expression", expression); - StorageImplUtils.assertNotNull("outputStream", outputStream); - this.expression = expression; - this.outputStream = outputStream; - } - - /** - * Gets the query expression. - * - * @return the query expression. - */ - public String getExpression() { - return expression; - } - - /** - * Gets the outputStream where the downloaded data will be written. - * - * @return the outputStream. - */ - public OutputStream getOutputStream() { - return this.outputStream; - } - - /** - * Gets the input serialization. - * - * @return the input serialization. - */ - public BlobQuerySerialization getInputSerialization() { - return inputSerialization; - } - - /** - * Sets the input serialization. - * - * @param inputSerialization The input serialization. - * @return the updated BlobQueryOptions object. - */ - public BlobQueryOptions setInputSerialization(BlobQuerySerialization inputSerialization) { - this.inputSerialization = inputSerialization; - return this; - } - - /** - * Gets the output serialization. - * - * @return the output serialization. - */ - public BlobQuerySerialization getOutputSerialization() { - return outputSerialization; - } - - /** - * Sets the output serialization. - * - * @param outputSerialization The output serialization. - * @return the updated BlobQueryOptions object. - */ - public BlobQueryOptions setOutputSerialization(BlobQuerySerialization outputSerialization) { - this.outputSerialization = outputSerialization; - return this; - } - - /** - * Gets the request conditions. - * - * @return the request conditions. - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the request conditions. - * - * @param requestConditions The request conditions. - * @return the updated BlobQueryOptions object. - */ - public BlobQueryOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the error consumer. - * - * @return the error consumer. - */ - public Consumer getErrorConsumer() { - return errorConsumer; - } - - /** - * Sets the error consumer. - * - * @param errorConsumer The error consumer. - * @return the updated BlobQueryOptions object. - */ - public BlobQueryOptions setErrorConsumer(Consumer errorConsumer) { - this.errorConsumer = errorConsumer; - return this; - } - - /** - * Gets the progress consumer. - * - * @return the progress consumer. - */ - public Consumer getProgressConsumer() { - return progressConsumer; - } - - /** - * Sets the progress consumer. - * - * @param progressConsumer The progress consumer. - * @return the updated BlobQueryOptions object. - */ - public BlobQueryOptions setProgressConsumer(Consumer progressConsumer) { - this.progressConsumer = progressConsumer; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobReleaseLeaseOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobReleaseLeaseOptions.java deleted file mode 100644 index 6dea5e276d59..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobReleaseLeaseOptions.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; - -/** - * Extended options that may be passed when releasing a lease to a blob or container. - */ -@Fluent -public class BlobReleaseLeaseOptions { - private BlobLeaseRequestConditions requestConditions; - - /** - * Creates a new instance of {@link BlobReleaseLeaseOptions}. - */ - public BlobReleaseLeaseOptions() { - } - - /** - * Gets the {@link BlobLeaseRequestConditions}. - * - * @return {@link BlobLeaseRequestConditions} - */ - public BlobLeaseRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobLeaseRequestConditions}. - * - * @param requestConditions {@link BlobLeaseRequestConditions} - * @return The updated options. - */ - public BlobReleaseLeaseOptions setRequestConditions(BlobLeaseRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobRenewLeaseOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobRenewLeaseOptions.java deleted file mode 100644 index 848da78af893..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobRenewLeaseOptions.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; - -/** - * Extended options that may be passed when renewing a lease to a blob or container. - */ -@Fluent -public class BlobRenewLeaseOptions { - private BlobLeaseRequestConditions requestConditions; - - /** - * Creates a new instance of {@link BlobRenewLeaseOptions}. - */ - public BlobRenewLeaseOptions() { - } - - /** - * Gets the {@link BlobLeaseRequestConditions}. - * - * @return {@link BlobLeaseRequestConditions} - */ - public BlobLeaseRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobLeaseRequestConditions}. - * - * @param requestConditions {@link BlobLeaseRequestConditions} - * @return The updated options. - */ - public BlobRenewLeaseOptions setRequestConditions(BlobLeaseRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSeekableByteChannelReadOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSeekableByteChannelReadOptions.java deleted file mode 100644 index ac92a1a022b3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSeekableByteChannelReadOptions.java +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.ConsistentReadControl; - -import java.nio.channels.SeekableByteChannel; - -/** - * Extended options that may be passed when opening a blob seekable byte channel for reading. - */ -@Fluent -public final class BlobSeekableByteChannelReadOptions { - private Long initialPosition; - private BlobRequestConditions requestConditions; - private Integer readSizeInBytes; - private ConsistentReadControl consistentReadControl; - - /** - * Creates a new instance of {@link BlobSeekableByteChannelReadOptions}. - */ - public BlobSeekableByteChannelReadOptions() { - } - - /** - * Gets the starting position of the resulting {@link SeekableByteChannel}. The channel will come with a prefetched - * range starting at this position. - * @return Initial position of the resulting channel. - */ - public Long getInitialPosition() { - return initialPosition; - } - - /** - * Sets the starting position of the resulting {@link SeekableByteChannel}. The channel will come with a prefetched - * range starting at this position. - * @param initialPosition Initial position of the resulting channel. - * @return The updated options. - */ - public BlobSeekableByteChannelReadOptions setInitialPosition(Long initialPosition) { - this.initialPosition = initialPosition; - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlobSeekableByteChannelReadOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the size of each data read from the service. If read size is large, the channel will make fewer network - * calls, but each individual call will be larger. The default value is 4 MB. - * - * @return The size of each data read from the service. If read size is large, the channel will make fewer network - * calls, but each individual call will be larger. The default value is 4 MB. - */ - public Integer getReadSizeInBytes() { - return readSizeInBytes; - } - - /** - * Sets the size of each data read from the service. If read size is large, the channel will make fewer network - * calls, but each individual call will be larger. The default value is 4 MB. - * - * @param readSizeInBytes The size of each data read from the service. If read size is large, the channel will make - * fewer network calls, but each individual call will be larger. The default value is 4 MB. - * @return The updated options. - */ - public BlobSeekableByteChannelReadOptions setReadSizeInBytes(Integer readSizeInBytes) { - this.readSizeInBytes = readSizeInBytes; - return this; - } - - /** - * Gets the {@link ConsistentReadControl} Default is E-Tag. - * - * @return {@link ConsistentReadControl} Default is E-Tag. - */ - public ConsistentReadControl getConsistentReadControl() { - return consistentReadControl; - } - - /** - * Sets the {@link ConsistentReadControl} Default is E-Tag. - * - * @param consistentReadControl {@link ConsistentReadControl} Default is E-Tag. - * @return The updated options. - */ - public BlobSeekableByteChannelReadOptions setConsistentReadControl(ConsistentReadControl consistentReadControl) { - this.consistentReadControl = consistentReadControl; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSetAccessTierOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSetAccessTierOptions.java deleted file mode 100644 index a8b7d4706df2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSetAccessTierOptions.java +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.common.implementation.StorageImplUtils; - -/** - * Extended options that may be passed when setting tier for a blob. - */ -@Fluent -public class BlobSetAccessTierOptions { - private final AccessTier tier; - private RehydratePriority priority; - private String leaseId; - private String tagsConditions; - - /** - * Creates a new instance of {@link BlobSetAccessTierOptions}. - * - * @param tier The new tier for the blob. - * @throws NullPointerException If {@code tier} is null. - */ - public BlobSetAccessTierOptions(AccessTier tier) { - StorageImplUtils.assertNotNull("tier", tier); - this.tier = tier; - } - - /** - * Gets the new tier for the blob. - * - * @return The new tier for the blob. - */ - public AccessTier getTier() { - return tier; - } - - /** - * Gets the priority to set for re-hydrating blobs. - * - * @return Priority to set for re-hydrating blobs. - */ - public RehydratePriority getPriority() { - return priority; - } - - /** - * Sets the priority to set for re-hydrating blobs. - * - * @param priority Priority to set for re-hydrating blobs. - * @return The updated BlobSetAccessTierOptions. - */ - public BlobSetAccessTierOptions setPriority(RehydratePriority priority) { - this.priority = priority; - return this; - } - - /** - * Gets the lease ID the active lease on the blob must match. - * - * @return The lease ID the active lease on the blob must match. - */ - public String getLeaseId() { - return leaseId; - } - - /** - * Sets the lease ID the active lease on the blob must match. - * - * @param leaseId The lease ID the active lease on the blob must match. - * @return The updated BlobSetAccessTierOptions. - */ - public BlobSetAccessTierOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - /** - * Gets the SQL statement that apply to the tags of the blob. - * - * @return The SQL statement that apply to the tags of the blob. - */ - public String getTagsConditions() { - return tagsConditions; - } - - /** - * Sets the SQL statement that apply to the tags of the blob. - * - * @param tagsConditions The SQL statement that apply to the tags of the blob. - * @return The updated BlobSetAccessTierOptions. - */ - public BlobSetAccessTierOptions setTagsConditions(String tagsConditions) { - this.tagsConditions = tagsConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSetTagsOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSetTagsOptions.java deleted file mode 100644 index 44f929267d7a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobSetTagsOptions.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.util.Collections; -import java.util.Map; - -/** - * Extended options that may be passed when setting tags for a blob. - */ -@Fluent -public class BlobSetTagsOptions { - private final Map tags; - private BlobRequestConditions requestConditions; - - /** - * Creates a new instance of {@link BlobSetTagsOptions}. - * - * @param tags Tags to associate with the blob. - * @throws NullPointerException If {@code tags} is null. - */ - public BlobSetTagsOptions(Map tags) { - StorageImplUtils.assertNotNull("tags", tags); - this.tags = Collections.unmodifiableMap(tags); - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlobSetTagsOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobUploadFromFileOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobUploadFromFileOptions.java deleted file mode 100644 index 65ca9b0ab052..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobUploadFromFileOptions.java +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.util.Map; - -/** - * Extended options that may be passed when uploading a blob from a file. - */ -@Fluent -public class BlobUploadFromFileOptions { - private final String filePath; - private ParallelTransferOptions parallelTransferOptions; - private BlobHttpHeaders headers; - private Map metadata; - private Map tags; - private AccessTier tier; - private BlobRequestConditions requestConditions; - - /** - * Constructs a {@link BlobUploadFromFileOptions}. - * - * @param filePath Path of the file to upload. - * @throws NullPointerException If {@code filePath} is null. - */ - public BlobUploadFromFileOptions(String filePath) { - StorageImplUtils.assertNotNull("filePath", filePath); - this.filePath = filePath; - } - - /** - * Gets the path of the file to upload. - * - * @return The path of the file to upload - */ - public String getFilePath() { - return filePath; - } - - /** - * Gets the {@link ParallelTransferOptions}. - * - * @return {@link ParallelTransferOptions} - */ - public ParallelTransferOptions getParallelTransferOptions() { - return parallelTransferOptions; - } - - /** - * Sets the {@link ParallelTransferOptions}. - * - * @param parallelTransferOptions {@link ParallelTransferOptions} - * @return The updated options. - */ - public BlobUploadFromFileOptions setParallelTransferOptions(ParallelTransferOptions parallelTransferOptions) { - this.parallelTransferOptions = parallelTransferOptions; - return this; - } - - /** - * Gets the {@link BlobHttpHeaders}. - * - * @return {@link BlobHttpHeaders} - */ - public BlobHttpHeaders getHeaders() { - return headers; - } - - /** - * Sets the {@link BlobHttpHeaders}. - * - * @param headers {@link BlobHttpHeaders} - * @return The updated {@code AppendBlobCreateOptions} - */ - public BlobUploadFromFileOptions setHeaders(BlobHttpHeaders headers) { - this.headers = headers; - return this; - } - - /** - * Gets the metadata to associate with the blob. - * - * @return The metadata to associate with the blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to associate with the blob. - * - * @param metadata The metadata to associate with the blob. - * @return The updated options - */ - public BlobUploadFromFileOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to associate with the blob. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public BlobUploadFromFileOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link AccessTier}. - * - * @return {@link AccessTier} - */ - public AccessTier getTier() { - return tier; - } - - /** - * Sets the {@link AccessTier}. - * - * @param tier {@link AccessTier} - * @return The updated options. - */ - public BlobUploadFromFileOptions setTier(AccessTier tier) { - this.tier = tier; - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlobUploadFromFileOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobUploadFromUrlOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobUploadFromUrlOptions.java deleted file mode 100644 index 17afe7fa6407..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobUploadFromUrlOptions.java +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.http.HttpAuthorization; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobCopySourceTagsMode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.util.Map; - -/** - * Extended options that may be passed when uploading a Block Blob from URL. - */ -public class BlobUploadFromUrlOptions { - private final String sourceUrl; - private BlobHttpHeaders headers; - private Map tags; - private AccessTier tier; - private byte[] contentMd5; - private BlobRequestConditions destinationRequestConditions; - private BlobRequestConditions sourceRequestConditions; - private Boolean copySourceBlobProperties; - private HttpAuthorization sourceAuthorization; - private BlobCopySourceTagsMode copySourceTags; - - /** - * Creates a new instance of {@link BlobUploadFromUrlOptions}. - * - * @param sourceUrl The source URL to upload from. - */ - public BlobUploadFromUrlOptions(String sourceUrl) { - StorageImplUtils.assertNotNull("copySource", sourceUrl); - this.sourceUrl = sourceUrl; - } - - /** - * Gets the source URL to upload from. - * - * @return The source URL to upload from. - */ - public String getSourceUrl() { - return this.sourceUrl; - } - - /** - * Gets the {@link BlobHttpHeaders}. - * - * @return {@link BlobHttpHeaders} - */ - public BlobHttpHeaders getHeaders() { - return headers; - } - - /** - * Sets the {@link BlobHttpHeaders}. - * - * @param headers {@link BlobHttpHeaders} - * @return The updated options - */ - public BlobUploadFromUrlOptions setHeaders(BlobHttpHeaders headers) { - this.headers = headers; - return this; - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to associate with the blob. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public BlobUploadFromUrlOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link AccessTier}. - * - * @return {@link AccessTier} - */ - public AccessTier getTier() { - return tier; - } - - /** - * Sets the {@link AccessTier}. - * - * @param tier {@link AccessTier} - * @return The updated options. - */ - public BlobUploadFromUrlOptions setTier(AccessTier tier) { - this.tier = tier; - return this; - } - - /** - * Gets the MD5 hash of the content. - * - * @return An MD5 hash of the content. This hash is used to verify the integrity of the content during transport. - * When this header is specified, the storage service compares the hash of the content that has arrived with this - * header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the operation - * will fail. - */ - public byte[] getContentMd5() { - return CoreUtils.clone(contentMd5); - } - - /** - * Sets the MD5 hash of the content. - * - * @param contentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @return The updated options - */ - public BlobUploadFromUrlOptions setContentMd5(byte[] contentMd5) { - this.contentMd5 = CoreUtils.clone(contentMd5); - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getDestinationRequestConditions() { - return destinationRequestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param destinationRequestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlobUploadFromUrlOptions - setDestinationRequestConditions(BlobRequestConditions destinationRequestConditions) { - this.destinationRequestConditions = destinationRequestConditions; - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getSourceRequestConditions() { - return sourceRequestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param sourceRequestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlobUploadFromUrlOptions setSourceRequestConditions(BlobRequestConditions sourceRequestConditions) { - this.sourceRequestConditions = sourceRequestConditions; - return this; - } - - /** - * Optional, default is true. Indicates if properties from the source blob should be copied. - * - * @return Whether properties from the source blob should be copied. - */ - public Boolean isCopySourceBlobProperties() { - return copySourceBlobProperties; - } - - /** - * Optional, default is true. Indicates if properties from the source blob should be copied. - * - * @param copySourceBlobProperties Whether properties from the source blob should be copied. - * @return The updated options. - */ - public BlobUploadFromUrlOptions setCopySourceBlobProperties(Boolean copySourceBlobProperties) { - this.copySourceBlobProperties = copySourceBlobProperties; - return this; - } - - /** - * Gets "Authorization" header for accessing source URL. Currently only "Bearer" authentication is accepted by - * Storage. - * - * @return auth header for access to source. - */ - public HttpAuthorization getSourceAuthorization() { - return sourceAuthorization; - } - - /** - * Sets "Authorization" header for accessing source URL. Currently only "Bearer" authentication is accepted by - * Storage. - * - * @param sourceAuthorization auth header for access to source. - * @return The updated options. - */ - public BlobUploadFromUrlOptions setSourceAuthorization(HttpAuthorization sourceAuthorization) { - this.sourceAuthorization = sourceAuthorization; - return this; - } - - /** - * Gets the copy source tags mode - * - * @return The copy source tags mode. - */ - public BlobCopySourceTagsMode getCopySourceTagsMode() { - return copySourceTags; - } - - /** - * Sets the copy source tags mode - * - * @param copySourceTags Indicates if a legal hold should be placed on the blob. - * @return The updated options. - */ - public BlobUploadFromUrlOptions setCopySourceTagsMode(BlobCopySourceTagsMode copySourceTags) { - this.copySourceTags = copySourceTags; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobCommitBlockListOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobCommitBlockListOptions.java deleted file mode 100644 index 0f96aaa63d07..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobCommitBlockListOptions.java +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRequestConditions; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Extended options that may be passed when committing a block list. - */ -@Fluent -public class BlockBlobCommitBlockListOptions { - private final List base64BlockIds; - private BlobHttpHeaders headers; - private Map metadata; - private Map tags; - private AccessTier tier; - private BlobRequestConditions requestConditions; - private BlobImmutabilityPolicy immutabilityPolicy; - private Boolean legalHold; - - /** - * Creates a new instance of {@link BlockBlobCommitBlockListOptions}. - * - * @param base64BlockIds A list of base64 encode {@code String}s that specifies the block IDs to be committed. - */ - public BlockBlobCommitBlockListOptions(List base64BlockIds) { - this.base64BlockIds = base64BlockIds == null ? null : Collections.unmodifiableList(base64BlockIds); - } - - /** - * Gets the list of base64 encode {@code String}s that specifies the block IDs to be committed. - * - * @return A list of base64 encode {@code String}s that specifies the block IDs to be committed. - */ - public List getBase64BlockIds() { - return this.base64BlockIds; - } - - /** - * Gets the {@link BlobHttpHeaders}. - * - * @return {@link BlobHttpHeaders} - */ - public BlobHttpHeaders getHeaders() { - return headers; - } - - /** - * Sets the {@link BlobHttpHeaders}. - * - * @param headers {@link BlobHttpHeaders} - * @return The updated {@code AppendBlobCreateOptions} - */ - public BlockBlobCommitBlockListOptions setHeaders(BlobHttpHeaders headers) { - this.headers = headers; - return this; - } - - /** - * Gets the metadata to associate with the blob. - * - * @return The metadata to associate with the blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to associate with the blob. - * - * @param metadata The metadata to associate with the blob. - * @return The updated options - */ - public BlockBlobCommitBlockListOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to associate with the blob. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public BlockBlobCommitBlockListOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link AccessTier}. - * - * @return {@link AccessTier} - */ - public AccessTier getTier() { - return tier; - } - - /** - * Sets the {@link AccessTier}. - * - * @param tier {@link AccessTier} - * @return The updated options. - */ - public BlockBlobCommitBlockListOptions setTier(AccessTier tier) { - this.tier = tier; - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlockBlobCommitBlockListOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the {@link BlobImmutabilityPolicy}. - * - * @return {@link BlobImmutabilityPolicy} - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return immutabilityPolicy; - } - - /** - * Sets the {@link BlobImmutabilityPolicy}. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy} - * @return The updated options. - */ - public BlockBlobCommitBlockListOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - this.immutabilityPolicy = immutabilityPolicy; - return this; - } - - /** - * Gets if a legal hold should be placed on the blob. - * - * @return If a legal hold should be placed on the blob. - */ - public Boolean isLegalHold() { - return legalHold; - } - - /** - * Sets if a legal hold should be placed on the blob. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param legalHold Indicates if a legal hold should be placed on the blob. - * @return The updated options. - */ - public BlockBlobCommitBlockListOptions setLegalHold(Boolean legalHold) { - this.legalHold = legalHold; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobListBlocksOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobListBlocksOptions.java deleted file mode 100644 index 0c561a03eb21..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobListBlocksOptions.java +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlockListType; - -/** - * Extended options that may be passed when listing blocks for a block blob. - */ -@Fluent -public class BlockBlobListBlocksOptions { - - private final BlockListType type; - private String leaseId; - private String ifTagsMatch; - - /** - * Creates a new instance of {@link BlockBlobListBlocksOptions}. - * - * @param type Specifies which type of blocks to return. - */ - public BlockBlobListBlocksOptions(BlockListType type) { - this.type = type; - } - - /** - * Gets the type of blocks to list. - * - * @return The type of blocks to return. - */ - public BlockListType getType() { - return type; - } - - /** - * Gets the lease ID that blobs and containers must match. - * - * @return The lease ID that blobs and containers must match. - */ - public String getLeaseId() { - return leaseId; - } - - /** - * Optionally limits requests to blobs and containers that match the lease ID. - * - * @param leaseId Lease ID that blobs and containers must match. - * @return The updated BlockBlobListBlocksOptions object. - */ - public BlockBlobListBlocksOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - /** - * Gets the SQL statement that apply to the tags of the blob. - * - * @return The SQL statement that apply to the tags of the blob. - */ - public String getIfTagsMatch() { - return ifTagsMatch; - } - - /** - * Optionally applies the SQL statement to the tags of the blob. - * - * @param ifTagsMatch The SQL statement that apply to the tags of the blob. - * @return The updated BlockBlobListBlocksOptions object. - */ - public BlockBlobListBlocksOptions setIfTagsMatch(String ifTagsMatch) { - this.ifTagsMatch = ifTagsMatch; - return this; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobOutputStreamOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobOutputStreamOptions.java deleted file mode 100644 index e6385dfe5207..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobOutputStreamOptions.java +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.ParallelTransferOptions; - -import java.util.Map; - -/** - * Extended options that may be passed when opening an output stream to a Block Blob. - */ -public class BlockBlobOutputStreamOptions { - private ParallelTransferOptions parallelTransferOptions; - private BlobHttpHeaders headers; - private Map metadata; - private Map tags; - private AccessTier tier; - private BlobRequestConditions requestConditions; - - /** - * Creates a new instance of {@link BlockBlobOutputStreamOptions}. - */ - public BlockBlobOutputStreamOptions() { - } - - /** - * Gets the {@link ParallelTransferOptions}. - * - * @return {@link ParallelTransferOptions} - */ - public ParallelTransferOptions getParallelTransferOptions() { - return parallelTransferOptions; - } - - /** - * Sets the {@link ParallelTransferOptions}. - * - * @param parallelTransferOptions {@link ParallelTransferOptions} - * @return The updated options. - */ - public BlockBlobOutputStreamOptions setParallelTransferOptions(ParallelTransferOptions parallelTransferOptions) { - this.parallelTransferOptions = parallelTransferOptions; - return this; - } - - /** - * Gets the {@link BlobHttpHeaders}. - * - * @return {@link BlobHttpHeaders} - */ - public BlobHttpHeaders getHeaders() { - return headers; - } - - /** - * Sets the {@link BlobHttpHeaders}. - * - * @param headers {@link BlobHttpHeaders} - * @return The updated {@code AppendBlobCreateOptions} - */ - public BlockBlobOutputStreamOptions setHeaders(BlobHttpHeaders headers) { - this.headers = headers; - return this; - } - - /** - * Gets the metadata to associate with the blob. - * - * @return The metadata to associate with the blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to associate with the blob. - * - * @param metadata The metadata to associate with the blob. - * @return The updated options - */ - public BlockBlobOutputStreamOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to associate with the blob. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public BlockBlobOutputStreamOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link AccessTier}. - * - * @return {@link AccessTier} - */ - public AccessTier getTier() { - return tier; - } - - /** - * Sets the {@link AccessTier}. - * - * @param tier {@link AccessTier} - * @return The updated options. - */ - public BlockBlobOutputStreamOptions setTier(AccessTier tier) { - this.tier = tier; - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlockBlobOutputStreamOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSeekableByteChannelWriteOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSeekableByteChannelWriteOptions.java deleted file mode 100644 index 1234ea04c738..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSeekableByteChannelWriteOptions.java +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.options; - -import com.azure.core.util.ExpandableStringEnum; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRequestConditions; - -import java.util.Collection; -import java.util.Map; -import java.util.Objects; - -/** - * Options for obtaining a {@link java.nio.channels.SeekableByteChannel} backed by an Azure Storage Share File. - */ -public final class BlockBlobSeekableByteChannelWriteOptions { - /** - * Mode to open the channel for writing. - */ - public static final class WriteMode extends ExpandableStringEnum { - /** - * Replaces the existing block blob, if any, with the newly written contents. Creates a new blob if none exists. - */ - public static final WriteMode OVERWRITE = fromString("Overwrite"); - - /** - * Creates a new instance of {@link WriteMode} with no string value. - * - * @deprecated Please use {@link #fromString(String)}. - */ - @Deprecated - public WriteMode() { - } - - /** - * Creates or finds a AccessTier from its string representation. - * - * @param name a name to look for. - * @return the corresponding AccessTier. - */ - public static WriteMode fromString(String name) { - return fromString(name, WriteMode.class); - } - - /** - * Gets known WriteMode values. - * - * @return known WriteMode values. - */ - public static Collection values() { - return values(WriteMode.class); - } - } - - private final WriteMode writeMode; - private Long blockSizeInBytes; - private BlobHttpHeaders headers; - private Map metadata; - private Map tags; - private AccessTier tier; - private BlobRequestConditions conditions; - - /** - * Options constructor. - * @param mode What usage mode to open the channel in. - * @throws NullPointerException If {@code mode} is null. - */ - public BlockBlobSeekableByteChannelWriteOptions(WriteMode mode) { - writeMode = Objects.requireNonNull(mode, "'mode' cannot be null."); - } - - /** - * Gets the usage mode to be used by the resulting channel. - * - * @return Usage mode to be used by the resulting channel. - */ - public WriteMode getWriteMode() { - return writeMode; - } - - /** - * Gets the size of individual writes to the service. - * - * @return The size of individual writes to the service. - */ - public Long getBlockSizeInBytes() { - return blockSizeInBytes; - } - - /** - * Sets the size of individual writes to the service. - * - * @param blockSizeInBytes The size of individual writes to the service. - * @return The updated instance. - */ - public BlockBlobSeekableByteChannelWriteOptions setBlockSizeInBytes(Long blockSizeInBytes) { - this.blockSizeInBytes = blockSizeInBytes; - return this; - } - - /** - * Gets the HTTP headers to write. - * - * @return Blob HTTP headers to write. - */ - public BlobHttpHeaders getHeaders() { - return headers; - } - - /** - * Sets the HTTP headers to write. - * - * @param headers Blob HTTP headers to write. - * @return The updated instance. - */ - public BlockBlobSeekableByteChannelWriteOptions setHeaders(BlobHttpHeaders headers) { - this.headers = headers; - return this; - } - - /** - * Gets the metadata to write. - * - * @return Blob metadata to write. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to write. - * - * @param metadata Blob metadata to write. - * @return The updated instance. - */ - public BlockBlobSeekableByteChannelWriteOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the tags to write. - * - * @return Blob tags to write. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to write. - * - * @param tags Blob tags to write. - * @return The updated instance. - */ - public BlockBlobSeekableByteChannelWriteOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the access tier for the target blob. - * - * @return Access tier for the target blob. - */ - public AccessTier getTier() { - return tier; - } - - /** - * Sets the access tier for the target blob. - * - * @param tier Access tier for the target blob. - * @return The updated instance. - */ - public BlockBlobSeekableByteChannelWriteOptions setTier(AccessTier tier) { - this.tier = tier; - return this; - } - - /** - * Gets the request conditions for writing to the blob. - * - * @return Request conditions for writing to the blob. - */ - public BlobRequestConditions getRequestConditions() { - return conditions; - } - - /** - * Sets the request conditions for writing to the blob. - * - * @param conditions Request conditions for writing to the blob. - * @return The updated instance. - */ - public BlockBlobSeekableByteChannelWriteOptions setRequestConditions(BlobRequestConditions conditions) { - this.conditions = conditions; - return this; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSimpleUploadOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSimpleUploadOptions.java deleted file mode 100644 index bef1780c2f59..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSimpleUploadOptions.java +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.util.BinaryData; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Flux; - -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.Map; - -/** - * Extended options that may be passed when uploading a Block Blob in a single request. - */ -public class BlockBlobSimpleUploadOptions { - private final Flux dataFlux; - private final InputStream dataStream; - private final BinaryData data; - private final long length; - private BlobHttpHeaders headers; - private Map metadata; - private Map tags; - private AccessTier tier; - private byte[] contentMd5; - private BlobRequestConditions requestConditions; - private BlobImmutabilityPolicy immutabilityPolicy; - private Boolean legalHold; - - /** - * Creates a new instance of {@link BlockBlobSimpleUploadOptions}. - * - * @param data The data to write to the block. Note that this {@code BinaryData} must have defined length - * and must be replayable if retries are enabled (the default), see {@link BinaryData#isReplayable()}. - * @throws NullPointerException If {@code data} is null or {@code data} does not have defined length. - */ - public BlockBlobSimpleUploadOptions(BinaryData data) { - StorageImplUtils.assertNotNull("data must not be null", data); - StorageImplUtils.assertNotNull("data must have defined length", data.getLength()); - this.data = data; - this.length = data.getLength(); - this.dataFlux = null; - this.dataStream = null; - } - - /** - * Creates a new instance of {@link BlockBlobSimpleUploadOptions}. - * - * @param data The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled - * (the default). In other words, the Flux must produce the same data each time it is subscribed to. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the data source. - * @throws NullPointerException If {@code data} is null. - * @throws IllegalArgumentException If {@code length} is less than 0 or greater than {@link Long#MAX_VALUE}. - */ - public BlockBlobSimpleUploadOptions(Flux data, long length) { - StorageImplUtils.assertNotNull("dataFlux", data); - StorageImplUtils.assertInBounds("length", length, 0, Long.MAX_VALUE); - this.dataFlux = data; - this.length = length; - this.dataStream = null; - this.data = null; - } - - /** - * Creates a new instance of {@link BlockBlobSimpleUploadOptions}. - * - * @param data The data to write to the blob. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the data source. - * @throws NullPointerException If {@code data} is null. - * @throws IllegalArgumentException If {@code length} is less than 0 or greater than {@link Long#MAX_VALUE}. - */ - public BlockBlobSimpleUploadOptions(InputStream data, long length) { - StorageImplUtils.assertNotNull("dataStream", data); - StorageImplUtils.assertInBounds("length", length, 0, Long.MAX_VALUE); - this.dataStream = data; - this.length = length; - this.dataFlux = null; - this.data = null; - } - - /** - * Gets the data to write to the blob. - * - * @return The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled - * (the default). In other words, the Flux must produce the same data each time it is subscribed to. - */ - public Flux getDataFlux() { - return this.dataFlux; - } - - /** - * Gets the data to write to the blob. - * - * @return The data to write to the blob. - */ - public InputStream getDataStream() { - return this.dataStream; - } - - /** - * Gets the data to write to the blob. - * - * @return The data to write to the blob. - */ - public BinaryData getData() { - return this.data; - } - - /** - * Gets the exact length of the data. - * - * @return The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the data source. - */ - public long getLength() { - return this.length; - } - - /** - * Gets the {@link BlobHttpHeaders}. - * - * @return {@link BlobHttpHeaders} - */ - public BlobHttpHeaders getHeaders() { - return headers; - } - - /** - * Sets the {@link BlobHttpHeaders}. - * - * @param headers {@link BlobHttpHeaders} - * @return The updated options - */ - public BlockBlobSimpleUploadOptions setHeaders(BlobHttpHeaders headers) { - this.headers = headers; - return this; - } - - /** - * Gets the metadata to associate with the blob. - * - * @return The metadata to associate with the blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to associate with the blob. - * - * @param metadata The metadata to associate with the blob. - * @return The updated options - */ - public BlockBlobSimpleUploadOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to associate with the blob. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public BlockBlobSimpleUploadOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link AccessTier}. - * - * @return {@link AccessTier} - */ - public AccessTier getTier() { - return tier; - } - - /** - * Sets the {@link AccessTier}. - * - * @param tier {@link AccessTier} - * @return The updated options. - */ - public BlockBlobSimpleUploadOptions setTier(AccessTier tier) { - this.tier = tier; - return this; - } - - /** - * Gets the MD5 hash of the content. - * - * @return An MD5 hash of the content. This hash is used to verify the integrity of the content during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - */ - public byte[] getContentMd5() { - return CoreUtils.clone(contentMd5); - } - - /** - * Sets the MD5 hash of the content. - * - * @param contentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @return The updated options - */ - public BlockBlobSimpleUploadOptions setContentMd5(byte[] contentMd5) { - this.contentMd5 = CoreUtils.clone(contentMd5); - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public BlockBlobSimpleUploadOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the {@link BlobImmutabilityPolicy}. - * - * @return {@link BlobImmutabilityPolicy} - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return immutabilityPolicy; - } - - /** - * Sets the {@link BlobImmutabilityPolicy}. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * @param immutabilityPolicy {@link BlobImmutabilityPolicy} - * @return The updated options. - */ - public BlockBlobSimpleUploadOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - this.immutabilityPolicy = immutabilityPolicy; - return this; - } - - /** - * Gets if a legal hold should be placed on the blob. - * - * @return If a legal hold should be placed on the blob. - */ - public Boolean isLegalHold() { - return legalHold; - } - - /** - * Sets if a legal hold should be placed on the blob. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * @param legalHold Indicates if a legal hold should be placed on the blob. - * @return The updated options. - */ - public BlockBlobSimpleUploadOptions setLegalHold(Boolean legalHold) { - this.legalHold = legalHold; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobStageBlockFromUrlOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobStageBlockFromUrlOptions.java deleted file mode 100644 index 923cc7bd991e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobStageBlockFromUrlOptions.java +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpAuthorization; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; - -/** - * Extended options that may be passed when staging a block from a source URL. - */ -@Fluent -public final class BlockBlobStageBlockFromUrlOptions { - private final String base64BlockId; - private final String sourceUrl; - private BlobRange sourceRange; - private byte[] sourceContentMd5; - private String leaseId; - private BlobRequestConditions sourceRequestConditions; - private HttpAuthorization sourceAuthorization; - - /** - * Creates a new instance of {@link BlockBlobStageBlockFromUrlOptions}. - * - * @param base64BlockId The block ID to assign the new block. - * @param sourceUrl The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - */ - public BlockBlobStageBlockFromUrlOptions(String base64BlockId, String sourceUrl) { - this.base64BlockId = base64BlockId; - this.sourceUrl = sourceUrl; - } - - /** - * Gets the block ID to assign the new block. - * - * @return The block ID to assign the new block. - */ - public String getBase64BlockId() { - return base64BlockId; - } - - /** - * Gets the source URL to upload from. - * - * @return The source URL to upload from. - */ - public String getSourceUrl() { - return sourceUrl; - } - - /** - * Gets the range of bytes to read from the source. - * - * @return Range of bytes to read from the source. - */ - public BlobRange getSourceRange() { - return sourceRange; - } - - /** - * Sets the range of bytes to read from the source. - * - * @param sourceRange Range of bytes to read from the source. - * @return The updated options. - */ - public BlockBlobStageBlockFromUrlOptions setSourceRange(BlobRange sourceRange) { - this.sourceRange = sourceRange; - return this; - } - - /** - * Gets the MD5 of the source content. - * - * @return MD5 of the source content. - */ - public byte[] getSourceContentMd5() { - return CoreUtils.clone(sourceContentMd5); - } - - /** - * Sets the MD5 of the source content. - * - * @param sourceContentMd5 MD5 of the source content. - * @return The updated options. - */ - public BlockBlobStageBlockFromUrlOptions setSourceContentMd5(byte[] sourceContentMd5) { - this.sourceContentMd5 = CoreUtils.clone(sourceContentMd5); - return this; - } - - /** - * Gets the lease ID for accessing source content. - * - * @return Lease ID for accessing source content. - */ - public String getLeaseId() { - return leaseId; - } - - /** - * Sets the lease ID for accessing source content. - * - * @param leaseId Lease ID for accessing source content. - * @return The updated options. - */ - public BlockBlobStageBlockFromUrlOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - /** - * Gets the {@link BlobRequestConditions} for accessing source content. - * - * @return {@link BlobRequestConditions} for accessing source content. - */ - public BlobRequestConditions getSourceRequestConditions() { - return sourceRequestConditions; - } - - /** - * Sets the {@link BlobRequestConditions} for accessing source content. - * - * @param sourceRequestConditions {@link BlobRequestConditions} for accessing source content. - * @return The updated options. - */ - public BlockBlobStageBlockFromUrlOptions setSourceRequestConditions(BlobRequestConditions sourceRequestConditions) { - this.sourceRequestConditions = sourceRequestConditions; - return this; - } - - /** - * Gets "Authorization" header for accessing source URL. Currently only "Bearer" authentication is accepted by - * Storage. - * - * @return auth header to access source. - */ - public HttpAuthorization getSourceAuthorization() { - return sourceAuthorization; - } - - /** - * Sets "Authorization" header for accessing source URL. Currently only "Bearer" authentication is accepted by - * Storage. - * - * @param sourceAuthorization auth header to access source. - * @return The updated options. - */ - public BlockBlobStageBlockFromUrlOptions setSourceAuthorization(HttpAuthorization sourceAuthorization) { - this.sourceAuthorization = sourceAuthorization; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobStageBlockOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobStageBlockOptions.java deleted file mode 100644 index 37445b450a28..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobStageBlockOptions.java +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.BinaryData; -import com.azure.core.util.CoreUtils; -import com.azure.storage.common.implementation.StorageImplUtils; - -/** - * Extended options that may be passed when staging a block. - */ -@Fluent -public final class BlockBlobStageBlockOptions { - private final String base64BlockId; - private final BinaryData data; - private String leaseId; - private byte[] contentMd5; - - /** - * Creates a new instance of {@link BlockBlobStageBlockOptions}. - * - * @param base64BlockId The block ID to assign the new block. - * @param data The data to write to the block. Note that this {@code BinaryData} must have defined length - * and must be replayable if retries are enabled (the default), see {@link BinaryData#isReplayable()}. - * @throws NullPointerException If {@code base64BlockId} or {@code data} is null. - */ - public BlockBlobStageBlockOptions(String base64BlockId, BinaryData data) { - StorageImplUtils.assertNotNull("base64BlockId must not be null", base64BlockId); - StorageImplUtils.assertNotNull("data must not be null", data); - StorageImplUtils.assertNotNull("data must have defined length", data.getLength()); - this.base64BlockId = base64BlockId; - this.data = data; - } - - /** - * Gets the block ID to assign the new block. - * - * @return The block ID to assign the new block. - */ - public String getBase64BlockId() { - return base64BlockId; - } - - /** - * Gets the data to write to the blob. - * - * @return The data to write to the blob. - */ - public BinaryData getData() { - return this.data; - } - - /** - * Gets the lease ID for accessing source content. - * - * @return Lease ID for accessing source content. - */ - public String getLeaseId() { - return leaseId; - } - - /** - * Sets the lease ID for accessing source content. - * - * @param leaseId Lease ID for accessing source content. - * @return The updated options. - */ - public BlockBlobStageBlockOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - /** - * Gets the MD5 of the block content. - * - * @return An MD5 hash of the content. This hash is used to verify the integrity of the content during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - */ - public byte[] getContentMd5() { - return CoreUtils.clone(contentMd5); - } - - /** - * Sets the MD5 of the block content. - * - * @param contentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @return The updated options - */ - public BlockBlobStageBlockOptions setContentMd5(byte[] contentMd5) { - this.contentMd5 = CoreUtils.clone(contentMd5); - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/FindBlobsOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/FindBlobsOptions.java deleted file mode 100644 index 35b00eaf8d40..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/FindBlobsOptions.java +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.time.Duration; - -/** - * Defines options available to configure the behavior of a call to - * {@link com.azure.storage.blob.BlobServiceClient#findBlobsByTags(FindBlobsOptions, Duration, - * com.azure.core.util.Context)} or - * {@link com.azure.storage.blob.BlobServiceAsyncClient#findBlobsByTags(FindBlobsOptions)}. See the constructor - * for details on each of the options. - */ -public class FindBlobsOptions { - private static final ClientLogger LOGGER = new ClientLogger(FindBlobsOptions.class); - - private final String query; - private Integer maxResultsPerPage; - - /** - * Creates a new instance of {@link FindBlobsOptions}. - * - * @param query Filters the results to return only blobs whose tags match the specified expression. - * @throws NullPointerException If {@code query} is null. - */ - public FindBlobsOptions(String query) { - StorageImplUtils.assertNotNull("query", query); - this.query = query; - } - - /** - * Gets the filters the results to return only blobs whose tags match the specified expression. - * - * @return Filters the results to return only blobs whose tags match the specified expression. - */ - public String getQuery() { - return this.query; - } - - /** - * Specifies the maximum number of blobs to return. If the request does not specify maxResultsPerPage or specifies a - * value greater than 5,000, the server will return up to 5,000 items. - * - * @return the number of blobs that will be returned in a single response - */ - public Integer getMaxResultsPerPage() { - return maxResultsPerPage; - } - - /** - * Specifies the maximum number of blobs to return. If the request does not specify maxResultsPerPage or specifies a - * value greater than 5,000, the server will return up to 5,000 items. - * - * @param maxResultsPerPage The number of blobs to returned in a single response - * @return the updated FindBlobsOptions object - * @throws IllegalArgumentException If {@code maxResultsPerPage} is less than or equal to {@code 0}. - */ - public FindBlobsOptions setMaxResultsPerPage(Integer maxResultsPerPage) { - if (maxResultsPerPage != null && maxResultsPerPage <= 0) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("MaxResultsPerPage must be greater than 0.")); - } - this.maxResultsPerPage = maxResultsPerPage; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/ListPageRangesDiffOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/ListPageRangesDiffOptions.java deleted file mode 100644 index 1e22f0263293..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/ListPageRangesDiffOptions.java +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; - -import java.util.Objects; - -/** - * Extended options that may be passed when getting the page ranges diff of a page blob. - */ -@Fluent -public class ListPageRangesDiffOptions { - private final BlobRange range; - private final String previousSnapshot; - private BlobRequestConditions requestConditions; - private Integer pageSize; - - /** - * Creates a new instance of {@link ListPageRangesDiffOptions}. - * - * @param range The range to diff. - * @param previousSnapshot The previous snapshot that will serve as the base of the diff. - * @throws NullPointerException If {@code range} or {@code previousSnapshot} is null. - */ - public ListPageRangesDiffOptions(BlobRange range, String previousSnapshot) { - Objects.requireNonNull(range); - Objects.requireNonNull(previousSnapshot); - this.range = new BlobRange(range.getOffset(), range.getCount()); - this.previousSnapshot = previousSnapshot; - } - - /** - * Gets the range property. - * - * @return The range property. - */ - public BlobRange getRange() { - return range; - } - - /** - * Gets the previousSnapshot property. - * - * @return The previousSnapshot property. - */ - public String getPreviousSnapshot() { - return previousSnapshot; - } - - /** - * Gets the requestConditions property. - * - * @return The requestConditions property. - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the requestConditions property. - * - * @param requestConditions The requestConditions value to set. - * @return The updated object - */ - public ListPageRangesDiffOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the pageSize property. - * - * @return The pageSize property. - */ - public Integer getMaxResultsPerPage() { - return pageSize; - } - - /** - * Sets the pageSize property. - * - * @param pageSize The pageSize value to set. - * @return The updated object - */ - public ListPageRangesDiffOptions setMaxResultsPerPage(Integer pageSize) { - this.pageSize = pageSize; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/ListPageRangesOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/ListPageRangesOptions.java deleted file mode 100644 index 2d4953b3f59e..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/ListPageRangesOptions.java +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; - -import java.util.Objects; - -/** - * Extended options that may be passed when getting the page ranges of a page blob. - */ -@Fluent -public class ListPageRangesOptions { - private final BlobRange range; - private BlobRequestConditions requestConditions; - private Integer pageSize; - - /** - * Creates a new instance of {@link ListPageRangesOptions}. - * - * @param range The range to diff. - * @throws NullPointerException If {@code range} is null. - */ - public ListPageRangesOptions(BlobRange range) { - Objects.requireNonNull(range); - this.range = new BlobRange(range.getOffset(), range.getCount()); - } - - /** - * Gets the range property. - * - * @return The range property. - */ - public BlobRange getRange() { - return range; - } - - /** - * Gets the requestConditions property. - * - * @return The requestConditions property. - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the requestConditions property. - * - * @param requestConditions The requestConditions value to set. - * @return The updated object - */ - public ListPageRangesOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the pageSize property. - * - * @return The pageSize property. - */ - public Integer getMaxResultsPerPage() { - return pageSize; - } - - /** - * Sets the pageSize property. - * - * @param pageSize The pageSize value to set. - * @return The updated object - */ - public ListPageRangesOptions setMaxResultsPerPage(Integer pageSize) { - this.pageSize = pageSize; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCopyIncrementalOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCopyIncrementalOptions.java deleted file mode 100644 index d6962ad4f6b0..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCopyIncrementalOptions.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.blob.models.PageBlobCopyIncrementalRequestConditions; -import com.azure.storage.common.implementation.StorageImplUtils; - -/** - * Extended options that may be passed when incrementally copying a Page Blob. - */ -@Fluent -public class PageBlobCopyIncrementalOptions { - - private final String source; - private final String snapshot; - private PageBlobCopyIncrementalRequestConditions requestConditions; - - /** - * Creates a new instance of {@link PageBlobCopyIncrementalOptions}. - * - * @param source The source page blob. - * @param snapshot The snapshot on the copy source. - * @throws NullPointerException If {@code source} or {@code snapshot} is null. - */ - public PageBlobCopyIncrementalOptions(String source, String snapshot) { - StorageImplUtils.assertNotNull("source", source); - StorageImplUtils.assertNotNull("snapshot", snapshot); - this.source = source; - this.snapshot = snapshot; - } - - /** - * Gets the source page blob. - * - * @return The source page blob. - */ - public String getSource() { - return source; - } - - /** - * Gets the snapshot on the copy source. - * - * @return The snapshot on the copy source. - */ - public String getSnapshot() { - return snapshot; - } - - /** - * Gets the {@link PageBlobCopyIncrementalRequestConditions} for the destination. - * - * @return {@link PageBlobCopyIncrementalRequestConditions} for the destination. - */ - public PageBlobCopyIncrementalRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link PageBlobCopyIncrementalRequestConditions} for the blob. - * - * @param requestConditions {@link PageBlobCopyIncrementalRequestConditions} for the blob. - * @return The updated options. - */ - public PageBlobCopyIncrementalOptions - setRequestConditions(PageBlobCopyIncrementalRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCreateOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCreateOptions.java deleted file mode 100644 index 0ea380380c87..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCreateOptions.java +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRequestConditions; - -import java.util.Map; - -/** - * Extended options that may be passed when creating a Page Blob. - */ -public class PageBlobCreateOptions { - private final long size; - private Long sequenceNumber; - private BlobHttpHeaders headers; - private Map metadata; - private Map tags; - private BlobRequestConditions requestConditions; - private BlobImmutabilityPolicy immutabilityPolicy; - private Boolean legalHold; - - /** - * Creates a new instance of {@link PageBlobCreateOptions}. - * - * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - */ - public PageBlobCreateOptions(long size) { - this.size = size; - } - - /** - * Gets the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a 512-byte boundary. - * - * @return Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - */ - public long getSize() { - return this.size; - } - - /** - * Gets a user-controlled value that you can use to track requests. The value of the sequence number must be - * between 0 and 2^63 - 1.The default value is 0. - * - * @return A user-controlled value that you can use to track requests. The value of the sequence - * number must be between 0 and 2^63 - 1.The default value is 0. - */ - public Long getSequenceNumber() { - return sequenceNumber; - } - - /** - * Sets a user-controlled value that you can use to track requests. The value of the sequence number must be - * between 0 and 2^63 - 1.The default value is 0. - * - * @param sequenceNumber A user-controlled value that you can use to track requests. The value of the sequence - * number must be between 0 and 2^63 - 1.The default value is 0. - * @return The updated options. - */ - public PageBlobCreateOptions setSequenceNumber(Long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - return this; - } - - /** - * Gets the {@link BlobHttpHeaders}. - * - * @return {@link BlobHttpHeaders} - */ - public BlobHttpHeaders getHeaders() { - return headers; - } - - /** - * Sets the {@link BlobHttpHeaders}. - * - * @param headers {@link BlobHttpHeaders} - * @return The updated {@code AppendBlobCreateOptions} - */ - public PageBlobCreateOptions setHeaders(BlobHttpHeaders headers) { - this.headers = headers; - return this; - } - - /** - * Gets the metadata to associate with the blob. - * - * @return The metadata to associate with the blob. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Sets the metadata to associate with the blob. - * - * @param metadata The metadata to associate with the blob. - * @return The updated options. - */ - public PageBlobCreateOptions setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Gets the tags to associate with the blob. - * - * @return The tags to associate with the blob. - */ - public Map getTags() { - return tags; - } - - /** - * Sets the tags to associate with the blob. - * - * @param tags The tags to associate with the blob. - * @return The updated options. - */ - public PageBlobCreateOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Gets the {@link BlobRequestConditions}. - * - * @return {@link BlobRequestConditions} - */ - public BlobRequestConditions getRequestConditions() { - return requestConditions; - } - - /** - * Sets the {@link BlobRequestConditions}. - * - * @param requestConditions {@link BlobRequestConditions} - * @return The updated options. - */ - public PageBlobCreateOptions setRequestConditions(BlobRequestConditions requestConditions) { - this.requestConditions = requestConditions; - return this; - } - - /** - * Gets the {@link BlobImmutabilityPolicy}. - * - * @return {@link BlobImmutabilityPolicy} - */ - public BlobImmutabilityPolicy getImmutabilityPolicy() { - return immutabilityPolicy; - } - - /** - * Sets the {@link BlobImmutabilityPolicy}. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy} - * @return The updated options. - */ - public PageBlobCreateOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - this.immutabilityPolicy = immutabilityPolicy; - return this; - } - - /** - * Gets if a legal hold should be placed on the blob. - * - * @return If a legal hold should be placed on the blob. - */ - public Boolean isLegalHold() { - return legalHold; - } - - /** - * Sets if a legal hold should be placed on the blob. - *

- * Note that this parameter is only applicable to a blob within a container that has immutable storage with - * versioning enabled. - * - * @param legalHold Indicates if a legal hold should be placed on the blob. - * @return The updated options. - */ - public PageBlobCreateOptions setLegalHold(Boolean legalHold) { - this.legalHold = legalHold; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobUploadPagesFromUrlOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobUploadPagesFromUrlOptions.java deleted file mode 100644 index 45b0ea5630e3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobUploadPagesFromUrlOptions.java +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.core.http.HttpAuthorization; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.PageBlobRequestConditions; -import com.azure.storage.blob.models.PageRange; - -/** - * Extended options that may be passed when uploading a page range from a source URL. - */ -@Fluent -public final class PageBlobUploadPagesFromUrlOptions { - private final PageRange range; - private final String sourceUrl; - private Long sourceOffset; - private byte[] sourceContentMd5; - private PageBlobRequestConditions destinationRequestConditions; - private BlobRequestConditions sourceRequestConditions; - private HttpAuthorization sourceAuthorization; - - /** - * Creates a new instance of {@link PageBlobUploadPagesFromUrlOptions}. - * - * @param range The destination page range. Pages must be aligned to 512 byte blocks. - * @param sourceUrl The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - */ - public PageBlobUploadPagesFromUrlOptions(PageRange range, String sourceUrl) { - this.range = range; - this.sourceUrl = sourceUrl; - } - - /** - * Gets the destination page range. - * @return The destination page range. - */ - public PageRange getRange() { - return range; - } - - /** - * Gets the source URL to copy from. - * - * @return the source URL to copy from. - */ - public String getSourceUrl() { - return sourceUrl; - } - - /** - * Gets the offset at source to copy from. - * - * @return Offset at source to copy from. - */ - public Long getSourceOffset() { - return sourceOffset; - } - - /** - * Sets the offset at source to copy from. - * - * @param sourceOffset Offset at source to copy from. - * @return The updated options. - */ - public PageBlobUploadPagesFromUrlOptions setSourceOffset(Long sourceOffset) { - this.sourceOffset = sourceOffset; - return this; - } - - /** - * Gets the content MD5 of source content to copy. - * - * @return Content MD5 of source content to copy. - */ - public byte[] getSourceContentMd5() { - return CoreUtils.clone(sourceContentMd5); - } - - /** - * Sets the content MD5 of source content to copy. - * - * @param sourceContentMd5 Content MD5 of source content to copy. - * @return The updated options. - */ - public PageBlobUploadPagesFromUrlOptions setSourceContentMd5(byte[] sourceContentMd5) { - this.sourceContentMd5 = CoreUtils.clone(sourceContentMd5); - return this; - } - - /** - * Gets {@link PageBlobRequestConditions} for writing to destination. - * - * @return {@link PageBlobRequestConditions} for writing to destination. - */ - public PageBlobRequestConditions getDestinationRequestConditions() { - return destinationRequestConditions; - } - - /** - * Sets {@link PageBlobRequestConditions} for writing to destination. - * - * @param destinationRequestConditions {@link PageBlobRequestConditions} for writing to destination. - * @return The updated options. - */ - public PageBlobUploadPagesFromUrlOptions - setDestinationRequestConditions(PageBlobRequestConditions destinationRequestConditions) { - this.destinationRequestConditions = destinationRequestConditions; - return this; - } - - /** - * Gets {@link BlobRequestConditions} for accessing source content. - * - * @return {@link BlobRequestConditions} for accessing source content. - */ - public BlobRequestConditions getSourceRequestConditions() { - return sourceRequestConditions; - } - - /** - * Sets {@link BlobRequestConditions} for accessing source content. - * - * @param sourceRequestConditions {@link BlobRequestConditions} for accessing source content. - * @return The updated options. - */ - public PageBlobUploadPagesFromUrlOptions setSourceRequestConditions(BlobRequestConditions sourceRequestConditions) { - this.sourceRequestConditions = sourceRequestConditions; - return this; - } - - /** - * Gets "Authorization" header for accessing source URL. Currently only "Bearer" authentication is accepted by - * Storage. - * - * @return auth header for accessing source content. - */ - public HttpAuthorization getSourceAuthorization() { - return sourceAuthorization; - } - - /** - * Sets "Authorization" header for accessing source URL. Currently only "Bearer" authentication is accepted by - * Storage. - * - * @param sourceAuthorization auth header for accessing source content. - * @return The updated options. - */ - public PageBlobUploadPagesFromUrlOptions setSourceAuthorization(HttpAuthorization sourceAuthorization) { - this.sourceAuthorization = sourceAuthorization; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/UndeleteBlobContainerOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/UndeleteBlobContainerOptions.java deleted file mode 100644 index 2660163c1b76..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/UndeleteBlobContainerOptions.java +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.options; - -import com.azure.core.annotation.Fluent; -import com.azure.storage.common.implementation.StorageImplUtils; - -/** - * Extended options that may be passed when restoring a blob container. - */ -@Fluent -public class UndeleteBlobContainerOptions { - private final String deletedContainerName; - private final String deletedContainerVersion; - private String destinationContainerName; - - /** - * Constructs a {@link UndeleteBlobContainerOptions}. - * - * @param deletedContainerName The name of the previously deleted container. - * @param deletedContainerVersion The version of the previously deleted container. - * @throws NullPointerException If {@code deletedContainerName} or {@code deletedContainerVersion} is null. - */ - public UndeleteBlobContainerOptions(String deletedContainerName, String deletedContainerVersion) { - StorageImplUtils.assertNotNull("deletedContainerName", deletedContainerName); - StorageImplUtils.assertNotNull("deletedContainerVersion", deletedContainerVersion); - this.deletedContainerName = deletedContainerName; - this.deletedContainerVersion = deletedContainerVersion; - } - - /** - * Gets the deleted blob container name. - * - * @return The name of the previously deleted container. - */ - public String getDeletedContainerName() { - return deletedContainerName; - } - - /** - * Gets the deleted blob container version. - * - * @return The version of the previously deleted container. - */ - public String getDeletedContainerVersion() { - return deletedContainerVersion; - } - - /** - * Gets the destination blob container name. - * The restored container - * will be renamed to the destinationContainerName. - * If the container associated with provided destinationContainerName - * already exists, the undelete operation will result in a 409 (conflict). - * - * @return The destination blob container name. - * @deprecated Destination container name must match deleted container name - */ - @Deprecated - public String getDestinationContainerName() { - return destinationContainerName; - } - - /** - * Sets the destination blob container name. - * The restored container - * will be renamed to the destinationContainerName. - * If the container associated with provided destinationContainerName - * already exists, the undelete operation will result in a 409 (conflict). - * - * @param destinationContainerName The destination blob container name. - * @return The updated options. - * @deprecated Destination container name must match deleted container name - */ - @Deprecated - public UndeleteBlobContainerOptions setDestinationContainerName(String destinationContainerName) { - this.destinationContainerName = destinationContainerName; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/package-info.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/package-info.java deleted file mode 100644 index c56471eef743..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package containing options model classes used by Azure Storage Blobs. - */ -package com.azure.storage.blob.options; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/package-info.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/package-info.java index 54ad22687275..5b3fee76fd02 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/package-info.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/package-info.java @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator +// Code generated by Microsoft (R) TypeSpec Code Generator. /** - * Package containing the classes for BlobServiceClient. + * Package containing the classes for Blob. */ package com.azure.storage.blob; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobContainerSasPermission.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobContainerSasPermission.java deleted file mode 100644 index e34e3e122fd1..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobContainerSasPermission.java +++ /dev/null @@ -1,409 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.sas; - -import com.azure.storage.common.implementation.Constants; - -import java.util.Locale; - -/** - * This is a helper class to construct a string representing the permissions granted by a ServiceSAS to a container. - * Setting a value to true means that any SAS which uses these permissions will grant permissions for that operation. - * It is possible to construct the permissions string without this class, but the order of the permissions is - * particular and this class guarantees correctness. - */ -public final class BlobContainerSasPermission { - private boolean readPermission; - private boolean addPermission; - private boolean createPermission; - private boolean writePermission; - private boolean deletePermission; - private boolean deleteVersionPermission; - private boolean listPermission; - private boolean tagsPermission; - private boolean movePermission; - private boolean executePermission; - private boolean filterPermission; - private boolean immutabilityPolicyPermission; - - /** - * Initializes an {@code BlobContainerSasPermission} object with all fields set to false. - */ - public BlobContainerSasPermission() { - } - - /** - * Creates an {@code BlobContainerSasPermission} from the specified permissions string. This method will throw an - * {@code IllegalArgumentException} if it encounters a character that does not correspond to a valid permission. - * - * @param permissionString A {@code String} which represents the {@code BlobContainerSasPermission}. - * @return A {@code BlobContainerSasPermission} generated from the given {@code String}. - * @throws IllegalArgumentException If {@code permString} contains a character other than r, a, c, w, d, x, l, t or - * i. - */ - public static BlobContainerSasPermission parse(String permissionString) { - BlobContainerSasPermission permissions = new BlobContainerSasPermission(); - - for (int i = 0; i < permissionString.length(); i++) { - char c = permissionString.charAt(i); - switch (c) { - case 'r': - permissions.readPermission = true; - break; - - case 'a': - permissions.addPermission = true; - break; - - case 'c': - permissions.createPermission = true; - break; - - case 'w': - permissions.writePermission = true; - break; - - case 'd': - permissions.deletePermission = true; - break; - - case 'x': - permissions.deleteVersionPermission = true; - break; - - case 'l': - permissions.listPermission = true; - break; - - case 't': - permissions.tagsPermission = true; - break; - - case 'm': - permissions.movePermission = true; - break; - - case 'e': - permissions.executePermission = true; - break; - - case 'f': - permissions.filterPermission = true; - break; - - case 'i': - permissions.immutabilityPolicyPermission = true; - break; - - default: - throw new IllegalArgumentException(String.format(Locale.ROOT, - Constants.ENUM_COULD_NOT_BE_PARSED_INVALID_VALUE, "Permissions", permissionString, c)); - } - } - return permissions; - } - - /** - * Gets the read permission status. - * - * @return the read permission status - */ - public boolean hasReadPermission() { - return readPermission; - } - - /** - * Sets the read permission status. - * - * @param hasReadPermission Permission status to set - * @return the updated BlobContainerSasPermission object - */ - public BlobContainerSasPermission setReadPermission(boolean hasReadPermission) { - this.readPermission = hasReadPermission; - return this; - } - - /** - * Gets the add permission status. - * - * @return the add permission status - */ - public boolean hasAddPermission() { - return addPermission; - } - - /** - * Sets the add permission status. - * - * @param hasAddPermission Permission status to set - * @return the updated BlobContainerSasPermission object - */ - public BlobContainerSasPermission setAddPermission(boolean hasAddPermission) { - this.addPermission = hasAddPermission; - return this; - } - - /** - * Gets the create permission status. - * - * @return the create permission status - */ - public boolean hasCreatePermission() { - return createPermission; - } - - /** - * Sets the create permission status. - * - * @param hasCreatePermission Permission status to set - * @return the updated BlobContainerSasPermission object - */ - public BlobContainerSasPermission setCreatePermission(boolean hasCreatePermission) { - this.createPermission = hasCreatePermission; - return this; - } - - /** - * Gets the write permission status. - * - * @return the write permission status - */ - public boolean hasWritePermission() { - return writePermission; - } - - /** - * Sets the write permission status. - * - * @param hasWritePermission Permission status to set - * @return the updated BlobContainerSasPermission object - */ - public BlobContainerSasPermission setWritePermission(boolean hasWritePermission) { - this.writePermission = hasWritePermission; - return this; - } - - /** - * Gets the delete permission status. - * - * @return the delete permission status - */ - public boolean hasDeletePermission() { - return deletePermission; - } - - /** - * Sets the delete permission status. - * - * @param hasDeletePermission Permission status to set - * @return the updated BlobContainerSasPermission object - */ - public BlobContainerSasPermission setDeletePermission(boolean hasDeletePermission) { - this.deletePermission = hasDeletePermission; - return this; - } - - /** - * Gets the delete version permission status. - * - * @return the delete version permission status - */ - public boolean hasDeleteVersionPermission() { - return deleteVersionPermission; - } - - /** - * Sets the delete version permission status. - * - * @param hasDeleteVersionPermission Permission status to set - * @return the updated BlobContainerSasPermission object - */ - public BlobContainerSasPermission setDeleteVersionPermission(boolean hasDeleteVersionPermission) { - this.deleteVersionPermission = hasDeleteVersionPermission; - return this; - } - - /** - * Gets the list permission status. - * - * @return the list permission status - */ - public boolean hasListPermission() { - return listPermission; - } - - /** - * Sets the list permission status. - * - * @param hasListPermission Permission status to set - * @return the updated BlobContainerSasPermission object - */ - public BlobContainerSasPermission setListPermission(boolean hasListPermission) { - this.listPermission = hasListPermission; - return this; - } - - /** - * Gets the tags permission status. - * - * @return the tags permission status. - */ - public boolean hasTagsPermission() { - return tagsPermission; - } - - /** - * Sets the tags permission status. - * - * @param tagsPermission Permission status to set - * @return the updated BlobContainerSasPermission object. - */ - public BlobContainerSasPermission setTagsPermission(boolean tagsPermission) { - this.tagsPermission = tagsPermission; - return this; - } - - /** - * Gets the move permission status. - * - * @return the move permission status. - */ - public boolean hasMovePermission() { - return movePermission; - } - - /** - * Sets the move permission status. - * - * @param hasMovePermission Permission status to set - * @return the updated BlobContainerSasPermission object. - */ - public BlobContainerSasPermission setMovePermission(boolean hasMovePermission) { - this.movePermission = hasMovePermission; - return this; - } - - /** - * Gets the execute permission status. - * - * @return the execute permission status. - */ - public boolean hasExecutePermission() { - return executePermission; - } - - /** - * Sets the execute permission status. - * - * @param hasExecutePermission Permission status to set - * @return the updated BlobContainerSasPermission object. - */ - public BlobContainerSasPermission setExecutePermission(boolean hasExecutePermission) { - this.executePermission = hasExecutePermission; - return this; - } - - /** - * Gets the filter permission status. - * - * @return the filter permission status. - */ - public boolean hasFilterPermission() { - return filterPermission; - } - - /** - * Sets the filter permission status. - * - * @param hasFilterPermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobContainerSasPermission setFilterPermission(boolean hasFilterPermission) { - this.filterPermission = hasFilterPermission; - return this; - } - - /** - * Gets the set immutability policy permission status. - * - * @return the set immutability policy permission status. - */ - public boolean hasImmutabilityPolicyPermission() { - return immutabilityPolicyPermission; - } - - /** - * Sets the set immutability policy permission status. - * - * @param immutabilityPolicyPermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobContainerSasPermission setImmutabilityPolicyPermission(boolean immutabilityPolicyPermission) { - this.immutabilityPolicyPermission = immutabilityPolicyPermission; - return this; - } - - /** - * Converts the given permissions to a {@code String}. Using this method will guarantee the permissions are in an - * order accepted by the service. - * - * @return A {@code String} which represents the {@code BlobContainerSasPermission}. - */ - @Override - public String toString() { - // The order of the characters should be as specified here to ensure correctness: - // https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas - final StringBuilder builder = new StringBuilder(); - - if (this.readPermission) { - builder.append('r'); - } - - if (this.addPermission) { - builder.append('a'); - } - - if (this.createPermission) { - builder.append('c'); - } - - if (this.writePermission) { - builder.append('w'); - } - - if (this.deletePermission) { - builder.append('d'); - } - - if (this.deleteVersionPermission) { - builder.append('x'); - } - - if (this.listPermission) { - builder.append('l'); - } - - if (this.tagsPermission) { - builder.append('t'); - } - - if (this.movePermission) { - builder.append('m'); - } - - if (this.executePermission) { - builder.append('e'); - } - - if (this.filterPermission) { - builder.append('f'); - } - - if (this.immutabilityPolicyPermission) { - builder.append('i'); - } - - return builder.toString(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasPermission.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasPermission.java deleted file mode 100644 index 26767e7389bf..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasPermission.java +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.sas; - -import com.azure.storage.common.implementation.Constants; - -import java.util.Locale; - -/** - * This is a helper class to construct a string representing the permissions granted by a ServiceSAS to a blob. Setting - * a value to true means that any SAS which uses these permissions will grant permissions for that operation. It is - * possible to construct the permissions string without this class, but the order of the permissions is particular and - * this class guarantees correctness. - */ -public final class BlobSasPermission { - private boolean readPermission; - private boolean addPermission; - private boolean createPermission; - private boolean writePermission; - private boolean deletePermission; - private boolean deleteVersionPermission; - private boolean permanentDeletePermission; - private boolean tagsPermission; - private boolean listPermission; - private boolean movePermission; - private boolean executePermission; - private boolean immutabilityPolicyPermission; - - /** - * Initializes a {@code BlobSasPermission} object with all fields set to false. - */ - public BlobSasPermission() { - } - - /** - * Creates a {@code BlobSasPermission} from the specified permissions string. This method will throw an - * {@code IllegalArgumentException} if it encounters a character that does not correspond to a valid permission. - * - * @param permissionString A {@code String} which represents the {@code BlobSasPermission}. - * @return A {@code BlobSasPermission} generated from the given {@code String}. - * @throws IllegalArgumentException If {@code permString} contains a character other than r, a, c, w, d, x, l, t, - * m, e or i. - */ - public static BlobSasPermission parse(String permissionString) { - BlobSasPermission permissions = new BlobSasPermission(); - - for (int i = 0; i < permissionString.length(); i++) { - char c = permissionString.charAt(i); - switch (c) { - case 'r': - permissions.readPermission = true; - break; - - case 'a': - permissions.addPermission = true; - break; - - case 'c': - permissions.createPermission = true; - break; - - case 'w': - permissions.writePermission = true; - break; - - case 'd': - permissions.deletePermission = true; - break; - - case 'x': - permissions.deleteVersionPermission = true; - break; - - case 'y': - permissions.permanentDeletePermission = true; - break; - - case 't': - permissions.tagsPermission = true; - break; - - case 'l': - permissions.listPermission = true; - break; - - case 'm': - permissions.movePermission = true; - break; - - case 'e': - permissions.executePermission = true; - break; - - case 'i': - permissions.immutabilityPolicyPermission = true; - break; - - default: - throw new IllegalArgumentException(String.format(Locale.ROOT, - Constants.ENUM_COULD_NOT_BE_PARSED_INVALID_VALUE, "Permissions", permissionString, c)); - } - } - return permissions; - } - - /** - * Gets the read permission status. - * - * @return the read permission status. - */ - public boolean hasReadPermission() { - return readPermission; - } - - /** - * Sets the read permission status. - * - * @param hasReadPermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setReadPermission(boolean hasReadPermission) { - this.readPermission = hasReadPermission; - return this; - } - - /** - * Gets the add permission status. - * - * @return the add permission status. - */ - public boolean hasAddPermission() { - return addPermission; - } - - /** - * Sets the add permission status. - * - * @param hasAddPermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setAddPermission(boolean hasAddPermission) { - this.addPermission = hasAddPermission; - return this; - } - - /** - * Gets the create permission status. - * - * @return the create permission status. - */ - public boolean hasCreatePermission() { - return createPermission; - } - - /** - * Sets the create permission status. - * - * @param hasCreatePermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setCreatePermission(boolean hasCreatePermission) { - this.createPermission = hasCreatePermission; - return this; - } - - /** - * Gets the write permission status. - * - * @return the write permission status. - */ - public boolean hasWritePermission() { - return writePermission; - } - - /** - * Sets the write permission status. - * - * @param hasWritePermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setWritePermission(boolean hasWritePermission) { - this.writePermission = hasWritePermission; - return this; - } - - /** - * Gets the delete permission status. - * - * @return the delete permission status. - */ - public boolean hasDeletePermission() { - return deletePermission; - } - - /** - * Sets the delete permission status. - * - * @param hasDeletePermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setDeletePermission(boolean hasDeletePermission) { - this.deletePermission = hasDeletePermission; - return this; - } - - /** - * Gets the delete version permission status. - * - * @return the delete version permission status. - */ - public boolean hasDeleteVersionPermission() { - return deleteVersionPermission; - } - - /** - * Sets the delete version permission status. - * - * @param hasDeleteVersionPermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setDeleteVersionPermission(boolean hasDeleteVersionPermission) { - this.deleteVersionPermission = hasDeleteVersionPermission; - return this; - } - - /** - * Gets the permanent delete permission status. - * - * @return the permanent delete permission status. - */ - public boolean hasPermanentDeletePermission() { - return permanentDeletePermission; - } - - /** - * Sets the permanent delete permission status. - * - * @param permanentDeletePermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setPermanentDeletePermission(boolean permanentDeletePermission) { - this.permanentDeletePermission = permanentDeletePermission; - return this; - } - - /** - * Gets the tags permission status. - * - * @return the tags permission status. - */ - public boolean hasTagsPermission() { - return tagsPermission; - } - - /** - * Sets the tags permission status. - * - * @param tagsPermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setTagsPermission(boolean tagsPermission) { - this.tagsPermission = tagsPermission; - return this; - } - - /** - * Gets the list permission status. - * - * @return the list permission status. - */ - public boolean hasListPermission() { - return listPermission; - } - - /** - * Sets the list permission status. - * - * @param hasListPermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setListPermission(boolean hasListPermission) { - this.listPermission = hasListPermission; - return this; - } - - /** - * Gets the move permission status. - * - * @return the move permission status. - */ - public boolean hasMovePermission() { - return movePermission; - } - - /** - * Sets the move permission status. - * - * @param hasMovePermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setMovePermission(boolean hasMovePermission) { - this.movePermission = hasMovePermission; - return this; - } - - /** - * Gets the execute permission status. - * - * @return the execute permission status. - */ - public boolean hasExecutePermission() { - return executePermission; - } - - /** - * Sets the execute permission status. - * - * @param hasExecutePermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setExecutePermission(boolean hasExecutePermission) { - this.executePermission = hasExecutePermission; - return this; - } - - /** - * Gets the set immutability policy permission status. - * - * @return the set immutability policy permission status. - */ - public boolean hasImmutabilityPolicyPermission() { - return immutabilityPolicyPermission; - } - - /** - * Sets the set immutability policy permission status. - * - * @param immutabilityPolicyPermission Permission status to set - * @return the updated BlobSasPermission object. - */ - public BlobSasPermission setImmutabilityPolicyPermission(boolean immutabilityPolicyPermission) { - this.immutabilityPolicyPermission = immutabilityPolicyPermission; - return this; - } - - /** - * Converts the given permissions to a {@code String}. Using this method will guarantee the permissions are in an - * order accepted by the service. - * - * @return A {@code String} which represents the {@code BlobSasPermission}. - */ - @Override - public String toString() { - // The order of the characters should be as specified here to ensure correctness: - // https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas - - final StringBuilder builder = new StringBuilder(); - - if (this.readPermission) { - builder.append('r'); - } - - if (this.addPermission) { - builder.append('a'); - } - - if (this.createPermission) { - builder.append('c'); - } - - if (this.writePermission) { - builder.append('w'); - } - - if (this.deletePermission) { - builder.append('d'); - } - - if (this.deleteVersionPermission) { - builder.append('x'); - } - - if (this.permanentDeletePermission) { - builder.append('y'); - } - - if (this.listPermission) { - builder.append('l'); - } - - if (this.tagsPermission) { - builder.append('t'); - } - - if (this.movePermission) { - builder.append('m'); - } - - if (this.executePermission) { - builder.append('e'); - } - - if (this.immutabilityPolicyPermission) { - builder.append('i'); - } - - return builder.toString(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasServiceVersion.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasServiceVersion.java deleted file mode 100644 index a751d11e5585..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasServiceVersion.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.sas; - -import com.azure.core.util.ServiceVersion; - -/** - * The versions of Azure Storage Blob Sas supported by this client library. - * @deprecated The version is set to the latest version of sas. - */ -@Deprecated -public enum BlobSasServiceVersion implements ServiceVersion { - /** - * Service version {@code 2019-02-02}. - */ - V2019_02_02("2019-02-02"), - - /** - * Service version {@code 2019-07-07}. - */ - V2019_07_07("2019-07-07"), - - /** - * Service version {@code 2019-12-12}. - */ - V2019_12_12("2019-12-12"), - - /** - * Service version {@code 2020-02-10}. - */ - V2020_02_10("2020-02-10"), - - /** - * Service version {@code 2020-04-08}. - */ - V2020_04_08("2020-04-08"), - - /** - * Service version {@code 2020-06-12}. - */ - V2020_06_12("2020-06-12"), - - /** - * Service version {@code 2020-08-04}. - */ - V2020_08_04("2020-08-04"); - - private final String version; - - BlobSasServiceVersion(String version) { - this.version = version; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVersion() { - return this.version; - } - - /** - * Gets the latest Sas service version supported by this client library - * - * @return the latest {@link BlobSasServiceVersion} - */ - public static BlobSasServiceVersion getLatest() { - return V2020_08_04; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java deleted file mode 100644 index 79f74ece8239..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.sas; - -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.BlobClientBuilder; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.sas.BaseSasQueryParameters; -import com.azure.storage.common.sas.SasProtocol; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.sas.SasIpRange; - -import java.time.OffsetDateTime; -import java.util.Map; - -/** - * Represents the components that make up an Azure Storage SAS' query parameters. This type is not constructed directly - * by the user; it is only generated by the {@link BlobServiceSasSignatureValues} type. Once generated, it can be set on - * a {@link BlobClientBuilder} object to be constructed as part of a URL or it can be encoded into a {@code String} and - * appended to a URL directly (though caution should be taken here in case there are existing query parameters, which - * might affect the appropriate means of appending these query parameters). NOTE: Instances of this class are immutable - * to ensure thread safety. - * @deprecated Please use the generateSas method on the desired blob/container client after initializing - * {@link BlobServiceSasSignatureValues}. - */ -@Deprecated -public final class BlobServiceSasQueryParameters extends BaseSasQueryParameters { - - private final String identifier; - - private final String keyObjectId; - - private final String keyTenantId; - - private final OffsetDateTime keyStart; - - private final OffsetDateTime keyExpiry; - - private final String keyService; - - private final String keyVersion; - - private final String resource; - - private final String cacheControl; - - private final String contentDisposition; - - private final String contentEncoding; - - private final String contentLanguage; - - private final String contentType; - - /** - * Creates a new {@link BlobServiceSasQueryParameters} object. - * - * @param queryParamsMap All query parameters for the request as key-value pairs - * @param removeSasParametersFromMap When {@code true}, the SAS query parameters will be removed from - * queryParamsMap - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public BlobServiceSasQueryParameters(Map queryParamsMap, boolean removeSasParametersFromMap) { - super(queryParamsMap, removeSasParametersFromMap); - this.identifier = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_IDENTIFIER, - removeSasParametersFromMap); - this.keyObjectId = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_OBJECT_ID, - removeSasParametersFromMap); - this.keyTenantId = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_TENANT_ID, - removeSasParametersFromMap); - this.keyStart = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_KEY_START, - removeSasParametersFromMap, StorageImplUtils::parseDateAndFormat).getDateTime(); - this.keyExpiry = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_KEY_EXPIRY, - removeSasParametersFromMap, StorageImplUtils::parseDateAndFormat).getDateTime(); - this.keyService = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_KEY_SERVICE, - removeSasParametersFromMap); - this.keyVersion = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_KEY_VERSION, - removeSasParametersFromMap); - this.resource - = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_RESOURCE, removeSasParametersFromMap); - this.cacheControl - = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_CACHE_CONTROL, removeSasParametersFromMap); - this.contentDisposition = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_CONTENT_DISPOSITION, - removeSasParametersFromMap); - this.contentEncoding = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_CONTENT_ENCODING, - removeSasParametersFromMap); - this.contentLanguage = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_CONTENT_LANGUAGE, - removeSasParametersFromMap); - this.contentType - = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_CONTENT_TYPE, removeSasParametersFromMap); - } - - /** - * Creates a new {@link BlobServiceSasQueryParameters} object. These objects are only created internally by - * SASSignatureValues classes. - * - * @param version A {@code String} representing the storage version. - * @param protocol A {@code String} representing the allowed HTTP protocol(s) or {@code null}. - * @param startTime A {@code java.util.Date} representing the start time for this SAS token or {@code null}. - * @param expiryTime A {@code java.util.Date} representing the expiry time for this SAS token. - * @param sasIpRange A {@link SasIpRange} representing the range of valid IP addresses for this SAS token or - * {@code null}. - * @param identifier A {@code String} representing the signed identifier (only for Service SAS) or {@code null}. - * @param resource A {@code String} representing the storage container or blob (only for Service SAS). - * @param permissions A {@code String} representing the storage permissions or {@code null}. - * @param signature A {@code String} representing the signature for the SAS token. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - BlobServiceSasQueryParameters(String version, SasProtocol protocol, OffsetDateTime startTime, - OffsetDateTime expiryTime, SasIpRange sasIpRange, String identifier, String resource, String permissions, - String signature, String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, String contentType, UserDelegationKey key) { - super(version, protocol, startTime, expiryTime, sasIpRange, permissions, signature); - - this.identifier = identifier; - this.resource = resource; - this.cacheControl = cacheControl; - this.contentDisposition = contentDisposition; - this.contentEncoding = contentEncoding; - this.contentLanguage = contentLanguage; - this.contentType = contentType; - - if (key != null) { - this.keyObjectId = key.getSignedObjectId(); - this.keyTenantId = key.getSignedTenantId(); - this.keyStart = key.getSignedStart(); - this.keyExpiry = key.getSignedExpiry(); - this.keyService = key.getSignedService(); - this.keyVersion = key.getSignedVersion(); - } else { - this.keyObjectId = null; - this.keyTenantId = null; - this.keyStart = null; - this.keyExpiry = null; - this.keyService = null; - this.keyVersion = null; - } - } - - /** - * @return The signed identifier (only for {@link BlobServiceSasSignatureValues}) or {@code null}. Please see - * here - * for more information. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getIdentifier() { - return identifier; - } - - /** - * @return The storage container or blob (only for {@link BlobServiceSasSignatureValues}). - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getResource() { - return resource; - } - - /** - * @return The Cache-Control header value when a client accesses the resource with this sas token. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getCacheControl() { - return cacheControl; - } - - /** - * @return The Content-Disposition header value when a client accesses the resource with this sas token. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getContentDisposition() { - return contentDisposition; - } - - /** - * @return The Content-Encoding header value when a client accesses the resource with this sas token. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getContentEncoding() { - return contentEncoding; - } - - /** - * @return The Content-Language header value when a client accesses the resource with this sas token. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getContentLanguage() { - return contentLanguage; - } - - /** - * @return The Content-Type header value when a client accesses the resource with this sas token. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getContentType() { - return contentType; - } - - /** - * @return the object ID of the key. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getKeyObjectId() { - return keyObjectId; - } - - /** - * @return the tenant ID of the key. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getKeyTenantId() { - return keyTenantId; - } - - /** - * @return the datetime when the key becomes active. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public OffsetDateTime getKeyStart() { - return keyStart; - } - - /** - * @return the datetime when the key expires. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public OffsetDateTime getKeyExpiry() { - return keyExpiry; - } - - /** - * @return the services that are permitted by the key. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getKeyService() { - return keyService; - } - - /** - * @return the service version that created the key. - * @deprecated Please use {@link BlobServiceSasSignatureValues} - */ - @Deprecated - public String getKeyVersion() { - return keyVersion; - } - - @Deprecated - UserDelegationKey userDelegationKey() { - return new UserDelegationKey().setSignedExpiry(this.keyExpiry) - .setSignedObjectId(this.keyObjectId) - .setSignedService(this.keyService) - .setSignedStart(this.keyStart) - .setSignedTenantId(this.keyTenantId) - .setSignedVersion(this.keyVersion); - } - - /** - * Encodes all SAS query parameters into a string that can be appended to a URL. - * - * @return A {@code String} representing the SAS query parameters. - * @deprecated Please use the generateSas method on the desired blob/container client after initializing - * {@link BlobServiceSasSignatureValues}. - */ - @Deprecated - public String encode() { - /* - We should be url-encoding each key and each value, but because we know all the keys and values will encode to - themselves, we cheat except for the signature value. - */ - StringBuilder sb = new StringBuilder(); - - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SERVICE_VERSION, this.version); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_PROTOCOL, this.protocol); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_START_TIME, formatQueryParameterDate(this.startTime)); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_EXPIRY_TIME, formatQueryParameterDate(this.expiryTime)); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_IP_RANGE, this.sasIpRange); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_IDENTIFIER, this.identifier); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_OBJECT_ID, this.keyObjectId); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_TENANT_ID, this.keyTenantId); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_START, - formatQueryParameterDate(this.keyStart)); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_EXPIRY, - formatQueryParameterDate(this.keyExpiry)); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_SERVICE, this.keyService); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_VERSION, this.keyVersion); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_RESOURCE, this.resource); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_PERMISSIONS, this.permissions); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNATURE, this.signature); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CACHE_CONTROL, this.cacheControl); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_DISPOSITION, this.contentDisposition); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_ENCODING, this.contentEncoding); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_LANGUAGE, this.contentLanguage); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_TYPE, this.contentType); - - return sb.toString(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasSignatureValues.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasSignatureValues.java deleted file mode 100644 index 113672d9522c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasSignatureValues.java +++ /dev/null @@ -1,766 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.sas; - -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.sas.SasIpRange; -import com.azure.storage.common.sas.SasProtocol; - -import java.time.OffsetDateTime; - -/** - * Used to initialize parameters for a Shared Access Signature (SAS) for an Azure Blob Storage service. Once all the - * values here are set, use the appropriate SAS generation method on the desired container/blob client to obtain a - * representation of the SAS which can then be applied to a new client using the .sasToken(String) method on the - * desired client builder. - * - * @see Storage SAS overview - * @see Constructing a Service - * SAS - * @see Constructing a - * User Delegation SAS - */ -public final class BlobServiceSasSignatureValues { - /** - * The SAS blob constant. - */ - private static final String SAS_BLOB_CONSTANT = "b"; - - /** - * The SAS blob snapshot constant. - */ - private static final String SAS_BLOB_SNAPSHOT_CONSTANT = "bs"; - - /** - * The SAS blob container constant. - */ - private static final String SAS_CONTAINER_CONSTANT = "c"; - - private static final ClientLogger LOGGER = new ClientLogger(BlobServiceSasSignatureValues.class); - - private static final String VERSION = Configuration.getGlobalConfiguration() - .get(Constants.PROPERTY_AZURE_STORAGE_SAS_SERVICE_VERSION, BlobServiceVersion.getLatest().getVersion()); - - /** - * Pin down to highest version that worked with string to sign defined here. - */ - private static final String VERSION_DEPRECATED_SHARED_KEY_SAS_STRING_TO_SIGN - = Configuration.getGlobalConfiguration() - .get(Constants.PROPERTY_AZURE_STORAGE_SAS_SERVICE_VERSION, BlobServiceVersion.V2020_10_02.getVersion()); - - /** - * Pin down to highest version that worked with string to sign defined here. - */ - private static final String VERSION_DEPRECATED_USER_DELEGATION_SAS_STRING_TO_SIGN - = Configuration.getGlobalConfiguration() - .get(Constants.PROPERTY_AZURE_STORAGE_SAS_SERVICE_VERSION, BlobServiceVersion.V2019_12_12.getVersion()); - - private SasProtocol protocol; - private OffsetDateTime startTime; - private OffsetDateTime expiryTime; - private String permissions; - private SasIpRange sasIpRange; - private String containerName; - private String blobName; - private String resource; - private String snapshotId; - private String identifier; - private String cacheControl; - private String contentDisposition; - private String contentEncoding; - private String contentLanguage; - private String contentType; - private String preauthorizedAgentObjectId; /* saoid */ - private String correlationId; - private String encryptionScope; - - /** - * Creates an object with empty values for all fields. - * - * @deprecated Please use {@link #BlobServiceSasSignatureValues(String)}, - * {@link #BlobServiceSasSignatureValues(OffsetDateTime, BlobSasPermission)}, or - * {@link #BlobServiceSasSignatureValues(OffsetDateTime, BlobContainerSasPermission)} - */ - @Deprecated - public BlobServiceSasSignatureValues() { - } - - /** - * Creates an object with the specified expiry time and permissions - * - * @param expiryTime The time after which the SAS will no longer work. - * @param permissions {@link BlobContainerSasPermission} allowed by the SAS. - */ - public BlobServiceSasSignatureValues(OffsetDateTime expiryTime, BlobContainerSasPermission permissions) { - StorageImplUtils.assertNotNull("expiryTime", expiryTime); - StorageImplUtils.assertNotNull("permissions", permissions); - this.expiryTime = expiryTime; - this.permissions = permissions.toString(); - } - - /** - * Creates an object with the specified expiry time and permissions - * - * @param expiryTime When the SAS will no longer work - * @param permissions {@link BlobSasPermission} allowed by the SAS - */ - public BlobServiceSasSignatureValues(OffsetDateTime expiryTime, BlobSasPermission permissions) { - StorageImplUtils.assertNotNull("expiryTime", expiryTime); - StorageImplUtils.assertNotNull("permissions", permissions); - this.expiryTime = expiryTime; - this.permissions = permissions.toString(); - } - - /** - * Creates an object with the specified identifier. - * NOTE: Identifier can not be used for a {@link UserDelegationKey} SAS. - * - * @param identifier Name of the access policy - */ - public BlobServiceSasSignatureValues(String identifier) { - StorageImplUtils.assertNotNull("identifier", identifier); - this.identifier = identifier; - } - - /** - * Creates an object with the specified values. - * - * @param version The version of the service this SAS will target. If not specified, it will default to the version - * targeted by the library. - * @param sasProtocol The {@link SasProtocol} which determines the protocols allowed by the SAS. - * @param startTime When the SAS will take effect. - * @param expiryTime The time after which the SAS will no longer work. - * @param permission The permissions string allowed by the SAS. - * @param sasIpRange The {@link SasIpRange} which determines the IP ranges that are allowed to use the SAS. - * @param identifier The name of the access policy on the container this SAS references if any. - * @param cacheControl The cache-control header for the SAS. - * @param contentDisposition The content-disposition header for the SAS. - * @param contentEncoding The content-encoding header for the SAS. - * @param contentLanguage The content-language header for the SAS. - * @param contentType The content-type header for the SAS. - * @deprecated Please use {@link #BlobServiceSasSignatureValues(String)}, - * {@link #BlobServiceSasSignatureValues(OffsetDateTime, BlobSasPermission)}, or - * {@link #BlobServiceSasSignatureValues(OffsetDateTime, BlobContainerSasPermission)} - * followed by calls to the desired setters. - */ - @Deprecated - public BlobServiceSasSignatureValues(String version, SasProtocol sasProtocol, OffsetDateTime startTime, - OffsetDateTime expiryTime, String permission, SasIpRange sasIpRange, String identifier, String cacheControl, - String contentDisposition, String contentEncoding, String contentLanguage, String contentType) { - this.protocol = sasProtocol; - this.startTime = startTime; - this.expiryTime = expiryTime; - this.permissions = permission; - this.sasIpRange = sasIpRange; - this.identifier = identifier; - this.cacheControl = cacheControl; - this.contentDisposition = contentDisposition; - this.contentEncoding = contentEncoding; - this.contentLanguage = contentLanguage; - this.contentType = contentType; - } - - /** - * Gets the version of the service this SAS will target. If not specified, it will default to the version targeted - * by the library. - * - * @return the version of the service this SAS will target. If not specified, it will default to the version - * targeted by the library. - */ - public String getVersion() { - return VERSION; - } - - /** - * Sets the version of the service this SAS will target. If not specified, it will default to the version targeted - * by the library. - * - * @param version Version to target - * @return the updated BlobServiceSASSignatureValues object - * @deprecated The version is set to the latest version of sas. Users should stop calling this API as it is now - * treated as a no-op. - */ - @Deprecated - public BlobServiceSasSignatureValues setVersion(String version) { - /* No-op.*/ - return this; - } - - /** - * Gets the {@link SasProtocol} which determines the protocols allowed by the SAS. - * - * @return the {@link SasProtocol} which determines the protocols allowed by the SAS. - */ - public SasProtocol getProtocol() { - return protocol; - } - - /** - * Sets the {@link SasProtocol} which determines the protocols allowed by the SAS. - * - * @param protocol Protocol for the SAS - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setProtocol(SasProtocol protocol) { - this.protocol = protocol; - return this; - } - - /** - * Gets when the SAS will take effect. - * - * @return when the SAS will take effect. - */ - public OffsetDateTime getStartTime() { - return startTime; - } - - /** - * Sets when the SAS will take effect. - * - * @param startTime When the SAS takes effect - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setStartTime(OffsetDateTime startTime) { - this.startTime = startTime; - return this; - } - - /** - * Gets the time after which the SAS will no longer work. - * - * @return the time after which the SAS will no longer work. - */ - public OffsetDateTime getExpiryTime() { - return expiryTime; - } - - /** - * Sets the time after which the SAS will no longer work. - * - * @param expiryTime When the SAS will no longer work - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setExpiryTime(OffsetDateTime expiryTime) { - this.expiryTime = expiryTime; - return this; - } - - /** - * Gets the permissions string allowed by the SAS. Please refer to either {@link BlobContainerSasPermission} or - * {@link BlobSasPermission} depending on the resource being accessed for help determining the permissions allowed. - * - * @return the permissions string allowed by the SAS. Please refer to either {@link BlobContainerSasPermission} or - * {@link BlobSasPermission} depending on the resource being accessed for help determining the permissions allowed. - */ - public String getPermissions() { - return permissions; - } - - /** - * Sets the Blob permissions allowed by the SAS. - * - * @param permissions {@link BlobSasPermission} - * @return the updated BlobServiceSASSignatureValues object - * @throws NullPointerException if {@code permissions} is null. - */ - public BlobServiceSasSignatureValues setPermissions(BlobSasPermission permissions) { - StorageImplUtils.assertNotNull("permissions", permissions); - this.permissions = permissions.toString(); - return this; - } - - /** - * Sets the Container permissions allowed by the SAS. - * - * @param permissions {@link BlobContainerSasPermission} - * @return the updated BlobServiceSASSignatureValues object - * @throws NullPointerException if {@code permissions} is null. - */ - public BlobServiceSasSignatureValues setPermissions(BlobContainerSasPermission permissions) { - StorageImplUtils.assertNotNull("permissions", permissions); - this.permissions = permissions.toString(); - return this; - } - - /** - * Gets the {@link SasIpRange} which determines the IP ranges that are allowed to use the SAS. - * - * @return the {@link SasIpRange} which determines the IP ranges that are allowed to use the SAS. - */ - public SasIpRange getSasIpRange() { - return sasIpRange; - } - - /** - * Sets the {@link SasIpRange} which determines the IP ranges that are allowed to use the SAS. - * - * @param sasIpRange Allowed IP range to set - * @return the updated BlobServiceSASSignatureValues object - * @see Specifying IP Address or IP range - */ - public BlobServiceSasSignatureValues setSasIpRange(SasIpRange sasIpRange) { - this.sasIpRange = sasIpRange; - return this; - } - - /** - * Gets the name of the container the SAS user may access. - * - * @return The name of the container the SAS user may access. - * @deprecated Container name is now auto-populated by the SAS generation methods provided on the desired - * container/blob client. - */ - @Deprecated - public String getContainerName() { - return containerName; - } - - /** - * Sets the container the SAS user may access. - * - * @param containerName The name of the container. - * @return The updated BlobServiceSASSignatureValues object. - * @deprecated Please use the SAS generation methods provided on the desired container/blob client that will - * auto-populate the container name. - */ - @Deprecated - public BlobServiceSasSignatureValues setContainerName(String containerName) { - this.containerName = containerName; - return this; - } - - /** - * Decodes and gets the name of the blob the SAS user may access. {@code null} or an empty string is returned when a - * creating a container SAS. - * - * @return The decoded name of the blob the SAS user may access. {@code null} or an empty string is returned when a - * creating a container SAS. - * @deprecated Blob name is now auto-populated by the SAS generation methods provided on the desired blob client. - */ - @Deprecated - public String getBlobName() { - return blobName; - } - - /** - * Sets the blob the SAS user may access. Use {@code null} or an empty string to create a container SAS. - * - * @param blobName The name of the blob. Use {@code null} or an empty string to create a container SAS. - * @return The updated BlobServiceSASSignatureValues object. - * @deprecated Please use the SAS generation methods provided on the desired blob client that will auto-populate the - * blob name. - */ - @Deprecated - public BlobServiceSasSignatureValues setBlobName(String blobName) { - this.blobName = (blobName == null) ? null : Utility.urlDecode(blobName); - return this; - } - - /** - * Gets the specific snapshot the SAS user may access. - * - * @return the specific snapshot the SAS user may access. - * @deprecated Snapshot id is now auto-populated by the SAS generation methods provided on the desired (snapshot) - * blob client. - */ - @Deprecated - public String getSnapshotId() { - return this.snapshotId; - } - - /** - * Sets the specific snapshot the SAS user may access. - * - *

{@link #resource} will be set to {@link #SAS_BLOB_SNAPSHOT_CONSTANT} if the passed {@code snapshotId} isn't - * {@code null} amd {@link #resource} is set to {@link #SAS_BLOB_CONSTANT}.

- * - * @param snapshotId Identifier of the snapshot - * @return the updated BlobServiceSASSignatureValues object - * @deprecated Please use the SAS generation methods provided on the desired (snapshot) blob client that will - * auto-populate the snapshot id. - */ - @Deprecated - public BlobServiceSasSignatureValues setSnapshotId(String snapshotId) { - this.snapshotId = snapshotId; - if (snapshotId != null && SAS_BLOB_CONSTANT.equals(resource)) { - this.resource = SAS_BLOB_SNAPSHOT_CONSTANT; - } - return this; - } - - /** - * Gets the name of the access policy on the container this SAS references if any. Please see - * here - * for more information. - * - * @return the name of the access policy on the container this SAS references if any. Please see - * here - * for more information. - */ - public String getIdentifier() { - return identifier; - } - - /** - * Sets the name of the access policy on the container this SAS references if any. Please see - * here - * for more information. - * - * @param identifier Name of the access policy - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setIdentifier(String identifier) { - this.identifier = identifier; - return this; - } - - /** - * Gets the encryption scope to use for the SAS. - * - * @return the cache-control header for the SAS. - */ - public String getCacheControl() { - return cacheControl; - } - - /** - * Sets the cache-control header for the SAS. - * - * @param cacheControl Cache-Control header value - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - /** - * Gets the content-disposition header for the SAS. - * - * @return the content-disposition header for the SAS. - */ - public String getContentDisposition() { - return contentDisposition; - } - - /** - * Sets the content-disposition header for the SAS. - * - * @param contentDisposition Content-Disposition header value - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setContentDisposition(String contentDisposition) { - this.contentDisposition = contentDisposition; - return this; - } - - /** - * Gets the content-encoding header for the SAS. - * - * @return the content-encoding header for the SAS. - */ - public String getContentEncoding() { - return contentEncoding; - } - - /** - * Sets the content-encoding header for the SAS. - * - * @param contentEncoding Content-Encoding header value - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - /** - * Gets the content-language header for the SAS. - * - * @return the content-language header for the SAS. - */ - public String getContentLanguage() { - return contentLanguage; - } - - /** - * Sets the content-language header for the SAS. - * - * @param contentLanguage Content-Language header value - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Gets the content-type header for the SAS. - * - * @return the content-type header for the SAS. - */ - public String getContentType() { - return contentType; - } - - /** - * Sets the content-type header for the SAS. - * - * @param contentType Content-Type header value - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Gets the AAD object ID of a user assumed to be authorized by the owner of the user delegation key to perform the - * action granted by the SAS token. - * - * @return The AAD object ID of a user assumed to be authorized by the owner of the user delegation key to perform - * the action granted by the SAS token. The service will validate the SAS token and ensure that the owner of the - * user delegation key has the required permissions before granting access but no additional permission check for - * the agent object id will be performed. - */ - public String getPreauthorizedAgentObjectId() { - return preauthorizedAgentObjectId; - } - - /** - * Sets the AAD object ID of a user assumed to be authorized by the owner of the user delegation key to perform the - * action granted by the SAS token. - * - * @param preauthorizedAgentObjectId The AAD object ID of a user assumed to be authorized by the owner of the user - * delegation key to perform the action granted by the SAS token. The service will validate the SAS token and - * ensure that the owner of the user delegation key has the required permissions before granting access but no - * additional permission check for the agent object id will be performed. - * @return the updated BlobServiceSASSignatureValues object - */ - public BlobServiceSasSignatureValues setPreauthorizedAgentObjectId(String preauthorizedAgentObjectId) { - this.preauthorizedAgentObjectId = preauthorizedAgentObjectId; - return this; - } - - /** - * Gets the encryption scope to use for the SAS. - * - * @return the correlation id value for the SAS. - */ - public String getCorrelationId() { - return correlationId; - } - - /** - * Sets the correlation id value for the SAS. - * - *

Note: This parameter is only valid for user delegation SAS.

- * - * @param correlationId A correlation ID used to correlate the storage audit logs with the audit logs used by the - * principal generating and distributing SAS. - * @return the updated BlobServiceSasSignatureValues object - */ - public BlobServiceSasSignatureValues setCorrelationId(String correlationId) { - this.correlationId = correlationId; - return this; - } - - /** - * Uses an account's shared key credential to sign these signature values to produce the proper SAS query - * parameters. - * - *

Notes on SAS generation

- *
    - *
  • If {@link #setIdentifier(String) identifier} is set, {@link #setExpiryTime(OffsetDateTime) expiryTime} and - * permissions should not be set. These values are inherited from the stored access policy.
  • - *
  • Otherwise, {@link #setExpiryTime(OffsetDateTime) expiryTime} and {@link #getPermissions() permissions} must - * be set.
  • - *
- * - *

- * The type of SAS query parameters returned depends on the following: - *

    - *
  1. If {@link #getBlobName()} is not set, container SAS query parameters are returned.
  2. - *
  3. If {@link #getBlobName()} and {@link #getSnapshotId()} are set, blob snapshot SAS query parameters - * are returned.
  4. - *
  5. If only {@link #getBlobName()} is set, blob SAS query parameters are returned.
  6. - *
- * - * See class level JavaDocs for code snippets. - * - * @param storageSharedKeyCredentials A {@link StorageSharedKeyCredential} object used to sign the SAS values. - * @return {@link BlobServiceSasQueryParameters} - * @throws IllegalStateException If the HMAC-SHA256 algorithm isn't supported, if the key isn't a valid Base64 - * encoded string, or the UTF-8 charset isn't supported. - * @throws IllegalArgumentException if {@link #getPermissions()} contains an invalid character for the SAS resource. - * @throws NullPointerException if {@code storageSharedKeyCredentials} is null. - * @deprecated Please use the generateSas(BlobServiceSasSignatureValues) method on the desired container/blob client - * after initializing {@link BlobServiceSasSignatureValues}. - */ - @Deprecated - public BlobServiceSasQueryParameters - generateSasQueryParameters(StorageSharedKeyCredential storageSharedKeyCredentials) { - StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); - - ensureState(); - - // Signature is generated on the un-url-encoded values. - final String canonicalName = getCanonicalName(storageSharedKeyCredentials.getAccountName()); - final String signature = storageSharedKeyCredentials.computeHmac256(stringToSign(canonicalName)); - - return new BlobServiceSasQueryParameters(VERSION_DEPRECATED_SHARED_KEY_SAS_STRING_TO_SIGN, this.protocol, - this.startTime, this.expiryTime, this.sasIpRange, this.identifier, this.resource, this.permissions, - signature, this.cacheControl, this.contentDisposition, this.contentEncoding, this.contentLanguage, - this.contentType, null /* delegate */); - } - - /** - * Uses a user delegation key to sign these signature values to produce the proper SAS query parameters. - * - *

Notes on SAS generation

- *
    - *
  • If {@link #setIdentifier(String) identifier} is set, {@link #setExpiryTime(OffsetDateTime) expiryTime} and - * permissions should not be set. These values are inherited from the stored access policy.
  • - *
  • Otherwise, {@link #setExpiryTime(OffsetDateTime) expiryTime} and {@link #getPermissions() permissions} must - * be set.
  • - *
- * - *

- * The type of SAS query parameters returned depends on the following: - *

    - *
  1. If {@link #getBlobName()} is not set, container SAS query parameters are returned.
  2. - *
  3. If {@link #getBlobName()} and {@link #getSnapshotId()} are set, blob snapshot SAS query parameters - * are returned.
  4. - *
  5. If only {@link #getBlobName()} is set, blob SAS query parameters are returned.
  6. - *
- * - * See class level JavaDocs for code snippets. - * - * @param delegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * @param accountName Azure Storage account name to generate SAS for. - * @return {@link BlobServiceSasQueryParameters} - * @throws IllegalStateException If the HMAC-SHA256 algorithm isn't supported, if the key isn't a valid Base64 - * encoded string, or the UTF-8 charset isn't supported. - * @throws IllegalArgumentException if {@link #getPermissions()} contains an invalid character for the SAS resource. - * @throws NullPointerException if {@code delegationKey} or {@code account} is null. - * @see - * Create a user delegation SAS - * @deprecated Please use the generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey) method on - * the desired container/blob client after initializing {@link BlobServiceSasSignatureValues}. - */ - @Deprecated - public BlobServiceSasQueryParameters generateSasQueryParameters(UserDelegationKey delegationKey, - String accountName) { - StorageImplUtils.assertNotNull("delegationKey", delegationKey); - StorageImplUtils.assertNotNull("accountName", accountName); - - ensureState(); - - // Signature is generated on the un-url-encoded values. - final String canonicalName = getCanonicalName(accountName); - String signature - = StorageImplUtils.computeHMac256(delegationKey.getValue(), stringToSign(delegationKey, canonicalName)); - - return new BlobServiceSasQueryParameters(VERSION_DEPRECATED_USER_DELEGATION_SAS_STRING_TO_SIGN, this.protocol, - this.startTime, this.expiryTime, this.sasIpRange, null /* identifier */, this.resource, this.permissions, - signature, this.cacheControl, this.contentDisposition, this.contentEncoding, this.contentLanguage, - this.contentType, delegationKey); - } - - /** - * Ensures that the builder's properties are in a consistent state. - *

- * 1. If there is no version, use latest. - * 2. Resource name is chosen by: - * a. If "BlobName" is _not_ set, it is a container resource. - * b. Otherwise, if "SnapshotId" is set, it is a blob snapshot resource. - * c. Otherwise, it is a blob resource. - * 3. Reparse permissions depending on what the resource is. If it is an unrecognised resource, do nothing. - *

- * Taken from: - * https://github.com/Azure/azure-storage-blob-go/blob/master/azblob/sas_service.go#L33 - * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/src/Sas/BlobSasBuilder.cs - */ - private void ensureState() { - if (CoreUtils.isNullOrEmpty(blobName)) { - resource = SAS_CONTAINER_CONSTANT; - } else if (snapshotId != null) { - resource = SAS_BLOB_SNAPSHOT_CONSTANT; - } else { - resource = SAS_BLOB_CONSTANT; - } - - if (permissions != null) { - switch (resource) { - case SAS_BLOB_CONSTANT: - case SAS_BLOB_SNAPSHOT_CONSTANT: - permissions = BlobSasPermission.parse(permissions).toString(); - break; - - case SAS_CONTAINER_CONSTANT: - permissions = BlobContainerSasPermission.parse(permissions).toString(); - break; - - default: - // We won't reparse the permissions if we don't know the type. - LOGGER.info("Not re-parsing permissions. Resource type '{}' is unknown.", resource); - break; - } - } - } - - /** - * Computes the canonical name for a container or blob resource for SAS signing. - */ - private String getCanonicalName(String account) { - // Container: "/blob/account/containername" - // Blob: "/blob/account/containername/blobname" - return CoreUtils.isNullOrEmpty(blobName) - ? "/blob/" + account + "/" + containerName - : "/blob/" + account + "/" + containerName + "/" + blobName.replace('\\', '/'); - } - - private String stringToSign(String canonicalName) { - return String.join("\n", this.permissions == null ? "" : permissions, - this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), canonicalName, - this.identifier == null ? "" : this.identifier, this.sasIpRange == null ? "" : this.sasIpRange.toString(), - this.protocol == null ? "" : this.protocol.toString(), - VERSION_DEPRECATED_SHARED_KEY_SAS_STRING_TO_SIGN, /* Pin down to version so old string to sign works. */ - resource, this.snapshotId == null ? "" : this.snapshotId, - this.cacheControl == null ? "" : this.cacheControl, - this.contentDisposition == null ? "" : this.contentDisposition, - this.contentEncoding == null ? "" : this.contentEncoding, - this.contentLanguage == null ? "" : this.contentLanguage, this.contentType == null ? "" : this.contentType); - } - - private String stringToSign(final UserDelegationKey key, String canonicalName) { - return String.join("\n", this.permissions == null ? "" : this.permissions, - this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), canonicalName, - key.getSignedObjectId() == null ? "" : key.getSignedObjectId(), - key.getSignedTenantId() == null ? "" : key.getSignedTenantId(), - key.getSignedStart() == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedStart()), - key.getSignedExpiry() == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedExpiry()), - key.getSignedService() == null ? "" : key.getSignedService(), - key.getSignedVersion() == null ? "" : key.getSignedVersion(), - this.sasIpRange == null ? "" : this.sasIpRange.toString(), - this.protocol == null ? "" : this.protocol.toString(), - VERSION_DEPRECATED_USER_DELEGATION_SAS_STRING_TO_SIGN, /* Pin down to version so old string to sign works. */ - resource, this.snapshotId == null ? "" : this.snapshotId, - this.cacheControl == null ? "" : this.cacheControl, - this.contentDisposition == null ? "" : this.contentDisposition, - this.contentEncoding == null ? "" : this.contentEncoding, - this.contentLanguage == null ? "" : this.contentLanguage, this.contentType == null ? "" : this.contentType); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/package-info.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/package-info.java deleted file mode 100644 index ba7a43717361..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package containing SAS (shared access signature) classes used by Azure Storage Blobs. - */ -package com.azure.storage.blob.sas; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java deleted file mode 100644 index db80aaf79666..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java +++ /dev/null @@ -1,711 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobContainerAsyncClient; -import com.azure.storage.blob.BlobServiceAsyncClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.models.AppendBlobsAppendBlockFromUrlHeaders; -import com.azure.storage.blob.implementation.models.AppendBlobsAppendBlockHeaders; -import com.azure.storage.blob.implementation.models.AppendBlobsCreateHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.AppendBlobRequestConditions; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.options.AppendBlobAppendBlockFromUrlOptions; -import com.azure.storage.blob.options.AppendBlobCreateOptions; -import com.azure.storage.blob.options.AppendBlobSealOptions; -import com.azure.storage.common.implementation.Constants; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.util.Map; - -import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.core.util.FluxUtil.withContext; - -/** - * Client to an append blob. It may only be instantiated through a - * {@link SpecializedBlobClientBuilder#buildAppendBlobAsyncClient()} or via the method - * {@link BlobAsyncClient#getAppendBlobAsyncClient()}. This class does not hold any state about a - * particular blob, but is instead a convenient way of sending appropriate requests to the resource on the service. - * - *

- * This client contains operations on a blob. Operations on a container are available on {@link - * BlobContainerAsyncClient}, and operations on the service are available on {@link BlobServiceAsyncClient}. - * - *

- * Please refer to the Azure - * Docs for more information. - * - *

- * Note this client is an async client that returns reactive responses from Spring Reactor Core project - * (https://projectreactor.io/). Calling the methods in this client will NOT start the actual network - * operation, until {@code .subscribe()} is called on the reactive response. You can simply convert one of these - * responses to a {@link java.util.concurrent.CompletableFuture} object through {@link Mono#toFuture()}. - */ -@ServiceClient(builder = SpecializedBlobClientBuilder.class, isAsync = true) -public final class AppendBlobAsyncClient extends BlobAsyncClientBase { - private static final ClientLogger LOGGER = new ClientLogger(AppendBlobAsyncClient.class); - - /** - * Indicates the maximum number of bytes that can be sent in a call to appendBlock. - * @deprecated use {@link AppendBlobAsyncClient#getMaxAppendBlockBytes()}. - */ - @Deprecated - public static final int MAX_APPEND_BLOCK_BYTES = 4 * Constants.MB; - - /** - * Indicates the maximum number of blocks allowed in an append blob. - * @deprecated use {@link AppendBlobAsyncClient#getMaxBlocks()}. - */ - @Deprecated - public static final int MAX_BLOCKS = 50000; - - /** - * Indicates the maximum number of bytes that can be sent in a call to appendBlock. - */ - static final int MAX_APPEND_BLOCK_BYTES_VERSIONS_2021_12_02_AND_BELOW - = BlobConstants.MAX_APPEND_BLOCK_BYTES_VERSIONS_2021_12_02_AND_BELOW; - - /** - * Indicates the maximum number of bytes that can be sent in a call to appendBlock. - * For versions 2022-11-02 and above. - */ - static final int MAX_APPEND_BLOCK_BYTES_VERSIONS_2022_11_02_AND_ABOVE - = BlobConstants.MAX_APPEND_BLOCK_BYTES_VERSIONS_2022_11_02_AND_ABOVE; - - /** - * Indicates the maximum number of blocks allowed in an append blob. - */ - static final int MAX_APPEND_BLOCKS = BlobConstants.MAX_BLOCKS; - - /** - * Package-private constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - AppendBlobAsyncClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, - EncryptionScope encryptionScope, String versionId) { - super(pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, customerProvidedKey, - encryptionScope, versionId); - } - - /** - * Creates a new {@link AppendBlobAsyncClient} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link AppendBlobAsyncClient} with the specified {@code encryptionScope}. - */ - @Override - public AppendBlobAsyncClient getEncryptionScopeAsyncClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - return new AppendBlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), getCustomerProvidedKey(), finalEncryptionScope, - getVersionId()); - } - - /** - * Creates a new {@link AppendBlobAsyncClient} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link AppendBlobAsyncClient} with the specified {@code customerProvidedKey}. - */ - @Override - public AppendBlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - return new AppendBlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), finalCustomerProvidedKey, encryptionScope, - getVersionId()); - } - - /** - * Creates a 0-length append blob. Call appendBlock to append data to an append blob. By default this method will - * not overwrite an existing blob. - * - *

Code Samples

- * - * - *
-     * client.create().subscribe(response ->
-     *     System.out.printf("Created AppendBlob at %s%n", response.getLastModified()));
-     * 
- * - * - * @return A {@link Mono} containing the information of the created appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono create() { - return create(false); - } - - /** - * Creates a 0-length append blob. Call appendBlock to append data to an append blob. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default behavior
-     * client.create(overwrite).subscribe(response ->
-     *     System.out.printf("Created AppendBlob at %s%n", response.getLastModified()));
-     * 
- * - * - * @param overwrite Whether to overwrite, should data exist on the blob. - * - * @return A {@link Mono} containing the information of the created appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono create(boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return createWithResponse(null, null, blobRequestConditions).flatMap(FluxUtil::toMono); - } - - /** - * Creates a 0-length append blob. Call appendBlock to append data to an append blob. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentType("binary")
-     *     .setContentLanguage("en-US");
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.createWithResponse(headers, metadata, requestConditions).subscribe(response ->
-     *     System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified()));
-     * 
- * - * - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @return A {@link Mono} containing {@link Response} whose {@link Response#getValue() value} contains the created - * appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponse(BlobHttpHeaders headers, Map metadata, - BlobRequestConditions requestConditions) { - return this.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers) - .setMetadata(metadata) - .setRequestConditions(requestConditions)); - } - - /** - * Creates a 0-length append blob. Call appendBlock to append data to an append blob. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentType("binary")
-     *     .setContentLanguage("en-US");
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata)
-     *     .setTags(tags).setRequestConditions(requestConditions)).subscribe(response ->
-     *     System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified()));
-     * 
- * - * - * @param options {@link AppendBlobCreateOptions} - * @return A {@link Mono} containing {@link Response} whose {@link Response#getValue() value} contains the created - * appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponse(AppendBlobCreateOptions options) { - try { - return withContext(context -> createWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> createWithResponse(AppendBlobCreateOptions options, Context context) { - options = (options == null) ? new AppendBlobCreateOptions() : options; - - BlobRequestConditions requestConditions = options.getRequestConditions(); - requestConditions = (requestConditions == null) ? new BlobRequestConditions() : requestConditions; - context = context == null ? Context.NONE : context; - BlobImmutabilityPolicy immutabilityPolicy - = options.getImmutabilityPolicy() == null ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); - - return this.azureBlobStorage.getAppendBlobs() - .createWithResponseAsync(containerName, blobName, 0, null, options.getMetadata(), - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, - ModelHelper.tagsToString(options.getTags()), immutabilityPolicy.getExpiryTime(), - immutabilityPolicy.getPolicyMode(), options.hasLegalHold(), options.getHeaders(), - getCustomerProvidedKey(), encryptionScope, context) - .map(rb -> { - AppendBlobsCreateHeaders hd = rb.getDeserializedHeaders(); - AppendBlobItem item = new AppendBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), null, - null, hd.getXMsVersionId()); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Creates a 0-length append blob if it does not exist. Call appendBlock to append data to an append blob. - * - *

Code Samples

- * - * - *
-     * client.createIfNotExists().subscribe(response ->
-     *     System.out.printf("Created AppendBlob at %s%n", response.getLastModified()));
-     * 
- * - * - * @return A reactive response {@link Mono} signaling completion. {@link AppendBlobItem} contains the information of - * the created appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createIfNotExists() { - return this.createIfNotExistsWithResponse(new AppendBlobCreateOptions()).flatMap(FluxUtil::toMono); - } - - /** - * Creates a 0-length append blob if it does not exist. Call appendBlock to append data to an append blob. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentType("binary")
-     *     .setContentLanguage("en-US");
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     *
-     * client.createIfNotExistsWithResponse(new AppendBlobCreateOptions().setHeaders(headers)
-     *     .setMetadata(metadata).setTags(tags)).subscribe(response -> {
-     *         if (response.getStatusCode() == 409) {
-     *             System.out.println("Already exists.");
-     *         } else {
-     *             System.out.println("successfully created.");
-     *         }
-     *     });
-     * 
- * - * - * @param options {@link AppendBlobCreateOptions} - * @return A {@link Mono} containing {@link Response} signaling completion, whose {@link Response#getValue() value} - * contains a {@link AppendBlobItem} containing information about the append blob. If {@link Response}'s status code - * is 201, a new page blob was successfully created. If status code is 409, an append blob already existed at this - * location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createIfNotExistsWithResponse(AppendBlobCreateOptions options) { - try { - return withContext(context -> createIfNotExistsWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> createIfNotExistsWithResponse(AppendBlobCreateOptions options, Context context) { - try { - options = options == null ? new AppendBlobCreateOptions() : options; - options.setRequestConditions( - new AppendBlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD)); - return createWithResponse(options, context).onErrorResume( - t -> t instanceof BlobStorageException && ((BlobStorageException) t).getStatusCode() == 409, t -> { - HttpResponse response = ((BlobStorageException) t).getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), null)); - }); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Commits a new block of data to the end of the existing append blob. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - * For service versions 2022-11-02 and later, the max block size is 100 MB. For previous versions, the max block - * size is 4 MB. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.appendBlock(data, length).subscribe(response ->
-     *     System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount()));
-     * 
- * - * - * @param data The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled - * (the default). In other words, the Flux must produce the same data each time it is subscribed to. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the {@code Flux}. - * @return {@link Mono} containing the information of the append blob operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono appendBlock(Flux data, long length) { - return appendBlockWithResponse(data, length, null, null).flatMap(FluxUtil::toMono); - } - - /** - * Commits a new block of data to the end of the existing append blob. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - * For service versions 2022-11-02 and later, the max block size is 100 MB. For previous versions, the max block - * size is 4 MB. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions()
-     *     .setAppendPosition(POSITION)
-     *     .setMaxSize(maxSize);
-     *
-     * client.appendBlockWithResponse(data, length, md5, requestConditions).subscribe(response ->
-     *     System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount()));
-     * 
- * - * - * @param data The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled - * (the default). In other words, the Flux must produce the same data each time it is subscribed to. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the {@code Flux}. - * @param contentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @param appendBlobRequestConditions {@link AppendBlobRequestConditions} - * @return A {@link Mono} containing {@link Response} whose {@link Response#getValue() value} contains the append - * blob operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockWithResponse(Flux data, long length, byte[] contentMd5, - AppendBlobRequestConditions appendBlobRequestConditions) { - try { - return withContext( - context -> appendBlockWithResponse(data, length, contentMd5, appendBlobRequestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> appendBlockWithResponse(Flux data, long length, byte[] contentMd5, - AppendBlobRequestConditions appendBlobRequestConditions, Context context) { - - if (data == null) { - return Mono.error(new NullPointerException("'data' cannot be null.")); - } - - appendBlobRequestConditions - = appendBlobRequestConditions == null ? new AppendBlobRequestConditions() : appendBlobRequestConditions; - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getAppendBlobs() - .appendBlockWithResponseAsync(containerName, blobName, length, data, null, contentMd5, null, - appendBlobRequestConditions.getLeaseId(), appendBlobRequestConditions.getMaxSize(), - appendBlobRequestConditions.getAppendPosition(), appendBlobRequestConditions.getIfModifiedSince(), - appendBlobRequestConditions.getIfUnmodifiedSince(), appendBlobRequestConditions.getIfMatch(), - appendBlobRequestConditions.getIfNoneMatch(), appendBlobRequestConditions.getTagsConditions(), null, - null, null, getCustomerProvidedKey(), encryptionScope, context) - .map(rb -> { - AppendBlobsAppendBlockHeaders hd = rb.getDeserializedHeaders(); - AppendBlobItem item = new AppendBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), - hd.getXMsBlobAppendOffset(), hd.getXMsBlobCommittedBlockCount()); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Commits a new block of data from another blob to the end of this append blob. - * - *

Code Samples

- * - * - *
-     * client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).subscribe(response ->
-     *     System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount()));
-     * 
- * - * - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceRange The source {@link BlobRange} to copy. - * @return {@link Mono} containing the information of the append blob operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono appendBlockFromUrl(String sourceUrl, BlobRange sourceRange) { - return appendBlockFromUrlWithResponse(sourceUrl, sourceRange, null, null, null).flatMap(FluxUtil::toMono); - } - - /** - * Commits a new block of data from another blob to the end of this append blob. - * - *

Code Samples

- * - * - *
-     * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions()
-     *     .setAppendPosition(POSITION)
-     *     .setMaxSize(maxSize);
-     *
-     * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null,
-     *     appendBlobRequestConditions, modifiedRequestConditions).subscribe(response ->
-     *     System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount()));
-     * 
- * - * - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceRange {@link BlobRange} - * @param sourceContentMD5 An MD5 hash of the block content from the source blob. If specified, the service will - * calculate the MD5 of the received data and fail the request if it does not match the provided MD5. - * @param destRequestConditions {@link AppendBlobRequestConditions} - * @param sourceRequestConditions {@link BlobRequestConditions} - * @return A {@link Mono} containing {@link Response} whose {@link Response#getValue() value} contains the append - * blob operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockFromUrlWithResponse(String sourceUrl, BlobRange sourceRange, - byte[] sourceContentMD5, AppendBlobRequestConditions destRequestConditions, - BlobRequestConditions sourceRequestConditions) { - return appendBlockFromUrlWithResponse( - new AppendBlobAppendBlockFromUrlOptions(sourceUrl).setSourceRange(sourceRange) - .setSourceContentMd5(sourceContentMD5) - .setDestinationRequestConditions(destRequestConditions) - .setSourceRequestConditions(sourceRequestConditions)); - } - - /** - * Commits a new block of data from another blob to the end of this append blob. - * - *

Code Samples

- * - * - *
-     * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions()
-     *     .setAppendPosition(POSITION)
-     *     .setMaxSize(maxSize);
-     *
-     * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl)
-     *     .setSourceRange(new BlobRange(offset, count))
-     *     .setDestinationRequestConditions(appendBlobRequestConditions)
-     *     .setSourceRequestConditions(modifiedRequestConditions)).subscribe(response ->
-     *     System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount()));
-     * 
- * - * - * @param options Parameters for the operation. - * @return A {@link Mono} containing {@link Response} whose {@link Response#getValue() value} contains the append - * blob operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> appendBlockFromUrlWithResponse(AppendBlobAppendBlockFromUrlOptions options) { - try { - return withContext(context -> appendBlockFromUrlWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> appendBlockFromUrlWithResponse(AppendBlobAppendBlockFromUrlOptions options, - Context context) { - BlobRange sourceRange = (options.getSourceRange() == null) ? new BlobRange(0) : options.getSourceRange(); - AppendBlobRequestConditions destRequestConditions = (options.getDestinationRequestConditions() == null) - ? new AppendBlobRequestConditions() - : options.getDestinationRequestConditions(); - RequestConditions sourceRequestConditions = (options.getSourceRequestConditions() == null) - ? new RequestConditions() - : options.getSourceRequestConditions(); - - try { - new URL(options.getSourceUrl()); - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'sourceUrl' is not a valid url.", ex)); - } - context = context == null ? Context.NONE : context; - String sourceAuth - = options.getSourceAuthorization() == null ? null : options.getSourceAuthorization().toString(); - - return this.azureBlobStorage.getAppendBlobs() - .appendBlockFromUrlWithResponseAsync(containerName, blobName, options.getSourceUrl(), 0, - sourceRange.toString(), options.getSourceContentMd5(), null, null, null, - destRequestConditions.getLeaseId(), destRequestConditions.getMaxSize(), - destRequestConditions.getAppendPosition(), destRequestConditions.getIfModifiedSince(), - destRequestConditions.getIfUnmodifiedSince(), destRequestConditions.getIfMatch(), - destRequestConditions.getIfNoneMatch(), destRequestConditions.getTagsConditions(), - sourceRequestConditions.getIfModifiedSince(), sourceRequestConditions.getIfUnmodifiedSince(), - sourceRequestConditions.getIfMatch(), sourceRequestConditions.getIfNoneMatch(), null, sourceAuth, - getCustomerProvidedKey(), encryptionScope, context) - .map(rb -> { - AppendBlobsAppendBlockFromUrlHeaders hd = rb.getDeserializedHeaders(); - AppendBlobItem item = new AppendBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), - hd.getXMsBlobAppendOffset(), hd.getXMsBlobCommittedBlockCount()); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Seals an append blob, making it read only. Any subsequent appends will fail. - * - *

Code Samples

- * - * - *
-     * client.seal().subscribe(response -> System.out.println("Sealed AppendBlob"));
-     * 
- * - * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono seal() { - return sealWithResponse(new AppendBlobSealOptions()).flatMap(FluxUtil::toMono); - } - - /** - * Seals an append blob, making it read only. Any subsequent appends will fail. - * - *

Code Samples

- * - * - *
-     * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions))
-     *     .subscribe(response -> System.out.println("Sealed AppendBlob"));
-     * 
- * - * - * @param options {@link AppendBlobSealOptions} - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> sealWithResponse(AppendBlobSealOptions options) { - try { - return withContext(context -> sealWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> sealWithResponse(AppendBlobSealOptions options, Context context) { - options = (options == null) ? new AppendBlobSealOptions() : options; - - AppendBlobRequestConditions requestConditions = options.getRequestConditions(); - requestConditions = (requestConditions == null) ? new AppendBlobRequestConditions() : requestConditions; - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getAppendBlobs() - .sealNoCustomHeadersWithResponseAsync(containerName, blobName, null, null, requestConditions.getLeaseId(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getAppendPosition(), context); - } - - /** - * Get the max number of append block bytes based on service version being used. Service versions 2022-11-02 and - * above support uploading block bytes up to 100MB, all older service versions support up to 4MB. - * - * @return the max number of block bytes that can be uploaded based on service version. - */ - public int getMaxAppendBlockBytes() { - if (getServiceVersion().ordinal() < BlobServiceVersion.V2022_11_02.ordinal()) { - return MAX_APPEND_BLOCK_BYTES_VERSIONS_2021_12_02_AND_BELOW; - } else { - return MAX_APPEND_BLOCK_BYTES_VERSIONS_2022_11_02_AND_ABOVE; - } - } - - /** - * Get the maximum number of blocks allowed in an append blob. - * - * @return the max number of blocks that can be uploaded in an append blob. - */ - public int getMaxBlocks() { - return MAX_APPEND_BLOCKS; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java deleted file mode 100644 index eea76b00e751..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java +++ /dev/null @@ -1,710 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobClientBuilder; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.BlobServiceClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.models.AppendBlobsCreateHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.AppendBlobRequestConditions; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.options.AppendBlobAppendBlockFromUrlOptions; -import com.azure.storage.blob.options.AppendBlobCreateOptions; -import com.azure.storage.blob.options.AppendBlobSealOptions; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.Callable; - -import static com.azure.storage.common.implementation.StorageImplUtils.sendRequest; - -/** - * Client to an append blob. It may only be instantiated through a {@link SpecializedBlobClientBuilder} or via the - * method {@link BlobClient#getAppendBlobClient()}. This class does not hold any state about a particular blob, but is - * instead a convenient way of sending appropriate requests to the resource on the service. - * - *

- * This client contains operations on a blob. Operations on a container are available on {@link BlobContainerClient}, - * and operations on the service are available on {@link BlobServiceClient}. - * - *

- * Please refer to the Azure - * Docs for more information. - */ -@ServiceClient(builder = SpecializedBlobClientBuilder.class) -public final class AppendBlobClient extends BlobClientBase { - private static final ClientLogger LOGGER = new ClientLogger(AppendBlobClient.class); - private final AppendBlobAsyncClient appendBlobAsyncClient; - - /** - * Indicates the maximum number of bytes that can be sent in a call to appendBlock. - * @deprecated use {@link AppendBlobClient#getMaxAppendBlockBytes()}. - */ - @Deprecated - public static final int MAX_APPEND_BLOCK_BYTES = 4 * Constants.MB; - - /** - * Indicates the maximum number of blocks allowed in an append blob. - * @deprecated use {@link AppendBlobClient#getMaxBlocks()}. - */ - @Deprecated - public static final int MAX_BLOCKS = 50000; - - /** - * Indicates the maximum number of bytes that can be sent in a call to appendBlock. - */ - static final int MAX_APPEND_BLOCK_BYTES_VERSIONS_2021_12_02_AND_BELOW - = BlobConstants.MAX_APPEND_BLOCK_BYTES_VERSIONS_2021_12_02_AND_BELOW; - - /** - * Indicates the maximum number of bytes that can be sent in a call to appendBlock. - * For versions 2022-11-02 and above. - */ - static final int MAX_APPEND_BLOCK_BYTES_VERSIONS_2022_11_02_AND_ABOVE - = BlobConstants.MAX_APPEND_BLOCK_BYTES_VERSIONS_2022_11_02_AND_ABOVE; - /** - * Indicates the maximum number of blocks allowed in an append blob. - */ - static final int MAX_APPEND_BLOCKS = BlobConstants.MAX_BLOCKS; - - /** - * Package-private constructor for use by {@link BlobClientBuilder}. - * - * @param appendBlobAsyncClient the async append blob client - */ - AppendBlobClient(AppendBlobAsyncClient appendBlobAsyncClient) { - this(appendBlobAsyncClient, appendBlobAsyncClient.getHttpPipeline(), appendBlobAsyncClient.getAccountUrl(), - appendBlobAsyncClient.getServiceVersion(), appendBlobAsyncClient.getAccountName(), - appendBlobAsyncClient.getContainerName(), appendBlobAsyncClient.getBlobName(), - appendBlobAsyncClient.getSnapshotId(), appendBlobAsyncClient.getCustomerProvidedKey(), - new EncryptionScope().setEncryptionScope(appendBlobAsyncClient.getEncryptionScope()), - appendBlobAsyncClient.getVersionId()); - } - - /** - * Package-private constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - AppendBlobClient(AppendBlobAsyncClient asyncClient, HttpPipeline pipeline, String url, - BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, - CpkInfo customerProvidedKey, EncryptionScope encryptionScope, String versionId) { - super(asyncClient, pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, - customerProvidedKey, encryptionScope, versionId); - this.appendBlobAsyncClient = asyncClient; - } - - /** - * Creates a new {@link AppendBlobClient} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link AppendBlobClient} with the specified {@code encryptionScope}. - */ - @Override - public AppendBlobClient getEncryptionScopeClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - return new AppendBlobClient(this.appendBlobAsyncClient.getEncryptionScopeAsyncClient(encryptionScope), - getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), getContainerName(), - getBlobName(), getSnapshotId(), getCustomerProvidedKey(), finalEncryptionScope, getVersionId()); - } - - /** - * Creates a new {@link AppendBlobClient} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link AppendBlobClient} with the specified {@code customerProvidedKey}. - */ - @Override - public AppendBlobClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - return new AppendBlobClient(this.appendBlobAsyncClient.getCustomerProvidedKeyAsyncClient(customerProvidedKey), - getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), getContainerName(), - getBlobName(), getSnapshotId(), finalCustomerProvidedKey, encryptionScope, getVersionId()); - } - - /** - * Creates and opens an output stream to write data to the append blob. If the blob already exists on the service, - * new data will get appended to the existing blob. - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream() { - return getBlobOutputStream(null); - } - - /** - * Creates and opens an output stream to write data to the append blob. If overwrite is specified {@code true}, - * the existing blob will be deleted and recreated, should data exist on the blob. If overwrite is specified - * {@code false}, new data will get appended to the existing blob. - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @param overwrite Whether an existing blob should be deleted and recreated, should data exist on the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream(boolean overwrite) { - AppendBlobRequestConditions requestConditions = null; - if (!overwrite) { - requestConditions - = new AppendBlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } else { - // creating new blob to overwrite existing blob - create(true); - } - return getBlobOutputStream(requestConditions); - } - - /** - * Creates and opens an output stream to write data to the append blob. - * - * @param requestConditions A {@link BlobRequestConditions} object that represents the access conditions for the - * blob. - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream(AppendBlobRequestConditions requestConditions) { - return BlobOutputStream.appendBlobOutputStream(appendBlobAsyncClient, requestConditions); - } - - /** - * Creates a 0-length append blob. Call appendBlock to append data to an append blob. By default this method will - * not overwrite an existing blob. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Created AppendBlob at %s%n", client.create().getLastModified());
-     * 
- * - * - * @return The information of the created appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public AppendBlobItem create() { - return create(false); - } - - /** - * Creates a 0-length append blob. Call appendBlock to append data to an append blob. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default value
-     * System.out.printf("Created AppendBlob at %s%n", client.create(overwrite).getLastModified());
-     * 
- * - * - * @param overwrite Whether or not to overwrite, should data exist on the blob. - * - * @return The information of the created appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public AppendBlobItem create(boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return createWithResponse(null, null, blobRequestConditions, null, Context.NONE).getValue(); - } - - /** - * Creates a 0-length append blob. Call appendBlock to append data to an append blob. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentType("binary")
-     *     .setContentLanguage("en-US");
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("Created AppendBlob at %s%n",
-     *     client.createWithResponse(headers, metadata, requestConditions, timeout, context).getValue()
-     *         .getLastModified());
-     * 
- * - * - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} contains the created appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createWithResponse(BlobHttpHeaders headers, Map metadata, - BlobRequestConditions requestConditions, Duration timeout, Context context) { - return this.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers) - .setMetadata(metadata) - .setRequestConditions(requestConditions), timeout, context); - } - - /** - * Creates a 0-length append blob. Call appendBlock to append data to an append blob. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentType("binary")
-     *     .setContentLanguage("en-US");
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tags", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("Created AppendBlob at %s%n",
-     *     client.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata)
-     *         .setTags(tags).setRequestConditions(requestConditions), timeout, context).getValue()
-     *         .getLastModified());
-     * 
- * - * - * @param options {@link AppendBlobCreateOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} contains the created appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createWithResponse(AppendBlobCreateOptions options, Duration timeout, - Context context) { - AppendBlobCreateOptions finalOptions = (options == null) ? new AppendBlobCreateOptions() : options; - BlobRequestConditions requestConditions = finalOptions.getRequestConditions() == null - ? new BlobRequestConditions() - : finalOptions.getRequestConditions(); - Context finalContext = context == null ? Context.NONE : context; - BlobImmutabilityPolicy immutabilityPolicy = finalOptions.getImmutabilityPolicy() == null - ? new BlobImmutabilityPolicy() - : finalOptions.getImmutabilityPolicy(); - Callable> operation = () -> this.azureBlobStorage.getAppendBlobs() - .createWithResponse(containerName, blobName, 0, null, finalOptions.getMetadata(), - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, - ModelHelper.tagsToString(finalOptions.getTags()), immutabilityPolicy.getExpiryTime(), - immutabilityPolicy.getPolicyMode(), finalOptions.hasLegalHold(), finalOptions.getHeaders(), - getCustomerProvidedKey(), encryptionScope, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - AppendBlobsCreateHeaders hd = response.getDeserializedHeaders(); - AppendBlobItem item = new AppendBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), null, null, - hd.getXMsVersionId()); - return new SimpleResponse<>(response, item); - } - - /** - * Creates a 0-length append blob if it does not exist. Call appendBlock to append data to an append blob. - * - *

Code Samples

- * - * - *
-     * client.createIfNotExists();
-     * System.out.println("Created AppendBlob");
-     * 
- * - * - * @return {@link AppendBlobItem} containing information of the created appended blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public AppendBlobItem createIfNotExists() { - return createIfNotExistsWithResponse(new AppendBlobCreateOptions(), null, null).getValue(); - } - - /** - * Creates a 0-length append blob if it does not exist. Call appendBlock to append data to an append blob. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentType("binary")
-     *     .setContentLanguage("en-US");
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tags", "value");
-     * Context context = new Context("key", "value");
-     *
-     * Response<AppendBlobItem> response = client.createIfNotExistsWithResponse(new AppendBlobCreateOptions()
-     *     .setHeaders(headers).setMetadata(metadata).setTags(tags), timeout, context);
-     * if (response.getStatusCode() == 409) {
-     *     System.out.println("Already existed.");
-     * } else {
-     *     System.out.printf("Create completed with status %d%n", response.getStatusCode());
-     * }
-     * 
- * - * - * @param options {@link AppendBlobCreateOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A reactive response {@link Response} signaling completion, whose {@link Response#getValue() value} - * contains the {@link AppendBlobItem} containing information about the append blob. If {@link Response}'s status - * code is 201, a new append blob was successfully created. If status code is 409, an append blob already existed at - * this location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createIfNotExistsWithResponse(AppendBlobCreateOptions options, Duration timeout, - Context context) { - AppendBlobCreateOptions finalOptions = options == null ? new AppendBlobCreateOptions() : options; - finalOptions.setRequestConditions( - new AppendBlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD)); - try { - return createWithResponse(finalOptions, timeout, context); - } catch (BlobStorageException e) { - if (e.getStatusCode() == 409) { - HttpResponse res = e.getResponse(); - return new SimpleResponse<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), null); - } else { - throw LOGGER.logExceptionAsError(e); - } - } catch (RuntimeException e) { - throw LOGGER.logExceptionAsError(e); - } - } - - /** - * Commits a new block of data to the end of the existing append blob. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - * For service versions 2022-11-02 and later, the max block size is 100 MB. For previous versions, the max block - * size is 4 MB. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * System.out.printf("AppendBlob has %d committed blocks%n",
-     *     client.appendBlock(data, length).getBlobCommittedBlockCount());
-     * 
- * - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream. - * Alternatively, consider wrapping your data source in a {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the {@code Flux}. - * @return The information of the append blob operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public AppendBlobItem appendBlock(InputStream data, long length) { - return appendBlockWithResponse(data, length, null, null, null, Context.NONE).getValue(); - } - - /** - * Commits a new block of data to the end of the existing append blob. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - * For service versions 2022-11-02 and later, the max block size is 100 MB. For previous versions, the max block - * size is 4 MB. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions()
-     *     .setAppendPosition(POSITION)
-     *     .setMaxSize(maxSize);
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("AppendBlob has %d committed blocks%n",
-     *     client.appendBlockWithResponse(data, length, md5, requestConditions, timeout, context)
-     *         .getValue().getBlobCommittedBlockCount());
-     * 
- * - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream. - * Alternatively, consider wrapping your data source in a {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the {@code Flux}. - * @param contentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @param appendBlobRequestConditions {@link AppendBlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link Response} whose {@link Response#getValue() value} contains the append blob operation. - * @throws UnexpectedLengthException when the length of data does not match the input {@code length}. - * @throws NullPointerException if the input data is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response appendBlockWithResponse(InputStream data, long length, byte[] contentMd5, - AppendBlobRequestConditions appendBlobRequestConditions, Duration timeout, Context context) { - Objects.requireNonNull(data, "'data' cannot be null."); - Flux fbb; - - // service versions 2022-11-02 and above support uploading block bytes up to 100MB, all older service versions - // support up to 4MB - fbb = Utility.convertStreamToByteBuffer(data, length, getMaxAppendBlockBytes(), true); - - Mono> response = appendBlobAsyncClient.appendBlockWithResponse(fbb, length, contentMd5, - appendBlobRequestConditions, context); - return StorageImplUtils.blockWithOptionalTimeout(response, timeout); - } - - /** - * Commits a new block of data from another blob to the end of this append blob. - * - *

Code Samples

- * - * - *
-     * System.out.printf("AppendBlob has %d committed blocks%n",
-     *     client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).getBlobCommittedBlockCount());
-     * 
- * - * - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceRange The source {@link BlobRange} to copy. - * @return The information of the append blob operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public AppendBlobItem appendBlockFromUrl(String sourceUrl, BlobRange sourceRange) { - return appendBlockFromUrlWithResponse(sourceUrl, sourceRange, null, null, null, null, Context.NONE).getValue(); - } - - /** - * Commits a new block of data from another blob to the end of this append blob. - * - *

Code Samples

- * - * - *
-     * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions()
-     *     .setAppendPosition(POSITION)
-     *     .setMaxSize(maxSize);
-     *
-     * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("AppendBlob has %d committed blocks%n",
-     *     client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null,
-     *         appendBlobRequestConditions, modifiedRequestConditions, timeout,
-     *         context).getValue().getBlobCommittedBlockCount());
-     * 
- * - * - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceRange {@link BlobRange} - * @param sourceContentMd5 An MD5 hash of the block content from the source blob. If specified, the service will - * calculate the MD5 of the received data and fail the request if it does not match the provided MD5. - * @param destRequestConditions {@link AppendBlobRequestConditions} - * @param sourceRequestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The information of the append blob operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response appendBlockFromUrlWithResponse(String sourceUrl, BlobRange sourceRange, - byte[] sourceContentMd5, AppendBlobRequestConditions destRequestConditions, - BlobRequestConditions sourceRequestConditions, Duration timeout, Context context) { - Mono> response = appendBlobAsyncClient.appendBlockFromUrlWithResponse( - new AppendBlobAppendBlockFromUrlOptions(sourceUrl).setSourceRange(sourceRange) - .setSourceContentMd5(sourceContentMd5) - .setDestinationRequestConditions(destRequestConditions) - .setSourceRequestConditions(sourceRequestConditions), - context); - return StorageImplUtils.blockWithOptionalTimeout(response, timeout); - } - - /** - * Commits a new block of data from another blob to the end of this append blob. - * - *

Code Samples

- * - * - *
-     * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions()
-     *     .setAppendPosition(POSITION)
-     *     .setMaxSize(maxSize);
-     *
-     * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("AppendBlob has %d committed blocks%n",
-     *     client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl)
-     *         .setSourceRange(new BlobRange(offset, count))
-     *         .setDestinationRequestConditions(appendBlobRequestConditions)
-     *         .setSourceRequestConditions(modifiedRequestConditions), timeout,
-     *         context).getValue().getBlobCommittedBlockCount());
-     * 
- * - * - * @param options options for the operation - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The information of the append blob operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response appendBlockFromUrlWithResponse(AppendBlobAppendBlockFromUrlOptions options, - Duration timeout, Context context) { - Mono> response - = appendBlobAsyncClient.appendBlockFromUrlWithResponse(options, context); - return StorageImplUtils.blockWithOptionalTimeout(response, timeout); - } - - /** - * Seals an append blob, making it read only. Any subsequent appends will fail. - * - *

Code Samples

- * - * - *
-     * client.seal();
-     * System.out.println("Sealed AppendBlob");
-     * 
- * - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void seal() { - sealWithResponse(new AppendBlobSealOptions(), null, Context.NONE); - } - - /** - * Seals an append blob, making it read only. Any subsequent appends will fail. - * - *

Code Samples

- * - * - *
-     * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions), timeout, context);
-     * System.out.println("Sealed AppendBlob");
-     * 
- * - * - * @param options {@link AppendBlobSealOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response sealWithResponse(AppendBlobSealOptions options, Duration timeout, Context context) { - AppendBlobSealOptions finalOptions = (options == null) ? new AppendBlobSealOptions() : options; - - AppendBlobRequestConditions requestConditions = (finalOptions.getRequestConditions() == null) - ? new AppendBlobRequestConditions() - : finalOptions.getRequestConditions(); - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation = () -> this.azureBlobStorage.getAppendBlobs() - .sealNoCustomHeadersWithResponse(containerName, blobName, null, null, requestConditions.getLeaseId(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getAppendPosition(), finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Get the max number of append block bytes based on service version being used. Service versions 2022-11-02 and - * above support uploading block bytes up to 100MB, all older service versions support up to 4MB. - * - * @return the max number of block bytes that can be uploaded based on service version. - */ - public int getMaxAppendBlockBytes() { - if (getServiceVersion().ordinal() < BlobServiceVersion.V2022_11_02.ordinal()) { - return MAX_APPEND_BLOCK_BYTES_VERSIONS_2021_12_02_AND_BELOW; - } else { - return MAX_APPEND_BLOCK_BYTES_VERSIONS_2022_11_02_AND_ABOVE; - } - } - - /** - * Get the maximum number of blocks allowed in an append blob. - * - * @return the max number of blocks that can be uploaded in an append blob. - */ - public int getMaxBlocks() { - return MAX_APPEND_BLOCKS; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java deleted file mode 100644 index 7254a4568737..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java +++ /dev/null @@ -1,2846 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.http.rest.StreamResponse; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.ProgressListener; -import com.azure.core.util.ProgressReporter; -import com.azure.core.util.io.IOUtils; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.PollerFlux; -import com.azure.storage.blob.BlobContainerAsyncClient; -import com.azure.storage.blob.BlobContainerClientBuilder; -import com.azure.storage.blob.BlobServiceAsyncClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.AzureBlobStorageImpl; -import com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder; -import com.azure.storage.blob.implementation.accesshelpers.BlobDownloadAsyncResponseConstructorProxy; -import com.azure.storage.blob.implementation.accesshelpers.BlobPropertiesConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobPropertiesInternalGetProperties; -import com.azure.storage.blob.implementation.models.BlobTag; -import com.azure.storage.blob.implementation.models.BlobTags; -import com.azure.storage.blob.implementation.models.BlobsDownloadHeaders; -import com.azure.storage.blob.implementation.models.BlobsGetAccountInfoHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetImmutabilityPolicyHeaders; -import com.azure.storage.blob.implementation.models.BlobsStartCopyFromURLHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.InternalBlobLegalHoldResult; -import com.azure.storage.blob.implementation.models.QueryRequest; -import com.azure.storage.blob.implementation.models.QuerySerialization; -import com.azure.storage.blob.implementation.util.BlobQueryReader; -import com.azure.storage.blob.implementation.util.BlobRequestConditionProperty; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; -import com.azure.storage.blob.implementation.util.ChunkedDownloadUtils; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobDownloadAsyncResponse; -import com.azure.storage.blob.models.BlobDownloadContentAsyncResponse; -import com.azure.storage.blob.models.BlobDownloadHeaders; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.BlobLegalHoldResult; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobQueryAsyncResponse; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobBeginCopyOptions; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.options.BlobDownloadToFileOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.BlobQueryOptions; -import com.azure.storage.blob.options.BlobSetAccessTierOptions; -import com.azure.storage.blob.options.BlobSetTagsOptions; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.core.publisher.SignalType; - -import java.io.IOException; -import java.io.UncheckedIOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.channels.AsynchronousFileChannel; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.Files; -import java.nio.file.OpenOption; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeoutException; -import java.util.function.BiFunction; -import java.util.function.Consumer; - -import static com.azure.core.util.FluxUtil.fluxError; -import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.core.util.FluxUtil.withContext; - -/** - * This class provides a client that contains all operations that apply to any blob type. - * - *

- * This client offers the ability to download blobs. Note that uploading data is specific to each type of blob. Please - * refer to the {@link BlockBlobClient}, {@link PageBlobClient}, or {@link AppendBlobClient} for upload options. - */ -public class BlobAsyncClientBase { - private static final ClientLogger LOGGER = new ClientLogger(BlobAsyncClientBase.class); - - private static final Set DEFAULT_OPEN_OPTIONS_SET = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.READ, StandardOpenOption.WRITE))); - - /** - * Backing REST client for the blob client. - */ - protected final AzureBlobStorageImpl azureBlobStorage; - - private final String snapshot; - private final String versionId; - private final CpkInfo customerProvidedKey; - - /** - * Encryption scope of the blob. - */ - protected final EncryptionScope encryptionScope; - - /** - * Storage account name that contains the blob. - */ - protected final String accountName; - - /** - * Container name that contains the blob. - */ - protected final String containerName; - - /** - * Name of the blob. - */ - protected final String blobName; - - /** - * Storage REST API version used in requests to the Storage service. - */ - protected final BlobServiceVersion serviceVersion; - - /** - * Protected constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - */ - protected BlobAsyncClientBase(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, - String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey) { - this(pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, customerProvidedKey, null); - } - - /** - * Protected constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - */ - protected BlobAsyncClientBase(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, - String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, - EncryptionScope encryptionScope) { - this(pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, customerProvidedKey, - encryptionScope, null); - } - - /** - * Protected constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - protected BlobAsyncClientBase(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, - String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, - EncryptionScope encryptionScope, String versionId) { - if (snapshot != null && versionId != null) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("'snapshot' and 'versionId' cannot be used at the same time.")); - } - if (blobName == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'blobName' can not be set to null.")); - } - this.azureBlobStorage = new AzureBlobStorageImplBuilder().pipeline(pipeline) - .url(url) - .version(serviceVersion.getVersion()) - .buildClient(); - this.serviceVersion = serviceVersion; - - this.accountName = accountName; - this.containerName = containerName; - this.blobName = blobName; - this.snapshot = snapshot; - this.customerProvidedKey = customerProvidedKey; - this.encryptionScope = encryptionScope; - this.versionId = versionId; - /* Check to make sure the uri is valid. We don't want the error to occur later in the generated layer - when the sas token has already been applied. */ - try { - URI.create(getBlobUrl()); - } catch (IllegalArgumentException ex) { - throw LOGGER.logExceptionAsError(ex); - } - } - - /** - * Gets the {@code encryption scope} used to encrypt this blob's content on the server. - * - * @return the encryption scope used for encryption. - */ - protected String getEncryptionScope() { - if (encryptionScope == null) { - return null; - } - return encryptionScope.getEncryptionScope(); - } - - /** - * Creates a new {@link BlobAsyncClientBase} linked to the {@code snapshot} of this blob resource. - * - * @param snapshot the identifier for a specific snapshot of this blob - * @return a {@link BlobAsyncClientBase} used to interact with the specific snapshot. - */ - public BlobAsyncClientBase getSnapshotClient(String snapshot) { - return new BlobAsyncClientBase(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), snapshot, getCustomerProvidedKey(), encryptionScope, getVersionId()); - } - - /** - * Creates a new {@link BlobAsyncClientBase} linked to the {@code versionId} of this blob resource. - * - * @param versionId the identifier for a specific version of this blob, - * pass {@code null} to interact with the latest blob version. - * @return a {@link BlobAsyncClientBase} used to interact with the specific version. - */ - public BlobAsyncClientBase getVersionClient(String versionId) { - return new BlobAsyncClientBase(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), getCustomerProvidedKey(), encryptionScope, versionId); - } - - /** - * Creates a new {@link BlobAsyncClientBase} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link BlobAsyncClientBase} with the specified {@code encryptionScope}. - */ - public BlobAsyncClientBase getEncryptionScopeAsyncClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - return new BlobAsyncClientBase(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), snapshot, getCustomerProvidedKey(), finalEncryptionScope, - getVersionId()); - } - - /** - * Creates a new {@link BlobAsyncClientBase} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link BlobAsyncClientBase} with the specified {@code customerProvidedKey}. - */ - public BlobAsyncClientBase getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - return new BlobAsyncClientBase(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), snapshot, finalCustomerProvidedKey, encryptionScope, getVersionId()); - } - - /** - * Get the url of the storage account. - * - * @return the URL of the storage account - */ - public String getAccountUrl() { - return azureBlobStorage.getUrl(); - } - - /** - * Gets the URL of the blob represented by this client. - * - * @return the URL. - */ - public String getBlobUrl() { - String blobUrl = azureBlobStorage.getUrl() + "/" + containerName + "/" + Utility.urlEncode(blobName); - if (this.isSnapshot()) { - blobUrl = Utility.appendQueryParameter(blobUrl, "snapshot", getSnapshotId()); - } - if (this.getVersionId() != null) { - blobUrl = Utility.appendQueryParameter(blobUrl, "versionid", getVersionId()); - } - return blobUrl; - } - - /** - * Get the container name. - * - *

Code Samples

- * - * - *
-     * String containerName = client.getContainerName();
-     * System.out.println("The name of the container is " + containerName);
-     * 
- * - * - * @return The name of the container. - */ - public final String getContainerName() { - return containerName; - } - - /** - * Get an async client pointing to the parent container. - * - *

Code Samples

- * - * - *
-     * BlobContainerAsyncClient containerClient = client.getContainerAsyncClient();
-     * System.out.println("The name of the container is " + containerClient.getBlobContainerName());
-     * 
- * - * - * @return {@link BlobContainerAsyncClient} - */ - public BlobContainerAsyncClient getContainerAsyncClient() { - return getContainerClientBuilder().buildAsyncClient(); - } - - final BlobContainerClientBuilder getContainerClientBuilder() { - CustomerProvidedKey encryptionKey = this.customerProvidedKey == null - ? null - : new CustomerProvidedKey(this.customerProvidedKey.getEncryptionKey()); - return new BlobContainerClientBuilder().endpoint(this.getBlobUrl()) - .pipeline(this.getHttpPipeline()) - .serviceVersion(this.serviceVersion) - .customerProvidedKey(encryptionKey) - .encryptionScope(this.getEncryptionScope()); - } - - /** - * Decodes and gets the blob name. - * - *

Code Samples

- * - * - *
-     * String blobName = client.getBlobName();
-     * System.out.println("The name of the blob is " + blobName);
-     * 
- * - * - * @return The decoded name of the blob. - */ - public final String getBlobName() { - return blobName; - } - - /** - * Gets the {@link HttpPipeline} powering this client. - * - * @return The pipeline. - */ - public HttpPipeline getHttpPipeline() { - return azureBlobStorage.getHttpPipeline(); - } - - /** - * Gets the {@link CpkInfo} used to encrypt this blob's content on the server. - * - * @return the customer provided key used for encryption. - */ - public CpkInfo getCustomerProvidedKey() { - return customerProvidedKey; - } - - /** - * Get associated account name. - * - * @return account name associated with this storage resource. - */ - public String getAccountName() { - return accountName; - } - - /** - * Gets the service version the client is using. - * - * @return the service version the client is using. - */ - public BlobServiceVersion getServiceVersion() { - return serviceVersion; - } - - /** - * Gets the snapshotId for a blob resource - * - * @return A string that represents the snapshotId of the snapshot blob - */ - public String getSnapshotId() { - return this.snapshot; - } - - /** - * Determines if a blob is a snapshot - * - * @return A boolean that indicates if a blob is a snapshot - */ - public boolean isSnapshot() { - return this.snapshot != null; - } - - /** - * Gets the versionId for a blob resource - * - * @return A string that represents the versionId of the snapshot blob - */ - public String getVersionId() { - return this.versionId; - } - - /** - * Determines if the blob this client represents exists in the cloud. - * - *

Code Samples

- * - * - *
-     * client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
-     * 
- * - * - * @return true if the blob exists, false if it doesn't - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono exists() { - return existsWithResponse().flatMap(FluxUtil::toMono); - } - - /** - * Determines if the blob this client represents exists in the cloud. - * - *

Code Samples

- * - * - *
-     * client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
-     * 
- * - * - * @return true if the blob exists, false if it doesn't - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> existsWithResponse() { - try { - return withContext(this::existsWithResponse); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> existsWithResponse(Context context) { - return this.getPropertiesWithResponseNoHeaders(context) - .map(cp -> (Response) new SimpleResponse<>(cp, true)) - .onErrorResume(BlobStorageException.class, e -> { - if (BlobErrorCode.BLOB_USES_CUSTOMER_SPECIFIED_ENCRYPTION.equals(e.getErrorCode())) { - HttpResponse response = e.getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), true)); - } else if (e.getStatusCode() == 404) { - HttpResponse response = e.getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), false)); - } else { - return Mono.error(e); - } - }); - } - - /** - * Copies the data at the source URL to a blob. - *

- * This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If - * the source is in another account, the source must either be public or authenticated with a SAS token. If the - * source is in the same account, the Shared Key authorization on the destination will also be applied to the - * source. The source URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * client.beginCopy(url, Duration.ofSeconds(3))
-     *     .subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param sourceUrl The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - * @param pollInterval Duration between each poll for the copy status. If none is specified, a default of one second - * is used. - * @return A {@link PollerFlux} that polls the blob copy operation until it has completed, has failed, or has been - * cancelled. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PollerFlux beginCopy(String sourceUrl, Duration pollInterval) { - return beginCopy(sourceUrl, null, null, null, null, null, pollInterval); - } - - /** - * Copies the data at the source URL to a blob. - *

- * This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If - * the source is in another account, the source must either be public or authenticated with a SAS token. If the - * source is in the same account, the Shared Key authorization on the destination will also be applied to the - * source. The source URL must be URL encoded. - * - *

Starting a copy operation

- * Starting a copy operation and polling on the responses. - * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.beginCopy(url, metadata, AccessTier.HOT, RehydratePriority.STANDARD,
-     *     modifiedRequestConditions, blobRequestConditions, Duration.ofSeconds(2))
-     *     .subscribe(response -> {
-     *         BlobCopyInfo info = response.getValue();
-     *         System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus());
-     *     });
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param sourceUrl The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - * @param metadata Metadata to associate with the destination blob. If there is leading or trailing whitespace in - * any metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param priority {@link RehydratePriority} for rehydrating the blob. - * @param sourceModifiedRequestConditions {@link RequestConditions} against the source. Standard HTTP Access - * conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions - * related to when the blob was changed relative to the given request. The request will fail if the specified - * condition is not satisfied. - * @param destRequestConditions {@link BlobRequestConditions} against the destination. - * @param pollInterval Duration between each poll for the copy status. If none is specified, a default of one second - * is used. - * @return A {@link PollerFlux} that polls the blob copy operation until it has completed, has failed, or has been - * cancelled. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PollerFlux beginCopy(String sourceUrl, Map metadata, AccessTier tier, - RehydratePriority priority, RequestConditions sourceModifiedRequestConditions, - BlobRequestConditions destRequestConditions, Duration pollInterval) { - try { - return this.beginCopy(new BlobBeginCopyOptions(sourceUrl).setMetadata(metadata) - .setTier(tier) - .setRehydratePriority(priority) - .setSourceRequestConditions( - ModelHelper.populateBlobSourceRequestConditions(sourceModifiedRequestConditions)) - .setDestinationRequestConditions(destRequestConditions) - .setPollInterval(pollInterval)); - } catch (RuntimeException ex) { - return PollerFlux.error(LOGGER.logExceptionAsError(ex)); - } - } - - /** - * Copies the data at the source URL to a blob. - *

- * This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If - * the source is in another account, the source must either be public or authenticated with a SAS token. If the - * source is in the same account, the Shared Key authorization on the destination will also be applied to the - * source. The source URL must be URL encoded. - * - *

Starting a copy operation

- * Starting a copy operation and polling on the responses. - * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.beginCopy(new BlobBeginCopyOptions(url).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
-     *     .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions)
-     *     .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2)))
-     *     .subscribe(response -> {
-     *         BlobCopyInfo info = response.getValue();
-     *         System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus());
-     *     });
-     * 
- * - * - *

Cancelling a copy operation

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * PollerFlux<BlobCopyInfo, Void> poller = client.beginCopy(new BlobBeginCopyOptions(url)
-     *     .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
-     *     .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions)
-     *     .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2)));
-     *
-     * poller.take(Duration.ofMinutes(30))
-     *         .last()
-     *         .flatMap(asyncPollResponse -> {
-     *             if (!asyncPollResponse.getStatus().isComplete()) {
-     *                 return asyncPollResponse
-     *                         .cancelOperation()
-     *                         .then(Mono.error(new RuntimeException("Blob copy taking long time, "
-     *                                 + "operation is cancelled!")));
-     *             }
-     *             return Mono.just(asyncPollResponse);
-     *         }).block();
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobBeginCopyOptions} - * @return A {@link PollerFlux} that polls the blob copy operation until it has completed, has failed, or has been - * cancelled. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PollerFlux beginCopy(BlobBeginCopyOptions options) { - StorageImplUtils.assertNotNull("options", options); - final Duration interval = options.getPollInterval() != null ? options.getPollInterval() : Duration.ofSeconds(1); - final BlobBeginCopySourceRequestConditions sourceModifiedCondition - = options.getSourceRequestConditions() == null - ? new BlobBeginCopySourceRequestConditions() - : options.getSourceRequestConditions(); - final BlobRequestConditions destinationRequestConditions = options.getDestinationRequestConditions() == null - ? new BlobRequestConditions() - : options.getDestinationRequestConditions(); - final BlobImmutabilityPolicy immutabilityPolicy - = options.getImmutabilityPolicy() == null ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); - - return new PollerFlux<>(interval, (pollingContext) -> { - try { - return onStart(options.getSourceUrl(), options.getMetadata(), options.getTags(), options.getTier(), - options.getRehydratePriority(), options.isSealDestination(), sourceModifiedCondition, - destinationRequestConditions, immutabilityPolicy, options.isLegalHold()); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - }, (pollingContext) -> { - try { - return onPoll(pollingContext.getLatestResponse()); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - }, (pollingContext, firstResponse) -> { - if (firstResponse == null || firstResponse.getValue() == null) { - return Mono.error(LOGGER.logExceptionAsError( - new IllegalArgumentException("Cannot cancel a poll response that never started."))); - } - final String copyIdentifier = firstResponse.getValue().getCopyId(); - - if (!CoreUtils.isNullOrEmpty(copyIdentifier)) { - LOGGER.info("Cancelling copy operation for copy id: {}", copyIdentifier); - - return abortCopyFromUrl(copyIdentifier).thenReturn(firstResponse.getValue()); - } - - return Mono.empty(); - }, (pollingContext) -> Mono.empty()); - } - - private Mono onStart(String sourceUrl, Map metadata, Map tags, - AccessTier tier, RehydratePriority priority, Boolean sealBlob, - BlobBeginCopySourceRequestConditions sourceModifiedRequestConditions, - BlobRequestConditions destinationRequestConditions, BlobImmutabilityPolicy immutabilityPolicy, - Boolean legalHold) { - try { - new URL(sourceUrl); - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'sourceUrl' is not a valid url.", ex)); - } - - return withContext(context -> azureBlobStorage.getBlobs() - .startCopyFromURLWithResponseAsync(containerName, blobName, sourceUrl, null, metadata, tier, priority, - sourceModifiedRequestConditions.getIfModifiedSince(), - sourceModifiedRequestConditions.getIfUnmodifiedSince(), sourceModifiedRequestConditions.getIfMatch(), - sourceModifiedRequestConditions.getIfNoneMatch(), sourceModifiedRequestConditions.getTagsConditions(), - destinationRequestConditions.getIfModifiedSince(), destinationRequestConditions.getIfUnmodifiedSince(), - destinationRequestConditions.getIfMatch(), destinationRequestConditions.getIfNoneMatch(), - destinationRequestConditions.getTagsConditions(), destinationRequestConditions.getLeaseId(), null, - ModelHelper.tagsToString(tags), sealBlob, immutabilityPolicy.getExpiryTime(), - immutabilityPolicy.getPolicyMode(), legalHold, context)).map(response -> { - final BlobsStartCopyFromURLHeaders headers = response.getDeserializedHeaders(); - - return new BlobCopyInfo(sourceUrl, headers.getXMsCopyId(), headers.getXMsCopyStatus(), - headers.getETag(), headers.getLastModified(), ModelHelper.getErrorCode(response.getHeaders()), - headers.getXMsVersionId()); - }); - } - - private Mono> onPoll(PollResponse pollResponse) { - if (pollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED - || pollResponse.getStatus() == LongRunningOperationStatus.FAILED) { - return Mono.just(pollResponse); - } - - final BlobCopyInfo lastInfo = pollResponse.getValue(); - if (lastInfo == null) { - LOGGER.warning("BlobCopyInfo does not exist. Activation operation failed."); - return Mono - .just(new PollResponse<>(LongRunningOperationStatus.fromString("COPY_START_FAILED", true), null)); - } - - return getProperties().map(response -> { - final CopyStatusType status = response.getCopyStatus(); - final BlobCopyInfo result - = new BlobCopyInfo(response.getCopySource(), response.getCopyId(), status, response.getETag(), - response.getCopyCompletionTime(), response.getCopyStatusDescription(), response.getVersionId()); - - LongRunningOperationStatus operationStatus = ModelHelper.mapStatusToLongRunningOperationStatus(status); - return new PollResponse<>(operationStatus, result); - }).onErrorReturn(new PollResponse<>(LongRunningOperationStatus.fromString("POLLING_FAILED", true), lastInfo)); - } - - /** - * Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata. - * - *

Code Samples

- * - * - *
-     * client.abortCopyFromUrl(copyId).doOnSuccess(response -> System.out.println("Aborted copy from URL"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param copyId The id of the copy operation to abort. - * @return A reactive response signalling completion. - * @see #copyFromUrl(String) - * @see #beginCopy(String, Duration) - * @see #beginCopy(String, Map, AccessTier, RehydratePriority, RequestConditions, BlobRequestConditions, Duration) - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono abortCopyFromUrl(String copyId) { - return abortCopyFromUrlWithResponse(copyId, null).flatMap(FluxUtil::toMono); - } - - /** - * Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata. - * - *

Code Samples

- * - * - *
-     * client.abortCopyFromUrlWithResponse(copyId, leaseId)
-     *     .subscribe(response -> System.out.printf("Aborted copy completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param copyId The id of the copy operation to abort. - * @param leaseId The lease ID the active lease on the blob must match. - * @return A reactive response signalling completion. - * @see #copyFromUrl(String) - * @see #beginCopy(String, Duration) - * @see #beginCopy(String, Map, AccessTier, RehydratePriority, RequestConditions, BlobRequestConditions, Duration) - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> abortCopyFromUrlWithResponse(String copyId, String leaseId) { - try { - return withContext(context -> abortCopyFromUrlWithResponse(copyId, leaseId, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> abortCopyFromUrlWithResponse(String copyId, String leaseId, Context context) { - return this.azureBlobStorage.getBlobs() - .abortCopyFromURLNoCustomHeadersWithResponseAsync(containerName, blobName, copyId, null, leaseId, null, - context); - } - - /** - * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. - *

- * The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token - * attached. The URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * client.copyFromUrl(url).subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param copySource The source URL to copy from. - * @return A reactive response containing the copy ID for the long-running operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono copyFromUrl(String copySource) { - return copyFromUrlWithResponse(copySource, null, null, null, null).flatMap(FluxUtil::toMono); - } - - /** - * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. - *

- * The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token - * attached. The URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions, blobRequestConditions)
-     *     .subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param copySource The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - * @param metadata Metadata to associate with the destination blob. If there is leading or trailing whitespace in - * any metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param sourceModifiedRequestConditions {@link RequestConditions} against the source. Standard HTTP Access - * conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions - * related to when the blob was changed relative to the given request. The request will fail if the specified - * condition is not satisfied. - * @param destRequestConditions {@link BlobRequestConditions} against the destination. - * @return A reactive response containing the copy ID for the long-running operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyFromUrlWithResponse(String copySource, Map metadata, - AccessTier tier, RequestConditions sourceModifiedRequestConditions, - BlobRequestConditions destRequestConditions) { - try { - return this.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(copySource).setMetadata(metadata) - .setTier(tier) - .setSourceRequestConditions(sourceModifiedRequestConditions) - .setDestinationRequestConditions(destRequestConditions)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. - *

- * The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token - * attached. The URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(url).setMetadata(metadata).setTags(tags)
-     *     .setTier(AccessTier.HOT).setSourceRequestConditions(modifiedRequestConditions)
-     *     .setDestinationRequestConditions(blobRequestConditions))
-     *     .subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobCopyFromUrlOptions} - * @return A reactive response containing the copy ID for the long-running operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyFromUrlWithResponse(BlobCopyFromUrlOptions options) { - try { - return withContext(context -> copyFromUrlWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> copyFromUrlWithResponse(BlobCopyFromUrlOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - RequestConditions sourceModifiedRequestConditions = options.getSourceRequestConditions() == null - ? new RequestConditions() - : options.getSourceRequestConditions(); - BlobRequestConditions destRequestConditions = options.getDestinationRequestConditions() == null - ? new BlobRequestConditions() - : options.getDestinationRequestConditions(); - BlobImmutabilityPolicy immutabilityPolicy - = options.getImmutabilityPolicy() == null ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); - - try { - new URL(options.getCopySource()); - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'copySource' is not a valid url.", ex)); - } - String sourceAuth - = options.getSourceAuthorization() == null ? null : options.getSourceAuthorization().toString(); - - return this.azureBlobStorage.getBlobs() - .copyFromURLWithResponseAsync(containerName, blobName, options.getCopySource(), null, options.getMetadata(), - options.getTier(), sourceModifiedRequestConditions.getIfModifiedSince(), - sourceModifiedRequestConditions.getIfUnmodifiedSince(), sourceModifiedRequestConditions.getIfMatch(), - sourceModifiedRequestConditions.getIfNoneMatch(), destRequestConditions.getIfModifiedSince(), - destRequestConditions.getIfUnmodifiedSince(), destRequestConditions.getIfMatch(), - destRequestConditions.getIfNoneMatch(), destRequestConditions.getTagsConditions(), - destRequestConditions.getLeaseId(), null, null, ModelHelper.tagsToString(options.getTags()), - immutabilityPolicy.getExpiryTime(), immutabilityPolicy.getPolicyMode(), options.hasLegalHold(), - sourceAuth, options.getCopySourceTagsMode(), this.encryptionScope, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsCopyId())); - } - - /** - * Reads the entire blob. Uploading data must be done from the {@link BlockBlobClient}, {@link PageBlobClient}, or - * {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
-     * client.download().subscribe(piece -> {
-     *     try {
-     *         downloadData.write(piece.array());
-     *     } catch (IOException ex) {
-     *         throw new UncheckedIOException(ex);
-     *     }
-     * });
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - *

This method will be deprecated in the future. Use {@link #downloadStream()} instead. - * - * @return A reactive response containing the blob data. - * @deprecated use {@link #downloadStream()} instead. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - @Deprecated - public Flux download() { - return downloadStream(); - } - - /** - * Reads the entire blob. Uploading data must be done from the {@link BlockBlobClient}, {@link PageBlobClient}, or - * {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
-     * client.downloadStream().subscribe(piece -> {
-     *     try {
-     *         downloadData.write(piece.array());
-     *     } catch (IOException ex) {
-     *         throw new UncheckedIOException(ex);
-     *     }
-     * });
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return A reactive response containing the blob data. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public Flux downloadStream() { - return downloadWithResponse(null, null, null, false).flatMapMany(BlobDownloadAsyncResponse::getValue); - } - - /** - * Reads the entire blob. Uploading data must be done from the {@link BlockBlobClient}, {@link PageBlobClient}, or - * {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * client.downloadContent().subscribe(data -> {
-     *     System.out.printf("Downloaded %s", data.toString());
-     * });
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - *

This method supports downloads up to 2GB of data. Content will be buffered in memory. If the blob is larger, - * use {@link #downloadStream()} to download larger blobs.

- * - * @return A reactive response containing the blob data. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono downloadContent() { - return downloadWithResponse(null, null, null, false) - .flatMap(response -> BinaryData.fromFlux(response.getValue())); - } - - /** - * Reads a range of bytes from a blob. Uploading data must be done from the {@link BlockBlobClient}, {@link - * PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * BlobRange range = new BlobRange(1024, (long) 2048);
-     * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
-     *
-     * client.downloadWithResponse(range, options, null, false).subscribe(response -> {
-     *     ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
-     *     response.getValue().subscribe(piece -> {
-     *         try {
-     *             downloadData.write(piece.array());
-     *         } catch (IOException ex) {
-     *             throw new UncheckedIOException(ex);
-     *         }
-     *     });
-     * });
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - *

This method will be deprecated in the future. - * Use {@link #downloadStreamWithResponse(BlobRange, DownloadRetryOptions, BlobRequestConditions, boolean)} instead. - * - * @param range {@link BlobRange} - * @param options {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param getRangeContentMd5 Whether the contentMD5 for the specified blob range should be returned. - * @return A reactive response containing the blob data. - * @deprecated use {@link #downloadStreamWithResponse(BlobRange, DownloadRetryOptions, BlobRequestConditions, boolean)} instead. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public Mono downloadWithResponse(BlobRange range, DownloadRetryOptions options, - BlobRequestConditions requestConditions, boolean getRangeContentMd5) { - return downloadStreamWithResponse(range, options, requestConditions, getRangeContentMd5); - } - - /** - * Reads a range of bytes from a blob. Uploading data must be done from the {@link BlockBlobClient}, {@link - * PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * BlobRange range = new BlobRange(1024, (long) 2048);
-     * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
-     *
-     * client.downloadStreamWithResponse(range, options, null, false).subscribe(response -> {
-     *     ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
-     *     response.getValue().subscribe(piece -> {
-     *         try {
-     *             downloadData.write(piece.array());
-     *         } catch (IOException ex) {
-     *             throw new UncheckedIOException(ex);
-     *         }
-     *     });
-     * });
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param range {@link BlobRange} - * @param options {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param getRangeContentMd5 Whether the contentMD5 for the specified blob range should be returned. - * @return A reactive response containing the blob data. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono downloadStreamWithResponse(BlobRange range, DownloadRetryOptions options, - BlobRequestConditions requestConditions, boolean getRangeContentMd5) { - try { - return withContext( - context -> downloadStreamWithResponse(range, options, requestConditions, getRangeContentMd5, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Reads a range of bytes from a blob. Uploading data must be done from the {@link BlockBlobClient}, {@link - * PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
-     *
-     * client.downloadContentWithResponse(options, null).subscribe(response -> {
-     *     BinaryData content = response.getValue();
-     *     System.out.println(content.toString());
-     * });
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - *

This method supports downloads up to 2GB of data. Content will be buffered in memory. If the blob is larger, - * use {@link #downloadStreamWithResponse(BlobRange, DownloadRetryOptions, BlobRequestConditions, boolean)} - * to download larger blobs.

- * - * @param options {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response containing the blob data. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono downloadContentWithResponse(DownloadRetryOptions options, - BlobRequestConditions requestConditions) { - try { - return withContext(context -> downloadStreamWithResponse(null, options, requestConditions, false, context) - .flatMap(r -> BinaryData.fromFlux(r.getValue()) - .map(data -> new BlobDownloadContentAsyncResponse(r.getRequest(), r.getStatusCode(), r.getHeaders(), - data, r.getDeserializedHeaders())))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono downloadStreamWithResponse(BlobRange range, DownloadRetryOptions options, - BlobRequestConditions requestConditions, boolean getRangeContentMd5, Context context) { - BlobRange finalRange = range == null ? new BlobRange(0) : range; - Boolean getMD5 = getRangeContentMd5 ? getRangeContentMd5 : null; - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - DownloadRetryOptions finalOptions = (options == null) ? new DownloadRetryOptions() : options; - - // The first range should eagerly convert headers as they'll be used to create response types. - Context firstRangeContext = context == null - ? new Context("azure-eagerly-convert-headers", true) - : context.addData("azure-eagerly-convert-headers", true); - - return downloadRange(finalRange, finalRequestConditions, finalRequestConditions.getIfMatch(), getMD5, - firstRangeContext).map(response -> { - BlobsDownloadHeaders blobsDownloadHeaders = new BlobsDownloadHeaders(response.getHeaders()); - String eTag = blobsDownloadHeaders.getETag(); - BlobDownloadHeaders blobDownloadHeaders = ModelHelper.populateBlobDownloadHeaders(blobsDownloadHeaders, - ModelHelper.getErrorCode(response.getHeaders())); - - /* - * If the customer did not specify a count, they are reading to the end of the blob. Extract this value - * from the response for better book-keeping towards the end. - */ - long finalCount; - long initialOffset = finalRange.getOffset(); - if (finalRange.getCount() == null) { - long blobLength = ModelHelper.getBlobLength(blobDownloadHeaders); - finalCount = blobLength - initialOffset; - } else { - finalCount = finalRange.getCount(); - } - - // The resume function takes throwable and offset at the destination. - // I.e. offset is relative to the starting point. - BiFunction> onDownloadErrorResume = (throwable, offset) -> { - if (!(throwable instanceof IOException || throwable instanceof TimeoutException)) { - return Mono.error(throwable); - } - - long newCount = finalCount - offset; - - /* - * It's possible that the network stream will throw an error after emitting all data but before - * completing. Issuing a retry at this stage would leave the download in a bad state with - * incorrect count and offset values. Because we have read the intended amount of data, we can - * ignore the error at the end of the stream. - */ - if (newCount == 0) { - LOGGER.warning("Exception encountered in ReliableDownload after all data read from the network " - + "but before stream signaled completion. Returning success as all data was downloaded. " - + "Exception message: " + throwable.getMessage()); - return Mono.empty(); - } - - try { - return downloadRange(new BlobRange(initialOffset + offset, newCount), finalRequestConditions, - eTag, getMD5, context); - } catch (Exception e) { - return Mono.error(e); - } - }; - - return BlobDownloadAsyncResponseConstructorProxy.create(response, onDownloadErrorResume, finalOptions); - }); - } - - private Mono downloadRange(BlobRange range, BlobRequestConditions requestConditions, String eTag, - Boolean getMD5, Context context) { - return azureBlobStorage.getBlobs() - .downloadNoCustomHeadersWithResponseAsync(containerName, blobName, snapshot, versionId, null, - range.toHeaderValue(), requestConditions.getLeaseId(), getMD5, null, null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), eTag, - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, customerProvidedKey, - context); - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

The file will be created and must not exist, if the file already exists a {@link FileAlreadyExistsException} - * will be thrown.

- * - *

Code Samples

- * - * - *
-     * client.downloadToFile(file).subscribe(response -> System.out.println("Completed download to file"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param filePath A {@link String} representing the filePath where the downloaded data will be written. - * @return A reactive response containing the blob properties and metadata. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono downloadToFile(String filePath) { - return downloadToFile(filePath, false); - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

If overwrite is set to false, the file will be created and must not exist, if the file already exists a - * {@link FileAlreadyExistsException} will be thrown.

- * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default value
-     * client.downloadToFile(file, overwrite).subscribe(response -> System.out.println("Completed download to file"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param filePath A {@link String} representing the filePath where the downloaded data will be written. - * @param overwrite Whether to overwrite the file, should the file exist. - * @return A reactive response containing the blob properties and metadata. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono downloadToFile(String filePath, boolean overwrite) { - Set openOptions = null; - if (overwrite) { - openOptions = new HashSet<>(); - openOptions.add(StandardOpenOption.CREATE); - openOptions.add(StandardOpenOption.TRUNCATE_EXISTING); // If the file already exists and it is opened - // for WRITE access, then its length is truncated to 0. - openOptions.add(StandardOpenOption.READ); - openOptions.add(StandardOpenOption.WRITE); - } - return downloadToFileWithResponse(filePath, null, null, null, null, false, openOptions) - .flatMap(FluxUtil::toMono); - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

The file will be created and must not exist, if the file already exists a {@link FileAlreadyExistsException} - * will be thrown.

- * - *

Code Samples

- * - * - *
-     * BlobRange range = new BlobRange(1024, 2048L);
-     * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
-     *
-     * client.downloadToFileWithResponse(file, range, null, options, null, false)
-     *     .subscribe(response -> System.out.println("Completed download to file"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param filePath A {@link String} representing the filePath where the downloaded data will be written. - * @param range {@link BlobRange} - * @param parallelTransferOptions {@link ParallelTransferOptions} to use to download to file. Number of parallel - * transfers parameter is ignored. - * @param options {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param rangeGetContentMd5 Whether the contentMD5 for the specified blob range should be returned. - * @return A reactive response containing the blob properties and metadata. - * @throws IllegalArgumentException If {@code blockSize} is less than 0 or greater than 4000MB. - * @throws UncheckedIOException If an I/O error occurs. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> downloadToFileWithResponse(String filePath, BlobRange range, - ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions options, - BlobRequestConditions requestConditions, boolean rangeGetContentMd5) { - return downloadToFileWithResponse(filePath, range, parallelTransferOptions, options, requestConditions, - rangeGetContentMd5, null); - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

By default the file will be created and must not exist, if the file already exists a - * {@link FileAlreadyExistsException} will be thrown. To override this behavior, provide appropriate - * {@link OpenOption OpenOptions}

- * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(1024, 2048L);
-     * DownloadRetryOptions downloadRetryOptions = new DownloadRetryOptions().setMaxRetryRequests(5);
-     * Set<OpenOption> openOptions = new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW,
-     *     StandardOpenOption.WRITE, StandardOpenOption.READ)); // Default options
-     *
-     * client.downloadToFileWithResponse(file, blobRange, null, downloadRetryOptions, null, false, openOptions)
-     *     .subscribe(response -> System.out.println("Completed download to file"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param filePath A {@link String} representing the filePath where the downloaded data will be written. - * @param range {@link BlobRange} - * @param parallelTransferOptions {@link ParallelTransferOptions} to use to download to file. Number of parallel - * transfers parameter is ignored. - * @param options {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param rangeGetContentMd5 Whether the contentMD5 for the specified blob range should be returned. - * @param openOptions {@link OpenOption OpenOptions} to use to configure how to open or create the file. - * @return A reactive response containing the blob properties and metadata. - * @throws IllegalArgumentException If {@code blockSize} is less than 0 or greater than 4000MB. - * @throws UncheckedIOException If an I/O error occurs. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> downloadToFileWithResponse(String filePath, BlobRange range, - ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions options, - BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Set openOptions) { - try { - final com.azure.storage.common.ParallelTransferOptions finalParallelTransferOptions - = ModelHelper.wrapBlobOptions(ModelHelper.populateAndApplyDefaults(parallelTransferOptions)); - return withContext( - context -> downloadToFileWithResponse(new BlobDownloadToFileOptions(filePath).setRange(range) - .setParallelTransferOptions(finalParallelTransferOptions) - .setDownloadRetryOptions(options) - .setRequestConditions(requestConditions) - .setRetrieveContentRangeMd5(rangeGetContentMd5) - .setOpenOptions(openOptions), context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

By default the file will be created and must not exist, if the file already exists a - * {@link FileAlreadyExistsException} will be thrown. To override this behavior, provide appropriate - * {@link OpenOption OpenOptions}

- * - *

Code Samples

- * - * - *
-     * client.downloadToFileWithResponse(new BlobDownloadToFileOptions(file)
-     *     .setRange(new BlobRange(1024, 2018L))
-     *     .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(5))
-     *     .setOpenOptions(new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE,
-     *         StandardOpenOption.READ))))
-     *     .subscribe(response -> System.out.println("Completed download to file"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobDownloadToFileOptions} - * @return A reactive response containing the blob properties and metadata. - * @throws IllegalArgumentException If {@code blockSize} is less than 0 or greater than 4000MB. - * @throws UncheckedIOException If an I/O error occurs. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> downloadToFileWithResponse(BlobDownloadToFileOptions options) { - try { - return withContext(context -> downloadToFileWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> downloadToFileWithResponse(BlobDownloadToFileOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - - BlobRange finalRange = options.getRange() == null ? new BlobRange(0) : options.getRange(); - final com.azure.storage.common.ParallelTransferOptions finalParallelTransferOptions - = ModelHelper.populateAndApplyDefaults(options.getParallelTransferOptions()); - BlobRequestConditions finalConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - - // Default behavior is not to overwrite - Set openOptions = options.getOpenOptions(); - if (openOptions == null) { - openOptions = DEFAULT_OPEN_OPTIONS_SET; - } - - AsynchronousFileChannel channel = downloadToFileResourceSupplier(options.getFilePath(), openOptions); - return Mono.just(channel) - .flatMap(c -> this.downloadToFileImpl(c, finalRange, finalParallelTransferOptions, - options.getDownloadRetryOptions(), finalConditions, options.isRetrieveContentRangeMd5(), context)) - .doFinally(signalType -> this.downloadToFileCleanup(channel, options.getFilePath(), signalType)); - } - - private AsynchronousFileChannel downloadToFileResourceSupplier(String filePath, Set openOptions) { - try { - return AsynchronousFileChannel.open(Paths.get(filePath), openOptions, null); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new UncheckedIOException(e)); - } - } - - private Mono> downloadToFileImpl(AsynchronousFileChannel file, BlobRange finalRange, - com.azure.storage.common.ParallelTransferOptions finalParallelTransferOptions, - DownloadRetryOptions downloadRetryOptions, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, - Context context) { - // See ProgressReporter for an explanation on why this lock is necessary and why we use AtomicLong. - ProgressListener progressReceiver = finalParallelTransferOptions.getProgressListener(); - ProgressReporter progressReporter - = progressReceiver == null ? null : ProgressReporter.withProgressListener(progressReceiver); - - /* - * Downloads the first chunk and gets the size of the data and etag if not specified by the user. - */ - BiFunction> downloadFunc - = (range, conditions) -> this.downloadStreamWithResponse(range, downloadRetryOptions, conditions, - rangeGetContentMd5, context); - - return ChunkedDownloadUtils - .downloadFirstChunk(finalRange, finalParallelTransferOptions, requestConditions, downloadFunc, true, - context) - .flatMap(setupTuple3 -> { - long newCount = setupTuple3.getT1(); - BlobRequestConditions finalConditions = setupTuple3.getT2(); - - int numChunks = ChunkedDownloadUtils.calculateNumBlocks(newCount, - finalParallelTransferOptions.getBlockSizeLong()); - - // In case it is an empty blob, this ensures we still actually perform a download operation. - numChunks = numChunks == 0 ? 1 : numChunks; - - BlobDownloadAsyncResponse initialResponse = setupTuple3.getT3(); - return Flux.range(0, numChunks) - .flatMap( - chunkNum -> ChunkedDownloadUtils.downloadChunk(chunkNum, initialResponse, finalRange, - finalParallelTransferOptions, finalConditions, newCount, downloadFunc, - response -> writeBodyToFile(response, file, chunkNum, finalParallelTransferOptions, - progressReporter == null ? null : progressReporter.createChild()).flux()), - finalParallelTransferOptions.getMaxConcurrency()) - - // Only the first download call returns a value. - .then(Mono.just(ModelHelper.buildBlobPropertiesResponse(initialResponse))); - }); - } - - private static Mono writeBodyToFile(BlobDownloadAsyncResponse response, AsynchronousFileChannel file, - long chunkNum, com.azure.storage.common.ParallelTransferOptions finalParallelTransferOptions, - ProgressReporter progressReporter) { - - long position = chunkNum * finalParallelTransferOptions.getBlockSizeLong(); - return response.writeValueToAsync(IOUtils.toAsynchronousByteChannel(file, position), progressReporter); - } - - private void downloadToFileCleanup(AsynchronousFileChannel channel, String filePath, SignalType signalType) { - try { - channel.close(); - if (!signalType.equals(SignalType.ON_COMPLETE)) { - Files.deleteIfExists(Paths.get(filePath)); - LOGGER.verbose("Downloading to file failed. Cleaning up resources."); - } - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new UncheckedIOException(e)); - } - } - - /** - * Deletes the specified blob or snapshot. To delete a blob with its snapshots use - * {@link #deleteIfExistsWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions)} and set - * {@code DeleteSnapshotsOptionType} to INCLUDE. - * - *

Code Samples

- * - * - *
-     * client.delete().doOnSuccess(response -> System.out.println("Completed delete"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono delete() { - return deleteWithResponse(null, null).flatMap(FluxUtil::toMono); - } - - /** - * Deletes the specified blob or snapshot. To delete a blob with its snapshots set {@code DeleteSnapshotsOptionType} - * to INCLUDE. - * - *

Code Samples

- * - * - *
-     * client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null)
-     *     .subscribe(response -> System.out.printf("Delete completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param deleteBlobSnapshotOptions Specifies the behavior for deleting the snapshots on this blob. {@code Include} - * will delete the base blob and all snapshots. {@code Only} will delete only the snapshots. If a snapshot is being - * deleted, you must pass null. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, - BlobRequestConditions requestConditions) { - try { - return withContext(context -> deleteWithResponse(deleteBlobSnapshotOptions, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, - BlobRequestConditions requestConditions, Context context) { - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - return this.azureBlobStorage.getBlobs() - .deleteNoCustomHeadersWithResponseAsync(containerName, blobName, snapshot, versionId, null, - requestConditions.getLeaseId(), deleteBlobSnapshotOptions, requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, null, context); - } - - /** - * Deletes the specified blob or snapshot if it exists. To delete a blob with its snapshots use - * {@link #deleteWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions)} and set - * {@code DeleteSnapshotsOptionType} to INCLUDE. - * - *

Code Samples

- * - * - *
-     * client.deleteIfExists().subscribe(deleted -> {
-     *     if (deleted) {
-     *         System.out.println("Successfully deleted.");
-     *     } else {
-     *         System.out.println("Does not exist.");
-     *     }
-     * });
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return A reactive response signaling completion. {@code true} indicates that the blob was deleted. - * {@code false} indicates the blob does not exist at this location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteIfExists() { - return deleteIfExistsWithResponse(null, null).flatMap(FluxUtil::toMono); - } - - /** - * Deletes the specified blob or snapshot if it exists. To delete a blob with its snapshots set {@code DeleteSnapshotsOptionType} - * to INCLUDE. - * - *

Code Samples

- * - * - *
-     * client.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, null).subscribe(response -> {
-     *     if (response.getStatusCode() == 404) {
-     *         System.out.println("Does not exist.");
-     *     } else {
-     *         System.out.println("successfully deleted.");
-     *     }
-     * });
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param deleteBlobSnapshotOptions Specifies the behavior for deleting the snapshots on this blob. {@code Include} - * will delete the base blob and all snapshots. {@code Only} will delete only the snapshots. If a snapshot is being - * deleted, you must pass null. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response signaling completion. If {@link Response}'s status code is 202, the base blob was - * successfully deleted. If status code is 404, the base blob does not exist. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteIfExistsWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, - BlobRequestConditions requestConditions) { - try { - return withContext( - context -> deleteIfExistsWithResponse(deleteBlobSnapshotOptions, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> deleteIfExistsWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, - BlobRequestConditions requestConditions, Context context) { - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - return deleteWithResponse(deleteBlobSnapshotOptions, requestConditions, context) - .map(response -> (Response) new SimpleResponse<>(response, true)) - .onErrorResume(t -> t instanceof BlobStorageException && ((BlobStorageException) t).getStatusCode() == 404, - t -> { - HttpResponse response = ((BlobStorageException) t).getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), false)); - }); - } - - /** - * Returns the blob's metadata and properties. - * - *

Code Samples

- * - * - *
-     * client.getProperties().subscribe(response ->
-     *     System.out.printf("Type: %s, Size: %d%n", response.getBlobType(), response.getBlobSize()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return A reactive response containing the blob properties and metadata. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getProperties() { - return getPropertiesWithResponse(null).flatMap(FluxUtil::toMono); - } - - /** - * Returns the blob's metadata and properties. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.getPropertiesWithResponse(requestConditions).subscribe(
-     *     response -> System.out.printf("Type: %s, Size: %d%n", response.getValue().getBlobType(),
-     *         response.getValue().getBlobSize()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response containing the blob properties and metadata. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesWithResponse(BlobRequestConditions requestConditions) { - try { - return withContext(context -> getPropertiesWithResponse(requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getPropertiesWithResponse(BlobRequestConditions requestConditions, Context context) { - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getBlobs() - .getPropertiesWithResponseAsync(containerName, blobName, snapshot, versionId, null, - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, customerProvidedKey, - context) - .map(rb -> new SimpleResponse<>(rb, BlobPropertiesConstructorProxy - .create(new BlobPropertiesInternalGetProperties(rb.getDeserializedHeaders())))); - } - - Mono> getPropertiesWithResponseNoHeaders(Context context) { - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getBlobs() - .getPropertiesNoCustomHeadersWithResponseAsync(containerName, blobName, snapshot, versionId, null, null, - null, null, null, null, null, null, customerProvidedKey, context); - } - - /** - * Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In - * order to preserve existing values, they must be passed alongside the header being changed. - * - *

Code Samples

- * - * - *
-     * client.setHttpHeaders(new BlobHttpHeaders()
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param headers {@link BlobHttpHeaders} - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setHttpHeaders(BlobHttpHeaders headers) { - return setHttpHeadersWithResponse(headers, null).flatMap(FluxUtil::toMono); - } - - /** - * Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In - * order to preserve existing values, they must be passed alongside the header being changed. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.setHttpHeadersWithResponse(new BlobHttpHeaders()
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary"), requestConditions).subscribe(
-     *         response ->
-     *             System.out.printf("Set HTTP headers completed with status %d%n",
-     *                 response.getStatusCode()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param headers {@link BlobHttpHeaders} - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setHttpHeadersWithResponse(BlobHttpHeaders headers, - BlobRequestConditions requestConditions) { - try { - return withContext(context -> setHttpHeadersWithResponse(headers, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> setHttpHeadersWithResponse(BlobHttpHeaders headers, BlobRequestConditions requestConditions, - Context context) { - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - return this.azureBlobStorage.getBlobs() - .setHttpHeadersNoCustomHeadersWithResponseAsync(containerName, blobName, null, - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, headers, context); - } - - /** - * Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values - * must be preserved, they must be downloaded and included in the call to this method. - * - *

Code Samples

- * - * - *
-     * client.setMetadata(Collections.singletonMap("metadata", "value"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setMetadata(Map metadata) { - return setMetadataWithResponse(metadata, null).flatMap(FluxUtil::toMono); - } - - /** - * Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values - * must be preserved, they must be downloaded and included in the call to this method. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions)
-     *     .subscribe(response -> System.out.printf("Set metadata completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setMetadataWithResponse(Map metadata, - BlobRequestConditions requestConditions) { - try { - return withContext(context -> setMetadataWithResponse(metadata, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> setMetadataWithResponse(Map metadata, BlobRequestConditions requestConditions, - Context context) { - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getBlobs() - .setMetadataNoCustomHeadersWithResponseAsync(containerName, blobName, null, metadata, - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, customerProvidedKey, - encryptionScope, context); - } - - /** - * Returns the blob's tags. - * - *

Code Samples

- * - * - *
-     * client.getTags().subscribe(response ->
-     *     System.out.printf("Num tags: %d%n", response.size()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return A reactive response containing the blob's tags. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getTags() { - return this.getTagsWithResponse(new BlobGetTagsOptions()).map(Response::getValue); - } - - /** - * Returns the blob's tags. - * - *

Code Samples

- * - * - *
-     * client.getTagsWithResponse(new BlobGetTagsOptions()).subscribe(response ->
-     *     System.out.printf("Status code: %d. Num tags: %d%n", response.getStatusCode(), response.getValue().size()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobGetTagsOptions} - * @return A reactive response containing the blob's tags. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> getTagsWithResponse(BlobGetTagsOptions options) { - try { - return withContext(context -> getTagsWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono>> getTagsWithResponse(BlobGetTagsOptions options, Context context) { - options = (options == null) ? new BlobGetTagsOptions() : options; - BlobRequestConditions requestConditions - = (options.getRequestConditions() == null) ? new BlobRequestConditions() : options.getRequestConditions(); - return this.azureBlobStorage.getBlobs() - .getTagsWithResponseAsync(containerName, blobName, null, null, snapshot, versionId, - requestConditions.getTagsConditions(), requestConditions.getLeaseId(), context) - .map(response -> { - Map tags = new HashMap<>(); - for (BlobTag tag : response.getValue().getBlobTagSet()) { - tags.put(tag.getKey(), tag.getValue()); - } - return new SimpleResponse<>(response, tags); - }); - } - - /** - * Sets user defined tags. The specified tags in this method will replace existing tags. If old values must be - * preserved, they must be downloaded and included in the call to this method. - * - *

Code Samples

- * - * - *
-     * client.setTags(Collections.singletonMap("tag", "value"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param tags Tags to associate with the blob. - * @return A reactive response signaling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setTags(Map tags) { - try { - return this.setTagsWithResponse(new BlobSetTagsOptions(tags)).flatMap(FluxUtil::toMono); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Sets user defined tags. The specified tags in this method will replace existing tags. If old values must be - * preserved, they must be downloaded and included in the call to this method. - * - *

Code Samples

- * - * - *
-     * client.setTagsWithResponse(new BlobSetTagsOptions(Collections.singletonMap("tag", "value")))
-     *     .subscribe(response -> System.out.printf("Set tags completed with stats %d%n", response.getStatusCode()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobSetTagsOptions} - * @return A reactive response signaling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setTagsWithResponse(BlobSetTagsOptions options) { - try { - return withContext(context -> setTagsWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> setTagsWithResponse(BlobSetTagsOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - BlobRequestConditions requestConditions - = (options.getRequestConditions() == null) ? new BlobRequestConditions() : options.getRequestConditions(); - List tagList = null; - if (options.getTags() != null) { - tagList = new ArrayList<>(); - for (Map.Entry entry : options.getTags().entrySet()) { - tagList.add(new BlobTag().setKey(entry.getKey()).setValue(entry.getValue())); - } - } - BlobTags t = new BlobTags().setBlobTagSet(tagList); - return this.azureBlobStorage.getBlobs() - .setTagsNoCustomHeadersWithResponseAsync(containerName, blobName, null, versionId, null, null, null, - requestConditions.getTagsConditions(), requestConditions.getLeaseId(), t, context); - } - - /** - * Creates a read-only snapshot of the blob. - * - *

Code Samples

- * - * - *
-     * client.createSnapshot()
-     *     .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n",
-     *         response.getSnapshotId()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return A response containing a {@link BlobAsyncClientBase} which is used to interact with the created snapshot, - * use {@link #getSnapshotId()} to get the identifier for the snapshot. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createSnapshot() { - return createSnapshotWithResponse(null, null).flatMap(FluxUtil::toMono); - } - - /** - * Creates a read-only snapshot of the blob. - * - *

Code Samples

- * - * - *
-     * Map<String, String> snapshotMetadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.createSnapshotWithResponse(snapshotMetadata, requestConditions)
-     *     .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n", response.getValue()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param metadata Metadata to associate with the resource. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @return A response containing a {@link BlobAsyncClientBase} which is used to interact with the created snapshot, - * use {@link #getSnapshotId()} to get the identifier for the snapshot. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createSnapshotWithResponse(Map metadata, - BlobRequestConditions requestConditions) { - try { - return withContext(context -> createSnapshotWithResponse(metadata, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> createSnapshotWithResponse(Map metadata, - BlobRequestConditions requestConditions, Context context) { - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - return this.azureBlobStorage.getBlobs() - .createSnapshotWithResponseAsync(containerName, blobName, null, metadata, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), requestConditions.getLeaseId(), null, customerProvidedKey, - encryptionScope, context) - .map(rb -> new SimpleResponse<>(rb, this.getSnapshotClient(rb.getDeserializedHeaders().getXMsSnapshot()))); - } - - /** - * Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in - * a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of - * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's - * etag. - * - *

Code Samples

- * - * - *
-     * client.setAccessTier(AccessTier.HOT);
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param tier The new tier for the blob. - * @return A reactive response signalling completion. - * @throws NullPointerException if {@code tier} is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setAccessTier(AccessTier tier) { - return setAccessTierWithResponse(tier, null, null).flatMap(FluxUtil::toMono); - } - - /** - * Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in - * a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of - * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's - * etag. - * - *

Code Samples

- * - * - *
-     * client.setAccessTierWithResponse(AccessTier.HOT, RehydratePriority.STANDARD, leaseId)
-     *     .subscribe(response -> System.out.printf("Set tier completed with status code %d%n",
-     *         response.getStatusCode()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param tier The new tier for the blob. - * @param priority Optional priority to set for re-hydrating blobs. - * @param leaseId The lease ID the active lease on the blob must match. - * @return A reactive response signalling completion. - * @throws NullPointerException if {@code tier} is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setAccessTierWithResponse(AccessTier tier, RehydratePriority priority, String leaseId) { - try { - return setAccessTierWithResponse( - new BlobSetAccessTierOptions(tier).setPriority(priority).setLeaseId(leaseId)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in - * a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of - * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's - * etag. - * - *

Code Samples

- * - * - *
-     * client.setAccessTierWithResponse(new BlobSetAccessTierOptions(AccessTier.HOT)
-     *     .setPriority(RehydratePriority.STANDARD)
-     *     .setLeaseId(leaseId)
-     *     .setTagsConditions(tags))
-     *     .subscribe(response -> System.out.printf("Set tier completed with status code %d%n",
-     *         response.getStatusCode()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobSetAccessTierOptions} - * @return A reactive response signalling completion. - * @throws NullPointerException if {@code tier} is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setAccessTierWithResponse(BlobSetAccessTierOptions options) { - try { - return withContext(context -> setTierWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> setTierWithResponse(BlobSetAccessTierOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - - return this.azureBlobStorage.getBlobs() - .setTierNoCustomHeadersWithResponseAsync(containerName, blobName, options.getTier(), snapshot, versionId, - null, options.getPriority(), null, options.getLeaseId(), options.getTagsConditions(), context); - } - - /** - * Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots. - * - *

Code Samples

- * - * - *
-     * client.undelete().doOnSuccess(response -> System.out.println("Completed undelete"));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono undelete() { - return undeleteWithResponse().flatMap(FluxUtil::toMono); - } - - /** - * Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots. - * - *

Code Samples

- * - * - *
-     * client.undeleteWithResponse()
-     *     .subscribe(response -> System.out.printf("Undelete completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> undeleteWithResponse() { - try { - return withContext(this::undeleteWithResponse); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> undeleteWithResponse(Context context) { - return this.azureBlobStorage.getBlobs() - .undeleteNoCustomHeadersWithResponseAsync(containerName, blobName, null, null, context); - } - - /** - * Returns the sku name and account kind for the account. - * - *

Code Samples

- * - * - *
-     * client.getAccountInfo().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n",
-     *     response.getAccountKind(), response.getSkuName()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return a reactor response containing the sku name and account kind. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAccountInfo() { - return getAccountInfoWithResponse().flatMap(FluxUtil::toMono); - } - - /** - * Returns the sku name and account kind for the account. - * - *

Code Samples

- * - * - *
-     * client.getAccountInfoWithResponse().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n",
-     *     response.getValue().getAccountKind(), response.getValue().getSkuName()));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return a reactor response containing the sku name and account kind. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAccountInfoWithResponse() { - try { - return withContext(this::getAccountInfoWithResponse); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getAccountInfoWithResponse(Context context) { - return this.azureBlobStorage.getBlobs() - .getAccountInfoWithResponseAsync(containerName, blobName, null, null, context) - .map(rb -> { - BlobsGetAccountInfoHeaders hd = rb.getDeserializedHeaders(); - return new SimpleResponse<>(rb, - new StorageAccountInfo(hd.getXMsSkuName(), hd.getXMsAccountKind(), hd.isXMsIsHnsEnabled())); - }); - } - - /** - * Generates a user delegation SAS for the blob using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateUserDelegationSas(values, userDelegationKey);
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey) { - return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, getAccountName(), - Context.NONE); - } - - /** - * Generates a user delegation SAS for the blob using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value"));
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * @param accountName The account name. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey, String accountName, Context context) { - return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, accountName, null, context); - } - - /** - * Generates a user delegation SAS for the blob using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * @param accountName The account name. - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey, String accountName, Consumer stringToSignHandler, - Context context) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId(), - getVersionId(), getEncryptionScope()).generateUserDelegationSas(userDelegationKey, accountName, - stringToSignHandler, context); - } - - /** - * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobSasPermission permission = new BlobSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return generateSas(blobServiceSasSignatureValues, Context.NONE); - } - - /** - * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobSasPermission permission = new BlobSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * // Client must be authenticated via StorageSharedKeyCredential
-     * client.generateSas(values, new Context("key", "value"));
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context) { - return generateSas(blobServiceSasSignatureValues, null, context); - } - - /** - * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - Consumer stringToSignHandler, Context context) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId(), - getVersionId(), getEncryptionScope()) - .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); - } - - /** - * Queries the entire blob. - * - *

For more information, see the - * Azure Docs

- * - *

Code Samples

- * - * - *
-     * ByteArrayOutputStream queryData = new ByteArrayOutputStream();
-     * String expression = "SELECT * from BlobStorage";
-     * client.query(expression).subscribe(piece -> {
-     *     try {
-     *         queryData.write(piece.array());
-     *     } catch (IOException ex) {
-     *         throw new UncheckedIOException(ex);
-     *     }
-     * });
-     * 
- * - * - * @param expression The query expression. - * @return A reactive response containing the queried data. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public Flux query(String expression) { - try { - return queryWithResponse(new BlobQueryOptions(expression)).flatMapMany(BlobQueryAsyncResponse::getValue); - } catch (RuntimeException ex) { - return fluxError(LOGGER, ex); - } - } - - /** - * Queries the entire blob. - * - *

For more information, see the - * Azure Docs

- * - *

Code Samples

- * - * - *
-     * String expression = "SELECT * from BlobStorage";
-     * BlobQueryJsonSerialization input = new BlobQueryJsonSerialization()
-     *     .setRecordSeparator('\n');
-     * BlobQueryDelimitedSerialization output = new BlobQueryDelimitedSerialization()
-     *     .setEscapeChar('\0')
-     *     .setColumnSeparator(',')
-     *     .setRecordSeparator('\n')
-     *     .setFieldQuote('\'')
-     *     .setHeadersPresent(true);
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * Consumer<BlobQueryError> errorConsumer = System.out::println;
-     * Consumer<BlobQueryProgress> progressConsumer = progress -> System.out.println("total blob bytes read: "
-     *     + progress.getBytesScanned());
-     * BlobQueryOptions queryOptions = new BlobQueryOptions(expression)
-     *     .setInputSerialization(input)
-     *     .setOutputSerialization(output)
-     *     .setRequestConditions(requestConditions)
-     *     .setErrorConsumer(errorConsumer)
-     *     .setProgressConsumer(progressConsumer);
-     *
-     * client.queryWithResponse(queryOptions)
-     *     .subscribe(response -> {
-     *         ByteArrayOutputStream queryData = new ByteArrayOutputStream();
-     *         response.getValue().subscribe(piece -> {
-     *             try {
-     *                 queryData.write(piece.array());
-     *             } catch (IOException ex) {
-     *                 throw new UncheckedIOException(ex);
-     *             }
-     *         });
-     *     });
-     * 
- * - * - * @param queryOptions {@link BlobQueryOptions The query options}. - * @return A reactive response containing the queried data. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono queryWithResponse(BlobQueryOptions queryOptions) { - try { - return withContext(context -> queryWithResponse(queryOptions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono queryWithResponse(BlobQueryOptions queryOptions, Context context) { - StorageImplUtils.assertNotNull("queryOptions", queryOptions); - BlobRequestConditions requestConditions = queryOptions.getRequestConditions() == null - ? new BlobRequestConditions() - : queryOptions.getRequestConditions(); - - QuerySerialization in - = BlobQueryReader.transformInputSerialization(queryOptions.getInputSerialization(), LOGGER); - QuerySerialization out - = BlobQueryReader.transformOutputSerialization(queryOptions.getOutputSerialization(), LOGGER); - - QueryRequest qr = new QueryRequest().setExpression(queryOptions.getExpression()) - .setInputSerialization(in) - .setOutputSerialization(out); - - return this.azureBlobStorage.getBlobs() - .queryWithResponseAsync(containerName, blobName, getSnapshotId(), null, requestConditions.getLeaseId(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, qr, getCustomerProvidedKey(), context) - .map(response -> new BlobQueryAsyncResponse(response.getRequest(), response.getStatusCode(), - response.getHeaders(), - /* Parse the avro reactive stream. */ - new BlobQueryReader(response.getValue(), queryOptions.getProgressConsumer(), - queryOptions.getErrorConsumer()).read(), - ModelHelper.transformQueryHeaders(response.getDeserializedHeaders(), response.getHeaders()))); - } - - /** - * Sets the immutability policy on a blob, blob snapshot or blob version. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * object level immutable policy enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * BlobImmutabilityPolicy policy = new BlobImmutabilityPolicy()
-     *     .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED)
-     *     .setExpiryTime(OffsetDateTime.now().plusDays(1));
-     * client.setImmutabilityPolicy(policy).subscribe(response -> System.out.println("Completed. Set immutability "
-     *     + "policy to " + response.getPolicyMode()));
-     * 
- * - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy The immutability policy}. - * @return A reactive response containing the immutability policy. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - return setImmutabilityPolicyWithResponse(immutabilityPolicy, null).flatMap(FluxUtil::toMono); - } - - /** - * Sets the immutability policy on a blob, blob snapshot or blob version. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * immutable storage with versioning enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy()
-     *     .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED)
-     *     .setExpiryTime(OffsetDateTime.now().plusDays(1));
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1));
-     * client.setImmutabilityPolicyWithResponse(immutabilityPolicy, requestConditions).subscribe(response ->
-     *     System.out.println("Completed. Set immutability policy to " + response.getValue().getPolicyMode()));
-     * 
- * - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy The immutability policy}. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response containing the immutability policy. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setImmutabilityPolicyWithResponse( - BlobImmutabilityPolicy immutabilityPolicy, BlobRequestConditions requestConditions) { - try { - return withContext( - context -> setImmutabilityPolicyWithResponse(immutabilityPolicy, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy immutabilityPolicy, - BlobRequestConditions requestConditions, Context context) { - context = context == null ? Context.NONE : context; - BlobImmutabilityPolicy finalImmutabilityPolicy - = immutabilityPolicy == null ? new BlobImmutabilityPolicy() : immutabilityPolicy; - if (BlobImmutabilityPolicyMode.MUTABLE.equals(finalImmutabilityPolicy.getPolicyMode())) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException(String.format("immutabilityPolicy.policyMode must be %s or %s", - BlobImmutabilityPolicyMode.LOCKED.toString(), BlobImmutabilityPolicyMode.UNLOCKED.toString()))); - } - - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - ModelHelper.validateConditionsNotPresent(finalRequestConditions, - EnumSet.of(BlobRequestConditionProperty.LEASE_ID, BlobRequestConditionProperty.TAGS_CONDITIONS, - BlobRequestConditionProperty.IF_MATCH, BlobRequestConditionProperty.IF_NONE_MATCH, - BlobRequestConditionProperty.IF_MODIFIED_SINCE), - "setImmutabilityPolicy(WithResponse)", "requestConditions"); - - return this.azureBlobStorage.getBlobs() - .setImmutabilityPolicyWithResponseAsync(containerName, blobName, null, null, - finalRequestConditions.getIfUnmodifiedSince(), finalImmutabilityPolicy.getExpiryTime(), - finalImmutabilityPolicy.getPolicyMode(), snapshot, versionId, context) - .map(response -> { - BlobsSetImmutabilityPolicyHeaders headers = response.getDeserializedHeaders(); - BlobImmutabilityPolicy responsePolicy - = new BlobImmutabilityPolicy().setPolicyMode(headers.getXMsImmutabilityPolicyMode()) - .setExpiryTime(headers.getXMsImmutabilityPolicyUntilDate()); - return new SimpleResponse<>(response, responsePolicy); - }); - } - - /** - * Deletes the immutability policy on a blob, blob snapshot or blob version. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * object level immutable policy enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * client.deleteImmutabilityPolicy().subscribe(response -> System.out.println("Completed immutability policy"
-     *     + " deletion."));
-     * 
- * - * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteImmutabilityPolicy() { - return deleteImmutabilityPolicyWithResponse().flatMap(FluxUtil::toMono); - } - - /** - * Deletes the immutability policy on a blob, blob snapshot or blob version. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * immutable storage with versioning enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * client.deleteImmutabilityPolicyWithResponse().subscribe(response ->
-     *     System.out.println("Delete immutability policy completed with status: " + response.getStatusCode()));
-     * 
- * - * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteImmutabilityPolicyWithResponse() { - try { - return withContext(this::deleteImmutabilityPolicyWithResponse); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> deleteImmutabilityPolicyWithResponse(Context context) { - context = context == null ? Context.NONE : context; - return this.azureBlobStorage.getBlobs() - .deleteImmutabilityPolicyNoCustomHeadersWithResponseAsync(containerName, blobName, null, null, snapshot, - versionId, context); - } - - /** - * Sets a legal hold on the blob. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * object level immutable policy enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * client.setLegalHold(true).subscribe(response -> System.out.println("Legal hold status: "
-     *     + response.hasLegalHold()));
-     * 
- * - * - * @param legalHold Whether you want a legal hold on the blob. - * @return A reactive response containing the legal hold result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setLegalHold(boolean legalHold) { - return setLegalHoldWithResponse(legalHold).flatMap(FluxUtil::toMono); - } - - /** - * Sets a legal hold on the blob. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * immutable storage with versioning enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * client.setLegalHoldWithResponse(true).subscribe(response ->
-     *     System.out.println("Legal hold status: " + response.getValue().hasLegalHold()));
-     * 
- * - * - * @param legalHold Whether you want a legal hold on the blob. - * @return A reactive response containing the legal hold result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setLegalHoldWithResponse(boolean legalHold) { - try { - return withContext(context -> setLegalHoldWithResponse(legalHold, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> setLegalHoldWithResponse(boolean legalHold, Context context) { - context = context == null ? Context.NONE : context; - return this.azureBlobStorage.getBlobs() - .setLegalHoldWithResponseAsync(containerName, blobName, legalHold, null, null, snapshot, versionId, context) - .map(response -> new SimpleResponse<>(response, - new InternalBlobLegalHoldResult(response.getDeserializedHeaders().isXMsLegalHold()))); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java deleted file mode 100644 index e2211b71e785..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java +++ /dev/null @@ -1,2802 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.PollingContext; -import com.azure.core.util.polling.SyncPoller; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.BlobContainerClientBuilder; -import com.azure.storage.blob.BlobServiceClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.AzureBlobStorageImpl; -import com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder; -import com.azure.storage.blob.implementation.accesshelpers.BlobPropertiesConstructorProxy; -import com.azure.storage.blob.implementation.models.BlobPropertiesInternalGetProperties; -import com.azure.storage.blob.implementation.models.BlobTag; -import com.azure.storage.blob.implementation.models.BlobTags; -import com.azure.storage.blob.implementation.models.BlobsCopyFromURLHeaders; -import com.azure.storage.blob.implementation.models.BlobsCreateSnapshotHeaders; -import com.azure.storage.blob.implementation.models.BlobsGetAccountInfoHeaders; -import com.azure.storage.blob.implementation.models.BlobsGetPropertiesHeaders; -import com.azure.storage.blob.implementation.models.BlobsGetTagsHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetImmutabilityPolicyHeaders; -import com.azure.storage.blob.implementation.models.BlobsSetLegalHoldHeaders; -import com.azure.storage.blob.implementation.models.BlobsStartCopyFromURLHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.InternalBlobLegalHoldResult; -import com.azure.storage.blob.implementation.util.BlobRequestConditionProperty; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; -import com.azure.storage.blob.implementation.util.ByteBufferBackedOutputStreamUtil; -import com.azure.storage.blob.implementation.util.ChunkedDownloadUtils; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobDownloadAsyncResponse; -import com.azure.storage.blob.models.BlobDownloadContentAsyncResponse; -import com.azure.storage.blob.models.BlobDownloadContentResponse; -import com.azure.storage.blob.models.BlobDownloadResponse; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.BlobLegalHoldResult; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobQueryAsyncResponse; -import com.azure.storage.blob.models.BlobQueryResponse; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobSeekableByteChannelReadResult; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.ConsistentReadControl; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobBeginCopyOptions; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.options.BlobDownloadToFileOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.BlobInputStreamOptions; -import com.azure.storage.blob.options.BlobQueryOptions; -import com.azure.storage.blob.options.BlobSeekableByteChannelReadOptions; -import com.azure.storage.blob.options.BlobSetAccessTierOptions; -import com.azure.storage.blob.options.BlobSetTagsOptions; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.FluxInputStream; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.implementation.StorageSeekableByteChannel; -import reactor.core.publisher.Mono; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UncheckedIOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.channels.SeekableByteChannel; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.OpenOption; -import java.nio.file.StandardOpenOption; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.function.Consumer; - -import static com.azure.storage.common.implementation.StorageImplUtils.blockWithOptionalTimeout; -import static com.azure.storage.common.implementation.StorageImplUtils.sendRequest; - -/** - * This class provides a client that contains all operations that apply to any blob type. - * - *

- * This client offers the ability to download blobs. Note that uploading data is specific to each type of blob. Please - * refer to the {@link BlockBlobClient}, {@link PageBlobClient}, or {@link AppendBlobClient} for upload options. - */ -public class BlobClientBase { - private static final ClientLogger LOGGER = new ClientLogger(BlobClientBase.class); - private static final Set DEFAULT_OPEN_OPTIONS_SET = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.READ, StandardOpenOption.WRITE))); - - /** - * Backing REST client for the blob client. - */ - final AzureBlobStorageImpl azureBlobStorage; - - private final String snapshot; - private final String versionId; - private final CpkInfo customerProvidedKey; - - /** - * Encryption scope of the blob. - */ - final EncryptionScope encryptionScope; - - /** - * Storage account name that contains the blob. - */ - protected final String accountName; - - /** - * Container name that contains the blob. - */ - protected final String containerName; - - /** - * Name of the blob. - */ - protected final String blobName; - - /** - * Storage REST API version used in requests to the Storage service. - */ - protected final BlobServiceVersion serviceVersion; - - private final BlobAsyncClientBase client; - - /** - * Constructor used by {@link SpecializedBlobClientBuilder}. - * - * @param client the async blob client - */ - protected BlobClientBase(BlobAsyncClientBase client) { - this(client, client.getHttpPipeline(), client.getAccountUrl(), client.getServiceVersion(), - client.getAccountName(), client.getContainerName(), client.getBlobName(), client.getSnapshotId(), - client.getCustomerProvidedKey(), new EncryptionScope().setEncryptionScope(client.getEncryptionScope()), - client.getVersionId()); - } - - /** - * Protected constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param client the async blob client - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - protected BlobClientBase(BlobAsyncClientBase client, HttpPipeline pipeline, String url, - BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, - CpkInfo customerProvidedKey, EncryptionScope encryptionScope, String versionId) { - if (snapshot != null && versionId != null) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("'snapshot' and 'versionId' cannot be used at the same time.")); - } - this.client = client; - this.azureBlobStorage = new AzureBlobStorageImplBuilder().pipeline(pipeline) - .url(url) - .version(serviceVersion.getVersion()) - .buildClient(); - this.serviceVersion = serviceVersion; - - this.accountName = accountName; - this.containerName = containerName; - this.blobName = blobName; - this.snapshot = snapshot; - this.customerProvidedKey = customerProvidedKey; - this.encryptionScope = encryptionScope; - this.versionId = versionId; - /* Check to make sure the uri is valid. We don't want the error to occur later in the generated layer - when the sas token has already been applied. */ - try { - URI.create(getBlobUrl()); - } catch (IllegalArgumentException ex) { - throw LOGGER.logExceptionAsError(ex); - } - } - - /** - * Creates a new {@link BlobClientBase} linked to the {@code snapshot} of this blob resource. - * - * @param snapshot the identifier for a specific snapshot of this blob - * @return a {@link BlobClientBase} used to interact with the specific snapshot. - */ - public BlobClientBase getSnapshotClient(String snapshot) { - return new BlobClientBase(this.client.getSnapshotClient(snapshot), getHttpPipeline(), getAccountUrl(), - getServiceVersion(), getAccountName(), getContainerName(), getBlobName(), snapshot, - getCustomerProvidedKey(), encryptionScope, getVersionId()); - } - - /** - * Creates a new {@link BlobClientBase} linked to the {@code version} of this blob resource. - * - * @param versionId the identifier for a specific version of this blob, - * pass {@code null} to interact with the latest blob version. - * @return a {@link BlobClientBase} used to interact with the specific version. - */ - public BlobClientBase getVersionClient(String versionId) { - return new BlobClientBase(this.client.getVersionClient(versionId), getHttpPipeline(), getAccountUrl(), - getServiceVersion(), getAccountName(), getContainerName(), getBlobName(), getSnapshotId(), - getCustomerProvidedKey(), encryptionScope, versionId); - } - - /** - * Creates a new {@link BlobClientBase} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link BlobClientBase} with the specified {@code encryptionScope}. - */ - public BlobClientBase getEncryptionScopeClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - return new BlobClientBase(this.client.getEncryptionScopeAsyncClient(encryptionScope), getHttpPipeline(), - getAccountUrl(), getServiceVersion(), getAccountName(), getContainerName(), getBlobName(), snapshot, - getCustomerProvidedKey(), finalEncryptionScope, getVersionId()); - } - - /** - * Creates a new {@link BlobClientBase} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link BlobClientBase} with the specified {@code customerProvidedKey}. - */ - public BlobClientBase getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - return new BlobClientBase(this.client.getCustomerProvidedKeyAsyncClient(customerProvidedKey), getHttpPipeline(), - getAccountUrl(), getServiceVersion(), getAccountName(), getContainerName(), getBlobName(), snapshot, - finalCustomerProvidedKey, encryptionScope, getVersionId()); - } - - /** - * Get the url of the storage account. - * - * @return the URL of the storage account - */ - public String getAccountUrl() { - return azureBlobStorage.getUrl(); - } - - /** - * Gets the URL of the blob represented by this client. - * - * @return the URL. - */ - public String getBlobUrl() { - String blobUrl = azureBlobStorage.getUrl() + "/" + containerName + "/" + Utility.urlEncode(blobName); - if (this.isSnapshot()) { - blobUrl = Utility.appendQueryParameter(blobUrl, "snapshot", getSnapshotId()); - } - if (this.getVersionId() != null) { - blobUrl = Utility.appendQueryParameter(blobUrl, "versionid", getVersionId()); - } - return blobUrl; - } - - /** - * Get associated account name. - * - * @return account name associated with this storage resource. - */ - public String getAccountName() { - return this.accountName; - } - - /** - * Get the container name. - * - *

Code Samples

- * - * - *
-     * String containerName = client.getContainerName();
-     * System.out.println("The name of the container is " + containerName);
-     * 
- * - * - * @return The name of the container. - */ - public final String getContainerName() { - return this.containerName; - } - - /** - * Gets a client pointing to the parent container. - * - *

Code Samples

- * - * - *
-     * BlobContainerClient containerClient = client.getContainerClient();
-     * System.out.println("The name of the container is " + containerClient.getBlobContainerName());
-     * 
- * - * - * @return {@link BlobContainerClient} - */ - public BlobContainerClient getContainerClient() { - CustomerProvidedKey encryptionKey = this.customerProvidedKey == null - ? null - : new CustomerProvidedKey(this.customerProvidedKey.getEncryptionKey()); - return new BlobContainerClientBuilder().endpoint(this.getBlobUrl()) - .pipeline(this.getHttpPipeline()) - .serviceVersion(this.serviceVersion) - .customerProvidedKey(encryptionKey) - .encryptionScope(this.getEncryptionScope()) - .buildClient(); - } - - /** - * Decodes and gets the blob name. - * - *

Code Samples

- * - * - *
-     * String blobName = client.getBlobName();
-     * System.out.println("The name of the blob is " + blobName);
-     * 
- * - * - * @return The decoded name of the blob. - */ - public final String getBlobName() { - return this.blobName; - } - - /** - * Gets the {@link HttpPipeline} powering this client. - * - * @return The pipeline. - */ - public HttpPipeline getHttpPipeline() { - return azureBlobStorage.getHttpPipeline(); - } - - /** - * Gets the {@link CpkInfo} used to encrypt this blob's content on the server. - * - * @return the customer provided key used for encryption. - */ - public CpkInfo getCustomerProvidedKey() { - return this.customerProvidedKey; - } - - /** - * Gets the {@code encryption scope} used to encrypt this blob's content on the server. - * - * @return the encryption scope used for encryption. - */ - public String getEncryptionScope() { - if (encryptionScope == null) { - return null; - } - return encryptionScope.getEncryptionScope(); - } - - /** - * Gets the service version the client is using. - * - * @return the service version the client is using. - */ - public BlobServiceVersion getServiceVersion() { - return this.serviceVersion; - } - - /** - * Gets the snapshotId for a blob resource - * - * @return A string that represents the snapshotId of the snapshot blob - */ - public String getSnapshotId() { - return this.snapshot; - } - - /** - * Gets the versionId for a blob resource - * - * @return A string that represents the versionId of the snapshot blob - */ - public String getVersionId() { - return this.versionId; - } - - /** - * Determines if a blob is a snapshot - * - * @return A boolean that indicates if a blob is a snapshot - */ - public boolean isSnapshot() { - return this.snapshot != null; - } - - /** - * Opens a blob input stream to download the blob. - * - * @return An InputStream object that represents the stream to use for reading from the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobInputStream openInputStream() { - return openInputStream((BlobRange) null, null); - } - - /** - * Opens a blob input stream to download the specified range of the blob. - * - * @param range {@link BlobRange} - * @param requestConditions An {@link BlobRequestConditions} object that represents the access conditions for the - * blob. - * @return An InputStream object that represents the stream to use for reading from the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobInputStream openInputStream(BlobRange range, BlobRequestConditions requestConditions) { - return openInputStream(new BlobInputStreamOptions().setRange(range).setRequestConditions(requestConditions)); - } - - /** - * Opens a blob input stream to download the specified range of the blob. - * - * @param options {@link BlobInputStreamOptions} - * @return An InputStream object that represents the stream to use for reading from the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobInputStream openInputStream(BlobInputStreamOptions options) { - return openInputStream(options, null); - } - - /** - * Opens a blob input stream to download the specified range of the blob. - * - * @param options {@link BlobInputStreamOptions} - * @param context {@link Context} - * @return An InputStream object that represents the stream to use for reading from the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobInputStream openInputStream(BlobInputStreamOptions options, Context context) { - Context contextFinal = context == null ? Context.NONE : context; - options = options == null ? new BlobInputStreamOptions() : options; - ConsistentReadControl consistentReadControl = options.getConsistentReadControl() == null - ? ConsistentReadControl.ETAG - : options.getConsistentReadControl(); - BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - - BlobRange range = options.getRange() == null ? new BlobRange(0) : options.getRange(); - int chunkSize = options.getBlockSize() == null ? 4 * Constants.MB : options.getBlockSize(); - - com.azure.storage.common.ParallelTransferOptions parallelTransferOptions - = new com.azure.storage.common.ParallelTransferOptions().setBlockSizeLong((long) chunkSize); - BiFunction> downloadFunc = (chunkRange, - conditions) -> client.downloadStreamWithResponse(chunkRange, null, conditions, false, contextFinal); - return ChunkedDownloadUtils - .downloadFirstChunk(range, parallelTransferOptions, requestConditions, downloadFunc, true) - .flatMap(tuple3 -> { - BlobDownloadAsyncResponse downloadResponse = tuple3.getT3(); - return FluxUtil.collectBytesInByteBufferStream(downloadResponse.getValue()) - .map(ByteBuffer::wrap) - .zipWith(Mono.just(downloadResponse)); - }) - .flatMap(tuple2 -> { - ByteBuffer initialBuffer = tuple2.getT1(); - BlobDownloadAsyncResponse downloadResponse = tuple2.getT2(); - - BlobProperties properties = ModelHelper.buildBlobPropertiesResponse(downloadResponse).getValue(); - - String eTag = properties.getETag(); - String versionId = properties.getVersionId(); - BlobClientBase client = this; - - switch (consistentReadControl) { - case NONE: - break; - - case ETAG: - // Target the user specified eTag by default. If not provided, target the latest eTag. - if (requestConditions.getIfMatch() == null) { - requestConditions.setIfMatch(eTag); - } - break; - - case VERSION_ID: - if (versionId == null) { - return FluxUtil.monoError(LOGGER, - new UnsupportedOperationException("Versioning is not supported on this account.")); - } else { - // Target the user specified version by default. If not provided, target the latest version. - if (getVersionId() == null) { - client = getVersionClient(versionId); - } - } - break; - - default: - return FluxUtil.monoError(LOGGER, - new IllegalArgumentException("Concurrency control type not " + "supported.")); - } - - return Mono.just(new BlobInputStream(client, range.getOffset(), range.getCount(), chunkSize, - initialBuffer, requestConditions, properties, contextFinal)); - }) - .block(); - } - - /** - * Opens a seekable byte channel in read-only mode to download the blob. - * - * @param options {@link BlobSeekableByteChannelReadOptions} - * @param context {@link Context} - * @return A SeekableByteChannel that represents the channel to use for reading from the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobSeekableByteChannelReadResult openSeekableByteChannelRead(BlobSeekableByteChannelReadOptions options, - Context context) { - context = context == null ? Context.NONE : context; - options = options == null ? new BlobSeekableByteChannelReadOptions() : options; - ConsistentReadControl consistentReadControl = options.getConsistentReadControl() == null - ? ConsistentReadControl.ETAG - : options.getConsistentReadControl(); - int chunkSize = options.getReadSizeInBytes() == null ? 4 * Constants.MB : options.getReadSizeInBytes(); - long initialPosition = options.getInitialPosition() == null ? 0 : options.getInitialPosition(); - - ByteBuffer initialRange = ByteBuffer.allocate(chunkSize); - BlobProperties properties; - BlobDownloadResponse response; - try (ByteBufferBackedOutputStreamUtil dstStream = new ByteBufferBackedOutputStreamUtil(initialRange)) { - response = this.downloadStreamWithResponse(dstStream, - new BlobRange(initialPosition, (long) initialRange.remaining()), null /*downloadRetryOptions*/, - options.getRequestConditions(), false, null, context); - properties = ModelHelper.buildBlobPropertiesResponse(response).getValue(); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new UncheckedIOException(e)); - } - - initialRange.limit(initialRange.position()); - initialRange.rewind(); - - BlobClientBase behaviorClient = this; - BlobRequestConditions requestConditions = options.getRequestConditions(); - switch (consistentReadControl) { - case NONE: - break; - - case ETAG: - requestConditions = requestConditions != null ? requestConditions : new BlobRequestConditions(); - // If etag locking but no explicitly specified etag, use the etag from prefetch - if (requestConditions.getIfMatch() == null) { - requestConditions.setIfMatch(properties.getETag()); - } - break; - - case VERSION_ID: - if (properties.getVersionId() == null) { - throw LOGGER.logExceptionAsError(new UnsupportedOperationException( - "Version ID locking unsupported. Versioning is not supported on this account.")); - } else { - // If version locking but no explicitly specified version, use the latest version from prefetch - if (getVersionId() == null) { - behaviorClient = this.getVersionClient(properties.getVersionId()); - } - } - break; - - default: - throw LOGGER.logExceptionAsError(new IllegalArgumentException( - "Concurrency control type " + consistentReadControl + " not supported.")); - } - - StorageSeekableByteChannelBlobReadBehavior behavior = new StorageSeekableByteChannelBlobReadBehavior( - behaviorClient, initialRange, initialPosition, properties.getBlobSize(), requestConditions); - - SeekableByteChannel channel = new StorageSeekableByteChannel(chunkSize, behavior, initialPosition); - return new BlobSeekableByteChannelReadResult(channel, properties); - } - - /** - * Gets if the blob this client represents exists in the cloud. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Exists? %b%n", client.exists());
-     * 
- * - * - * @return true if the blob exists, false if it doesn't - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Boolean exists() { - return existsWithResponse(null, Context.NONE).getValue(); - } - - /** - * Gets if the blob this client represents exists in the cloud. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, new Context(key2, value2)).getValue());
-     * 
- * - * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return true if the blob exists, false if it doesn't - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response existsWithResponse(Duration timeout, Context context) { - try { - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .getPropertiesNoCustomHeadersWithResponse(containerName, blobName, snapshot, versionId, null, null, - null, null, null, null, null, null, customerProvidedKey, context); - return new SimpleResponse<>(sendRequest(operation, timeout, BlobStorageException.class), true); - } catch (RuntimeException e) { - if (e instanceof BlobStorageException) { - HttpResponse response = ((BlobStorageException) e).getResponse(); - if (BlobErrorCode.BLOB_USES_CUSTOMER_SPECIFIED_ENCRYPTION - .equals(((BlobStorageException) e).getErrorCode())) { - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - true); - } else if (((BlobStorageException) e).getResponse().getStatusCode() == 404) { - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - false); - } else { - throw LOGGER.logExceptionAsError(e); - } - } else { - throw LOGGER.logExceptionAsError(e); - } - } - } - - /** - * Copies the data at the source URL to a blob. - *

- * This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If - * the source is in another account, the source must either be public or authenticated with a SAS token. If the - * source is in the same account, the Shared Key authorization on the destination will also be applied to the - * source. The source URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * final SyncPoller<BlobCopyInfo, Void> poller = client.beginCopy(url, Duration.ofSeconds(2));
-     * PollResponse<BlobCopyInfo> pollResponse = poller.poll();
-     * System.out.printf("Copy identifier: %s%n", pollResponse.getValue().getCopyId());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param sourceUrl The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - * @param pollInterval Duration between each poll for the copy status. If none is specified, a default of one second - * is used. - * @return A {@link SyncPoller} to poll the progress of blob copy operation. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public SyncPoller beginCopy(String sourceUrl, Duration pollInterval) { - return beginCopy(sourceUrl, null, null, null, null, null, pollInterval); - } - - /** - * Copies the data at the source URL to a blob. - *

- * This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If - * the source is in another account, the source must either be public or authenticated with a SAS token. If the - * source is in the same account, the Shared Key authorization on the destination will also be applied to the - * source. The source URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * SyncPoller<BlobCopyInfo, Void> poller = client.beginCopy(url, metadata, AccessTier.HOT,
-     *     RehydratePriority.STANDARD, modifiedRequestConditions, blobRequestConditions, Duration.ofSeconds(2));
-     *
-     * PollResponse<BlobCopyInfo> response = poller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
-     * System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param sourceUrl The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - * @param metadata Metadata to associate with the destination blob. If there is leading or trailing whitespace in - * any metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param priority {@link RehydratePriority} for rehydrating the blob. - * @param sourceModifiedRequestConditions {@link RequestConditions} against the source. Standard HTTP Access - * conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions - * related to when the blob was changed relative to the given request. The request will fail if the specified - * condition is not satisfied. - * @param destRequestConditions {@link BlobRequestConditions} against the destination. - * @param pollInterval Duration between each poll for the copy status. If none is specified, a default of one second - * is used. - * @return A {@link SyncPoller} to poll the progress of blob copy operation. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public SyncPoller beginCopy(String sourceUrl, Map metadata, AccessTier tier, - RehydratePriority priority, RequestConditions sourceModifiedRequestConditions, - BlobRequestConditions destRequestConditions, Duration pollInterval) { - return this.beginCopy(new BlobBeginCopyOptions(sourceUrl).setMetadata(metadata) - .setTier(tier) - .setRehydratePriority(priority) - .setSourceRequestConditions( - ModelHelper.populateBlobSourceRequestConditions(sourceModifiedRequestConditions)) - .setDestinationRequestConditions(destRequestConditions) - .setPollInterval(pollInterval)); - } - - /** - * Copies the data at the source URL to a blob. - *

- * This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If - * the source is in another account, the source must either be public or authenticated with a SAS token. If the - * source is in the same account, the Shared Key authorization on the destination will also be applied to the - * source. The source URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * SyncPoller<BlobCopyInfo, Void> poller = client.beginCopy(new BlobBeginCopyOptions(url).setMetadata(metadata)
-     *     .setTags(tags).setTier(AccessTier.HOT).setRehydratePriority(RehydratePriority.STANDARD)
-     *     .setSourceRequestConditions(modifiedRequestConditions)
-     *     .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2)));
-     *
-     * PollResponse<BlobCopyInfo> response = poller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
-     * System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobBeginCopyOptions} - * @return A {@link SyncPoller} to poll the progress of blob copy operation. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public SyncPoller beginCopy(BlobBeginCopyOptions options) { - StorageImplUtils.assertNotNull("options", options); - final AtomicReference copyId = new AtomicReference<>(); - final Duration interval = options.getPollInterval() != null ? options.getPollInterval() : Duration.ofSeconds(1); - final BlobBeginCopySourceRequestConditions sourceModifiedConditions - = options.getSourceRequestConditions() == null - ? new BlobBeginCopySourceRequestConditions() - : options.getSourceRequestConditions(); - final BlobRequestConditions destinationRequestConditions = options.getDestinationRequestConditions() == null - ? new BlobRequestConditions() - : options.getDestinationRequestConditions(); - final BlobImmutabilityPolicy immutabilityPolicy - = options.getImmutabilityPolicy() == null ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); - - Function, PollResponse> syncActivationOperation - = (pollingContext) -> { - try { - new URL(options.getSourceUrl()); - } catch (MalformedURLException ex) { - throw LOGGER - .logExceptionAsError(new IllegalArgumentException("'sourceUrl' is not a valid url.", ex)); - } - ResponseBase response = azureBlobStorage.getBlobs() - .startCopyFromURLWithResponse(containerName, blobName, options.getSourceUrl(), null, - options.getMetadata(), options.getTier(), options.getRehydratePriority(), - sourceModifiedConditions.getIfModifiedSince(), sourceModifiedConditions.getIfUnmodifiedSince(), - sourceModifiedConditions.getIfMatch(), sourceModifiedConditions.getIfNoneMatch(), - sourceModifiedConditions.getTagsConditions(), destinationRequestConditions.getIfModifiedSince(), - destinationRequestConditions.getIfUnmodifiedSince(), destinationRequestConditions.getIfMatch(), - destinationRequestConditions.getIfNoneMatch(), destinationRequestConditions.getTagsConditions(), - destinationRequestConditions.getLeaseId(), null, ModelHelper.tagsToString(options.getTags()), - options.isSealDestination(), immutabilityPolicy.getExpiryTime(), - immutabilityPolicy.getPolicyMode(), options.isLegalHold(), Context.NONE); - - BlobsStartCopyFromURLHeaders headers = response.getDeserializedHeaders(); - copyId.set(headers.getXMsCopyId()); - - return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, - new BlobCopyInfo(options.getSourceUrl(), headers.getXMsCopyId(), headers.getXMsCopyStatus(), - headers.getETag(), headers.getLastModified(), ModelHelper.getErrorCode(response.getHeaders()), - headers.getXMsVersionId())); - }; - - Function, PollResponse> pollOperation - = (pollingContext) -> onPoll(pollingContext.getLatestResponse()); - - BiFunction, PollResponse, BlobCopyInfo> cancelOperation - = (pollingContext, firstResponse) -> { - if (firstResponse == null || firstResponse.getValue() == null) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("Cannot cancel a poll response that never started.")); - } - final String copyIdentifier = firstResponse.getValue().getCopyId(); - if (!CoreUtils.isNullOrEmpty(copyIdentifier)) { - LOGGER.info("Cancelling copy operation for copy id: {}", copyIdentifier); - abortCopyFromUrl(copyIdentifier); - return firstResponse.getValue(); - } - return null; - }; - - Function, Void> fetchResultOperation = (pollingContext) -> null; - return SyncPoller.createPoller(interval, syncActivationOperation, pollOperation, cancelOperation, - fetchResultOperation); - } - - private PollResponse onPoll(PollResponse pollResponse) { - if (pollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED - || pollResponse.getStatus() == LongRunningOperationStatus.FAILED) { - return pollResponse; - } - - final BlobCopyInfo lastInfo = pollResponse.getValue(); - if (lastInfo == null) { - LOGGER.warning("BlobCopyInfo does not exist. Activation operation failed."); - return new PollResponse<>(LongRunningOperationStatus.fromString("COPY_START_FAILED", true), null); - } - - try { - BlobProperties properties = getProperties(); - final CopyStatusType status = properties.getCopyStatus(); - final BlobCopyInfo result = new BlobCopyInfo(properties.getCopySource(), properties.getCopyId(), status, - properties.getETag(), properties.getCopyCompletionTime(), properties.getCopyStatusDescription(), - properties.getVersionId()); - - LongRunningOperationStatus operationStatus = ModelHelper.mapStatusToLongRunningOperationStatus(status); - return new PollResponse<>(operationStatus, result); - } catch (Exception e) { - return new PollResponse<>(LongRunningOperationStatus.fromString("POLLING_FAILED", true), lastInfo); - } - } - - /** - * Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata. - * - *

Code Samples

- * - * - *
-     * client.abortCopyFromUrl(copyId);
-     * System.out.println("Aborted copy completed.");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param copyId The id of the copy operation to abort. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void abortCopyFromUrl(String copyId) { - abortCopyFromUrlWithResponse(copyId, null, null, Context.NONE); - } - - /** - * Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Aborted copy completed with status %d%n",
-     *     client.abortCopyFromUrlWithResponse(copyId, leaseId, timeout,
-     *         new Context(key2, value2)).getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param copyId The id of the copy operation to abort. - * @param leaseId The lease ID the active lease on the blob must match. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response abortCopyFromUrlWithResponse(String copyId, String leaseId, Duration timeout, - Context context) { - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .abortCopyFromURLNoCustomHeadersWithResponse(containerName, blobName, copyId, null, leaseId, null, - finalContext); - - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. - *

- * The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token - * attached. The URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Copy identifier: %s%n", client.copyFromUrl(url));
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param copySource The source URL to copy from. - * @return The copy ID for the long running operation. - * @throws IllegalArgumentException If {@code copySource} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public String copyFromUrl(String copySource) { - return copyFromUrlWithResponse(copySource, null, null, null, null, null, Context.NONE).getValue(); - } - - /** - * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. - *

- * The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token - * attached. The URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * System.out.printf("Copy identifier: %s%n",
-     *     client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions,
-     *         blobRequestConditions, timeout,
-     *         new Context(key1, value1)).getValue());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param copySource The source URL to copy from. URLs outside of Azure may only be copied to block blobs. - * @param metadata Metadata to associate with the destination blob. If there is leading or trailing whitespace in - * any metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param sourceModifiedRequestConditions {@link RequestConditions} against the source. Standard HTTP Access - * conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions - * related to when the blob was changed relative to the given request. The request will fail if the specified - * condition is not satisfied. - * @param destRequestConditions {@link BlobRequestConditions} against the destination. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The copy ID for the long running operation. - * @throws IllegalArgumentException If {@code copySource} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response copyFromUrlWithResponse(String copySource, Map metadata, AccessTier tier, - RequestConditions sourceModifiedRequestConditions, BlobRequestConditions destRequestConditions, - Duration timeout, Context context) { - return this.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(copySource).setMetadata(metadata) - .setTier(tier) - .setSourceRequestConditions(sourceModifiedRequestConditions) - .setDestinationRequestConditions(destRequestConditions), timeout, context); - } - - /** - * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. - *

- * The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token - * attached. The URL must be URL encoded. - * - *

Code Samples

- * - * - *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * System.out.printf("Copy identifier: %s%n",
-     *     client.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(url).setMetadata(metadata).setTags(tags)
-     *         .setTier(AccessTier.HOT).setSourceRequestConditions(modifiedRequestConditions)
-     *         .setDestinationRequestConditions(blobRequestConditions), timeout,
-     *         new Context(key1, value1)).getValue());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobCopyFromUrlOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The copy ID for the long running operation. - * @throws IllegalArgumentException If {@code copySource} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response copyFromUrlWithResponse(BlobCopyFromUrlOptions options, Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", options); - RequestConditions sourceModifiedRequestConditions = options.getSourceRequestConditions() == null - ? new RequestConditions() - : options.getSourceRequestConditions(); - BlobRequestConditions destRequestConditions = options.getDestinationRequestConditions() == null - ? new BlobRequestConditions() - : options.getDestinationRequestConditions(); - BlobImmutabilityPolicy immutabilityPolicy - = options.getImmutabilityPolicy() == null ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); - - try { - new URL(options.getCopySource()); - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'copySource' is not a valid url.", ex)); - } - String sourceAuth - = options.getSourceAuthorization() == null ? null : options.getSourceAuthorization().toString(); - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .copyFromURLWithResponse(containerName, blobName, options.getCopySource(), null, options.getMetadata(), - options.getTier(), sourceModifiedRequestConditions.getIfModifiedSince(), - sourceModifiedRequestConditions.getIfUnmodifiedSince(), sourceModifiedRequestConditions.getIfMatch(), - sourceModifiedRequestConditions.getIfNoneMatch(), destRequestConditions.getIfModifiedSince(), - destRequestConditions.getIfUnmodifiedSince(), destRequestConditions.getIfMatch(), - destRequestConditions.getIfNoneMatch(), destRequestConditions.getTagsConditions(), - destRequestConditions.getLeaseId(), null, null, ModelHelper.tagsToString(options.getTags()), - immutabilityPolicy.getExpiryTime(), immutabilityPolicy.getPolicyMode(), options.hasLegalHold(), - sourceAuth, options.getCopySourceTagsMode(), this.encryptionScope, finalContext); - - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsCopyId()); - } - - /** - * Downloads the entire blob into an output stream. Uploading data must be done from the {@link BlockBlobClient}, - * {@link PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * client.download(new ByteArrayOutputStream());
-     * System.out.println("Download completed.");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - *

This method will be deprecated in the future. Use {@link #downloadStream(OutputStream)} instead. - * - * @param stream A non-null {@link OutputStream} instance where the downloaded data will be written. - * @throws UncheckedIOException If an I/O error occurs. - * @throws NullPointerException if {@code stream} is null - * @deprecated use {@link #downloadStream(OutputStream)} instead. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public void download(OutputStream stream) { - downloadStream(stream); - } - - /** - * Downloads the entire blob into an output stream. Uploading data must be done from the {@link BlockBlobClient}, - * {@link PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * client.downloadStream(new ByteArrayOutputStream());
-     * System.out.println("Download completed.");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param stream A non-null {@link OutputStream} instance where the downloaded data will be written. - * @throws UncheckedIOException If an I/O error occurs. - * @throws NullPointerException if {@code stream} is null - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void downloadStream(OutputStream stream) { - downloadWithResponse(stream, null, null, null, false, null, Context.NONE); - } - - /** - * Downloads the entire blob. Uploading data must be done from the {@link BlockBlobClient}, - * {@link PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * BinaryData data = client.downloadContent();
-     * System.out.printf("Downloaded %s", data.toString());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - *

This method supports downloads up to 2GB of data. Content will be buffered in memory. If the blob is larger, - * use {@link #downloadStream(OutputStream)} to download larger blobs.

- * - * @return The content of the blob. - * @throws UncheckedIOException If an I/O error occurs. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BinaryData downloadContent() { - return blockWithOptionalTimeout(client.downloadContent(), null); - } - - /** - * Downloads a range of bytes from a blob into an output stream. Uploading data must be done from the {@link - * BlockBlobClient}, {@link PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * BlobRange range = new BlobRange(1024, 2048L);
-     * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
-     *
-     * System.out.printf("Download completed with status %d%n",
-     *     client.downloadWithResponse(new ByteArrayOutputStream(), range, options, null, false,
-     *         timeout, new Context(key2, value2)).getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - *

This method will be deprecated in the future. - * Use {@link #downloadStreamWithResponse(OutputStream, BlobRange, DownloadRetryOptions, - * BlobRequestConditions, boolean, Duration, Context)} instead. - * - * @param stream A non-null {@link OutputStream} instance where the downloaded data will be written. - * @param range {@link BlobRange} - * @param options {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param getRangeContentMd5 Whether the contentMD5 for the specified blob range should be returned. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - * @throws UncheckedIOException If an I/O error occurs. - * @throws NullPointerException if {@code stream} is null - * @deprecated use {@link #downloadStreamWithResponse(OutputStream, BlobRange, DownloadRetryOptions, BlobRequestConditions, boolean, Duration, Context)} instead. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public BlobDownloadResponse downloadWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, - BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context) { - return downloadStreamWithResponse(stream, range, options, requestConditions, getRangeContentMd5, timeout, - context); - } - - /** - * Downloads a range of bytes from a blob into an output stream. Uploading data must be done from the {@link - * BlockBlobClient}, {@link PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * BlobRange range = new BlobRange(1024, 2048L);
-     * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
-     *
-     * System.out.printf("Download completed with status %d%n",
-     *     client.downloadStreamWithResponse(new ByteArrayOutputStream(), range, options, null, false,
-     *         timeout, new Context(key2, value2)).getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param stream A non-null {@link OutputStream} instance where the downloaded data will be written. - * @param range {@link BlobRange} - * @param options {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param getRangeContentMd5 Whether the contentMD5 for the specified blob range should be returned. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - * @throws UncheckedIOException If an I/O error occurs. - * @throws NullPointerException if {@code stream} is null - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobDownloadResponse downloadStreamWithResponse(OutputStream stream, BlobRange range, - DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, - Duration timeout, Context context) { - StorageImplUtils.assertNotNull("stream", stream); - Mono download - = client.downloadStreamWithResponse(range, options, requestConditions, getRangeContentMd5, context) - .flatMap(response -> FluxUtil.writeToOutputStream(response.getValue(), stream) - .thenReturn(new BlobDownloadResponse(response))); - - return blockWithOptionalTimeout(download, timeout); - } - - /** - * Downloads a range of bytes from a blob into an output stream. Uploading data must be done from the {@link - * BlockBlobClient}, {@link PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
-     *
-     * BlobDownloadContentResponse contentResponse = client.downloadContentWithResponse(options, null,
-     *     timeout, new Context(key2, value2));
-     * BinaryData content = contentResponse.getValue();
-     * System.out.printf("Download completed with status %d and content%s%n",
-     *     contentResponse.getStatusCode(), content.toString());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - *

This method supports downloads up to 2GB of data. Content will be buffered in memory. If the blob is larger, - * use {@link #downloadStreamWithResponse(OutputStream, BlobRange, - * DownloadRetryOptions, BlobRequestConditions, boolean, Duration, Context)} to download larger blobs.

- * - * @param options {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobDownloadContentResponse downloadContentWithResponse(DownloadRetryOptions options, - BlobRequestConditions requestConditions, Duration timeout, Context context) { - Mono download - = client.downloadStreamWithResponse(null, options, requestConditions, false, context) - .flatMap(r -> BinaryData.fromFlux(r.getValue()) - .map(data -> new BlobDownloadContentAsyncResponse(r.getRequest(), r.getStatusCode(), r.getHeaders(), - data, r.getDeserializedHeaders()))) - .map(BlobDownloadContentResponse::new); - - return blockWithOptionalTimeout(download, timeout); - } - - /** - * Downloads a range of bytes from a blob into an output stream. Uploading data must be done from the {@link - * BlockBlobClient}, {@link PageBlobClient}, or {@link AppendBlobClient}. - * - *

Code Samples

- * - * - *
-     * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
-     * BlobRange range = new BlobRange(1024, 2048L);
-     *
-     * BlobDownloadContentResponse contentResponse = client.downloadContentWithResponse(options, null,
-     *     range, false, timeout, new Context(key2, value2));
-     * BinaryData content = contentResponse.getValue();
-     * System.out.printf("Download completed with status %d and content%s%n",
-     *     contentResponse.getStatusCode(), content.toString());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - *

This method supports downloads up to 2GB of data. Content will be buffered in memory. If the blob is larger, - * use {@link #downloadStreamWithResponse(OutputStream, BlobRange, - * DownloadRetryOptions, BlobRequestConditions, boolean, Duration, Context)} to download larger blobs.

- * - * @param options {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param range {@link BlobRange} - * @param getRangeContentMd5 Whether the contentMD5 for the specified blob range should be returned. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobDownloadContentResponse downloadContentWithResponse(DownloadRetryOptions options, - BlobRequestConditions requestConditions, BlobRange range, boolean getRangeContentMd5, Duration timeout, - Context context) { - Mono download - = client.downloadStreamWithResponse(range, options, requestConditions, getRangeContentMd5, context) - .flatMap(r -> BinaryData.fromFlux(r.getValue()) - .map(data -> new BlobDownloadContentAsyncResponse(r.getRequest(), r.getStatusCode(), r.getHeaders(), - data, r.getDeserializedHeaders()))) - .map(BlobDownloadContentResponse::new); - - return blockWithOptionalTimeout(download, timeout); - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

The file will be created and must not exist, if the file already exists a {@link FileAlreadyExistsException} - * will be thrown.

- * - *

Code Samples

- * - * - *
-     * client.downloadToFile(file);
-     * System.out.println("Completed download to file");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param filePath A {@link String} representing the filePath where the downloaded data will be written. - * @return The blob properties and metadata. - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobProperties downloadToFile(String filePath) { - return downloadToFile(filePath, false); - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

If overwrite is set to false, the file will be created and must not exist, if the file already exists a - * {@link FileAlreadyExistsException} will be thrown.

- * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default value
-     * client.downloadToFile(file, overwrite);
-     * System.out.println("Completed download to file");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param filePath A {@link String} representing the filePath where the downloaded data will be written. - * @param overwrite Whether to overwrite the file, should the file exist. - * @return The blob properties and metadata. - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobProperties downloadToFile(String filePath, boolean overwrite) { - Set openOptions = null; - if (overwrite) { - openOptions = new HashSet<>(); - openOptions.add(StandardOpenOption.CREATE); - openOptions.add(StandardOpenOption.TRUNCATE_EXISTING); // If the file already exists and it is opened - // for WRITE access, then its length is truncated to 0. - openOptions.add(StandardOpenOption.READ); - openOptions.add(StandardOpenOption.WRITE); - } - return downloadToFileWithResponse(filePath, null, null, null, null, false, openOptions, null, Context.NONE) - .getValue(); - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

The file will be created and must not exist, if the file already exists a {@link FileAlreadyExistsException} - * will be thrown.

- * - *

Code Samples

- * - * - *
-     * BlobRange range = new BlobRange(1024, 2048L);
-     * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
-     *
-     * client.downloadToFileWithResponse(file, range, new ParallelTransferOptions().setBlockSizeLong(4L * Constants.MB),
-     *     options, null, false, timeout, new Context(key2, value2));
-     * System.out.println("Completed download to file");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param filePath A {@link String} representing the filePath where the downloaded data will be written. - * @param range {@link BlobRange} - * @param parallelTransferOptions {@link ParallelTransferOptions} to use to download to file. Number of parallel - * transfers parameter is ignored. - * @param downloadRetryOptions {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param rangeGetContentMd5 Whether the contentMD5 for the specified blob range should be returned. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing the blob properties and metadata. - * @throws UncheckedIOException If an I/O error occurs. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response downloadToFileWithResponse(String filePath, BlobRange range, - ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, - BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Duration timeout, Context context) { - return downloadToFileWithResponse(filePath, range, parallelTransferOptions, downloadRetryOptions, - requestConditions, rangeGetContentMd5, null, timeout, context); - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

By default the file will be created and must not exist, if the file already exists a - * {@link FileAlreadyExistsException} will be thrown. To override this behavior, provide appropriate - * {@link OpenOption OpenOptions}

- * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(1024, 2048L);
-     * DownloadRetryOptions downloadRetryOptions = new DownloadRetryOptions().setMaxRetryRequests(5);
-     * Set<OpenOption> openOptions = new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW,
-     *     StandardOpenOption.WRITE, StandardOpenOption.READ)); // Default options
-     *
-     * client.downloadToFileWithResponse(file, blobRange, new ParallelTransferOptions().setBlockSizeLong(4L * Constants.MB),
-     *     downloadRetryOptions, null, false, openOptions, timeout, new Context(key2, value2));
-     * System.out.println("Completed download to file");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param filePath A {@link String} representing the filePath where the downloaded data will be written. - * @param range {@link BlobRange} - * @param parallelTransferOptions {@link ParallelTransferOptions} to use to download to file. Number of parallel - * transfers parameter is ignored. - * @param downloadRetryOptions {@link DownloadRetryOptions} - * @param requestConditions {@link BlobRequestConditions} - * @param rangeGetContentMd5 Whether the contentMD5 for the specified blob range should be returned. - * @param openOptions {@link OpenOption OpenOptions} to use to configure how to open or create the file. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing the blob properties and metadata. - * @throws UncheckedIOException If an I/O error occurs. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response downloadToFileWithResponse(String filePath, BlobRange range, - ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, - BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Set openOptions, - Duration timeout, Context context) { - final com.azure.storage.common.ParallelTransferOptions finalParallelTransferOptions - = ModelHelper.wrapBlobOptions(ModelHelper.populateAndApplyDefaults(parallelTransferOptions)); - return downloadToFileWithResponse(new BlobDownloadToFileOptions(filePath).setRange(range) - .setParallelTransferOptions(finalParallelTransferOptions) - .setDownloadRetryOptions(downloadRetryOptions) - .setRequestConditions(requestConditions) - .setRetrieveContentRangeMd5(rangeGetContentMd5) - .setOpenOptions(openOptions), timeout, context); - } - - /** - * Downloads the entire blob into a file specified by the path. - * - *

By default the file will be created and must not exist, if the file already exists a - * {@link FileAlreadyExistsException} will be thrown. To override this behavior, provide appropriate - * {@link OpenOption OpenOptions}

- * - *

Code Samples

- * - * - *
-     * client.downloadToFileWithResponse(new BlobDownloadToFileOptions(file)
-     *     .setRange(new BlobRange(1024, 2018L))
-     *     .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(5))
-     *     .setOpenOptions(new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE,
-     *         StandardOpenOption.READ))), timeout, new Context(key2, value2));
-     * System.out.println("Completed download to file");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobDownloadToFileOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing the blob properties and metadata. - * @throws UncheckedIOException If an I/O error occurs. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response downloadToFileWithResponse(BlobDownloadToFileOptions options, Duration timeout, - Context context) { - Mono> download = client.downloadToFileWithResponse(options, context); - return blockWithOptionalTimeout(download, timeout); - } - - /** - * Deletes the specified blob or snapshot. To delete a blob with its snapshots use - * {@link #deleteWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions, Duration, Context)} and set - * {@code DeleteSnapshotsOptionType} to INCLUDE. - * - *

Code Samples

- * - * - *
-     * client.delete();
-     * System.out.println("Delete completed.");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void delete() { - deleteWithResponse(null, null, null, Context.NONE); - } - - /** - * Deletes the specified blob or snapshot. To delete a blob with its snapshots use - * {@link #deleteWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions, Duration, Context)} and set - * {@code DeleteSnapshotsOptionType} to INCLUDE. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Delete completed with status %d%n",
-     *     client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null, timeout,
-     *         new Context(key1, value1)).getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param deleteBlobSnapshotOptions Specifies the behavior for deleting the snapshots on this blob. {@code Include} - * will delete the base blob and all snapshots. {@code Only} will delete only the snapshots. If a snapshot is being - * deleted, you must pass null. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, - BlobRequestConditions requestConditions, Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - Callable> operation = () -> azureBlobStorage.getBlobs() - .deleteNoCustomHeadersWithResponse(containerName, blobName, snapshot, versionId, null, - finalRequestConditions.getLeaseId(), deleteBlobSnapshotOptions, - finalRequestConditions.getIfModifiedSince(), finalRequestConditions.getIfUnmodifiedSince(), - finalRequestConditions.getIfMatch(), finalRequestConditions.getIfNoneMatch(), - finalRequestConditions.getTagsConditions(), null, null, finalContext); - - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Deletes the specified blob or snapshot if it exists. To delete a blob with its snapshots use - * {@link #deleteIfExistsWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions, Duration, Context)} and set - * {@code DeleteSnapshotsOptionType} to INCLUDE. - * - *

Code Samples

- * - * - *
-     * boolean result = client.deleteIfExists();
-     * System.out.println("Delete completed: " + result);
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * @return {@code true} if delete succeeds, or {@code false} if blob does not exist. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public boolean deleteIfExists() { - return deleteIfExistsWithResponse(null, null, null, Context.NONE).getValue(); - } - - /** - * Deletes the specified blob or snapshot if it exists. To delete a blob with its snapshots use - * {@link #deleteIfExistsWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions, Duration, Context)} and set - * {@code DeleteSnapshotsOptionType} to INCLUDE. - * - *

Code Samples

- * - * - *
-     * Response<Boolean> response = client.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, null, timeout,
-     *     new Context(key1, value1));
-     * if (response.getStatusCode() == 404) {
-     *     System.out.println("Does not exist.");
-     * } else {
-     *     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
-     * }
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param deleteBlobSnapshotOptions Specifies the behavior for deleting the snapshots on this blob. {@code Include} - * will delete the base blob and all snapshots. {@code Only} will delete only the snapshots. If a snapshot is being - * deleted, you must pass null. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. If {@link Response}'s status code is 202, the base - * blob was successfully deleted. If status code is 404, the base blob does not exist. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteIfExistsWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, - BlobRequestConditions requestConditions, Duration timeout, Context context) { - try { - Response response - = this.deleteWithResponse(deleteBlobSnapshotOptions, requestConditions, timeout, context); - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), true); - } catch (RuntimeException e) { - if (e instanceof BlobStorageException && ((BlobStorageException) e).getResponse().getStatusCode() == 404) { - HttpResponse response = ((BlobStorageException) e).getResponse(); - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - false); - } else { - throw LOGGER.logExceptionAsError(e); - } - } - } - - /** - * Returns the blob's metadata and properties. - * - *

Code Samples

- * - * - *
-     * BlobProperties properties = client.getProperties();
-     * System.out.printf("Type: %s, Size: %d%n", properties.getBlobType(), properties.getBlobSize());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return The blob properties and metadata. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobProperties getProperties() { - return getPropertiesWithResponse(null, null, Context.NONE).getValue(); - } - - /** - * Returns the blob's metadata and properties. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * BlobProperties properties = client.getPropertiesWithResponse(requestConditions, timeout,
-     *     new Context(key2, value2)).getValue();
-     * System.out.printf("Type: %s, Size: %d%n", properties.getBlobType(), properties.getBlobSize());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The blob properties and metadata. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesWithResponse(BlobRequestConditions requestConditions, Duration timeout, - Context context) { - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .getPropertiesWithResponse(containerName, blobName, snapshot, versionId, null, - finalRequestConditions.getLeaseId(), finalRequestConditions.getIfModifiedSince(), - finalRequestConditions.getIfUnmodifiedSince(), finalRequestConditions.getIfMatch(), - finalRequestConditions.getIfNoneMatch(), finalRequestConditions.getTagsConditions(), null, - customerProvidedKey, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, BlobPropertiesConstructorProxy - .create(new BlobPropertiesInternalGetProperties(response.getDeserializedHeaders()))); - } - - /** - * Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In - * order to preserve existing values, they must be passed alongside the header being changed. - * - *

Code Samples

- * - * - *
-     * client.setHttpHeaders(new BlobHttpHeaders()
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary"));
-     * System.out.println("Set HTTP headers completed");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param headers {@link BlobHttpHeaders} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setHttpHeaders(BlobHttpHeaders headers) { - setHttpHeadersWithResponse(headers, null, null, Context.NONE); - } - - /** - * Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In - * order to preserve existing values, they must be passed alongside the header being changed. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * System.out.printf("Set HTTP headers completed with status %d%n",
-     *     client.setHttpHeadersWithResponse(new BlobHttpHeaders()
-     *         .setContentLanguage("en-US")
-     *         .setContentType("binary"), requestConditions, timeout, new Context(key1, value1))
-     *         .getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param headers {@link BlobHttpHeaders} - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setHttpHeadersWithResponse(BlobHttpHeaders headers, BlobRequestConditions requestConditions, - Duration timeout, Context context) { - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .setHttpHeadersNoCustomHeadersWithResponse(containerName, blobName, null, - finalRequestConditions.getLeaseId(), finalRequestConditions.getIfModifiedSince(), - finalRequestConditions.getIfUnmodifiedSince(), finalRequestConditions.getIfMatch(), - finalRequestConditions.getIfNoneMatch(), finalRequestConditions.getTagsConditions(), null, headers, - finalContext); - - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values - * must be preserved, they must be downloaded and included in the call to this method. - * - *

Code Samples

- * - * - *
-     * client.setMetadata(Collections.singletonMap("metadata", "value"));
-     * System.out.println("Set metadata completed");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setMetadata(Map metadata) { - setMetadataWithResponse(metadata, null, null, Context.NONE); - } - - /** - * Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values - * must be preserved, they must be downloaded and included in the call to this method. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * System.out.printf("Set metadata completed with status %d%n",
-     *     client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions, timeout,
-     *         new Context(key1, value1)).getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setMetadataWithResponse(Map metadata, BlobRequestConditions requestConditions, - Duration timeout, Context context) { - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .setMetadataNoCustomHeadersWithResponse(containerName, blobName, null, metadata, - finalRequestConditions.getLeaseId(), finalRequestConditions.getIfModifiedSince(), - finalRequestConditions.getIfUnmodifiedSince(), finalRequestConditions.getIfMatch(), - finalRequestConditions.getIfNoneMatch(), finalRequestConditions.getTagsConditions(), null, - customerProvidedKey, encryptionScope, finalContext); - - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Returns the blob's tags. - * - *

Code Samples

- * - * - *
-     * Map<String, String> tags = client.getTags();
-     * System.out.printf("Number of tags: %d%n", tags.size());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return The blob's tags. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Map getTags() { - return this.getTagsWithResponse(new BlobGetTagsOptions(), null, Context.NONE).getValue(); - } - - /** - * Returns the blob's tags. - * - *

Code Samples

- * - * - *
-     * Map<String, String> tags = client.getTagsWithResponse(new BlobGetTagsOptions(), timeout,
-     *     new Context(key1, value1)).getValue();
-     * System.out.printf("Number of tags: %d%n", tags.size());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobGetTagsOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The blob's tags. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response> getTagsWithResponse(BlobGetTagsOptions options, Duration timeout, - Context context) { - BlobGetTagsOptions finalTagOptions = (options == null) ? new BlobGetTagsOptions() : options; - BlobRequestConditions requestConditions = (finalTagOptions.getRequestConditions() == null) - ? new BlobRequestConditions() - : finalTagOptions.getRequestConditions(); - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .getTagsWithResponse(containerName, blobName, null, null, snapshot, versionId, - requestConditions.getTagsConditions(), requestConditions.getLeaseId(), finalContext); - - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - Map tags = new HashMap<>(); - for (BlobTag tag : response.getValue().getBlobTagSet()) { - tags.put(tag.getKey(), tag.getValue()); - } - return new SimpleResponse<>(response, tags); - } - - /** - * Sets user defined tags. The specified tags in this method will replace existing tags. If old values - * must be preserved, they must be downloaded and included in the call to this method. - * - *

Code Samples

- * - * - *
-     * client.setTags(Collections.singletonMap("tag", "value"));
-     * System.out.println("Set tag completed");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param tags Tags to associate with the blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setTags(Map tags) { - this.setTagsWithResponse(new BlobSetTagsOptions(tags), null, Context.NONE); - } - - /** - * Sets user defined tags. The specified tags in this method will replace existing tags. If old values - * must be preserved, they must be downloaded and included in the call to this method. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Set metadata completed with status %d%n",
-     *     client.setTagsWithResponse(new BlobSetTagsOptions(Collections.singletonMap("tag", "value")), timeout,
-     *         new Context(key1, value1))
-     *         .getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobSetTagsOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setTagsWithResponse(BlobSetTagsOptions options, Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", options); - Context finalContext = context == null ? Context.NONE : context; - BlobRequestConditions requestConditions - = (options.getRequestConditions() == null) ? new BlobRequestConditions() : options.getRequestConditions(); - List tagList = null; - if (options.getTags() != null) { - tagList = new ArrayList<>(); - for (Map.Entry entry : options.getTags().entrySet()) { - tagList.add(new BlobTag().setKey(entry.getKey()).setValue(entry.getValue())); - } - } - BlobTags t = new BlobTags().setBlobTagSet(tagList); - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .setTagsNoCustomHeadersWithResponse(containerName, blobName, null, versionId, null, null, null, - requestConditions.getTagsConditions(), requestConditions.getLeaseId(), t, finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Creates a read-only snapshot of the blob. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Identifier for the snapshot is %s%n", client.createSnapshot().getSnapshotId());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return A response containing a {@link BlobClientBase} which is used to interact with the created snapshot, use - * {@link BlobClientBase#getSnapshotId()} to get the identifier for the snapshot. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobClientBase createSnapshot() { - return createSnapshotWithResponse(null, null, null, Context.NONE).getValue(); - } - - /** - * Creates a read-only snapshot of the blob. - * - *

Code Samples

- * - * - *
-     * Map<String, String> snapshotMetadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * System.out.printf("Identifier for the snapshot is %s%n",
-     *     client.createSnapshotWithResponse(snapshotMetadata, requestConditions, timeout,
-     *         new Context(key1, value1)).getValue());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param metadata Metadata to associate with the resource. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing a {@link BlobClientBase} which is used to interact with the created snapshot, use - * {@link BlobClientBase#getSnapshotId()} to get the identifier for the snapshot. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createSnapshotWithResponse(Map metadata, - BlobRequestConditions requestConditions, Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .createSnapshotWithResponse(containerName, blobName, null, metadata, - finalRequestConditions.getIfModifiedSince(), finalRequestConditions.getIfUnmodifiedSince(), - finalRequestConditions.getIfMatch(), finalRequestConditions.getIfNoneMatch(), - finalRequestConditions.getTagsConditions(), finalRequestConditions.getLeaseId(), null, - customerProvidedKey, encryptionScope, finalContext); - - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, - this.getSnapshotClient(response.getDeserializedHeaders().getXMsSnapshot())); - } - - /** - * Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in - * a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of - * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's - * etag. - * - *

Code Samples

- * - * - *
-     * client.setAccessTier(AccessTier.HOT);
-     * System.out.println("Set tier completed.");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param tier The new tier for the blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void setAccessTier(AccessTier tier) { - setAccessTierWithResponse(tier, null, null, null, Context.NONE); - } - - /** - * Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in - * a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of - * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's - * etag. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Set tier completed with status code %d%n",
-     *     client.setAccessTierWithResponse(AccessTier.HOT, RehydratePriority.STANDARD, leaseId, timeout,
-     *         new Context(key2, value2)).getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param tier The new tier for the blob. - * @param priority Optional priority to set for re-hydrating blobs. - * @param leaseId The lease ID the active lease on the blob must match. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setAccessTierWithResponse(AccessTier tier, RehydratePriority priority, String leaseId, - Duration timeout, Context context) { - return setAccessTierWithResponse(new BlobSetAccessTierOptions(tier).setPriority(priority).setLeaseId(leaseId), - timeout, context); - } - - /** - * Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in - * a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of - * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's - * etag. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Set tier completed with status code %d%n",
-     *     client.setAccessTierWithResponse(new BlobSetAccessTierOptions(AccessTier.HOT)
-     *         .setPriority(RehydratePriority.STANDARD)
-     *         .setLeaseId(leaseId)
-     *         .setTagsConditions(tags),
-     *         timeout, new Context(key2, value2)).getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param options {@link BlobSetAccessTierOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setAccessTierWithResponse(BlobSetAccessTierOptions options, Duration timeout, - Context context) { - StorageImplUtils.assertNotNull("options", options); - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .setTierNoCustomHeadersWithResponse(containerName, blobName, options.getTier(), snapshot, versionId, null, - options.getPriority(), null, options.getLeaseId(), options.getTagsConditions(), finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots. - * - *

Code Samples

- * - * - *
-     * client.undelete();
-     * System.out.println("Undelete completed");
-     * 
- * - * - *

For more information, see the - * Azure Docs

- */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void undelete() { - undeleteWithResponse(null, Context.NONE); - } - - /** - * Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Undelete completed with status %d%n", client.undeleteWithResponse(timeout,
-     *     new Context(key1, value1)).getStatusCode());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response undeleteWithResponse(Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .undeleteNoCustomHeadersWithResponse(containerName, blobName, null, null, finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Returns the sku name and account kind for the account. - * - *

Code Samples

- * - * - *
-     * StorageAccountInfo accountInfo = client.getAccountInfo();
-     * System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @return The sku name and account kind. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public StorageAccountInfo getAccountInfo() { - return getAccountInfoWithResponse(null, Context.NONE).getValue(); - } - - /** - * Returns the sku name and account kind for the account. - * - *

Code Samples

- * - * - *
-     * StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, new Context(key1, value1)).getValue();
-     * System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());
-     * 
- * - * - *

For more information, see the - * Azure Docs

- * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The sku name and account kind. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getAccountInfoWithResponse(Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .getAccountInfoWithResponse(containerName, blobName, null, null, finalContext); - - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - BlobsGetAccountInfoHeaders hd = response.getDeserializedHeaders(); - return new SimpleResponse<>(response, new StorageAccountInfo(hd.getXMsSkuName(), hd.getXMsAccountKind())); - } - - /** - * Generates a user delegation SAS for the blob using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateUserDelegationSas(values, userDelegationKey);
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey) { - return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, getAccountName(), - Context.NONE); - } - - /** - * Generates a user delegation SAS for the blob using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context(key1, value1));
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * @param accountName The account name. - * @param context Additional context that is passed through the code when generating a SAS. - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey, String accountName, Context context) { - return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, accountName, null, context); - } - - /** - * Generates a user delegation SAS for the blob using the specified {@link BlobServiceSasSignatureValues}. - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

- * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. - * See {@link BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on - * how to get a user delegation key. - * @param accountName The account name. - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * @return A {@code String} representing the SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey, String accountName, Consumer stringToSignHandler, - Context context) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId(), - getVersionId(), getEncryptionScope()).generateUserDelegationSas(userDelegationKey, accountName, - stringToSignHandler, context); - } - - /** - * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobSasPermission permission = new BlobSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return generateSas(blobServiceSasSignatureValues, Context.NONE); - } - - /** - * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - *

Code Samples

- * - * - *
-     * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
-     * BlobSasPermission permission = new BlobSasPermission().setReadPermission(true);
-     *
-     * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
-     *     .setStartTime(OffsetDateTime.now());
-     *
-     * // Client must be authenticated via StorageSharedKeyCredential
-     * client.generateSas(values, new Context(key1, value1));
-     * 
- * - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context) { - return generateSas(blobServiceSasSignatureValues, null, context); - } - - /** - * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} - *

Note : The client must be authenticated via {@link StorageSharedKeyCredential} - *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

- * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the - * signature. - * @param context Additional context that is passed through the code when generating a SAS. - * - * @return A {@code String} representing the SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - Consumer stringToSignHandler, Context context) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId(), - getVersionId(), getEncryptionScope()) - .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); - } - - /** - * Opens a blob input stream to query the blob. - * - *

For more information, see the - * Azure Docs

- * - *

Code Samples

- * - * - *
-     * String expression = "SELECT * from BlobStorage";
-     * InputStream inputStream = client.openQueryInputStream(expression);
-     * // Now you can read from the input stream like you would normally.
-     * 
- * - * - * @param expression The query expression. - * @return An InputStream object that represents the stream to use for reading the query response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public InputStream openQueryInputStream(String expression) { - return openQueryInputStreamWithResponse(new BlobQueryOptions(expression)).getValue(); - } - - /** - * Opens a blob input stream to query the blob. - * - *

For more information, see the - * Azure Docs

- * - *

Code Samples

- * - * - *
-     * String expression = "SELECT * from BlobStorage";
-     * BlobQuerySerialization input = new BlobQueryDelimitedSerialization()
-     *     .setColumnSeparator(',')
-     *     .setEscapeChar('\n')
-     *     .setRecordSeparator('\n')
-     *     .setHeadersPresent(true)
-     *     .setFieldQuote('"');
-     * BlobQuerySerialization output = new BlobQueryJsonSerialization()
-     *     .setRecordSeparator('\n');
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId("leaseId");
-     * Consumer<BlobQueryError> errorConsumer = System.out::println;
-     * Consumer<BlobQueryProgress> progressConsumer = progress -> System.out.println("total blob bytes read: "
-     *     + progress.getBytesScanned());
-     * BlobQueryOptions queryOptions = new BlobQueryOptions(expression)
-     *     .setInputSerialization(input)
-     *     .setOutputSerialization(output)
-     *     .setRequestConditions(requestConditions)
-     *     .setErrorConsumer(errorConsumer)
-     *     .setProgressConsumer(progressConsumer);
-     *
-     * InputStream inputStream = client.openQueryInputStreamWithResponse(queryOptions).getValue();
-     * // Now you can read from the input stream like you would normally.
-     * 
- * - * - * @param queryOptions {@link BlobQueryOptions The query options}. - * @return A response containing status code and HTTP headers including an InputStream object - * that represents the stream to use for reading the query response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response openQueryInputStreamWithResponse(BlobQueryOptions queryOptions) { - - // Data to subscribe to and read from. - BlobQueryAsyncResponse response = client.queryWithResponse(queryOptions).block(); - - // Create input stream from the data. - if (response == null) { - throw LOGGER.logExceptionAsError(new IllegalStateException("Query response cannot be null")); - } - return new ResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - new FluxInputStream(response.getValue()), response.getDeserializedHeaders()); - } - - /** - * Queries an entire blob into an output stream. - * - *

For more information, see the - * Azure Docs

- * - *

Code Samples

- * - * - *
-     * ByteArrayOutputStream queryData = new ByteArrayOutputStream();
-     * String expression = "SELECT * from BlobStorage";
-     * client.query(queryData, expression);
-     * System.out.println("Query completed.");
-     * 
- * - * - * @param stream A non-null {@link OutputStream} instance where the downloaded data will be written. - * @param expression The query expression. - * @throws UncheckedIOException If an I/O error occurs. - * @throws NullPointerException if {@code stream} is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void query(OutputStream stream, String expression) { - queryWithResponse(new BlobQueryOptions(expression, stream), null, Context.NONE); - } - - /** - * Queries an entire blob into an output stream. - * - *

For more information, see the - * Azure Docs

- * - *

Code Samples

- * - * - *
-     * ByteArrayOutputStream queryData = new ByteArrayOutputStream();
-     * String expression = "SELECT * from BlobStorage";
-     * BlobQueryJsonSerialization input = new BlobQueryJsonSerialization()
-     *     .setRecordSeparator('\n');
-     * BlobQueryDelimitedSerialization output = new BlobQueryDelimitedSerialization()
-     *     .setEscapeChar('\0')
-     *     .setColumnSeparator(',')
-     *     .setRecordSeparator('\n')
-     *     .setFieldQuote('\'')
-     *     .setHeadersPresent(true);
-     * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * Consumer<BlobQueryError> errorConsumer = System.out::println;
-     * Consumer<BlobQueryProgress> progressConsumer = progress -> System.out.println("total blob bytes read: "
-     *     + progress.getBytesScanned());
-     * BlobQueryOptions queryOptions = new BlobQueryOptions(expression, queryData)
-     *     .setInputSerialization(input)
-     *     .setOutputSerialization(output)
-     *     .setRequestConditions(requestConditions)
-     *     .setErrorConsumer(errorConsumer)
-     *     .setProgressConsumer(progressConsumer);
-     * System.out.printf("Query completed with status %d%n",
-     *     client.queryWithResponse(queryOptions, timeout, new Context(key1, value1))
-     *         .getStatusCode());
-     * 
- * - * - * @param queryOptions {@link BlobQueryOptions The query options}. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - * @throws UncheckedIOException If an I/O error occurs. - * @throws NullPointerException if {@code stream} is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobQueryResponse queryWithResponse(BlobQueryOptions queryOptions, Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", queryOptions); - StorageImplUtils.assertNotNull("outputStream", queryOptions.getOutputStream()); - Mono download = client.queryWithResponse(queryOptions, context) - .flatMap(response -> FluxUtil.writeToOutputStream(response.getValue(), queryOptions.getOutputStream()) - .thenReturn(new BlobQueryResponse(response))); - - return blockWithOptionalTimeout(download, timeout); - } - - /** - * Sets the immutability policy on a blob, blob snapshot or blob version. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * immutable storage with versioning enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * BlobImmutabilityPolicy policy = new BlobImmutabilityPolicy()
-     *     .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED)
-     *     .setExpiryTime(OffsetDateTime.now().plusDays(1));
-     * BlobImmutabilityPolicy setPolicy = client.setImmutabilityPolicy(policy);
-     * System.out.println("Successfully completed setting the immutability policy");
-     * 
- * - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy The immutability policy}. - * @return The immutability policy. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobImmutabilityPolicy setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { - return setImmutabilityPolicyWithResponse(immutabilityPolicy, null, null, Context.NONE).getValue(); - } - - /** - * Sets the immutability policy on a blob, blob snapshot or blob version. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * immutable storage with versioning enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy()
-     *     .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED)
-     *     .setExpiryTime(OffsetDateTime.now().plusDays(1));
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1));
-     * Response<BlobImmutabilityPolicy> response = client.setImmutabilityPolicyWithResponse(immutabilityPolicy,
-     *     requestConditions, timeout, new Context(key1, value1));
-     * System.out.println("Successfully completed setting the immutability policy");
-     * 
- * - * - * @param immutabilityPolicy {@link BlobImmutabilityPolicy The immutability policy}. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing the immutability policy. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy immutabilityPolicy, - BlobRequestConditions requestConditions, Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - BlobImmutabilityPolicy finalImmutabilityPolicy - = immutabilityPolicy == null ? new BlobImmutabilityPolicy() : immutabilityPolicy; - if (BlobImmutabilityPolicyMode.MUTABLE.equals(finalImmutabilityPolicy.getPolicyMode())) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException(String.format("immutabilityPolicy.policyMode must be %s or %s", - BlobImmutabilityPolicyMode.LOCKED.toString(), BlobImmutabilityPolicyMode.UNLOCKED.toString()))); - } - - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - ModelHelper.validateConditionsNotPresent(finalRequestConditions, - EnumSet.of(BlobRequestConditionProperty.LEASE_ID, BlobRequestConditionProperty.TAGS_CONDITIONS, - BlobRequestConditionProperty.IF_MATCH, BlobRequestConditionProperty.IF_NONE_MATCH, - BlobRequestConditionProperty.IF_MODIFIED_SINCE), - "setImmutabilityPolicy(WithResponse)", "requestConditions"); - - Callable> operation - = () -> this.azureBlobStorage.getBlobs() - .setImmutabilityPolicyWithResponse(containerName, blobName, null, null, - finalRequestConditions.getIfUnmodifiedSince(), finalImmutabilityPolicy.getExpiryTime(), - finalImmutabilityPolicy.getPolicyMode(), snapshot, versionId, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - - BlobsSetImmutabilityPolicyHeaders headers = response.getDeserializedHeaders(); - BlobImmutabilityPolicy responsePolicy - = new BlobImmutabilityPolicy().setPolicyMode(headers.getXMsImmutabilityPolicyMode()) - .setExpiryTime(headers.getXMsImmutabilityPolicyUntilDate()); - return new SimpleResponse<>(response, responsePolicy); - } - - /** - * Delete the immutability policy on a blob, blob snapshot or blob version. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * immutable storage with versioning enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * client.deleteImmutabilityPolicy();
-     * System.out.println("Completed immutability policy deletion.");
-     * 
- * - * - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void deleteImmutabilityPolicy() { - deleteImmutabilityPolicyWithResponse(null, Context.NONE).getValue(); - } - - /** - * Delete the immutability policy on a blob, blob snapshot or blob version. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * immutable storage with versioning enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * System.out.println("Delete immutability policy completed with status: "
-     *     + client.deleteImmutabilityPolicyWithResponse(timeout, new Context(key1, value1)).getStatusCode());
-     * 
- * - * - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing the immutability policy. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteImmutabilityPolicyWithResponse(Duration timeout, Context context) { - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .deleteImmutabilityPolicyNoCustomHeadersWithResponse(containerName, blobName, null, null, snapshot, - versionId, finalContext); - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Sets a legal hold on the blob. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * immutable storage with versioning enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * System.out.println("Legal hold status: " + client.setLegalHold(true));
-     * 
- * - * - * @param legalHold Whether you want a legal hold on the blob. - * @return The legal hold result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlobLegalHoldResult setLegalHold(boolean legalHold) { - return setLegalHoldWithResponse(legalHold, null, Context.NONE).getValue(); - } - - /** - * Sets a legal hold on the blob. - *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with - * immutable storage with versioning enabled to call this API.

- * - *

Code Samples

- * - * - *
-     * System.out.println("Legal hold status: " + client.setLegalHoldWithResponse(true, timeout,
-     *     new Context(key1, value1)));
-     * 
- * - * - * @param legalHold Whether you want a legal hold on the blob. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing the legal hold result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setLegalHoldWithResponse(boolean legalHold, Duration timeout, - Context context) { - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getBlobs() - .setLegalHoldWithResponse(containerName, blobName, legalHold, null, null, snapshot, versionId, - finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, - new InternalBlobLegalHoldResult(response.getDeserializedHeaders().isXMsLegalHold())); - - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java deleted file mode 100644 index e3475b08ea75..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.specialized; - -import com.azure.core.util.Context; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.common.StorageInputStream; -import com.azure.storage.common.implementation.Constants; - -import java.io.IOException; -import java.nio.ByteBuffer; - -/** - * Provides an input stream to read a given blob resource. - */ -public final class BlobInputStream extends StorageInputStream { - /** - * Holds the reference to the blob this stream is associated with. - */ - private final BlobClientBase blobClient; - - /** - * Holds the {@link BlobRequestConditions} object that represents the access conditions for the blob. - */ - private final BlobRequestConditions accessCondition; - - /** - * Holds the {@link BlobProperties} object that represents the blob's properties. - */ - private final BlobProperties properties; - - /** - * The context. - */ - private final Context context; - - /** - * Initializes a new instance of the BlobInputStream class. Note that if {@code blobRangeOffset} is not {@code 0} or - * {@code blobRangeLength} is not {@code null}, there will be no content MD5 verification. - * - * @param blobClient A {@link BlobAsyncClientBase} object which represents the blob that this stream is associated - * with. - * @param blobRangeOffset The offset of blob data to begin stream. - * @param blobRangeLength How much data the stream should return after blobRangeOffset. - * @param chunkSize The size of the chunk to download. - * @param initialBuffer The result of the initial download. - * @param accessCondition An {@link BlobRequestConditions} object which represents the access conditions for the - * blob. - * @param context The {@link Context} - * @throws BlobStorageException An exception representing any error which occurred during the operation. - */ - BlobInputStream(BlobClientBase blobClient, long blobRangeOffset, Long blobRangeLength, int chunkSize, - ByteBuffer initialBuffer, BlobRequestConditions accessCondition, BlobProperties blobProperties, Context context) - throws BlobStorageException { - - super(blobRangeOffset, blobRangeLength, chunkSize, adjustBlobLength(blobProperties.getBlobSize(), context), - initialBuffer); - - this.blobClient = blobClient; - this.accessCondition = accessCondition; - this.properties = blobProperties; - this.context = context; - } - - /** - * Dispatches a read operation of N bytes. When using sparse page blobs, the page ranges are evaluated and zero - * bytes may be generated on the client side for some ranges that do not exist. - * - * @param readLength An int which represents the number of bytes to read. - * @throws IOException If an I/O error occurs. - */ - @Override - protected synchronized ByteBuffer dispatchRead(final int readLength, final long offset) throws IOException { - try { - ByteBuffer currentBuffer = this.blobClient - .downloadContentWithResponse(null, accessCondition, new BlobRange(offset, (long) readLength), false, - null, context) - .getValue() - .toByteBuffer(); - - this.bufferSize = readLength; - this.bufferStartOffset = offset; - return currentBuffer; - } catch (final BlobStorageException e) { - this.streamFaulted = true; - this.lastError = new IOException(e); - - throw this.lastError; - } - } - - /** - * Gets the blob properties as fetched upon download. - * - * @return {@link BlobProperties} - */ - public BlobProperties getProperties() { - return this.properties; - } - - /** - * Allows for encrypted blobs to use BlobInputStream correctly by using the non-encrypted blob length - */ - private static long adjustBlobLength(long initialLength, Context context) { - if (context != null && context.getData(Constants.ADJUSTED_BLOB_LENGTH_KEY).isPresent()) { - return (long) context.getData(Constants.ADJUSTED_BLOB_LENGTH_KEY).get(); - } - return initialLength; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseAsyncClient.java deleted file mode 100644 index 5bab379708f6..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseAsyncClient.java +++ /dev/null @@ -1,639 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobContainerAsyncClient; -import com.azure.storage.blob.implementation.AzureBlobStorageImpl; -import com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; -import com.azure.storage.blob.options.BlobAcquireLeaseOptions; -import com.azure.storage.blob.options.BlobBreakLeaseOptions; -import com.azure.storage.blob.options.BlobChangeLeaseOptions; -import com.azure.storage.blob.options.BlobReleaseLeaseOptions; -import com.azure.storage.blob.options.BlobRenewLeaseOptions; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Mono; - -import java.net.URL; -import java.time.Duration; - -import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.core.util.FluxUtil.withContext; - -/** - * This class provides a client that contains all the leasing operations for {@link BlobContainerAsyncClient containers} - * and {@link BlobAsyncClient blobs}. This client acts as a supplement to those clients and only handles leasing - * operations. - * - *

Instantiating a BlobLeaseAsyncClient

- * - * - *
- * BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder()
- *     .blobAsyncClient(blobAsyncClient)
- *     .buildAsyncClient();
- * 
- * - * - * - *
- * BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder()
- *     .containerAsyncClient(blobContainerAsyncClient)
- *     .buildAsyncClient();
- * 
- * - * - *

View {@link BlobLeaseClientBuilder this} for additional ways to construct the client.

- * - *

For more information about leasing see the - * container leasing or - * blob leasing documentation.

- * - * @see BlobLeaseClientBuilder - */ -@ServiceClient(builder = BlobLeaseClientBuilder.class, isAsync = true) -public final class BlobLeaseAsyncClient { - private static final ClientLogger LOGGER = new ClientLogger(BlobLeaseAsyncClient.class); - - private final String containerName; - private final String blobName; - private final boolean isBlob; - private final AzureBlobStorageImpl client; - private final String accountName; - - private volatile String leaseId; - - BlobLeaseAsyncClient(HttpPipeline pipeline, String url, String containerName, String blobName, String leaseId, - boolean isBlob, String accountName, String serviceVersion) { - this.isBlob = isBlob; - this.leaseId = leaseId; - this.client - = new AzureBlobStorageImplBuilder().pipeline(pipeline).url(url).version(serviceVersion).buildClient(); - this.accountName = accountName; - this.containerName = containerName; - this.blobName = blobName; - } - - /** - * Gets the {@link URL} of the lease client. - * - *

The lease will either be a container or blob URL depending on which the lease client is associated.

- * - * @return URL of the lease client. - */ - public String getResourceUrl() { - if (this.isBlob) { - return this.client.getUrl() + "/" + containerName + "/" + blobName; - } else { - return this.client.getUrl() + "/" + containerName; - } - } - - /** - * Get the lease ID for this lease. - * - * @return the lease ID. - */ - public String getLeaseId() { - return leaseId; - } - - /** - * Acquires a lease for write and delete operations. The lease duration must be between 15 and 60 seconds or -1 for - * an infinite duration. - * - *

Code Samples

- * - * - *
-     * client.acquireLease(60).subscribe(response -> System.out.printf("Lease ID is %s%n", response));
-     * 
- * - * - * @param durationInSeconds The duration of the lease between 15 and 60 seconds or -1 for an infinite duration. - * @return A reactive response containing the lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono acquireLease(int durationInSeconds) { - return acquireLeaseWithResponse(durationInSeconds, null).flatMap(FluxUtil::toMono); - } - - /** - * Acquires a lease for write and delete operations. The lease duration must be between 15 and 60 seconds, or -1 for - * an infinite duration. - * - *

Code Samples

- * - * - *
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfModifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.acquireLeaseWithResponse(60, modifiedRequestConditions).subscribe(response ->
-     *     System.out.printf("Lease ID is %s%n", response.getValue()));
-     * 
- * - * - * @param durationInSeconds The duration of the lease between 15 and 60 seconds or -1 for an infinite duration. - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @return A reactive response containing the lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseWithResponse(int durationInSeconds, - RequestConditions modifiedRequestConditions) { - return acquireLeaseWithResponse(new BlobAcquireLeaseOptions(durationInSeconds) - .setRequestConditions(ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions))); - } - - /** - * Acquires a lease for write and delete operations. The lease duration must be between 15 and 60 seconds, or -1 for - * an infinite duration. - * - *

Code Samples

- * - * - *
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfModifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobAcquireLeaseOptions options = new BlobAcquireLeaseOptions(60)
-     *     .setRequestConditions(requestConditions);
-     *
-     * client.acquireLeaseWithResponse(options).subscribe(response ->
-     *     System.out.printf("Lease ID is %s%n", response.getValue()));
-     * 
- * - * - * @param options {@link BlobAcquireLeaseOptions} - * @return A reactive response containing the lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> acquireLeaseWithResponse(BlobAcquireLeaseOptions options) { - try { - return withContext(context -> acquireLeaseWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> acquireLeaseWithResponse(BlobAcquireLeaseOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - BlobLeaseRequestConditions requestConditions = (options.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : options.getRequestConditions(); - context = context == null ? Context.NONE : context; - - Mono> response; - if (this.isBlob) { - response = this.client.getBlobs() - .acquireLeaseWithResponseAsync(containerName, blobName, null, options.getDuration(), this.leaseId, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsLeaseId())); - } else { - response = this.client.getContainers() - .acquireLeaseWithResponseAsync(containerName, null, options.getDuration(), this.leaseId, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsLeaseId())); - } - - response = response.doOnSuccess(r -> this.leaseId = r.getValue()); - return response; - } - - /** - * Renews the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * client.renewLease().subscribe(response -> System.out.printf("Renewed lease ID is %s%n", response));
-     * 
- * - * - * @return A reactive response containing the renewed lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono renewLease() { - return renewLeaseWithResponse((RequestConditions) null).flatMap(FluxUtil::toMono); - } - - /** - * Renews the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.renewLeaseWithResponse(modifiedRequestConditions).subscribe(response ->
-     *     System.out.printf("Renewed lease ID is %s%n", response.getValue()));
-     * 
- * - * - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @return A reactive response containing the renewed lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseWithResponse(RequestConditions modifiedRequestConditions) { - return renewLeaseWithResponse(new BlobRenewLeaseOptions() - .setRequestConditions(ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions))); - } - - /** - * Renews the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfModifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobRenewLeaseOptions options = new BlobRenewLeaseOptions()
-     *     .setRequestConditions(requestConditions);
-     *
-     * client.renewLeaseWithResponse(options).subscribe(response ->
-     *     System.out.printf("Lease ID is %s%n", response.getValue()));
-     * 
- * - * - * @param options {@link BlobRenewLeaseOptions} - * @return A reactive response containing the renewed lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> renewLeaseWithResponse(BlobRenewLeaseOptions options) { - try { - return withContext(context -> renewLeaseWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> renewLeaseWithResponse(BlobRenewLeaseOptions options, Context context) { - options = (options == null) ? new BlobRenewLeaseOptions() : options; - BlobLeaseRequestConditions requestConditions = (options.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : options.getRequestConditions(); - context = context == null ? Context.NONE : context; - - Mono> response; - if (this.isBlob) { - response = this.client.getBlobs() - .renewLeaseWithResponseAsync(containerName, blobName, this.leaseId, null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsLeaseId())); - } else { - response = this.client.getContainers() - .renewLeaseWithResponseAsync(containerName, this.leaseId, null, requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsLeaseId())); - } - - response = response.doOnSuccess(r -> this.leaseId = r.getValue()); - return response; - } - - /** - * Releases the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * client.releaseLease().subscribe(response -> System.out.println("Completed release lease"));
-     * 
- * - * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono releaseLease() { - return releaseLeaseWithResponse((RequestConditions) null).flatMap(FluxUtil::toMono); - } - - /** - * Releases the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.releaseLeaseWithResponse(modifiedRequestConditions).subscribe(response ->
-     *     System.out.printf("Release lease completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseWithResponse(RequestConditions modifiedRequestConditions) { - return releaseLeaseWithResponse(new BlobReleaseLeaseOptions() - .setRequestConditions(ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions))); - } - - /** - * Releases the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfModifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobReleaseLeaseOptions options = new BlobReleaseLeaseOptions()
-     *     .setRequestConditions(requestConditions);
-     *
-     * client.releaseLeaseWithResponse(options).subscribe(response ->
-     *     System.out.printf("Release lease completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param options {@link BlobReleaseLeaseOptions} - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseLeaseWithResponse(BlobReleaseLeaseOptions options) { - try { - return withContext(context -> releaseLeaseWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> releaseLeaseWithResponse(BlobReleaseLeaseOptions options, Context context) { - options = (options == null) ? new BlobReleaseLeaseOptions() : options; - BlobLeaseRequestConditions requestConditions = (options.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : options.getRequestConditions(); - context = context == null ? Context.NONE : context; - - if (this.isBlob) { - return this.client.getBlobs() - .releaseLeaseNoCustomHeadersWithResponseAsync(containerName, blobName, this.leaseId, null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, context); - } else { - return this.client.getContainers() - .releaseLeaseNoCustomHeadersWithResponseAsync(containerName, this.leaseId, null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), null, context); - } - } - - /** - * Breaks the previously acquired lease, if it exists. - * - *

Code Samples

- * - * - *
-     * client.breakLease().subscribe(response ->
-     *     System.out.printf("The broken lease has %d seconds remaining on the lease", response));
-     * 
- * - * - * @return A reactive response containing the remaining time in the broken lease in seconds. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono breakLease() { - return breakLeaseWithResponse((Integer) null, null).flatMap(FluxUtil::toMono); - } - - /** - * Breaks the previously acquired lease, if it exists. - * - *

If {@code null} is passed for {@code breakPeriodInSeconds} a fixed duration lease will break after the - * remaining lease period elapses and an infinite lease will break immediately.

- * - *

Code Samples

- * - * - *
-     * Integer retainLeaseInSeconds = 5;
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.breakLeaseWithResponse(retainLeaseInSeconds, modifiedRequestConditions).subscribe(response ->
-     *     System.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue()));
-     * 
- * - * - * @param breakPeriodInSeconds An optional duration, between 0 and 60 seconds, that the lease should continue before - * it is broken. If the break period is longer than the time remaining on the lease the remaining time on the lease - * is used. A new lease will not be available before the break period has expired, but the lease may be held for - * longer than the break period. - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @return A reactive response containing the remaining time in the broken lease in seconds. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseWithResponse(Integer breakPeriodInSeconds, - RequestConditions modifiedRequestConditions) { - return breakLeaseWithResponse(new BlobBreakLeaseOptions() - .setBreakPeriod(breakPeriodInSeconds == null ? null : Duration.ofSeconds(breakPeriodInSeconds)) - .setRequestConditions(ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions))); - } - - /** - * Breaks the previously acquired lease, if it exists. - * - *

If {@code null} is passed for {@code breakPeriodInSeconds} a fixed duration lease will break after the - * remaining lease period elapses and an infinite lease will break immediately.

- * - *

Code Samples

- * - * - *
-     * Integer retainLeaseInSeconds = 5;
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobBreakLeaseOptions options = new BlobBreakLeaseOptions()
-     *     .setBreakPeriod(Duration.ofSeconds(retainLeaseInSeconds))
-     *     .setRequestConditions(requestConditions);
-     *
-     * client.breakLeaseWithResponse(options).subscribe(response ->
-     *     System.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue()));
-     * 
- * - * - * @param options {@link BlobBreakLeaseOptions} - * @return A reactive response containing the remaining time in the broken lease in seconds. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> breakLeaseWithResponse(BlobBreakLeaseOptions options) { - try { - return withContext(context -> breakLeaseWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> breakLeaseWithResponse(BlobBreakLeaseOptions options, Context context) { - options = (options == null) ? new BlobBreakLeaseOptions() : options; - BlobLeaseRequestConditions requestConditions = (options.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : options.getRequestConditions(); - context = context == null ? Context.NONE : context; - Integer breakPeriod - = options.getBreakPeriod() == null ? null : Math.toIntExact(options.getBreakPeriod().getSeconds()); - - if (this.isBlob) { - return this.client.getBlobs() - .breakLeaseWithResponseAsync(containerName, blobName, null, breakPeriod, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsLeaseTime())); - } else { - return this.client.getContainers() - .breakLeaseWithResponseAsync(containerName, null, breakPeriod, requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsLeaseTime())); - } - } - - /** - * Changes the lease ID. - * - *

Code Samples

- * - * - *
-     * client.changeLease("proposedId").subscribe(response -> System.out.printf("Changed lease ID is %s%n", response));
-     * 
- * - * - * @param proposedId A new lease ID in a valid GUID format. - * @return A reactive response containing the new lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono changeLease(String proposedId) { - return changeLeaseWithResponse(proposedId, null).flatMap(FluxUtil::toMono); - } - - /** - * Changes the lease ID. - * - *

Code Samples

- * - * - *
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.changeLeaseWithResponse("proposedId", modifiedRequestConditions).subscribe(response ->
-     *     System.out.printf("Changed lease ID is %s%n", response.getValue()));
-     * 
- * - * - * @param proposedId A new lease ID in a valid GUID format. - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @return A reactive response containing the new lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseWithResponse(String proposedId, - RequestConditions modifiedRequestConditions) { - return changeLeaseWithResponse(new BlobChangeLeaseOptions(proposedId) - .setRequestConditions(ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions))); - } - - /** - * Changes the lease ID. - * - *

Code Samples

- * - * - *
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobChangeLeaseOptions options = new BlobChangeLeaseOptions("proposedId")
-     *     .setRequestConditions(requestConditions);
-     *
-     * client.changeLeaseWithResponse(options).subscribe(response ->
-     *     System.out.printf("Changed lease ID is %s%n", response.getValue()));
-     * 
- * - * - * @param options {@link BlobChangeLeaseOptions} - * @return A reactive response containing the new lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> changeLeaseWithResponse(BlobChangeLeaseOptions options) { - try { - return withContext(context -> changeLeaseWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> changeLeaseWithResponse(BlobChangeLeaseOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - BlobLeaseRequestConditions requestConditions = (options.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : options.getRequestConditions(); - context = context == null ? Context.NONE : context; - - Mono> response; - if (this.isBlob) { - response = this.client.getBlobs() - .changeLeaseWithResponseAsync(containerName, blobName, this.leaseId, options.getProposedId(), null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsLeaseId())); - } else { - response = this.client.getContainers() - .changeLeaseWithResponseAsync(containerName, this.leaseId, options.getProposedId(), null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsLeaseId())); - } - - response = response.doOnSuccess(r -> this.leaseId = r.getValue()); - return response; - } - - /** - * Get associated account name. - * - * @return account name associated with this storage resource. - */ - public String getAccountName() { - return this.accountName; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseClient.java deleted file mode 100644 index 4a0e76c17c8a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseClient.java +++ /dev/null @@ -1,649 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.implementation.AzureBlobStorageImpl; -import com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder; -import com.azure.storage.blob.implementation.models.BlobsAcquireLeaseHeaders; -import com.azure.storage.blob.implementation.models.BlobsBreakLeaseHeaders; -import com.azure.storage.blob.implementation.models.BlobsChangeLeaseHeaders; -import com.azure.storage.blob.implementation.models.BlobsRenewLeaseHeaders; -import com.azure.storage.blob.implementation.models.ContainersAcquireLeaseHeaders; -import com.azure.storage.blob.implementation.models.ContainersBreakLeaseHeaders; -import com.azure.storage.blob.implementation.models.ContainersChangeLeaseHeaders; -import com.azure.storage.blob.implementation.models.ContainersRenewLeaseHeaders; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.options.BlobAcquireLeaseOptions; -import com.azure.storage.blob.options.BlobBreakLeaseOptions; -import com.azure.storage.blob.options.BlobChangeLeaseOptions; -import com.azure.storage.blob.options.BlobReleaseLeaseOptions; -import com.azure.storage.blob.options.BlobRenewLeaseOptions; -import com.azure.storage.common.implementation.StorageImplUtils; - -import java.net.URL; -import java.time.Duration; -import java.util.concurrent.Callable; - -import static com.azure.storage.common.implementation.StorageImplUtils.sendRequest; - -/** - * This class provides a client that contains all the leasing operations for {@link BlobContainerClient containers} and - * {@link BlobClient blobs}. This client acts as a supplement to those clients and only handles leasing operations. - * - *

Instantiating a BlobLeaseClient

- * - * - *
- * BlobLeaseClient blobLeaseClient = new BlobLeaseClientBuilder()
- *     .blobClient(blobClient)
- *     .buildClient();
- * 
- * - * - * - *
- * BlobLeaseClient blobLeaseClient = new BlobLeaseClientBuilder()
- *     .containerClient(blobContainerClient)
- *     .buildClient();
- * 
- * - * - *

View {@link BlobLeaseClientBuilder this} for additional ways to construct the client.

- * - *

For more information about leasing see the - * container leasing or - * blob leasing documentation.

- * - * @see BlobLeaseClientBuilder - */ -@ServiceClient(builder = BlobLeaseClientBuilder.class) -public final class BlobLeaseClient { - private final String containerName; - private final String blobName; - private final boolean isBlob; - private final AzureBlobStorageImpl client; - private final String accountName; - - private volatile String leaseId; - - BlobLeaseClient(HttpPipeline pipeline, String url, String containerName, String blobName, String leaseId, - boolean isBlob, String accountName, String serviceVersion) { - this.isBlob = isBlob; - this.leaseId = leaseId; - this.client - = new AzureBlobStorageImplBuilder().pipeline(pipeline).url(url).version(serviceVersion).buildClient(); - this.accountName = accountName; - this.containerName = containerName; - this.blobName = blobName; - } - - /** - * Gets the {@link URL} of the lease client. - * - *

The lease will either be a container or blob URL depending on which the lease client is associated.

- * - * @return URL of the lease client. - */ - public String getResourceUrl() { - if (this.isBlob) { - return this.client.getUrl() + "/" + containerName + "/" + blobName; - } else { - return this.client.getUrl() + "/" + containerName; - } - } - - /** - * Get the lease ID for this lease. - * - * @return the lease ID. - */ - public String getLeaseId() { - return leaseId; - } - - /** - * Acquires a lease for write and delete operations. The lease duration must be between 15 to 60 seconds or - * -1 for an infinite duration. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Lease ID is %s%n", client.acquireLease(60));
-     * 
- * - * - * @param durationInSeconds The duration of the lease between 15 to 60 seconds or -1 for an infinite duration. - * @return The lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public String acquireLease(int durationInSeconds) { - return acquireLeaseWithResponse(durationInSeconds, null, null, Context.NONE).getValue(); - } - - /** - * Acquires a lease for write and delete operations. The lease duration must be between 15 to 60 seconds or - * -1 for an infinite duration. - * - *

Code Samples

- * - * - *
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfModifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * System.out.printf("Lease ID is %s%n", client
-     *     .acquireLeaseWithResponse(60, modifiedRequestConditions, timeout, new Context(key, value))
-     *     .getValue());
-     * 
- * - * - * @param durationInSeconds The duration of the lease between 15 to 60 seconds or -1 for an infinite duration. - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response acquireLeaseWithResponse(int durationInSeconds, RequestConditions modifiedRequestConditions, - Duration timeout, Context context) { - return acquireLeaseWithResponse(new BlobAcquireLeaseOptions(durationInSeconds).setRequestConditions( - ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions)), timeout, context); - } - - /** - * Acquires a lease for write and delete operations. The lease duration must be between 15 to 60 seconds or - * -1 for an infinite duration. - * - *

Code Samples

- * - * - *
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfModifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobAcquireLeaseOptions options = new BlobAcquireLeaseOptions(60)
-     *     .setRequestConditions(requestConditions);
-     *
-     * System.out.printf("Lease ID is %s%n", client
-     *     .acquireLeaseWithResponse(options, timeout, new Context(key, value))
-     *     .getValue());
-     * 
- * - * - * @param options {@link BlobAcquireLeaseOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response acquireLeaseWithResponse(BlobAcquireLeaseOptions options, Duration timeout, - Context context) { - StorageImplUtils.assertNotNull("options", options); - BlobLeaseRequestConditions requestConditions = (options.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : options.getRequestConditions(); - Context finalContext = context == null ? Context.NONE : context; - - if (this.isBlob) { - Callable> operation = () -> this.client.getBlobs() - .acquireLeaseWithResponse(containerName, blobName, null, options.getDuration(), this.leaseId, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - this.leaseId = response.getDeserializedHeaders().getXMsLeaseId(); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsLeaseId()); - } else { - Callable> operation = () -> this.client.getContainers() - .acquireLeaseWithResponse(containerName, null, options.getDuration(), this.leaseId, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), null, - finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - this.leaseId = response.getDeserializedHeaders().getXMsLeaseId(); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsLeaseId()); - } - } - - /** - * Renews the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Renewed lease ID is %s%n", client.renewLease());
-     * 
- * - * - * @return The renewed lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public String renewLease() { - return renewLeaseWithResponse((RequestConditions) null, null, Context.NONE).getValue(); - } - - /** - * Renews the previously-acquired lease. - * - *

Code Samples

- * - * - *
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * System.out.printf("Renewed lease ID is %s%n",
-     *     client.renewLeaseWithResponse(modifiedRequestConditions, timeout, new Context(key, value))
-     *         .getValue());
-     * 
- * - * - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The renewed lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response renewLeaseWithResponse(RequestConditions modifiedRequestConditions, Duration timeout, - Context context) { - return renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions( - ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions)), timeout, context); - } - - /** - * Renews the previously-acquired lease. - * - *

Code Samples

- * - * - *
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfModifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobRenewLeaseOptions options = new BlobRenewLeaseOptions()
-     *     .setRequestConditions(requestConditions);
-     *
-     * System.out.printf("Renewed lease ID is %s%n",
-     *     client.renewLeaseWithResponse(options, timeout, new Context(key, value))
-     *         .getValue());
-     * 
- * - * - * @param options {@link BlobRenewLeaseOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The renewed lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response renewLeaseWithResponse(BlobRenewLeaseOptions options, Duration timeout, Context context) { - BlobRenewLeaseOptions finalOptions = (options == null) ? new BlobRenewLeaseOptions() : options; - BlobLeaseRequestConditions requestConditions = (finalOptions.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : finalOptions.getRequestConditions(); - Context finalContext = context == null ? Context.NONE : context; - if (this.isBlob) { - Callable> operation = () -> this.client.getBlobs() - .renewLeaseWithResponse(containerName, blobName, this.leaseId, null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsLeaseId()); - } else { - Callable> operation = () -> this.client.getContainers() - .renewLeaseWithResponse(containerName, this.leaseId, null, requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsLeaseId()); - } - } - - /** - * Releases the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * client.releaseLease();
-     * System.out.println("Release lease completed");
-     * 
- * - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void releaseLease() { - releaseLeaseWithResponse((RequestConditions) null, null, Context.NONE); - } - - /** - * Releases the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * System.out.printf("Release lease completed with status %d%n",
-     *     client.releaseLeaseWithResponse(modifiedRequestConditions, timeout, new Context(key, value))
-     *         .getStatusCode());
-     * 
- * - * - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response releaseLeaseWithResponse(RequestConditions modifiedRequestConditions, Duration timeout, - Context context) { - return releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions( - ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions)), timeout, context); - } - - /** - * Releases the previously acquired lease. - * - *

Code Samples

- * - * - *
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfModifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobReleaseLeaseOptions options = new BlobReleaseLeaseOptions()
-     *     .setRequestConditions(requestConditions);
-     *
-     * System.out.printf("Release lease completed with status %d%n",
-     *     client.releaseLeaseWithResponse(options, timeout, new Context(key, value))
-     *         .getStatusCode());
-     * 
- * - * - * @param options {@link BlobReleaseLeaseOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response releaseLeaseWithResponse(BlobReleaseLeaseOptions options, Duration timeout, Context context) { - BlobReleaseLeaseOptions finalOptions = (options == null) ? new BlobReleaseLeaseOptions() : options; - BlobLeaseRequestConditions requestConditions = (finalOptions.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : finalOptions.getRequestConditions(); - Context finalContext = context == null ? Context.NONE : context; - Callable> operation; - if (this.isBlob) { - operation = () -> this.client.getBlobs() - .releaseLeaseNoCustomHeadersWithResponse(containerName, blobName, this.leaseId, null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, finalContext); - } else { - operation = () -> this.client.getContainers() - .releaseLeaseNoCustomHeadersWithResponse(containerName, this.leaseId, null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), null, - finalContext); - } - return sendRequest(operation, timeout, BlobStorageException.class); - } - - /** - * Breaks the previously acquired lease, if it exists. - * - *

Code Samples

- * - * - *
-     * System.out.printf("The broken lease has %d seconds remaining on the lease", client.breakLease());
-     * 
- * - * - * @return The remaining time in the broken lease in seconds. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Integer breakLease() { - return breakLeaseWithResponse(null, null, null, Context.NONE).getValue(); - } - - /** - * Breaks the previously acquired lease, if it exists. - * - *

If {@code null} is passed for {@code breakPeriodInSeconds} a fixed duration lease will break after the - * remaining lease period elapses and an infinite lease will break immediately.

- * - *

Code Samples

- * - * - *
-     * Integer retainLeaseInSeconds = 5;
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * System.out.printf("The broken lease has %d seconds remaining on the lease", client
-     *     .breakLeaseWithResponse(retainLeaseInSeconds, modifiedRequestConditions, timeout, new Context(key, value))
-     *     .getValue());
-     * 
- * - * - * @param breakPeriodInSeconds An optional duration, between 0 and 60 seconds, that the lease should continue before - * it is broken. If the break period is longer than the time remaining on the lease the remaining time on the lease - * is used. A new lease will not be available before the break period has expired, but the lease may be held for - * longer than the break period. - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The remaining time in the broken lease in seconds. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response breakLeaseWithResponse(Integer breakPeriodInSeconds, - RequestConditions modifiedRequestConditions, Duration timeout, Context context) { - return breakLeaseWithResponse( - new BlobBreakLeaseOptions() - .setBreakPeriod(breakPeriodInSeconds == null ? null : Duration.ofSeconds(breakPeriodInSeconds)) - .setRequestConditions(ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions)), - timeout, context); - } - - /** - * Breaks the previously acquired lease, if it exists. - * - *

If {@code null} is passed for {@code breakPeriodInSeconds} a fixed duration lease will break after the - * remaining lease period elapses and an infinite lease will break immediately.

- * - *

Code Samples

- * - * - *
-     * Integer retainLeaseInSeconds = 5;
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobBreakLeaseOptions options = new BlobBreakLeaseOptions()
-     *     .setBreakPeriod(Duration.ofSeconds(retainLeaseInSeconds))
-     *     .setRequestConditions(requestConditions);
-     *
-     * System.out.printf("The broken lease has %d seconds remaining on the lease", client
-     *     .breakLeaseWithResponse(options, timeout, new Context(key, value))
-     *     .getValue());
-     * 
- * - * - * @param options {@link BlobBreakLeaseOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The remaining time in the broken lease in seconds. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response breakLeaseWithResponse(BlobBreakLeaseOptions options, Duration timeout, Context context) { - BlobBreakLeaseOptions finalOptions = (options == null) ? new BlobBreakLeaseOptions() : options; - BlobLeaseRequestConditions requestConditions = (finalOptions.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : finalOptions.getRequestConditions(); - Context finalContext = context == null ? Context.NONE : context; - Integer breakPeriod = finalOptions.getBreakPeriod() == null - ? null - : Math.toIntExact(finalOptions.getBreakPeriod().getSeconds()); - - if (this.isBlob) { - Callable> operation = () -> this.client.getBlobs() - .breakLeaseWithResponse(containerName, blobName, null, breakPeriod, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsLeaseTime()); - } else { - Callable> operation = () -> this.client.getContainers() - .breakLeaseWithResponse(containerName, null, breakPeriod, requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsLeaseTime()); - } - } - - /** - * Changes the lease ID. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Changed lease ID is %s%n", client.changeLease("proposedId"));
-     * 
- * - * - * @param proposedId A new lease ID in a valid GUID format. - * @return The new lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public String changeLease(String proposedId) { - return changeLeaseWithResponse(proposedId, null, null, Context.NONE).getValue(); - } - - /** - * Changes the lease ID. - * - *

Code Samples

- * - * - *
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * System.out.printf("Changed lease ID is %s%n",
-     *     client.changeLeaseWithResponse("proposedId", modifiedRequestConditions, timeout, new Context(key, value))
-     *         .getValue());
-     * 
- * - * - * @param proposedId A new lease ID in a valid GUID format. - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The new lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response changeLeaseWithResponse(String proposedId, RequestConditions modifiedRequestConditions, - Duration timeout, Context context) { - return changeLeaseWithResponse(new BlobChangeLeaseOptions(proposedId).setRequestConditions( - ModelHelper.populateBlobLeaseRequestConditions(modifiedRequestConditions)), timeout, context); - } - - /** - * Changes the lease ID. - * - *

Code Samples

- * - * - *
-     * BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * BlobChangeLeaseOptions options = new BlobChangeLeaseOptions("proposedId")
-     *     .setRequestConditions(requestConditions);
-     *
-     * System.out.printf("Changed lease ID is %s%n",
-     *     client.changeLeaseWithResponse(options, timeout, new Context(key, value))
-     *         .getValue());
-     * 
- * - * - * @param options {@link BlobChangeLeaseOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The new lease ID. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response changeLeaseWithResponse(BlobChangeLeaseOptions options, Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", options); - BlobLeaseRequestConditions requestConditions = (options.getRequestConditions() == null) - ? new BlobLeaseRequestConditions() - : options.getRequestConditions(); - Context finalContext = context == null ? Context.NONE : context; - - if (this.isBlob) { - Callable> operation = () -> this.client.getBlobs() - .changeLeaseWithResponse(containerName, blobName, this.leaseId, options.getProposedId(), null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - this.leaseId = response.getDeserializedHeaders().getXMsLeaseId(); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsLeaseId()); - } else { - Callable> operation = () -> this.client.getContainers() - .changeLeaseWithResponse(containerName, this.leaseId, options.getProposedId(), null, - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), null, - finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - this.leaseId = response.getDeserializedHeaders().getXMsLeaseId(); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsLeaseId()); - } - } - - /** - * Get associated account name. - * - * @return account name associated with this storage resource. - */ - public String getAccountName() { - return this.accountName; - } - -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseClientBuilder.java deleted file mode 100644 index 6b24aac311be..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobLeaseClientBuilder.java +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.http.HttpPipeline; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobContainerAsyncClient; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.BlobServiceVersion; - -import java.net.URL; -import java.util.Objects; -import java.util.UUID; - -/** - * This class provides a fluent builder API to help aid the configuration and instantiation of Storage Lease - * clients. Lease clients are able to interact with both container and blob clients and act as a supplement client. A - * new instance of {@link BlobLeaseClient} and {@link BlobLeaseAsyncClient} are constructed every time - * {@link #buildClient() buildClient} and {@link #buildAsyncClient() buildAsyncClient} are called - * respectively. - * - *

When a client is instantiated and a {@link #leaseId(String) leaseId} hasn't been set a {@link UUID} will be used - * as the lease identifier.

- * - *

Instantiating LeaseClients

- * - * - *
- * BlobLeaseClient blobLeaseClient = new BlobLeaseClientBuilder()
- *     .blobClient(blobClient)
- *     .leaseId(leaseId)
- *     .buildClient();
- * 
- * - * - * - *
- * BlobLeaseClient blobLeaseClient = new BlobLeaseClientBuilder()
- *     .containerClient(blobContainerClient)
- *     .leaseId(leaseId)
- *     .buildClient();
- * 
- * - * - *

Instantiating LeaseAsyncClients

- * - * - *
- * BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder()
- *     .blobAsyncClient(blobAsyncClient)
- *     .leaseId(leaseId)
- *     .buildAsyncClient();
- * 
- * - * - * - *
- * BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder()
- *     .containerAsyncClient(blobContainerAsyncClient)
- *     .leaseId(leaseId)
- *     .buildAsyncClient();
- * 
- * - * - * @see BlobLeaseClient - * @see BlobLeaseAsyncClient - */ -@ServiceClientBuilder(serviceClients = { BlobLeaseClient.class, BlobLeaseAsyncClient.class }) -public final class BlobLeaseClientBuilder { - private HttpPipeline pipeline; - private String url; - private String containerName; - private String blobName; - private String leaseId; - private boolean isBlob; - private String accountName; - private BlobServiceVersion serviceVersion; - - /** - * Creates a {@link BlobLeaseClientBuilder}. - */ - public BlobLeaseClientBuilder() { - } - - /** - * Creates a {@link BlobLeaseClient} based on the configurations set in the builder. - * - * @return a {@link BlobLeaseClient} based on the configurations in this builder. - */ - public BlobLeaseClient buildClient() { - BlobServiceVersion version = (serviceVersion == null) ? BlobServiceVersion.getLatest() : serviceVersion; - return new BlobLeaseClient(pipeline, url, containerName, blobName, getLeaseId(), isBlob, accountName, - version.getVersion()); - } - - /** - * Creates a {@link BlobLeaseAsyncClient} based on the configurations set in the builder. - * - * @return a {@link BlobLeaseAsyncClient} based on the configurations in this builder. - */ - public BlobLeaseAsyncClient buildAsyncClient() { - BlobServiceVersion version = (serviceVersion == null) ? BlobServiceVersion.getLatest() : serviceVersion; - return new BlobLeaseAsyncClient(pipeline, url, containerName, blobName, getLeaseId(), isBlob, accountName, - version.getVersion()); - } - - /** - * Configures the builder based on the passed {@link BlobClient}. This will set the {@link HttpPipeline} and - * {@link URL} that are used to interact with the service. - * - * @param blobClient BlobClient used to configure the builder. - * @return the updated BlobLeaseClientBuilder object - * @throws NullPointerException If {@code blobClient} is {@code null}. - */ - public BlobLeaseClientBuilder blobClient(BlobClientBase blobClient) { - Objects.requireNonNull(blobClient); - this.pipeline = blobClient.getHttpPipeline(); - this.url = blobClient.getAccountUrl(); - this.containerName = blobClient.getContainerName(); - this.blobName = blobClient.getBlobName(); - this.isBlob = true; - this.accountName = blobClient.getAccountName(); - this.serviceVersion = blobClient.getServiceVersion(); - return this; - } - - /** - * Configures the builder based on the passed {@link BlobAsyncClient}. This will set the {@link HttpPipeline} and - * {@link URL} that are used to interact with the service. - * - * @param blobAsyncClient BlobAsyncClient used to configure the builder. - * @return the updated BlobLeaseClientBuilder object - * @throws NullPointerException If {@code blobAsyncClient} is {@code null}. - */ - public BlobLeaseClientBuilder blobAsyncClient(BlobAsyncClientBase blobAsyncClient) { - Objects.requireNonNull(blobAsyncClient); - this.pipeline = blobAsyncClient.getHttpPipeline(); - this.url = blobAsyncClient.getAccountUrl(); - this.containerName = blobAsyncClient.getContainerName(); - this.blobName = blobAsyncClient.getBlobName(); - this.isBlob = true; - this.accountName = blobAsyncClient.getAccountName(); - this.serviceVersion = blobAsyncClient.getServiceVersion(); - return this; - } - - /** - * Configures the builder based on the passed {@link BlobContainerClient}. This will set the {@link HttpPipeline} - * and {@link URL} that are used to interact with the service. - * - * @param blobContainerClient ContainerClient used to configure the builder. - * @return the updated BlobLeaseClientBuilder object - * @throws NullPointerException If {@code containerClient} is {@code null}. - */ - public BlobLeaseClientBuilder containerClient(BlobContainerClient blobContainerClient) { - Objects.requireNonNull(blobContainerClient); - this.pipeline = blobContainerClient.getHttpPipeline(); - this.url = blobContainerClient.getAccountUrl(); - this.containerName = blobContainerClient.getBlobContainerName(); - this.isBlob = false; - this.accountName = blobContainerClient.getAccountName(); - this.serviceVersion = blobContainerClient.getServiceVersion(); - return this; - } - - /** - * Configures the builder based on the passed {@link BlobContainerAsyncClient}. This will set the {@link - * HttpPipeline} and {@link URL} that are used to interact with the service. - * - * @param blobContainerAsyncClient ContainerAsyncClient used to configure the builder. - * @return the updated BlobLeaseClientBuilder object - * @throws NullPointerException If {@code containerAsyncClient} is {@code null}. - */ - public BlobLeaseClientBuilder containerAsyncClient(BlobContainerAsyncClient blobContainerAsyncClient) { - Objects.requireNonNull(blobContainerAsyncClient); - this.pipeline = blobContainerAsyncClient.getHttpPipeline(); - this.url = blobContainerAsyncClient.getAccountUrl(); - this.containerName = blobContainerAsyncClient.getBlobContainerName(); - this.isBlob = false; - this.accountName = blobContainerAsyncClient.getAccountName(); - this.serviceVersion = blobContainerAsyncClient.getServiceVersion(); - return this; - } - - /** - * Sets the identifier for the lease. - * - *

If a lease ID isn't set then a {@link UUID} will be used.

- * - * @param leaseId Identifier for the lease. - * @return the updated BlobLeaseClientBuilder object - */ - public BlobLeaseClientBuilder leaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - private String getLeaseId() { - return (leaseId == null) ? CoreUtils.randomUuid().toString() : leaseId; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobOutputStream.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobOutputStream.java deleted file mode 100644 index c43277ff30de..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobOutputStream.java +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.specialized; - -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.util.StorageBlockingSink; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.AppendBlobRequestConditions; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.PageBlobRequestConditions; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.BlockBlobOutputStreamOptions; -import com.azure.storage.common.StorageOutputStream; -import com.azure.storage.common.implementation.Constants; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.Map; -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -/** - * BlobOutputStream allows for the uploading of data to a blob using a stream-like approach. - */ -public abstract class BlobOutputStream extends StorageOutputStream { - - private volatile boolean isClosed; - - /** - * - * @param writeThreshold How many bytes the output will retain before it initiates a write to the Storage service. - */ - BlobOutputStream(final int writeThreshold) { - super(writeThreshold); - } - - static BlobOutputStream appendBlobOutputStream(final AppendBlobAsyncClient client, - final AppendBlobRequestConditions appendBlobRequestConditions) { - return new AppendBlobOutputStream(client, appendBlobRequestConditions); - } - - /** - * Creates a block blob output stream from a BlobAsyncClient - * @param client {@link BlobAsyncClient} The blob client. - * @param parallelTransferOptions {@link ParallelTransferOptions} used to configure buffered uploading. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param requestConditions {@link BlobRequestConditions} - * @return {@link BlobOutputStream} associated with the blob. - */ - public static BlobOutputStream blockBlobOutputStream(final BlobAsyncClient client, - final ParallelTransferOptions parallelTransferOptions, final BlobHttpHeaders headers, - final Map metadata, final AccessTier tier, final BlobRequestConditions requestConditions) { - return blockBlobOutputStream(client, parallelTransferOptions, headers, metadata, tier, requestConditions, - Context.NONE); - } - - /** - * Creates a block blob output stream from a BlobAsyncClient - * @param client {@link BlobAsyncClient} The blob client. - * @param parallelTransferOptions {@link ParallelTransferOptions} used to configure buffered uploading. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param requestConditions {@link BlobRequestConditions} - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return {@link BlobOutputStream} associated with the blob. - */ - public static BlobOutputStream blockBlobOutputStream(final BlobAsyncClient client, - final ParallelTransferOptions parallelTransferOptions, final BlobHttpHeaders headers, - final Map metadata, final AccessTier tier, final BlobRequestConditions requestConditions, - Context context) { - return blockBlobOutputStream(client, - new BlockBlobOutputStreamOptions().setParallelTransferOptions(parallelTransferOptions) - .setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setRequestConditions(requestConditions), - context); - } - - /** - * Creates a block blob output stream from a BlobAsyncClient - * @param client {@link BlobAsyncClient} The blob client. - * @param options {@link BlockBlobOutputStreamOptions} - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return {@link BlobOutputStream} associated with the blob. - */ - public static BlobOutputStream blockBlobOutputStream(final BlobAsyncClient client, - BlockBlobOutputStreamOptions options, Context context) { - options = options == null ? new BlockBlobOutputStreamOptions() : options; - return new BlockBlobOutputStream(client, options.getParallelTransferOptions(), options.getHeaders(), - options.getMetadata(), options.getTags(), options.getTier(), options.getRequestConditions(), context); - } - - static BlobOutputStream pageBlobOutputStream(final PageBlobAsyncClient client, final PageRange pageRange, - final BlobRequestConditions requestConditions) { - return new PageBlobOutputStream(client, pageRange, requestConditions); - } - - abstract void commit(); - - /** - * Closes this output stream and releases any system resources associated with this stream. If any data remains in - * the buffer it is committed to the service. - * - * @throws IOException If an I/O error occurs. - */ - @Override - public synchronized void close() throws IOException { - try { - // if the stream is already closed, we can stop executing any further steps to avoid throwing - // STREAM_CLOSED exception - if (isClosed) { - return; - } - // if an exception was thrown by any thread in the threadExecutor, realize it now - this.checkStreamState(); - - // flush any remaining data - this.flush(); - - // try to commit the blob - try { - this.commit(); - } catch (final BlobStorageException e) { - throw new IOException("The blob has not been committed. Data has not been persisted.", e); - } - /* Need this check because for block blob the buffered upload error only manifests itself after commit is - called */ - if (this.lastError != null) { - throw lastError; - } - } finally { - this.lastError = new IOException(Constants.STREAM_CLOSED); - isClosed = true; - } - } - - private static final class AppendBlobOutputStream extends BlobOutputStream { - private static final String INVALID_BLOCK_SIZE - = "Block data should not exceed BlockBlobURL.MAX_STAGE_BLOCK_BYTES"; - - private final AppendBlobRequestConditions appendBlobRequestConditions; - private final AppendBlobAsyncClient client; - - private AppendBlobOutputStream(final AppendBlobAsyncClient client, - final AppendBlobRequestConditions appendBlobRequestConditions) { - // service versions 2022-11-02 and above support uploading block bytes up to 100MB, all older service - // versions support up to 4MB - super(client.getServiceVersion().ordinal() < BlobServiceVersion.V2022_11_02.ordinal() - ? AppendBlobClient.MAX_APPEND_BLOCK_BYTES_VERSIONS_2021_12_02_AND_BELOW - : AppendBlobClient.MAX_APPEND_BLOCK_BYTES_VERSIONS_2022_11_02_AND_ABOVE); - - this.client = client; - this.appendBlobRequestConditions = (appendBlobRequestConditions == null) - ? new AppendBlobRequestConditions() - : appendBlobRequestConditions; - - if (this.appendBlobRequestConditions.getAppendPosition() == null) { - this.appendBlobRequestConditions.setAppendPosition(client.getProperties().block().getBlobSize()); - } - } - - private Mono appendBlock(Flux blockData, long writeLength) { - long newAppendOffset = appendBlobRequestConditions.getAppendPosition() + writeLength; - return client.appendBlockWithResponse(blockData, writeLength, null, appendBlobRequestConditions) - .doOnNext(ignored -> appendBlobRequestConditions.setAppendPosition(newAppendOffset)) - .then() - .onErrorResume(t -> t instanceof IOException || t instanceof BlobStorageException, e -> { - this.lastError = new IOException(e); - return Mono.empty(); - }); - } - - @Override - protected Mono dispatchWrite(byte[] data, int writeLength, long offset) { - if (writeLength == 0) { - return Mono.empty(); - } - - // We cannot differentiate between max size condition failing only in the retry versus failing in the - // first attempt and retry even for a single writer scenario. So we will eliminate the latter and handle - // the former in the append block method. - if (appendBlobRequestConditions.getMaxSize() != null - && appendBlobRequestConditions.getAppendPosition() > appendBlobRequestConditions.getMaxSize()) { - this.lastError = new IOException(INVALID_BLOCK_SIZE); - return Mono.error(this.lastError); - } - - return this.appendBlock(Mono.fromCallable(() -> ByteBuffer.wrap(data, (int) offset, writeLength)).flux(), - writeLength); - } - - @Override - void commit() { - // AppendBlob doesn't need to commit anything. - } - } - - private static final class BlockBlobOutputStream extends BlobOutputStream { - - private final Lock lock; - private final Condition transferComplete; - private final StorageBlockingSink sink; - - boolean complete; - - private BlockBlobOutputStream(final BlobAsyncClient client, - final ParallelTransferOptions parallelTransferOptions, final BlobHttpHeaders headers, - final Map metadata, Map tags, final AccessTier tier, - final BlobRequestConditions requestConditions, Context context) { - super(Integer.MAX_VALUE); // writeThreshold is effectively not used by BlockBlobOutputStream. - // There is a bug in reactor core that does not handle converting Context.NONE to a reactor context. - context = context == null || context.equals(Context.NONE) ? null : context; - - this.lock = new ReentrantLock(); - this.transferComplete = lock.newCondition(); - this.sink = new StorageBlockingSink(); - - Flux body = this.sink.asFlux(); - - client - .uploadWithResponse( - new BlobParallelUploadOptions(body).setParallelTransferOptions(parallelTransferOptions) - .setHeaders(headers) - .setMetadata(metadata) - .setTags(tags) - .setTier(tier) - .setRequestConditions(requestConditions)) - // This allows the operation to continue while maintaining the error that occurred. - .onErrorResume(e -> { - if (e instanceof IOException) { - this.lastError = (IOException) e; - } else { - this.lastError = new IOException(e); - } - return Mono.empty(); - }) - // Use doFinally to cover all termination scenarios of the Flux. - .doFinally(signalType -> { - lock.lock(); - try { - complete = true; - transferComplete.signal(); - } finally { - lock.unlock(); - } - }) - .contextWrite(FluxUtil.toReactorContext(context)) - .subscribe(); - } - - @Override - void commit() { - - // Need to wait until the uploadTask completes - lock.lock(); - try { - sink.emitCompleteOrThrow(); /* Allow upload task to try to complete. */ - - while (!complete) { - transferComplete.await(); - } - } catch (InterruptedException e) { - this.lastError = new IOException(e.getMessage()); // Should we just throw and not populate this since its recoverable? - } catch (Exception e) { // Catch any exceptions by the sink. - this.lastError = new IOException(e); - } finally { - lock.unlock(); - } - - } - - @Override - protected void writeInternal(final byte[] data, int offset, int length) { - this.checkStreamState(); - /* - We need to do a deep copy here because the writing is async in this case. It is a common pattern for - customers writing to an output stream to perform the writes in a tight loop with a reused buffer. This - coupled with async network behavior can result in the data being overwritten as the buffer is reused. - */ - byte[] buffer = new byte[length]; - System.arraycopy(data, offset, buffer, 0, length); - - try { - this.sink.emitNext(ByteBuffer.wrap(buffer)); - } catch (Exception e) { - this.lastError = new IOException(e); - } - } - - // Never called - @Override - protected Mono dispatchWrite(byte[] data, int writeLength, long offset) { - return Mono.empty(); - } - } - - private static final class PageBlobOutputStream extends BlobOutputStream { - private static final String INVALID_NUMBER_OF_BYTES_IN_THE_BUFFER - = "Page data must be a multiple of 512 bytes. Buffer currently contains %d bytes."; - - private static final ClientLogger LOGGER = new ClientLogger(PageBlobOutputStream.class); - private final PageBlobAsyncClient client; - private final PageBlobRequestConditions pageBlobRequestConditions; - private final PageRange pageRange; - - private PageBlobOutputStream(final PageBlobAsyncClient client, final PageRange pageRange, - final BlobRequestConditions blobRequestConditions) { - super(PageBlobClient.MAX_PUT_PAGES_BYTES); - this.client = client; - this.pageRange = pageRange; - - if (blobRequestConditions != null) { - this.pageBlobRequestConditions - = new PageBlobRequestConditions().setLeaseId(blobRequestConditions.getLeaseId()) - .setIfMatch(blobRequestConditions.getIfMatch()) - .setIfNoneMatch(blobRequestConditions.getIfNoneMatch()) - .setIfModifiedSince(blobRequestConditions.getIfModifiedSince()) - .setIfUnmodifiedSince(blobRequestConditions.getIfUnmodifiedSince()); - } else { - this.pageBlobRequestConditions = null; - } - } - - private Mono writePages(Flux pageData, int length, long offset) { - return client - .uploadPagesWithResponse(new PageRange().setStart(offset).setEnd(offset + length - 1), pageData, null, - pageBlobRequestConditions) - .then() - .onErrorResume(BlobStorageException.class, e -> { - this.lastError = new IOException(e); - return Mono.empty(); - }); - } - - @Override - protected Mono dispatchWrite(byte[] data, int writeLength, long offset) { - if (writeLength == 0) { - return Mono.empty(); - } - - if (writeLength % PageBlobAsyncClient.PAGE_BYTES != 0) { - return Mono.error(new IOException(String.format(INVALID_NUMBER_OF_BYTES_IN_THE_BUFFER, writeLength))); - } - - long pageOffset = pageRange.getStart(); - if (pageOffset + writeLength - 1 > pageRange.getEnd()) { - throw LOGGER - .logExceptionAsError(new RuntimeException("The input data length is larger than the page range.")); - } - pageRange.setStart(pageRange.getStart() + writeLength); - - return this.writePages(Mono.fromCallable(() -> ByteBuffer.wrap(data, (int) offset, writeLength)).flux(), - writeLength, pageOffset); - } - - @Override - void commit() { - // PageBlob doesn't need to commit anything. - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobAsyncClient.java deleted file mode 100644 index cbaeb3bd2d25..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobAsyncClient.java +++ /dev/null @@ -1,1170 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.models.BlockBlobsCommitBlockListHeaders; -import com.azure.storage.blob.implementation.models.BlockBlobsPutBlobFromUrlHeaders; -import com.azure.storage.blob.implementation.models.BlockBlobsUploadHeaders; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.BlockList; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.models.BlockLookupList; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.options.BlobUploadFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobListBlocksOptions; -import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockOptions; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.core.util.FluxUtil.withContext; - -/** - * Client to a block blob. It may only be instantiated through a {@link SpecializedBlobClientBuilder} or via the method - * {@link BlobAsyncClient#getBlockBlobAsyncClient()}. This class does not hold any state about a particular blob, but is - * instead a convenient way of sending appropriate requests to the resource on the service. - * - *

- * Please refer to the - * Azure Docs for more information. - * - *

- * Note this client is an async client that returns reactive responses from Spring Reactor Core project - * (https://projectreactor.io/). Calling the methods in this client will NOT start the actual network - * operation, until {@code .subscribe()} is called on the reactive response. You can simply convert one of these - * responses to a {@link java.util.concurrent.CompletableFuture} object through {@link Mono#toFuture()}. - */ -@ServiceClient(builder = SpecializedBlobClientBuilder.class, isAsync = true) -public final class BlockBlobAsyncClient extends BlobAsyncClientBase { - private static final ClientLogger LOGGER = new ClientLogger(BlockBlobAsyncClient.class); - - /** - * Indicates the maximum number of bytes that can be sent in a call to upload. - * @deprecated Use {@link #MAX_STAGE_BLOCK_BYTES_LONG} - */ - @Deprecated - public static final int MAX_UPLOAD_BLOB_BYTES = 256 * Constants.MB; - - /** - * Indicates the maximum number of bytes that can be sent in a call to upload. - */ - public static final long MAX_UPLOAD_BLOB_BYTES_LONG = BlobConstants.MAX_UPLOAD_BLOB_BYTES_LONG; - - /** - * Indicates the maximum number of bytes that can be sent in a call to stageBlock. - * @deprecated Use {@link #MAX_STAGE_BLOCK_BYTES_LONG} - */ - @Deprecated - public static final int MAX_STAGE_BLOCK_BYTES = 100 * Constants.MB; - - /** - * Indicates the maximum number of bytes that can be sent in a call to stageBlock. - */ - public static final long MAX_STAGE_BLOCK_BYTES_LONG = BlobConstants.MAX_STAGE_BLOCK_BYTES_LONG; - - /** - * Indicates the maximum number of blocks allowed in a block blob. - */ - public static final int MAX_BLOCKS = BlobConstants.MAX_BLOCKS; - - /** - * Package-private constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - BlockBlobAsyncClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, - EncryptionScope encryptionScope, String versionId) { - super(pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, customerProvidedKey, - encryptionScope, versionId); - } - - /** - * Creates a new {@link BlockBlobAsyncClient} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link BlockBlobAsyncClient} with the specified {@code encryptionScope}. - */ - @Override - public BlockBlobAsyncClient getEncryptionScopeAsyncClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - return new BlockBlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), getCustomerProvidedKey(), finalEncryptionScope, - getVersionId()); - } - - /** - * Creates a new {@link BlockBlobAsyncClient} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link BlockBlobAsyncClient} with the specified {@code customerProvidedKey}. - */ - @Override - public BlockBlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - return new BlockBlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), finalCustomerProvidedKey, encryptionScope, - getVersionId()); - } - - /** - * Creates a new block blob. By default, this method will not overwrite an existing blob. Updating an existing block - * blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content - * of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use - * PutBlock and PutBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - *

Code Samples

- * - * - *
-     * client.upload(data, length).subscribe(response ->
-     *     System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param data The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled - * (the default). In other words, the Flux must produce the same data each time it is subscribed to. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the {@code Flux}. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono upload(Flux data, long length) { - return upload(data, length, false); - } - - /** - * Creates a new block blob. By default, this method will not overwrite an existing blob. Updating an existing block - * blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content - * of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use - * PutBlock and PutBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - *

Code Samples

- * - * - *
-     * BinaryData.fromFlux(data, length, false)
-     *     .flatMap(binaryData -> client.upload(binaryData))
-     *     .subscribe(response ->
-     *         System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *             Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param data The data to write to the block. Note that this {@code BinaryData} must have defined length - * and must be replayable if retries are enabled (the default), see {@link BinaryData#isReplayable()}. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono upload(BinaryData data) { - return upload(data, false); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the - * existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock - * and PutBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default behavior
-     * client.upload(data, length, overwrite).subscribe(response ->
-     *     System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param data The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled - * (the default). In other words, the Flux must produce the same data each time it is subscribed to. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the {@code Flux}. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono upload(Flux data, long length, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return uploadWithResponse(data, length, null, null, null, null, blobRequestConditions) - .flatMap(FluxUtil::toMono); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the - * existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock - * and PutBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default behavior
-     * BinaryData.fromFlux(data, length, false)
-     *     .flatMap(binaryData -> client.upload(binaryData, overwrite))
-     *     .subscribe(response ->
-     *     System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param data The data to write to the block. Note that this {@code BinaryData} must have defined length - * and must be replayable if retries are enabled (the default), see {@link BinaryData#isReplayable()}. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono upload(BinaryData data, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return uploadWithResponse(new BlockBlobSimpleUploadOptions(data).setRequestConditions(blobRequestConditions)) - .flatMap(FluxUtil::toMono); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with PutBlob; the content of the existing blob is overwritten with the new content. To perform a partial update - * of a block blob's, use PutBlock and PutBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.uploadWithResponse(data, length, headers, metadata, AccessTier.HOT, md5, requestConditions)
-     *     .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
-     * 
- * - * - * @param data The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled - * (the default). In other words, the Flux must produce the same data each time it is subscribed to. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the {@code Flux}. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param contentMd5 An MD5 hash of the blob content. This hash is used to verify the integrity of the blob during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadWithResponse(Flux data, long length, BlobHttpHeaders headers, - Map metadata, AccessTier tier, byte[] contentMd5, BlobRequestConditions requestConditions) { - try { - return this.uploadWithResponse(new BlockBlobSimpleUploadOptions(data, length).setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setContentMd5(contentMd5) - .setRequestConditions(requestConditions)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with PutBlob; the content of the existing blob is overwritten with the new content. To perform a partial update - * of a block blob's, use PutBlock and PutBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.uploadWithResponse(new BlockBlobSimpleUploadOptions(data, length).setHeaders(headers)
-     *     .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5)
-     *     .setRequestConditions(requestConditions))
-     *     .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
-     * 
- * - * - * @param options {@link BlockBlobSimpleUploadOptions} - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadWithResponse(BlockBlobSimpleUploadOptions options) { - try { - return withContext(context -> uploadWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> uploadWithResponse(BlockBlobSimpleUploadOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - Mono dataMono; - BinaryData binaryData = options.getData(); - if (binaryData == null) { - Flux dataFlux = options.getDataFlux() == null - ? Utility.convertStreamToByteBuffer(options.getDataStream(), options.getLength(), - BlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE, true) - : options.getDataFlux(); - dataMono = BinaryData.fromFlux(dataFlux, options.getLength(), false); - } else { - dataMono = Mono.just(binaryData); - } - BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - Context finalContext = context == null ? Context.NONE : context; - BlobImmutabilityPolicy immutabilityPolicy - = options.getImmutabilityPolicy() == null ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); - - return dataMono.flatMap(data -> this.azureBlobStorage.getBlockBlobs() - .uploadWithResponseAsync(containerName, blobName, options.getLength(), data, null, options.getContentMd5(), - options.getMetadata(), requestConditions.getLeaseId(), options.getTier(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, ModelHelper.tagsToString(options.getTags()), - immutabilityPolicy.getExpiryTime(), immutabilityPolicy.getPolicyMode(), options.isLegalHold(), null, - null, null, options.getHeaders(), getCustomerProvidedKey(), encryptionScope, finalContext) - .map(rb -> { - BlockBlobsUploadHeaders hd = rb.getDeserializedHeaders(); - BlockBlobItem item = new BlockBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), - hd.getXMsVersionId()); - return new SimpleResponse<>(rb, item); - })); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with PutBlobFromUrl; the content of the existing blob is overwritten with the new content. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.uploadFromUrl(sourceUrl)
-     *     .subscribe(response ->
-     *         System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n",
-     *             Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param sourceUrl The source URL to upload from. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadFromUrl(String sourceUrl) { - return uploadFromUrl(sourceUrl, false); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with PutBlobFromUrl; the content of the existing blob is overwritten with the new content. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default behavior
-     * client.uploadFromUrl(sourceUrl, overwrite).subscribe(response ->
-     *     System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getContentMd5())));
-     * 
- * - * - * @param sourceUrl The source URL to upload from. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadFromUrl(String sourceUrl, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - - try { - return uploadFromUrlWithResponse( - new BlobUploadFromUrlOptions(sourceUrl).setDestinationRequestConditions(blobRequestConditions)) - .flatMap(FluxUtil::toMono); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with PutBlobFromUrl; the content of the existing blob is overwritten with the new content. - * For more information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.uploadFromUrlWithResponse(new BlobUploadFromUrlOptions(sourceUrl).setHeaders(headers)
-     *     .setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5)
-     *     .setDestinationRequestConditions(requestConditions))
-     *     .subscribe(response -> System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n",
-     *         Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
-     * 
- * - * - * @param options {@link BlobUploadFromUrlOptions} - * @return A reactive response containing the information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadFromUrlWithResponse(BlobUploadFromUrlOptions options) { - try { - return withContext(context -> uploadFromUrlWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> uploadFromUrlWithResponse(BlobUploadFromUrlOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - BlobRequestConditions destinationRequestConditions = options.getDestinationRequestConditions() == null - ? new BlobRequestConditions() - : options.getDestinationRequestConditions(); - BlobRequestConditions sourceRequestConditions = options.getSourceRequestConditions() == null - ? new BlobRequestConditions() - : options.getSourceRequestConditions(); - context = context == null ? Context.NONE : context; - String sourceAuth - = options.getSourceAuthorization() == null ? null : options.getSourceAuthorization().toString(); - - try { - new URL(options.getSourceUrl()); - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'sourceUrl' is not a valid url.", ex)); - } - - // TODO (kasobol-msft) add metadata back (https://github.com/Azure/azure-sdk-for-net/issues/15969) - return this.azureBlobStorage.getBlockBlobs() - .putBlobFromUrlWithResponseAsync(containerName, blobName, 0, options.getSourceUrl(), null, null, null, - destinationRequestConditions.getLeaseId(), options.getTier(), - destinationRequestConditions.getIfModifiedSince(), destinationRequestConditions.getIfUnmodifiedSince(), - destinationRequestConditions.getIfMatch(), destinationRequestConditions.getIfNoneMatch(), - destinationRequestConditions.getTagsConditions(), sourceRequestConditions.getIfModifiedSince(), - sourceRequestConditions.getIfUnmodifiedSince(), sourceRequestConditions.getIfMatch(), - sourceRequestConditions.getIfNoneMatch(), sourceRequestConditions.getTagsConditions(), null, - options.getContentMd5(), ModelHelper.tagsToString(options.getTags()), - options.isCopySourceBlobProperties(), sourceAuth, options.getCopySourceTagsMode(), options.getHeaders(), - getCustomerProvidedKey(), encryptionScope, context) - .map(rb -> { - BlockBlobsPutBlobFromUrlHeaders hd = rb.getDeserializedHeaders(); - BlockBlobItem item = new BlockBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), - hd.getXMsVersionId()); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Uploads the specified block to the block blob's "staging area" to be later committed by a call to - * commitBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param data The data to write to the block. Note that this {@code Flux} must be replayable if retries are enabled - * (the default). In other words, the {@code Flux} must produce the same data each time it is subscribed to. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the {@code Flux}. - * - * @return A reactive response signalling completion. - * - *

Code Samples

- * - * - *
-     * client.stageBlock(base64BlockID, data, length)
-     *     .subscribe(
-     *         response -> System.out.println("Staging block completed"),
-     *         error -> System.out.printf("Error when calling stage Block: %s", error));
-     * 
- * - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono stageBlock(String base64BlockId, Flux data, long length) { - return stageBlockWithResponse(base64BlockId, data, length, null, null).flatMap(FluxUtil::toMono); - } - - /** - * Uploads the specified block to the block blob's "staging area" to be later committed by a call to - * commitBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default), - * see {@link BinaryData#isReplayable()}. - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param data The data to write to the block. Note that this {@code BinaryData} must have defined length - * and must be replayable if retries are enabled (the default), see {@link BinaryData#isReplayable()}. - * - * @return A reactive response signalling completion. - * - *

Code Samples

- * - * - *
-     * BinaryData.fromFlux(data, length, false)
-     *     .flatMap(binaryData -> client.stageBlock(base64BlockID, binaryData))
-     *     .subscribe(
-     *         response -> System.out.println("Staging block completed"),
-     *         error -> System.out.printf("Error when calling stage Block: %s", error));
-     * 
- * - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono stageBlock(String base64BlockId, BinaryData data) { - return stageBlockWithResponse(new BlockBlobStageBlockOptions(base64BlockId, data)).flatMap(FluxUtil::toMono); - } - - /** - * Uploads the specified block to the block blob's "staging area" to be later committed by a call to - * commitBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - *

Code Samples

- * - * - *
-     * client.stageBlockWithResponse(base64BlockID, data, length, md5, leaseId).subscribe(response ->
-     *     System.out.printf("Staging block completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param data The data to write to the block. Note that this {@code Flux} must be replayable if retries are enabled - * (the default). In other words, the Flux must produce the same data each time it is subscribed to. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data emitted by the {@code Flux}. - * @param contentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @param leaseId The lease ID the active lease on the blob must match. - * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockWithResponse(String base64BlockId, Flux data, long length, - byte[] contentMd5, String leaseId) { - try { - return withContext( - context -> stageBlockWithResponse(base64BlockId, data, length, contentMd5, leaseId, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Uploads the specified block to the block blob's "staging area" to be later committed by a call to - * commitBlockList. For more information, see the - * Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default), - * see {@link BinaryData#isReplayable()}. - * - *

Code Samples

- * - * - *
-     * BinaryData.fromFlux(data, length, false)
-     *     .flatMap(binaryData -> client.stageBlockWithResponse(
-     *         new BlockBlobStageBlockOptions(base64BlockID, binaryData)
-     *             .setContentMd5(md5)
-     *             .setLeaseId(leaseId)))
-     *     .subscribe(response ->
-     *         System.out.printf("Staging block completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param options {@link BlockBlobStageBlockOptions} - * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockWithResponse(BlockBlobStageBlockOptions options) { - Objects.requireNonNull(options, "options must not be null"); - try { - return withContext(context -> stageBlockWithResponse(options.getBase64BlockId(), options.getData(), - options.getContentMd5(), options.getLeaseId(), context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> stageBlockWithResponse(String base64BlockId, Flux data, long length, - byte[] contentMd5, String leaseId, Context context) { - return BinaryData.fromFlux(data, length, false) - .flatMap(binaryData -> stageBlockWithResponse(base64BlockId, binaryData, contentMd5, leaseId, context)); - } - - Mono> stageBlockWithResponse(String base64BlockId, BinaryData data, byte[] contentMd5, - String leaseId, Context context) { - Objects.requireNonNull(data, "data must not be null"); - Objects.requireNonNull(data.getLength(), "data must have defined length"); - context = context == null ? Context.NONE : context; - return this.azureBlobStorage.getBlockBlobs() - .stageBlockNoCustomHeadersWithResponseAsync(containerName, blobName, base64BlockId, data.getLength(), data, - contentMd5, null, null, leaseId, null, null, null, getCustomerProvidedKey(), encryptionScope, context); - } - - /** - * Creates a new block to be committed as part of a blob where the contents are read from a URL. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * client.stageBlockFromUrl(base64BlockID, sourceUrl, new BlobRange(offset, count))
-     *     .subscribe(
-     *         response -> System.out.println("Staging block completed"),
-     *         error -> System.out.printf("Error when calling stage Block: %s", error));
-     * 
- * - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceRange {@link BlobRange} - * - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono stageBlockFromUrl(String base64BlockId, String sourceUrl, BlobRange sourceRange) { - return this.stageBlockFromUrlWithResponse(base64BlockId, sourceUrl, sourceRange, null, null, null) - .flatMap(FluxUtil::toMono); - } - - /** - * Creates a new block to be committed as part of a blob where the contents are read from a URL. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.stageBlockFromUrlWithResponse(base64BlockID, sourceUrl, new BlobRange(offset, count), null,
-     *     leaseId, sourceRequestConditions).subscribe(response ->
-     *     System.out.printf("Staging block from URL completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceRange {@link BlobRange} - * @param sourceContentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block - * during transport. When this header is specified, the storage service compares the hash of the content that has - * arrived with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not - * match, the operation will fail. - * @param leaseId The lease ID that the active lease on the blob must match. - * @param sourceRequestConditions {@link BlobRequestConditions} - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockFromUrlWithResponse(String base64BlockId, String sourceUrl, - BlobRange sourceRange, byte[] sourceContentMd5, String leaseId, BlobRequestConditions sourceRequestConditions) { - return this.stageBlockFromUrlWithResponse( - new BlockBlobStageBlockFromUrlOptions(base64BlockId, sourceUrl).setSourceRange(sourceRange) - .setSourceContentMd5(sourceContentMd5) - .setLeaseId(leaseId) - .setSourceRequestConditions(sourceRequestConditions)); - } - - /** - * Creates a new block to be committed as part of a blob where the contents are read from a URL. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.stageBlockFromUrlWithResponse(new BlockBlobStageBlockFromUrlOptions(base64BlockID, sourceUrl)
-     *     .setSourceRange(new BlobRange(offset, count)).setLeaseId(leaseId)
-     *     .setSourceRequestConditions(sourceRequestConditions)).subscribe(response ->
-     *     System.out.printf("Staging block from URL completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param options parameters for the operation. - * @return A reactive response signalling completion. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> stageBlockFromUrlWithResponse(BlockBlobStageBlockFromUrlOptions options) { - try { - return withContext(context -> stageBlockFromUrlWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> stageBlockFromUrlWithResponse(BlockBlobStageBlockFromUrlOptions options, Context context) { - BlobRange sourceRange = (options.getSourceRange() == null) ? new BlobRange(0) : options.getSourceRange(); - BlobRequestConditions sourceRequestConditions = (options.getSourceRequestConditions() == null) - ? new BlobRequestConditions() - : options.getSourceRequestConditions(); - - try { - new URL(options.getSourceUrl()); - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'sourceUrl' is not a valid url.", ex)); - } - context = context == null ? Context.NONE : context; - String sourceAuth - = options.getSourceAuthorization() == null ? null : options.getSourceAuthorization().toString(); - - return this.azureBlobStorage.getBlockBlobs() - .stageBlockFromURLNoCustomHeadersWithResponseAsync(containerName, blobName, options.getBase64BlockId(), 0, - options.getSourceUrl(), sourceRange.toHeaderValue(), options.getSourceContentMd5(), null, null, - options.getLeaseId(), sourceRequestConditions.getIfModifiedSince(), - sourceRequestConditions.getIfUnmodifiedSince(), sourceRequestConditions.getIfMatch(), - sourceRequestConditions.getIfNoneMatch(), null, sourceAuth, getCustomerProvidedKey(), encryptionScope, - context); - } - - /** - * Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.listBlocks(BlockListType.ALL).subscribe(block -> {
-     *     System.out.println("Committed Blocks:");
-     *     block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     *
-     *     System.out.println("Uncommitted Blocks:");
-     *     block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     * });
-     * 
- * - * - * @param listType Specifies which type of blocks to return. - * - * @return A reactive response containing the list of blocks. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listBlocks(BlockListType listType) { - return this.listBlocksWithResponse(listType, null).map(Response::getValue); - } - - /** - * Returns the list of blocks that have been uploaded as part of a block blob using the specified block list - * filter. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.listBlocksWithResponse(BlockListType.ALL, leaseId).subscribe(response -> {
-     *     BlockList block = response.getValue();
-     *     System.out.println("Committed Blocks:");
-     *     block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     *
-     *     System.out.println("Uncommitted Blocks:");
-     *     block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     * });
-     * 
- * - * - * @param listType Specifies which type of blocks to return. - * @param leaseId The lease ID the active lease on the blob must match. - * @return A reactive response containing the list of blocks. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlocksWithResponse(BlockListType listType, String leaseId) { - return this.listBlocksWithResponse(new BlockBlobListBlocksOptions(listType).setLeaseId(leaseId)); - } - - /** - * Returns the list of blocks that have been uploaded as part of a block blob using the specified block list - * filter. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.listBlocksWithResponse(new BlockBlobListBlocksOptions(BlockListType.ALL)
-     *     .setLeaseId(leaseId)
-     *     .setIfTagsMatch(tags)).subscribe(response -> {
-     *         BlockList block = response.getValue();
-     *         System.out.println("Committed Blocks:");
-     *         block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(),
-     *             b.getSizeLong()));
-     *
-     *         System.out.println("Uncommitted Blocks:");
-     *         block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(),
-     *             b.getSizeLong()));
-     *     });
-     * 
- * - * - * @param options {@link BlockBlobListBlocksOptions} - * @return A reactive response containing the list of blocks. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listBlocksWithResponse(BlockBlobListBlocksOptions options) { - try { - return withContext(context -> listBlocksWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> listBlocksWithResponse(BlockBlobListBlocksOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - - return this.azureBlobStorage.getBlockBlobs() - .getBlockListWithResponseAsync(containerName, blobName, options.getType(), getSnapshotId(), null, - options.getLeaseId(), options.getIfTagsMatch(), null, context) - .map(response -> new SimpleResponse<>(response, response.getValue())); - } - - /** - * Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part of - * a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call - * commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and - * existing blocks together. Any blocks not specified in the block list and permanently deleted. For more - * information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.commitBlockList(Collections.singletonList(base64BlockID)).subscribe(response ->
-     *     System.out.printf("Committing block list completed. Last modified: %s%n", response.getLastModified()));
-     * 
- * - * - * @param base64BlockIds A list of base64 encode {@code String}s that specifies the block IDs to be committed. - * @return A reactive response containing the information of the block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono commitBlockList(List base64BlockIds) { - return commitBlockList(base64BlockIds, false); - } - - /** - * Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part of - * a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call - * commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and - * existing blocks together. Any blocks not specified in the block list and permanently deleted. For more - * information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default behavior
-     * client.commitBlockList(Collections.singletonList(base64BlockID), overwrite).subscribe(response ->
-     *     System.out.printf("Committing block list completed. Last modified: %s%n", response.getLastModified()));
-     * 
- * - * - * @param base64BlockIds A list of base64 encode {@code String}s that specifies the block IDs to be committed. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @return A reactive response containing the information of the block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono commitBlockList(List base64BlockIds, boolean overwrite) { - BlobRequestConditions requestConditions = null; - if (!overwrite) { - requestConditions = new BlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return commitBlockListWithResponse(base64BlockIds, null, null, null, requestConditions) - .flatMap(FluxUtil::toMono); - } - - /** - * Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part - * of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can - * call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new - * and existing blocks together. Any blocks not specified in the block list and permanently deleted. For more - * information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * client.commitBlockListWithResponse(Collections.singletonList(base64BlockID), headers, metadata,
-     *     AccessTier.HOT, requestConditions).subscribe(response ->
-     *         System.out.printf("Committing block list completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param base64BlockIds A list of base64 encode {@code String}s that specifies the block IDs to be committed. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response containing the information of the block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> commitBlockListWithResponse(List base64BlockIds, - BlobHttpHeaders headers, Map metadata, AccessTier tier, - BlobRequestConditions requestConditions) { - return this.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(base64BlockIds).setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setRequestConditions(requestConditions)); - } - - /** - * Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part - * of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can - * call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new - * and existing blocks together. Any blocks not specified in the block list and permanently deleted. For more - * information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * client.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(Collections.singletonList(base64BlockID))
-     *     .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
-     *     .setRequestConditions(requestConditions))
-     *     .subscribe(response ->
-     *     System.out.printf("Committing block list completed with status %d%n", response.getStatusCode()));
-     * 
- * - * - * @param options {@link BlockBlobCommitBlockListOptions} - * @return A reactive response containing the information of the block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> commitBlockListWithResponse(BlockBlobCommitBlockListOptions options) { - try { - return withContext(context -> commitBlockListWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> commitBlockListWithResponse(BlockBlobCommitBlockListOptions options, - Context context) { - StorageImplUtils.assertNotNull("options", options); - BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - context = context == null ? Context.NONE : context; - BlobImmutabilityPolicy immutabilityPolicy - = options.getImmutabilityPolicy() == null ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); - - return this.azureBlobStorage.getBlockBlobs() - .commitBlockListWithResponseAsync(containerName, blobName, - new BlockLookupList().setLatest(options.getBase64BlockIds()), null, null, null, options.getMetadata(), - requestConditions.getLeaseId(), options.getTier(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, - ModelHelper.tagsToString(options.getTags()), immutabilityPolicy.getExpiryTime(), - immutabilityPolicy.getPolicyMode(), options.isLegalHold(), options.getHeaders(), - getCustomerProvidedKey(), encryptionScope, context) - .map(rb -> { - BlockBlobsCommitBlockListHeaders hd = rb.getDeserializedHeaders(); - BlockBlobItem item = new BlockBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), - hd.getXMsVersionId()); - return new SimpleResponse<>(rb, item); - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobClient.java deleted file mode 100644 index 8667e7afe28c..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobClient.java +++ /dev/null @@ -1,1196 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobClientBuilder; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.BlockList; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.BlobSeekableByteChannelReadOptions; -import com.azure.storage.blob.options.BlobUploadFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobListBlocksOptions; -import com.azure.storage.blob.options.BlockBlobOutputStreamOptions; -import com.azure.storage.blob.options.BlockBlobSeekableByteChannelWriteOptions; -import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockOptions; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.implementation.StorageSeekableByteChannel; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.InputStream; -import java.io.UncheckedIOException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.channels.SeekableByteChannel; -import java.time.Duration; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static com.azure.storage.common.implementation.StorageImplUtils.blockWithOptionalTimeout; - -/** - * Client to a block blob. It may only be instantiated through a {@link SpecializedBlobClientBuilder} or via the method - * {@link BlobClient#getBlockBlobClient()}. This class does not hold any state about a particular blob, but is instead - * a convenient way of sending appropriate requests to the resource on the service. - * - *

- * Please refer to the Azure Docs for more information. - */ -@ServiceClient(builder = SpecializedBlobClientBuilder.class) -public final class BlockBlobClient extends BlobClientBase { - private static final ClientLogger LOGGER = new ClientLogger(BlockBlobClient.class); - - private final BlockBlobAsyncClient client; - - /** - * Indicates the maximum number of bytes that can be sent in a call to upload. - * @deprecated Use {@link #MAX_STAGE_BLOCK_BYTES_LONG}. - */ - @Deprecated - public static final int MAX_UPLOAD_BLOB_BYTES = 256 * Constants.MB; - /** - * Indicates the maximum number of bytes that can be sent in a call to upload. - */ - public static final long MAX_UPLOAD_BLOB_BYTES_LONG = BlobConstants.MAX_UPLOAD_BLOB_BYTES_LONG; - /** - * Indicates the maximum number of bytes that can be sent in a call to stageBlock. - * @deprecated Use {@link #MAX_STAGE_BLOCK_BYTES_LONG} - */ - @Deprecated - public static final int MAX_STAGE_BLOCK_BYTES = 100 * Constants.MB; - /** - * Indicates the maximum number of bytes that can be sent in a call to stageBlock. - */ - public static final long MAX_STAGE_BLOCK_BYTES_LONG = BlobConstants.MAX_STAGE_BLOCK_BYTES_LONG; - /** - * Indicates the maximum number of blocks allowed in a block blob. - */ - public static final int MAX_BLOCKS = BlobConstants.MAX_BLOCKS; - - /** - * Package-private constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param client the async block blob client - */ - BlockBlobClient(BlockBlobAsyncClient client) { - this(client, client.getHttpPipeline(), client.getAccountUrl(), client.getServiceVersion(), - client.getAccountName(), client.getContainerName(), client.getBlobName(), client.getSnapshotId(), - client.getCustomerProvidedKey(), new EncryptionScope().setEncryptionScope(client.getEncryptionScope()), - client.getVersionId()); - } - - /** - * Package-private constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - BlockBlobClient(BlockBlobAsyncClient client, HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, - String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, - EncryptionScope encryptionScope, String versionId) { - super(client, pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, - customerProvidedKey, encryptionScope, versionId); - this.client = client; - } - - /** - * Creates a new {@link BlockBlobClient} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link BlockBlobClient} with the specified {@code encryptionScope}. - */ - @Override - public BlockBlobClient getEncryptionScopeClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - return new BlockBlobClient(client.getEncryptionScopeAsyncClient(encryptionScope), getHttpPipeline(), - getAccountUrl(), getServiceVersion(), getAccountName(), getContainerName(), getBlobName(), getSnapshotId(), - getCustomerProvidedKey(), finalEncryptionScope, getVersionId()); - } - - /** - * Creates a new {@link BlockBlobClient} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link BlockBlobClient} with the specified {@code customerProvidedKey}. - */ - @Override - public BlockBlobClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - return new BlockBlobClient(client.getCustomerProvidedKeyAsyncClient(customerProvidedKey), getHttpPipeline(), - getAccountUrl(), getServiceVersion(), getAccountName(), getContainerName(), getBlobName(), getSnapshotId(), - finalCustomerProvidedKey, encryptionScope, getVersionId()); - } - - /** - * Creates and opens an output stream to write data to the block blob. - *

- * Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream - * obtained below with a {@link java.io.BufferedOutputStream}. - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream() { - return getBlobOutputStream(false); - } - - /** - * Creates and opens an output stream to write data to the block blob. - *

- * Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream - * obtained below with a {@link java.io.BufferedOutputStream}. - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream(boolean overwrite) { - BlobRequestConditions requestConditions = null; - if (!overwrite) { - if (exists()) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException(Constants.BLOB_ALREADY_EXISTS)); - } - requestConditions = new BlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return getBlobOutputStream(requestConditions); - } - - /** - * Creates and opens an output stream to write data to the block blob. If the blob already exists on the service, it - * will be overwritten. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - *

- * Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream - * obtained below with a {@link java.io.BufferedOutputStream}. - * - * @param requestConditions A {@link BlobRequestConditions} object that represents the access conditions for the - * blob. - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream(BlobRequestConditions requestConditions) { - return getBlobOutputStream(null, null, null, null, requestConditions); - } - - /** - * Creates and opens an output stream to write data to the block blob. If the blob already exists on the service, it - * will be overwritten. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - *

- * Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream - * obtained below with a {@link java.io.BufferedOutputStream}. - * - * @param parallelTransferOptions {@link ParallelTransferOptions} used to configure buffered uploading. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param requestConditions {@link BlobRequestConditions} - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream(ParallelTransferOptions parallelTransferOptions, - BlobHttpHeaders headers, Map metadata, AccessTier tier, - BlobRequestConditions requestConditions) { - return this - .getBlobOutputStream(new BlockBlobOutputStreamOptions().setParallelTransferOptions(parallelTransferOptions) - .setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setRequestConditions(requestConditions)); - } - - /** - * Creates and opens an output stream to write data to the block blob. If the blob already exists on the service, it - * will be overwritten. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - *

- * Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream - * obtained below with a {@link java.io.BufferedOutputStream}. - * - * @param options {@link BlockBlobOutputStreamOptions} - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream(BlockBlobOutputStreamOptions options) { - return getBlobOutputStream(options, null); - } - - /** - * Creates and opens an output stream to write data to the block blob. If the blob already exists on the service, it - * will be overwritten. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - *

- * Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream - * obtained below with a {@link java.io.BufferedOutputStream}. - * - * @param options {@link BlockBlobOutputStreamOptions} - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream(BlockBlobOutputStreamOptions options, Context context) { - BlobAsyncClient blobClient = prepareBuilder().buildAsyncClient(); - - return BlobOutputStream.blockBlobOutputStream(blobClient, options, context); - } - - /** - * Opens a seekable byte channel in write-only mode to upload the blob. - * - * @param options {@link BlobSeekableByteChannelReadOptions} - * @return A SeekableByteChannel object that represents the channel to use for writing to the blob. - * @throws BlobStorageException If a storage service error occurred. - * @throws NullPointerException if 'options' is null. - */ - public SeekableByteChannel openSeekableByteChannelWrite(BlockBlobSeekableByteChannelWriteOptions options) { - Objects.requireNonNull(options); - - // Behavior can support more modes but this client does not currently support them - StorageSeekableByteChannelBlockBlobWriteBehavior.WriteMode internalMode; - long startingPosition = 0L; - if (options.getWriteMode() == BlockBlobSeekableByteChannelWriteOptions.WriteMode.OVERWRITE) { - internalMode = StorageSeekableByteChannelBlockBlobWriteBehavior.WriteMode.OVERWRITE; - } else { - throw LOGGER - .logExceptionAsError(new IllegalArgumentException("Unsupported value for `options.getWriteMode()`.")); - } - - return new StorageSeekableByteChannel( - options.getBlockSizeInBytes() != null - ? options.getBlockSizeInBytes().intValue() - : BlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE, - new StorageSeekableByteChannelBlockBlobWriteBehavior(this, options.getHeaders(), options.getMetadata(), - options.getTags(), options.getTier(), options.getRequestConditions(), internalMode, null), - startingPosition); - } - - private BlobClientBuilder prepareBuilder() { - BlobClientBuilder builder = new BlobClientBuilder().pipeline(getHttpPipeline()) - .endpoint(getBlobUrl()) - .snapshot(getSnapshotId()) - .serviceVersion(getServiceVersion()); - - CpkInfo cpk = getCustomerProvidedKey(); - if (cpk != null) { - builder.customerProvidedKey(new CustomerProvidedKey(cpk.getEncryptionKey())); - } - - return builder; - } - - /** - * Creates a new block blob. By default, this method will not overwrite an existing blob. Updating an existing block - * blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content - * of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use - * PutBlock and PutBlockList. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *     Base64.getEncoder().encodeToString(client.upload(data, length).getContentMd5()));
-     * 
- * - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream. - * Alternatively, consider wrapping your data source in a {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - * @return The information of the uploaded block blob. - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockBlobItem upload(InputStream data, long length) { - return upload(data, length, false); - } - - /** - * Creates a new block blob. By default, this method will not overwrite an existing blob. Updating an existing block - * blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content - * of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use - * PutBlock and PutBlockList. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BinaryData binaryData = BinaryData.fromStream(data, length);
-     * System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *     Base64.getEncoder().encodeToString(client.upload(binaryData).getContentMd5()));
-     * 
- * - * - * @param data The data to write to the block. Note that this {@code BinaryData} must have defined length - * and must be replayable if retries are enabled (the default), see {@link BinaryData#isReplayable()}. - * @return The information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockBlobItem upload(BinaryData data) { - return upload(data, false); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the - * existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock - * and PutBlockList. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false;
-     * System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *     Base64.getEncoder().encodeToString(client.upload(data, length, overwrite).getContentMd5()));
-     * 
- * - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream. - * Alternatively, consider wrapping your data source in a {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @return The information of the uploaded block blob. - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockBlobItem upload(InputStream data, long length, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return uploadWithResponse(data, length, null, null, null, null, blobRequestConditions, null, Context.NONE) - .getValue(); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the - * existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock - * and PutBlockList. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false;
-     * BinaryData binaryData = BinaryData.fromStream(data, length);
-     * System.out.printf("Uploaded BlockBlob MD5 is %s%n",
-     *     Base64.getEncoder().encodeToString(client.upload(binaryData, overwrite).getContentMd5()));
-     * 
- * - * - * @param data The data to write to the block. Note that this {@code BinaryData} must have defined length - * and must be replayable if retries are enabled (the default), see {@link BinaryData#isReplayable()}. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @return The information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockBlobItem upload(BinaryData data, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return uploadWithResponse(new BlockBlobSimpleUploadOptions(data).setRequestConditions(blobRequestConditions), - null, Context.NONE).getValue(); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the - * existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock - * and PutBlockList. For more information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5(MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     *
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder()
-     *     .encodeToString(client.uploadWithResponse(data, length, headers, metadata, AccessTier.HOT, md5,
-     *         requestConditions, timeout, context)
-     *         .getValue()
-     *         .getContentMd5()));
-     * 
- * - * - * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If - * the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream. - * Alternatively, consider wrapping your data source in a {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param contentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return The information of the uploaded block blob. - * - * @throws UnexpectedLengthException when the length of data does not match the input {@code length}. - * @throws NullPointerException if the input data is null. - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadWithResponse(InputStream data, long length, BlobHttpHeaders headers, - Map metadata, AccessTier tier, byte[] contentMd5, BlobRequestConditions requestConditions, - Duration timeout, Context context) { - return this.uploadWithResponse(new BlockBlobSimpleUploadOptions(data, length).setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setContentMd5(contentMd5) - .setRequestConditions(requestConditions), timeout, context); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob - * overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the - * existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock - * and PutBlockList. For more information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5(MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     *
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder()
-     *     .encodeToString(client.uploadWithResponse(new BlockBlobSimpleUploadOptions(data, length)
-     *         .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5)
-     *         .setRequestConditions(requestConditions), timeout, context)
-     *         .getValue()
-     *         .getContentMd5()));
-     * 
- * - * - * @param options {@link BlockBlobSimpleUploadOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return The information of the uploaded block blob. - * - * @throws UnexpectedLengthException when the length of data does not match the input {@code length}. - * @throws NullPointerException if the input data is null. - * @throws UncheckedIOException If an I/O error occurs - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadWithResponse(BlockBlobSimpleUploadOptions options, Duration timeout, - Context context) { - StorageImplUtils.assertNotNull("options", options); - Mono> upload = client.uploadWithResponse(options, context); - try { - return blockWithOptionalTimeout(upload, timeout); - } catch (UncheckedIOException e) { - throw LOGGER.logExceptionAsError(e); - } - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with PutBlobFromUrl; the content of the existing blob is overwritten with the new content. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n",
-     *     Base64.getEncoder().encodeToString(client.uploadFromUrl(sourceUrl).getContentMd5()));
-     * 
- * - * - * @param sourceUrl The source URL to upload from. - * @return The information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockBlobItem uploadFromUrl(String sourceUrl) { - return uploadFromUrl(sourceUrl, false); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with PutBlobFromUrl; the content of the existing blob is overwritten with the new content. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false;
-     * System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n",
-     *     Base64.getEncoder().encodeToString(client.uploadFromUrl(sourceUrl, overwrite).getContentMd5()));
-     * 
- * - * - * @param sourceUrl The source URL to upload from. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @return The information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockBlobItem uploadFromUrl(String sourceUrl, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return uploadFromUrlWithResponse( - new BlobUploadFromUrlOptions(sourceUrl).setDestinationRequestConditions(blobRequestConditions), null, - Context.NONE).getValue(); - } - - /** - * Creates a new block blob, or updates the content of an existing block blob. - *

- * Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported - * with PutBlobFromUrl; the content of the existing blob is overwritten with the new content. - * For more information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5(MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     *
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     *
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder()
-     *     .encodeToString(client.uploadFromUrlWithResponse(new BlobUploadFromUrlOptions(sourceUrl)
-     *         .setHeaders(headers).setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5)
-     *         .setDestinationRequestConditions(requestConditions), timeout, context)
-     *         .getValue()
-     *         .getContentMd5()));
-     * 
- * - * - * @param options {@link BlobUploadFromUrlOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The information of the uploaded block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadFromUrlWithResponse(BlobUploadFromUrlOptions options, Duration timeout, - Context context) { - StorageImplUtils.assertNotNull("options", options); - Mono> upload = client.uploadFromUrlWithResponse(options, context); - try { - return blockWithOptionalTimeout(upload, timeout); - } catch (UncheckedIOException e) { - throw LOGGER.logExceptionAsError(e); - } - } - - /** - * Uploads the specified block to the block blob's "staging area" to be later committed by a call to - * commitBlockList. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.stageBlock(base64BlockId, data, length);
-     * 
- * - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param data The data to write to the block. The data must be markable. This is in order to support retries. If - * the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream. - * Alternatively, consider wrapping your data source in a {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void stageBlock(String base64BlockId, InputStream data, long length) { - stageBlockWithResponse(base64BlockId, data, length, null, null, null, Context.NONE); - } - - /** - * Uploads the specified block to the block blob's "staging area" to be later committed by a call to - * commitBlockList. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BinaryData binaryData = BinaryData.fromStream(data, length);
-     * client.stageBlock(base64BlockId, binaryData);
-     * 
- * - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param data The data to write to the block. Note that this {@code BinaryData} must have defined length - * and must be replayable if retries are enabled (the default), see {@link BinaryData#isReplayable()}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void stageBlock(String base64BlockId, BinaryData data) { - stageBlockWithResponse(new BlockBlobStageBlockOptions(base64BlockId, data), null, Context.NONE); - } - - /** - * Uploads the specified block to the block blob's "staging area" to be later committed by a call to - * commitBlockList. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("key", "value");
-     * System.out.printf("Staging block completed with status %d%n",
-     *     client.stageBlockWithResponse(base64BlockId, data, length, md5, leaseId, timeout, context).getStatusCode());
-     * 
- * - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param data The data to write to the block. The data must be markable. This is in order to support retries. If - * the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream. - * Alternatively, consider wrapping your data source in a {@link java.io.BufferedInputStream} to add mark support. - * @param length The exact length of the data. It is important that this value match precisely the length of the - * data provided in the {@link InputStream}. - * @param contentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @param leaseId The lease ID the active lease on the blob must match. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return A response containing status code and HTTP headers - * - * @throws UnexpectedLengthException when the length of data does not match the input {@code length}. - * @throws NullPointerException if the input data is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response stageBlockWithResponse(String base64BlockId, InputStream data, long length, byte[] contentMd5, - String leaseId, Duration timeout, Context context) { - StorageImplUtils.assertNotNull("data", data); - Flux fbb - = Utility.convertStreamToByteBuffer(data, length, BlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE, true); - - Mono> response - = client.stageBlockWithResponse(base64BlockId, fbb, length, contentMd5, leaseId, context); - return blockWithOptionalTimeout(response, timeout); - } - - /** - * Uploads the specified block to the block blob's "staging area" to be later committed by a call to - * commitBlockList. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("key", "value");
-     * BinaryData binaryData = BinaryData.fromStream(data, length);
-     * BlockBlobStageBlockOptions options = new BlockBlobStageBlockOptions(base64BlockId, binaryData)
-     *     .setContentMd5(md5)
-     *     .setLeaseId(leaseId);
-     * System.out.printf("Staging block completed with status %d%n",
-     *     client.stageBlockWithResponse(options, timeout, context).getStatusCode());
-     * 
- * - * - * @param options {@link BlockBlobStageBlockOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return A response containing status code and HTTP headers - * - * @throws UnexpectedLengthException when the length of data does not match the input {@code length}. - * @throws NullPointerException if the input options is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response stageBlockWithResponse(BlockBlobStageBlockOptions options, Duration timeout, - Context context) { - Objects.requireNonNull(options, "options must not be null"); - Mono> response = client.stageBlockWithResponse(options.getBase64BlockId(), options.getData(), - options.getContentMd5(), options.getLeaseId(), context); - return blockWithOptionalTimeout(response, timeout); - } - - /** - * Creates a new block to be committed as part of a blob where the contents are read from a URL. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * client.stageBlockFromUrl(base64BlockId, sourceUrl, new BlobRange(offset, count));
-     * 
- * - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceRange {@link BlobRange} - * @throws IllegalArgumentException If {@code sourceUrl} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void stageBlockFromUrl(String base64BlockId, String sourceUrl, BlobRange sourceRange) { - stageBlockFromUrlWithResponse(base64BlockId, sourceUrl, sourceRange, null, null, null, null, Context.NONE); - } - - /** - * Creates a new block to be committed as part of a blob where the contents are read from a URL. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("Staging block from URL completed with status %d%n",
-     *     client.stageBlockFromUrlWithResponse(base64BlockId, sourceUrl, new BlobRange(offset, count), null,
-     *         leaseId, sourceRequestConditions, timeout, context).getStatusCode());
-     * 
- * - * - * @param base64BlockId A Base64 encoded {@code String} that specifies the ID for this block. Note that all block - * ids for a given blob must be the same length. - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceRange {@link BlobRange} - * @param sourceContentMd5 An MD5 hash of the block content. This hash is used to verify the integrity of the block - * during transport. When this header is specified, the storage service compares the hash of the content that has - * arrived with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not - * match, the operation will fail. - * @param leaseId The lease ID that the active lease on the blob must match. - * @param sourceRequestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return A response containing status code and HTTP headers - * @throws IllegalArgumentException If {@code sourceUrl} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response stageBlockFromUrlWithResponse(String base64BlockId, String sourceUrl, BlobRange sourceRange, - byte[] sourceContentMd5, String leaseId, BlobRequestConditions sourceRequestConditions, Duration timeout, - Context context) { - return stageBlockFromUrlWithResponse( - new BlockBlobStageBlockFromUrlOptions(base64BlockId, sourceUrl).setSourceRange(sourceRange) - .setSourceContentMd5(sourceContentMd5) - .setLeaseId(leaseId) - .setSourceRequestConditions(sourceRequestConditions), - timeout, context); - } - - /** - * Creates a new block to be committed as part of a blob where the contents are read from a URL. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("Staging block from URL completed with status %d%n",
-     *     client.stageBlockFromUrlWithResponse(new BlockBlobStageBlockFromUrlOptions(base64BlockId, sourceUrl)
-     *         .setSourceRange(new BlobRange(offset, count)).setLeaseId(leaseId)
-     *         .setSourceRequestConditions(sourceRequestConditions), timeout, context).getStatusCode());
-     * 
- * - * - * @param options Parameters for the operation - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return A response containing status code and HTTP headers - * @throws IllegalArgumentException If {@code sourceUrl} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response stageBlockFromUrlWithResponse(BlockBlobStageBlockFromUrlOptions options, Duration timeout, - Context context) { - Mono> response = client.stageBlockFromUrlWithResponse(options, context); - return blockWithOptionalTimeout(response, timeout); - } - - /** - * Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlockList block = client.listBlocks(BlockListType.ALL);
-     *
-     * System.out.println("Committed Blocks:");
-     * block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     *
-     * System.out.println("Uncommitted Blocks:");
-     * block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     * 
- * - * - * @param listType Specifies which type of blocks to return. - * - * @return The list of blocks. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockList listBlocks(BlockListType listType) { - return this.listBlocksWithResponse(listType, null, null, Context.NONE).getValue(); - } - - /** - * Returns the list of blocks that have been uploaded as part of a block blob using the specified block list - * filter. For more information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("key", "value");
-     * BlockList block = client.listBlocksWithResponse(BlockListType.ALL, leaseId, timeout, context).getValue();
-     *
-     * System.out.println("Committed Blocks:");
-     * block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     *
-     * System.out.println("Uncommitted Blocks:");
-     * block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     * 
- * - * - * @param listType Specifies which type of blocks to return. - * @param leaseId The lease ID the active lease on the blob must match. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return The list of blocks. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response listBlocksWithResponse(BlockListType listType, String leaseId, Duration timeout, - Context context) { - return listBlocksWithResponse(new BlockBlobListBlocksOptions(listType).setLeaseId(leaseId), timeout, context); - } - - /** - * Returns the list of blocks that have been uploaded as part of a block blob using the specified block list - * filter. For more information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * Context context = new Context("key", "value");
-     * BlockList block = client.listBlocksWithResponse(new BlockBlobListBlocksOptions(BlockListType.ALL)
-     *     .setLeaseId(leaseId)
-     *     .setIfTagsMatch(tags), timeout, context).getValue();
-     *
-     * System.out.println("Committed Blocks:");
-     * block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     *
-     * System.out.println("Uncommitted Blocks:");
-     * block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong()));
-     * 
- * - * - * @param options {@link BlockBlobListBlocksOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return The list of blocks. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response listBlocksWithResponse(BlockBlobListBlocksOptions options, Duration timeout, - Context context) { - return blockWithOptionalTimeout(client.listBlocksWithResponse(options, context), timeout); - } - - /** - * Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part of - * a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call - * commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and - * existing blocks together. Any blocks not specified in the block list and permanently deleted. For more - * information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * System.out.printf("Committing block list completed. Last modified: %s%n",
-     *     client.commitBlockList(Collections.singletonList(base64BlockId)).getLastModified());
-     * 
- * - * - * @param base64BlockIds A list of base64 encode {@code String}s that specifies the block IDs to be committed. - * @return The information of the block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockBlobItem commitBlockList(List base64BlockIds) { - return commitBlockList(base64BlockIds, false); - } - - /** - * Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part of - * a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call - * commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and - * existing blocks together. Any blocks not specified in the block list and permanently deleted. For more - * information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default behavior
-     * System.out.printf("Committing block list completed. Last modified: %s%n",
-     *     client.commitBlockList(Collections.singletonList(base64BlockId), overwrite).getLastModified());
-     * 
- * - * - * @param base64BlockIds A list of base64 encode {@code String}s that specifies the block IDs to be committed. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @return The information of the block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BlockBlobItem commitBlockList(List base64BlockIds, boolean overwrite) { - BlobRequestConditions requestConditions = null; - if (!overwrite) { - requestConditions = new BlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return commitBlockListWithResponse(base64BlockIds, null, null, null, requestConditions, null, Context.NONE) - .getValue(); - } - - /** - * Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part - * of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can - * call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new - * and existing blocks together. Any blocks not specified in the block list and permanently deleted. For more - * information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5(MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("Committing block list completed with status %d%n",
-     *     client.commitBlockListWithResponse(Collections.singletonList(base64BlockId), headers, metadata,
-     *         AccessTier.HOT, requestConditions, timeout, context).getStatusCode());
-     * 
- * - * - * @param base64BlockIds A list of base64 encode {@code String}s that specifies the block IDs to be committed. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param tier {@link AccessTier} for the destination blob. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return The information of the block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response commitBlockListWithResponse(List base64BlockIds, BlobHttpHeaders headers, - Map metadata, AccessTier tier, BlobRequestConditions requestConditions, Duration timeout, - Context context) { - return this.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(base64BlockIds).setHeaders(headers) - .setMetadata(metadata) - .setTier(tier) - .setRequestConditions(requestConditions), timeout, context); - } - - /** - * Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part - * of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can - * call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new - * and existing blocks together. Any blocks not specified in the block list and permanently deleted. For more - * information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * Map<String, String> metadata = Collections.singletonMap("metadata", "value");
-     * Map<String, String> tags = Collections.singletonMap("tag", "value");
-     * BlobRequestConditions requestConditions = new BlobRequestConditions()
-     *     .setLeaseId(leaseId)
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context("key", "value");
-     *
-     * System.out.printf("Committing block list completed with status %d%n",
-     *     client.commitBlockListWithResponse(
-     *         new BlockBlobCommitBlockListOptions(Collections.singletonList(base64BlockId)).setHeaders(headers)
-     *             .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
-     *             .setRequestConditions(requestConditions), timeout, context)
-     *         .getStatusCode());
-     * 
- * - * - * @param options {@link BlockBlobCommitBlockListOptions options} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * - * @return The information of the block blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response commitBlockListWithResponse(BlockBlobCommitBlockListOptions options, - Duration timeout, Context context) { - Mono> response = client.commitBlockListWithResponse(options, context); - - return blockWithOptionalTimeout(response, timeout); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobAsyncClient.java deleted file mode 100644 index 30e979f5cd35..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobAsyncClient.java +++ /dev/null @@ -1,1674 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpRange; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.PagedFlux; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.PagedResponseBase; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.UrlBuilder; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.PageBlobsClearPagesHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsCreateHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesDiffHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsResizeHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsUpdateSequenceNumberHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsUploadPagesFromURLHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsUploadPagesHeaders; -import com.azure.storage.blob.implementation.models.PageListHelper; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.ClearRange; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.PageBlobCopyIncrementalRequestConditions; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.models.PageBlobRequestConditions; -import com.azure.storage.blob.models.PageList; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.models.PageRangeItem; -import com.azure.storage.blob.models.SequenceNumberActionType; -import com.azure.storage.blob.options.ListPageRangesDiffOptions; -import com.azure.storage.blob.options.ListPageRangesOptions; -import com.azure.storage.blob.options.PageBlobCopyIncrementalOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.options.PageBlobUploadPagesFromUrlOptions; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.core.util.FluxUtil.withContext; - -/** - * Client to a page blob. It may only be instantiated through a {@link SpecializedBlobClientBuilder} or via the method - * {@link BlobAsyncClient#getPageBlobAsyncClient()}. This class does not hold any state about a particular blob, but is - * instead a convenient way of sending appropriate requests to the resource on the service. - * - *

- * Please refer to the Azure Docs for more information. - * - *

- * Note this client is an async client that returns reactive responses from Spring Reactor Core project - * (https://projectreactor.io/). Calling the methods in this client will NOT start the actual network - * operation, until {@code .subscribe()} is called on the reactive response. You can simply convert one of these - * responses to a {@link java.util.concurrent.CompletableFuture} object through {@link Mono#toFuture()}. - */ -@ServiceClient(builder = SpecializedBlobClientBuilder.class, isAsync = true) -public final class PageBlobAsyncClient extends BlobAsyncClientBase { - /** - * Indicates the number of bytes in a page. - */ - public static final int PAGE_BYTES = BlobConstants.PAGE_BYTES; - - /** - * Indicates the maximum number of bytes that may be sent in a call to putPage. - */ - public static final int MAX_PUT_PAGES_BYTES = BlobConstants.MAX_PUT_PAGES_BYTES; - - private static final ClientLogger LOGGER = new ClientLogger(PageBlobAsyncClient.class); - - /** - * Package-private constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - PageBlobAsyncClient(HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, - String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, - EncryptionScope encryptionScope, String versionId) { - super(pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, customerProvidedKey, - encryptionScope, versionId); - } - - /** - * Creates a new {@link PageBlobAsyncClient} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link PageBlobAsyncClient} with the specified {@code encryptionScope}. - */ - @Override - public PageBlobAsyncClient getEncryptionScopeAsyncClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - return new PageBlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), getCustomerProvidedKey(), finalEncryptionScope, - getVersionId()); - } - - /** - * Creates a new {@link PageBlobAsyncClient} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link PageBlobAsyncClient} with the specified {@code customerProvidedKey}. - */ - @Override - public PageBlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - return new PageBlobAsyncClient(getHttpPipeline(), getAccountUrl(), getServiceVersion(), getAccountName(), - getContainerName(), getBlobName(), getSnapshotId(), finalCustomerProvidedKey, encryptionScope, - getVersionId()); - } - - /** - * Creates a page blob of the specified length. By default, this method will not overwrite an existing blob. - * Call PutPage to upload data to a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.create(size).subscribe(response -> System.out.printf(
-     *     "Created page blob with sequence number %s%n", response.getBlobSequenceNumber()));
-     * 
- * - * - * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - * - * @return A reactive response containing the information of the created page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono create(long size) { - return create(size, false); - } - - /** - * Creates a page blob of the specified length. Call PutPage to upload data to a page blob. For more - * information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default behavior
-     * client.create(size, overwrite).subscribe(response -> System.out.printf(
-     *     "Created page blob with sequence number %s%n", response.getBlobSequenceNumber()));
-     * 
- * - * - * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - * @param overwrite Whether to overwrite, should data exist on the blob. - * @return A reactive response containing the information of the created page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono create(long size, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return createWithResponse(size, null, null, null, blobRequestConditions).flatMap(FluxUtil::toMono); - } - - /** - * Creates a page blob of the specified length. Call PutPage to upload data to a page blob. For more - * information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.createWithResponse(size, sequenceNumber, headers, metadata, blobRequestConditions)
-     *     .subscribe(response -> System.out.printf(
-     *         "Created page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
-     *
-     * 
- * - * - * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - * @param sequenceNumber A user-controlled value that you can use to track requests. The value of the sequence - * number must be between 0 and 2^63 - 1.The default value is 0. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response containing the information of the created page blob. - * - * @throws IllegalArgumentException If {@code size} isn't a multiple of {@link PageBlobAsyncClient#PAGE_BYTES} or - * {@code sequenceNumber} isn't null and is less than 0. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponse(long size, Long sequenceNumber, BlobHttpHeaders headers, - Map metadata, BlobRequestConditions requestConditions) { - return this.createWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber) - .setHeaders(headers) - .setMetadata(metadata) - .setRequestConditions(requestConditions)); - } - - /** - * Creates a page blob of the specified length. Call PutPage to upload data to a page blob. For more - * information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.createWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber)
-     *     .setHeaders(headers).setMetadata(metadata).setTags(tags).setRequestConditions(blobRequestConditions))
-     *     .subscribe(response -> System.out.printf(
-     *         "Created page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
-     *
-     * 
- * - * - * @param options {@link PageBlobCreateOptions} - * @return A reactive response containing the information of the created page blob. - * - * @throws IllegalArgumentException If {@code size} isn't a multiple of {@link PageBlobAsyncClient#PAGE_BYTES} or - * {@code sequenceNumber} isn't null and is less than 0. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponse(PageBlobCreateOptions options) { - try { - return withContext(context -> createWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> createWithResponse(PageBlobCreateOptions options, Context context) { - StorageImplUtils.assertNotNull("options", options); - BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - - if (options.getSize() % PAGE_BYTES != 0) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("size must be a multiple of PageBlobAsyncClient.PAGE_BYTES.")); - } - if (options.getSequenceNumber() != null && options.getSequenceNumber() < 0) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("SequenceNumber must be greater than or equal to 0.")); - } - context = context == null ? Context.NONE : context; - BlobImmutabilityPolicy immutabilityPolicy - = options.getImmutabilityPolicy() == null ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); - - return this.azureBlobStorage.getPageBlobs() - .createWithResponseAsync(containerName, blobName, 0, options.getSize(), null, null, options.getMetadata(), - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), options.getSequenceNumber(), - null, ModelHelper.tagsToString(options.getTags()), immutabilityPolicy.getExpiryTime(), - immutabilityPolicy.getPolicyMode(), options.isLegalHold(), options.getHeaders(), - getCustomerProvidedKey(), encryptionScope, context) - .map(rb -> { - PageBlobsCreateHeaders hd = rb.getDeserializedHeaders(); - PageBlobItem item = new PageBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), null, - hd.getXMsVersionId()); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Creates a page blob of the specified length if it does not exist. - * Call PutPage to upload data to a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.createIfNotExists(size).subscribe(response ->
-     *     System.out.printf("Created page blob with sequence number %s%n", response.getBlobSequenceNumber()));
-     * 
- * - * - * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - * - * @return A reactive response {@link Mono} signaling completion. {@link PageBlobItem} contains information of - * the newly created page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createIfNotExists(long size) { - return createIfNotExistsWithResponse(new PageBlobCreateOptions(size)).flatMap(FluxUtil::toMono); - } - - /** - * Creates a page blob of the specified length if it does not exist. Call PutPage to upload data to a page blob. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     *
-     * client.createIfNotExistsWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber)
-     *     .setHeaders(headers).setMetadata(metadata).setTags(tags)).subscribe(response -> {
-     *         if (response.getStatusCode() == 409) {
-     *             System.out.println("Already exists.");
-     *         } else {
-     *             System.out.println("successfully created.");
-     *         }
-     *     });
-     * 
- * - * - * @param options {@link PageBlobCreateOptions} - * @return A {@link Mono} containing {@link Response} signaling completion, whose {@link Response#getValue() value} - * contains a {@link PageBlobItem} containing information about the page blob. If {@link Response}'s status code is - * 201, a new page blob was successfully created. If status code is 409, a page blob already existed at this location. - * - * @throws IllegalArgumentException If {@code size} isn't a multiple of {@link PageBlobAsyncClient#PAGE_BYTES} or - * {@code sequenceNumber} isn't null and is less than 0. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createIfNotExistsWithResponse(PageBlobCreateOptions options) { - try { - return createIfNotExistsWithResponse(options, null); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> createIfNotExistsWithResponse(PageBlobCreateOptions options, Context context) { - try { - options.setRequestConditions( - new BlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD) - .setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD)); - return createWithResponse(options, context).onErrorResume( - t -> t instanceof BlobStorageException && ((BlobStorageException) t).getStatusCode() == 409, t -> { - HttpResponse response = ((BlobStorageException) t).getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), null)); - }); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Writes one or more pages to the page blob. Write size must be a multiple of 512. For more information, see - * the Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     *
-     * client.uploadPages(pageRange, body).subscribe(response -> System.out.printf(
-     *     "Uploaded page blob with sequence number %s%n", response.getBlobSequenceNumber()));
-     * 
- * - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @param body The data to upload. Note that this {@code Flux} must be replayable if retries are enabled (the - * default). In other words, the Flowable must produce the same data each time it is subscribed to. - * - * @return A reactive response containing the information of the uploaded pages. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadPages(PageRange pageRange, Flux body) { - return uploadPagesWithResponse(pageRange, body, null, null).flatMap(FluxUtil::toMono); - } - - /** - * Writes one or more pages to the page blob. Write size must be a multiple of 512. For more information, see - * the Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     *
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     * PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.uploadPagesWithResponse(pageRange, body, md5, pageBlobRequestConditions)
-     *     .subscribe(response -> System.out.printf(
-     *         "Uploaded page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
-     * 
- * - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @param body The data to upload. Note that this {@code Flux} must be replayable if retries are enabled (the - * default). In other words, the Flowable must produce the same data each time it is subscribed to. - * @param contentMd5 An MD5 hash of the page content. This hash is used to verify the integrity of the page during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @param pageBlobRequestConditions {@link PageBlobRequestConditions} - * @return A reactive response containing the information of the uploaded pages. - * - * @throws IllegalArgumentException If {@code pageRange} is {@code null} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesWithResponse(PageRange pageRange, Flux body, - byte[] contentMd5, PageBlobRequestConditions pageBlobRequestConditions) { - if (body == null) { - return Mono.error(new NullPointerException("'body' cannot be null.")); - } - try { - return withContext( - context -> uploadPagesWithResponse(pageRange, body, contentMd5, pageBlobRequestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> uploadPagesWithResponse(PageRange pageRange, Flux body, byte[] contentMd5, - PageBlobRequestConditions pageBlobRequestConditions, Context context) { - pageBlobRequestConditions - = pageBlobRequestConditions == null ? new PageBlobRequestConditions() : pageBlobRequestConditions; - - if (pageRange == null) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError(new IllegalArgumentException("pageRange cannot be null.")); - } - String pageRangeStr = ModelHelper.pageRangeToString(pageRange); - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getPageBlobs() - .uploadPagesWithResponseAsync(containerName, blobName, pageRange.getEnd() - pageRange.getStart() + 1, body, - contentMd5, null, null, pageRangeStr, pageBlobRequestConditions.getLeaseId(), - pageBlobRequestConditions.getIfSequenceNumberLessThanOrEqualTo(), - pageBlobRequestConditions.getIfSequenceNumberLessThan(), - pageBlobRequestConditions.getIfSequenceNumberEqualTo(), pageBlobRequestConditions.getIfModifiedSince(), - pageBlobRequestConditions.getIfUnmodifiedSince(), pageBlobRequestConditions.getIfMatch(), - pageBlobRequestConditions.getIfNoneMatch(), pageBlobRequestConditions.getTagsConditions(), null, null, - null, getCustomerProvidedKey(), encryptionScope, context) - .map(rb -> { - PageBlobsUploadPagesHeaders hd = rb.getDeserializedHeaders(); - PageBlobItem item = new PageBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), - hd.getXMsBlobSequenceNumber()); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Writes one or more pages from the source page blob to this page blob. Write size must be a multiple of 512. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     *
-     * client.uploadPagesFromUrl(pageRange, url, sourceOffset)
-     *     .subscribe(response -> System.out.printf(
-     *         "Uploaded page blob from URL with sequence number %s%n", response.getBlobSequenceNumber()));
-     * 
- * - * - * @param range A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceOffset The source offset to copy from. Pass null or 0 to copy from the beginning of source page - * blob. - * - * @return A reactive response containing the information of the uploaded pages. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadPagesFromUrl(PageRange range, String sourceUrl, Long sourceOffset) { - return uploadPagesFromUrlWithResponse(range, sourceUrl, sourceOffset, null, null, null) - .flatMap(FluxUtil::toMono); - } - - /** - * Writes one or more pages from the source page blob to this page blob. Write size must be a multiple of 512. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     * InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
-     * byte[] sourceContentMD5 = new byte[512];
-     * PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
-     * BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.uploadPagesFromUrlWithResponse(pageRange, url, sourceOffset, sourceContentMD5, pageBlobRequestConditions,
-     *         sourceRequestConditions)
-     *     .subscribe(response -> System.out.printf(
-     *         "Uploaded page blob from URL with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
-     * 
- * - * - * @param range The destination {@link PageRange} range. Given that pages must be aligned with 512-byte boundaries, - * the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte - * ranges are 0-511, 512-1023, etc. - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceOffset The source offset to copy from. Pass null or 0 to copy from the beginning of source blob. - * @param sourceContentMd5 An MD5 hash of the page content. This hash is used to verify the integrity of the page - * during transport. When this header is specified, the storage service compares the hash of the content that has - * arrived with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not - * match, the operation will fail. - * @param destRequestConditions {@link PageBlobRequestConditions} - * @param sourceRequestConditions {@link BlobRequestConditions} - * @return A reactive response containing the information of the uploaded pages. - * - * @throws IllegalArgumentException If {@code range} is {@code null} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesFromUrlWithResponse(PageRange range, String sourceUrl, - Long sourceOffset, byte[] sourceContentMd5, PageBlobRequestConditions destRequestConditions, - BlobRequestConditions sourceRequestConditions) { - return uploadPagesFromUrlWithResponse( - new PageBlobUploadPagesFromUrlOptions(range, sourceUrl).setSourceOffset(sourceOffset) - .setSourceContentMd5(sourceContentMd5) - .setDestinationRequestConditions(destRequestConditions) - .setSourceRequestConditions(sourceRequestConditions)); - } - - /** - * Writes one or more pages from the source page blob to this page blob. Write size must be a multiple of 512. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     * InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
-     * byte[] sourceContentMD5 = new byte[512];
-     * PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
-     * BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     *
-     * client.uploadPagesFromUrlWithResponse(new PageBlobUploadPagesFromUrlOptions(pageRange, url)
-     *     .setSourceOffset(sourceOffset).setSourceContentMd5(sourceContentMD5)
-     *     .setDestinationRequestConditions(pageBlobRequestConditions)
-     *     .setSourceRequestConditions(sourceRequestConditions))
-     *     .subscribe(response -> System.out.printf(
-     *         "Uploaded page blob from URL with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
-     * 
- * - * - * @param options Parameters for the operation. - * @return A reactive response containing the information of the uploaded pages. - * - * @throws IllegalArgumentException If {@code range} is {@code null} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadPagesFromUrlWithResponse(PageBlobUploadPagesFromUrlOptions options) { - try { - return withContext(context -> uploadPagesFromUrlWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> uploadPagesFromUrlWithResponse(PageBlobUploadPagesFromUrlOptions options, - Context context) { - if (options.getRange() == null) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError(new IllegalArgumentException("range cannot be null.")); - } - - String rangeString = ModelHelper.pageRangeToString(options.getRange()); - - long sourceOffset = options.getSourceOffset() == null ? 0L : options.getSourceOffset(); - - String sourceRangeString = ModelHelper.pageRangeToString(new PageRange().setStart(sourceOffset) - .setEnd(sourceOffset + (options.getRange().getEnd() - options.getRange().getStart()))); - - PageBlobRequestConditions destRequestConditions = (options.getDestinationRequestConditions() == null) - ? new PageBlobRequestConditions() - : options.getDestinationRequestConditions(); - BlobRequestConditions sourceRequestConditions = (options.getSourceRequestConditions() == null) - ? new BlobRequestConditions() - : options.getSourceRequestConditions(); - - try { - new URL(options.getSourceUrl()); - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'sourceUrl' is not a valid url.", ex)); - } - context = context == null ? Context.NONE : context; - String sourceAuth - = options.getSourceAuthorization() == null ? null : options.getSourceAuthorization().toString(); - - return this.azureBlobStorage.getPageBlobs() - .uploadPagesFromURLWithResponseAsync(containerName, blobName, options.getSourceUrl(), sourceRangeString, 0, - rangeString, options.getSourceContentMd5(), null, null, destRequestConditions.getLeaseId(), - destRequestConditions.getIfSequenceNumberLessThanOrEqualTo(), - destRequestConditions.getIfSequenceNumberLessThan(), destRequestConditions.getIfSequenceNumberEqualTo(), - destRequestConditions.getIfModifiedSince(), destRequestConditions.getIfUnmodifiedSince(), - destRequestConditions.getIfMatch(), destRequestConditions.getIfNoneMatch(), - destRequestConditions.getTagsConditions(), sourceRequestConditions.getIfModifiedSince(), - sourceRequestConditions.getIfUnmodifiedSince(), sourceRequestConditions.getIfMatch(), - sourceRequestConditions.getIfNoneMatch(), null, sourceAuth, getCustomerProvidedKey(), encryptionScope, - context) - .map(rb -> { - PageBlobsUploadPagesFromURLHeaders hd = rb.getDeserializedHeaders(); - PageBlobItem item = new PageBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), null); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Frees the specified pages from the page blob. The size of the range must be a multiple of 512. For more - * information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     *
-     * client.clearPages(pageRange).subscribe(response -> System.out.printf(
-     *     "Cleared page blob with sequence number %s%n", response.getBlobSequenceNumber()));
-     * 
- * - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * - * @return A reactive response containing the information of the cleared pages. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono clearPages(PageRange pageRange) { - return clearPagesWithResponse(pageRange, null).flatMap(FluxUtil::toMono); - } - - /** - * Frees the specified pages from the page blob. The size of the range must be a multiple of 512. For more - * information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     * PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.clearPagesWithResponse(pageRange, pageBlobRequestConditions)
-     *     .subscribe(response -> System.out.printf(
-     *         "Cleared page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
-     * 
- * - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @param pageBlobRequestConditions {@link PageBlobRequestConditions} - * @return A reactive response containing the information of the cleared pages. - * - * @throws IllegalArgumentException If {@code pageRange} is {@code null} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> clearPagesWithResponse(PageRange pageRange, - PageBlobRequestConditions pageBlobRequestConditions) { - try { - return withContext(context -> clearPagesWithResponse(pageRange, pageBlobRequestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> clearPagesWithResponse(PageRange pageRange, - PageBlobRequestConditions pageBlobRequestConditions, Context context) { - pageBlobRequestConditions - = pageBlobRequestConditions == null ? new PageBlobRequestConditions() : pageBlobRequestConditions; - if (pageRange == null) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError(new IllegalArgumentException("pageRange cannot be null.")); - } - String pageRangeStr = ModelHelper.pageRangeToString(pageRange); - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getPageBlobs() - .clearPagesWithResponseAsync(containerName, blobName, 0, null, pageRangeStr, - pageBlobRequestConditions.getLeaseId(), - pageBlobRequestConditions.getIfSequenceNumberLessThanOrEqualTo(), - pageBlobRequestConditions.getIfSequenceNumberLessThan(), - pageBlobRequestConditions.getIfSequenceNumberEqualTo(), pageBlobRequestConditions.getIfModifiedSince(), - pageBlobRequestConditions.getIfUnmodifiedSince(), pageBlobRequestConditions.getIfMatch(), - pageBlobRequestConditions.getIfNoneMatch(), pageBlobRequestConditions.getTagsConditions(), null, - getCustomerProvidedKey(), encryptionScope, context) - .map(rb -> { - PageBlobsClearPagesHeaders hd = rb.getDeserializedHeaders(); - PageBlobItem item = new PageBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), null, - hd.getXMsBlobSequenceNumber()); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     *
-     * client.getPageRanges(blobRange).subscribe(response -> {
-     *     System.out.println("Valid Page Ranges are:");
-     *     for (PageRange pageRange : response.getPageRange()) {
-     *         System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     *     }
-     * });
-     * 
- * - * - * @param blobRange {@link BlobRange} - * - * @return A reactive response containing the information of the cleared pages. - * @deprecated Use {@link #listPageRanges(BlobRange)} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public Mono getPageRanges(BlobRange blobRange) { - return getPageRangesWithResponse(blobRange, null).flatMap(FluxUtil::toMono); - } - - /** - * Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.getPageRangesWithResponse(blobRange, blobRequestConditions)
-     *     .subscribe(response -> {
-     *         System.out.println("Valid Page Ranges are:");
-     *         for (PageRange pageRange : response.getValue().getPageRange()) {
-     *             System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     *         }
-     *     });
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response emitting all the page ranges. - * @deprecated Use {@link #listPageRanges(ListPageRangesOptions)} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public Mono> getPageRangesWithResponse(BlobRange blobRange, - BlobRequestConditions requestConditions) { - try { - return withContext(context -> getPageRangesWithResponse(blobRange, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getPageRangesWithResponse(BlobRange blobRange, BlobRequestConditions requestConditions, - Context context) { - blobRange = blobRange == null ? new BlobRange(0) : blobRange; - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getPageBlobs() - .getPageRangesWithResponseAsync(containerName, blobName, getSnapshotId(), null, blobRange.toHeaderValue(), - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, null, null, context) - .map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), response.getValue())); - } - - /** - * Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * client.listPageRanges(blobRange).subscribe(rangeItem -> System.out.printf("Offset: %s, Length: %s%n",
-     *     rangeItem.getRange().getOffset(), rangeItem.getRange().getLength()));
-     * 
- * - * - * @param blobRange {@link BlobRange} - * - * @return A reactive response containing the information of the cleared pages. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listPageRanges(BlobRange blobRange) { - return listPageRanges(new ListPageRangesOptions(blobRange)); - } - - /** - * Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * ListPageRangesOptions options = new ListPageRangesOptions(new BlobRange(offset))
-     *     .setMaxResultsPerPage(1000).setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId));
-     *
-     * client.listPageRanges(options)
-     *     .subscribe(rangeItem -> System.out.printf("Offset: %s, Length: %s%n", rangeItem.getRange().getOffset(),
-     *         rangeItem.getRange().getLength()));
-     * 
- * - * - * @param options {@link ListPageRangesOptions} - * @return A reactive response emitting all the page ranges. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listPageRanges(ListPageRangesOptions options) { - return new PagedFlux<>( - pageSize -> withContext( - context -> listPageRangesWithOptionalTimeout(options, null, context).apply(null, pageSize)), - (continuationToken, - pageSize) -> withContext(context -> listPageRangesWithOptionalTimeout(options, null, context) - .apply(continuationToken, pageSize))); - } - - /* - * Implementation for this paged listing operation, supporting an optional timeout provided by the synchronous - * ContainerClient. Applies the given timeout to each Mono backing the - * PagedFlux. - * - * @param delimiter The delimiter for blob hierarchy, "/" for hierarchy based on directories - * @param options {@link PageBlobGetPageRangesOptions} - * @param timeout An optional timeout to be applied to the network asynchronous operations. - * @return A reactive response emitting the listed blobs, flattened. - */ - BiFunction>> - listPageRangesWithOptionalTimeout(ListPageRangesOptions options, Duration timeout, Context context) { - return (marker, pageSize) -> { - ListPageRangesOptions finalOptions; - /* - If pageSize was not set in a .byPage(int) method, the page size from options will be preserved. - Otherwise, prefer the new value. - */ - if (pageSize != null) { - finalOptions = new ListPageRangesOptions(options.getRange()).setMaxResultsPerPage(pageSize); - } else { - finalOptions = options; - } - return getPageRangesSegment(marker, finalOptions, timeout, context).map(response -> { - List value = response.getValue() == null - ? Collections.emptyList() - : Stream - .concat(response.getValue().getPageRange().stream().map(PageBlobAsyncClient::toPageBlobRange), - response.getValue().getClearRange().stream().map(PageBlobAsyncClient::toPageBlobRange)) - .collect(Collectors.toList()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - value, PageListHelper.getNextMarker(response.getValue()), response.getDeserializedHeaders()); - }); - }; - } - - private Mono> getPageRangesSegment(String marker, - ListPageRangesOptions options, Duration timeout, Context context) { - BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - context = context == null ? Context.NONE : context; - - return StorageImplUtils.applyOptionalTimeout( - this.azureBlobStorage.getPageBlobs() - .getPageRangesWithResponseAsync(containerName, blobName, getSnapshotId(), null, - options.getRange().toHeaderValue(), requestConditions.getLeaseId(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, marker, options.getMaxResultsPerPage(), context), - timeout); - } - - private static PageRangeItem toPageBlobRange(PageRange range) { - return new PageRangeItem(new HttpRange(range.getStart(), range.getEnd() - range.getStart() + 1), false); - } - - private static PageRangeItem toPageBlobRange(ClearRange range) { - return new PageRangeItem(new HttpRange(range.getStart(), range.getEnd() - range.getStart() + 1), true); - } - - /** - * Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * final String prevSnapshot = "previous snapshot";
-     *
-     * client.getPageRangesDiff(blobRange, prevSnapshot).subscribe(response -> {
-     *     System.out.println("Valid Page Ranges are:");
-     *     for (PageRange pageRange : response.getPageRange()) {
-     *         System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     *     }
-     * });
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshot Specifies that the response will contain only pages that were changed between target blob and - * previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as - * long as the snapshot specified by prevsnapshot is the older of the two. - * - * @return A reactive response emitting all the different page ranges. - * @deprecated See {@link #listPageRangesDiff(BlobRange, String)} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public Mono getPageRangesDiff(BlobRange blobRange, String prevSnapshot) { - return getPageRangesDiffWithResponse(blobRange, prevSnapshot, null).flatMap(FluxUtil::toMono); - } - - /** - * Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * final String prevSnapshot = "previous snapshot";
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.getPageRangesDiffWithResponse(blobRange, prevSnapshot, blobRequestConditions)
-     *     .subscribe(response -> {
-     *         System.out.println("Valid Page Ranges are:");
-     *         for (PageRange pageRange : response.getValue().getPageRange()) {
-     *             System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     *         }
-     *     });
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshot Specifies that the response will contain only pages that were changed between target blob and - * previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as - * long as the snapshot specified by prevsnapshot is the older of the two. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response emitting all the different page ranges. - * - * @throws IllegalArgumentException If {@code prevSnapshot} is {@code null} - * @deprecated See {@link #listPageRangesDiff(ListPageRangesDiffOptions)} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public Mono> getPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshot, - BlobRequestConditions requestConditions) { - try { - return withContext( - context -> getPageRangesDiffWithResponse(blobRange, prevSnapshot, null, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * String prevSnapshot = "previous snapshot";
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * client.listPageRangesDiff(blobRange, prevSnapshot).subscribe(rangeItem ->
-     *     System.out.printf("Offset: %s, Length: %s, isClear: %s%n",
-     *     rangeItem.getRange().getOffset(), rangeItem.getRange().getLength(), rangeItem.isClear()));
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshot Specifies that the response will contain only pages that were changed between target blob and - * previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as - * long as the snapshot specified by prevsnapshot is the older of the two. - * - * @return A reactive response emitting all the different page ranges. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listPageRangesDiff(BlobRange blobRange, String prevSnapshot) { - return listPageRangesDiff(new ListPageRangesDiffOptions(blobRange, prevSnapshot)); - } - - /** - * Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * ListPageRangesDiffOptions options = new ListPageRangesDiffOptions(new BlobRange(offset), "previous snapshot")
-     *     .setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId))
-     *     .setMaxResultsPerPage(1000);
-     *
-     * client.listPageRangesDiff(options)
-     *     .subscribe(rangeItem -> System.out.printf("Offset: %s, Length: %s, isClear: %s%n",
-     *         rangeItem.getRange().getOffset(), rangeItem.getRange().getLength(), rangeItem.isClear()));
-     * 
- * - * - * @param options {@link ListPageRangesDiffOptions}. - * @return A reactive response emitting all the different page ranges. - * - * @throws IllegalArgumentException If {@code prevSnapshot} is {@code null} - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listPageRangesDiff(ListPageRangesDiffOptions options) { - return new PagedFlux<>( - pageSize -> withContext( - context -> listPageRangesDiffWithOptionalTimeout(options, null, context).apply(null, pageSize)), - (continuationToken, - pageSize) -> withContext(context -> listPageRangesDiffWithOptionalTimeout(options, null, context) - .apply(continuationToken, pageSize))); - } - - /** - * This API only works for managed disk accounts. - *

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs.

- * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * final String prevSnapshotUrl = "previous snapshot url";
-     *
-     * client.getPageRangesDiff(blobRange, prevSnapshotUrl).subscribe(response -> {
-     *     System.out.println("Valid Page Ranges are:");
-     *     for (PageRange pageRange : response.getPageRange()) {
-     *         System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     *     }
-     * });
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshotUrl Specifies the URL of a previous snapshot of the target blob. Specifies that the - * response will contain only pages that were changed between target blob and previous snapshot. Changed pages - * include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by - * prevsnapshot is the older of the two. - * - * @return A reactive response emitting all the different page ranges. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getManagedDiskPageRangesDiff(BlobRange blobRange, String prevSnapshotUrl) { - return getManagedDiskPageRangesDiffWithResponse(blobRange, prevSnapshotUrl, null).flatMap(FluxUtil::toMono); - } - - /** - * This API only works for managed disk accounts. - *

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs.

- * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * final String prevSnapshotUrl = "previous snapshot url";
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.getPageRangesDiffWithResponse(blobRange, prevSnapshotUrl, blobRequestConditions)
-     *     .subscribe(response -> {
-     *         System.out.println("Valid Page Ranges are:");
-     *         for (PageRange pageRange : response.getValue().getPageRange()) {
-     *             System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     *         }
-     *     });
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshotUrl Specifies the URL of a previous snapshot of the target blob. Specifies that the - * response will contain only pages that were changed between target blob and previous snapshot. Changed pages - * include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by - * prevsnapshot is the older of the two. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response emitting all the different page ranges. - * - * @throws IllegalArgumentException If {@code prevSnapshot} is {@code null} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getManagedDiskPageRangesDiffWithResponse(BlobRange blobRange, - String prevSnapshotUrl, BlobRequestConditions requestConditions) { - try { - return withContext( - context -> getPageRangesDiffWithResponse(blobRange, null, prevSnapshotUrl, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> getPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshot, - String prevSnapshotUrl, BlobRequestConditions requestConditions, Context context) { - blobRange = blobRange == null ? new BlobRange(0) : blobRange; - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - if (prevSnapshotUrl == null && prevSnapshot == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("prevSnapshot cannot be null")); - } - if (prevSnapshotUrl != null) { - try { - new URL(prevSnapshotUrl); - } catch (MalformedURLException ex) { - throw LOGGER - .logExceptionAsError(new IllegalArgumentException("'prevSnapshotUrl' is not a valid url.", ex)); - } - } - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getPageBlobs() - .getPageRangesDiffWithResponseAsync(containerName, blobName, getSnapshotId(), null, prevSnapshot, - prevSnapshotUrl, blobRange.toHeaderValue(), requestConditions.getLeaseId(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, null, null, context) - .map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), response.getValue())); - } - - /* - * Implementation for this paged listing operation, supporting an optional timeout provided by the synchronous - * ContainerClient. Applies the given timeout to each Mono backing the - * PagedFlux. - * - * @param delimiter The delimiter for blob hierarchy, "/" for hierarchy based on directories - * @param options {@link PageBlobGetPageRangesDiffOptions} - * @param timeout An optional timeout to be applied to the network asynchronous operations. - * @return A reactive response emitting the listed blobs, flattened. - */ - BiFunction>> - listPageRangesDiffWithOptionalTimeout(ListPageRangesDiffOptions options, Duration timeout, Context context) { - return (marker, pageSize) -> { - ListPageRangesDiffOptions finalOptions; - /* - If pageSize was not set in a .byPage(int) method, the page size from options will be preserved. - Otherwise, prefer the new value. - */ - if (pageSize != null) { - finalOptions = new ListPageRangesDiffOptions(options.getRange(), options.getPreviousSnapshot()) - .setRequestConditions(options.getRequestConditions()) - .setMaxResultsPerPage(pageSize); - } else { - finalOptions = options; - } - - return getPageRangesDiffSegment(marker, finalOptions, timeout, context).map(response -> { - List value = response.getValue() == null - ? Collections.emptyList() - : Stream - .concat(response.getValue().getPageRange().stream().map(PageBlobAsyncClient::toPageBlobRange), - response.getValue().getClearRange().stream().map(PageBlobAsyncClient::toPageBlobRange)) - .collect(Collectors.toList()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - value, PageListHelper.getNextMarker(response.getValue()), response.getDeserializedHeaders()); - }); - }; - } - - private Mono> getPageRangesDiffSegment(String marker, - ListPageRangesDiffOptions options, Duration timeout, Context context) { - BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - context = context == null ? Context.NONE : context; - - return StorageImplUtils.applyOptionalTimeout(this.azureBlobStorage.getPageBlobs() - .getPageRangesDiffWithResponseAsync(containerName, blobName, getSnapshotId(), null, - options.getPreviousSnapshot(), null, options.getRange().toHeaderValue(), requestConditions.getLeaseId(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, marker, options.getMaxResultsPerPage(), context), - timeout); - } - - /** - * Resizes the page blob to the specified size (which must be a multiple of 512). For more information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * client.resize(size).subscribe(response -> System.out.printf(
-     *     "Page blob resized with sequence number %s%n", response.getBlobSequenceNumber()));
-     * 
- * - * - * @param size Resizes a page blob to the specified size. If the specified value is less than the current size of - * the blob, then all pages above the specified value are cleared. - * - * @return A reactive response emitting the resized page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono resize(long size) { - return resizeWithResponse(size, null).flatMap(FluxUtil::toMono); - } - - /** - * Resizes the page blob to the specified size (which must be a multiple of 512). For more information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.resizeWithResponse(size, blobRequestConditions)
-     *     .subscribe(response -> System.out.printf(
-     *         "Page blob resized with sequence number %s%n", response.getValue().getBlobSequenceNumber()));
-     * 
- * - * - * @param size Resizes a page blob to the specified size. If the specified value is less than the current size of - * the blob, then all pages above the specified value are cleared. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response emitting the resized page blob. - * - * @throws IllegalArgumentException If {@code size} isn't a multiple of {@link PageBlobAsyncClient#PAGE_BYTES} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> resizeWithResponse(long size, BlobRequestConditions requestConditions) { - try { - return withContext(context -> resizeWithResponse(size, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> resizeWithResponse(long size, BlobRequestConditions requestConditions, - Context context) { - if (size % PAGE_BYTES != 0) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("size must be a multiple of PageBlobAsyncClient.PAGE_BYTES.")); - } - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getPageBlobs() - .resizeWithResponseAsync(containerName, blobName, size, null, requestConditions.getLeaseId(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, getCustomerProvidedKey(), encryptionScope, context) - .map(rb -> { - PageBlobsResizeHeaders hd = rb.getDeserializedHeaders(); - PageBlobItem item = new PageBlobItem(hd.getETag(), hd.getLastModified(), null, null, null, null, - hd.getXMsBlobSequenceNumber()); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Sets the page blob's sequence number. For more information, see the - * Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * client.updateSequenceNumber(SequenceNumberActionType.INCREMENT, size)
-     *     .subscribe(response -> System.out.printf(
-     *         "Page blob updated to sequence number %s%n", response.getBlobSequenceNumber()));
-     * 
- * - * - * @param action Indicates how the service should modify the blob's sequence number. - * @param sequenceNumber The blob's sequence number. The sequence number is a user-controlled property that you can - * use to track requests and manage concurrency issues. - * - * @return A reactive response emitting the updated page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateSequenceNumber(SequenceNumberActionType action, Long sequenceNumber) { - return updateSequenceNumberWithResponse(action, sequenceNumber, null).flatMap(FluxUtil::toMono); - } - - /** - * Sets the page blob's sequence number. For more information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     *
-     * client.updateSequenceNumberWithResponse(SequenceNumberActionType.INCREMENT, size, blobRequestConditions)
-     *     .subscribe(response -> System.out.printf(
-     *         "Page blob updated to sequence number %s%n", response.getValue().getBlobSequenceNumber()));
-     * 
- * - * - * @param action Indicates how the service should modify the blob's sequence number. - * @param sequenceNumber The blob's sequence number. The sequence number is a user-controlled property that you can - * use to track requests and manage concurrency issues. - * @param requestConditions {@link BlobRequestConditions} - * @return A reactive response emitting the updated page blob. - * - * @throws IllegalArgumentException If {@code sequenceNumber} isn't null and is less than 0 - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateSequenceNumberWithResponse(SequenceNumberActionType action, - Long sequenceNumber, BlobRequestConditions requestConditions) { - try { - return withContext( - context -> updateSequenceNumberWithResponse(action, sequenceNumber, requestConditions, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> updateSequenceNumberWithResponse(SequenceNumberActionType action, Long sequenceNumber, - BlobRequestConditions requestConditions, Context context) { - if (sequenceNumber != null && sequenceNumber < 0) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("SequenceNumber must be greater than or equal to 0.")); - } - requestConditions = requestConditions == null ? new BlobRequestConditions() : requestConditions; - sequenceNumber = action == SequenceNumberActionType.INCREMENT ? null : sequenceNumber; - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getPageBlobs() - .updateSequenceNumberWithResponseAsync(containerName, blobName, action, null, - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), sequenceNumber, null, - context) - .map(rb -> { - PageBlobsUpdateSequenceNumberHeaders hd = rb.getDeserializedHeaders(); - PageBlobItem item = new PageBlobItem(hd.getETag(), hd.getLastModified(), null, null, null, null, - hd.getXMsBlobSequenceNumber()); - return new SimpleResponse<>(rb, item); - }); - } - - /** - * Begins an operation to start an incremental copy from one page blob's snapshot to this page blob. The snapshot - * is - * copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. For more information, see the Azure Docs - * here - * and - * here. - * - *

Code Samples

- * - * - *
-     * final String snapshot = "copy snapshot";
-     * client.copyIncremental(url, snapshot).subscribe(statusType -> {
-     *     switch (statusType) {
-     *         case SUCCESS:
-     *             System.out.println("Page blob copied successfully");
-     *             break;
-     *         case FAILED:
-     *             System.out.println("Page blob copied failed");
-     *             break;
-     *         case ABORTED:
-     *             System.out.println("Page blob copied aborted");
-     *             break;
-     *         case PENDING:
-     *             System.out.println("Page blob copied pending");
-     *             break;
-     *         default:
-     *             break;
-     *     }
-     * });
-     * 
- * - * - * @param source The source page blob. - * @param snapshot The snapshot on the copy source. - * - * @return A reactive response emitting the copy status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono copyIncremental(String source, String snapshot) { - return copyIncrementalWithResponse(source, snapshot, null).flatMap(FluxUtil::toMono); - } - - /** - * Begins an operation to start an incremental copy from one page blob's snapshot to this page blob. The snapshot - * is - * copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. For more information, see the Azure Docs - * here - * and - * here. - * - *

Code Samples

- * - * - *
-     * final String snapshot = "copy snapshot";
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfNoneMatch("snapshotMatch");
-     *
-     * client.copyIncrementalWithResponse(url, snapshot, modifiedRequestConditions)
-     *     .subscribe(response -> {
-     *         CopyStatusType statusType = response.getValue();
-     *
-     *         switch (statusType) {
-     *             case SUCCESS:
-     *                 System.out.println("Page blob copied successfully");
-     *                 break;
-     *             case FAILED:
-     *                 System.out.println("Page blob copied failed");
-     *                 break;
-     *             case ABORTED:
-     *                 System.out.println("Page blob copied aborted");
-     *                 break;
-     *             case PENDING:
-     *                 System.out.println("Page blob copied pending");
-     *                 break;
-     *             default:
-     *                 break;
-     *         }
-     *     });
-     * 
- * - * - * @param source The source page blob. - * @param snapshot The snapshot on the copy source. - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * - * @return A reactive response emitting the copy status. - * - * @throws IllegalStateException If {@code source} and {@code snapshot} form a malformed URL. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyIncrementalWithResponse(String source, String snapshot, - RequestConditions modifiedRequestConditions) { - return copyIncrementalWithResponse(new PageBlobCopyIncrementalOptions(source, snapshot) - .setRequestConditions(ModelHelper.populateBlobDestinationRequestConditions(modifiedRequestConditions))); - } - - /** - * Begins an operation to start an incremental copy from one page blob's snapshot to this page blob. The snapshot - * is - * copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. For more information, see the Azure Docs - * here - * and - * here. - * - *

Code Samples

- * - * - *
-     * final String snapshot = "copy snapshot";
-     * PageBlobCopyIncrementalRequestConditions destinationRequestConditions = new PageBlobCopyIncrementalRequestConditions()
-     *     .setIfNoneMatch("snapshotMatch");
-     *
-     * client.copyIncrementalWithResponse(new PageBlobCopyIncrementalOptions(url, snapshot)
-     *     .setRequestConditions(destinationRequestConditions))
-     *     .subscribe(response -> {
-     *         CopyStatusType statusType = response.getValue();
-     *
-     *         switch (statusType) {
-     *             case SUCCESS:
-     *                 System.out.println("Page blob copied successfully");
-     *                 break;
-     *             case FAILED:
-     *                 System.out.println("Page blob copied failed");
-     *                 break;
-     *             case ABORTED:
-     *                 System.out.println("Page blob copied aborted");
-     *                 break;
-     *             case PENDING:
-     *                 System.out.println("Page blob copied pending");
-     *                 break;
-     *             default:
-     *                 break;
-     *         }
-     *     });
-     * 
- * - * - * @param options {@link PageBlobCopyIncrementalOptions} - * - * @return A reactive response emitting the copy status. - * - * @throws IllegalStateException If {@code source} and {@code snapshot} form a malformed URL. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> copyIncrementalWithResponse(PageBlobCopyIncrementalOptions options) { - try { - return withContext(context -> copyIncrementalWithResponse(options, context)); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - Mono> copyIncrementalWithResponse(PageBlobCopyIncrementalOptions options, - Context context) { - StorageImplUtils.assertNotNull("options", options); - UrlBuilder builder = UrlBuilder.parse(options.getSource()); - builder.setQueryParameter(Constants.UrlConstants.SNAPSHOT_QUERY_PARAMETER, options.getSnapshot()); - PageBlobCopyIncrementalRequestConditions modifiedRequestConditions = (options.getRequestConditions() == null) - ? new PageBlobCopyIncrementalRequestConditions() - : options.getRequestConditions(); - - try { - builder.toUrl(); - } catch (MalformedURLException e) { - // We are parsing a valid url and adding a query parameter. If this fails, we can't recover. - throw LOGGER.logExceptionAsError(new IllegalArgumentException(e)); - } - context = context == null ? Context.NONE : context; - - return this.azureBlobStorage.getPageBlobs() - .copyIncrementalWithResponseAsync(containerName, blobName, builder.toString(), null, - modifiedRequestConditions.getIfModifiedSince(), modifiedRequestConditions.getIfUnmodifiedSince(), - modifiedRequestConditions.getIfMatch(), modifiedRequestConditions.getIfNoneMatch(), - modifiedRequestConditions.getTagsConditions(), null, context) - .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsCopyStatus())); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobClient.java deleted file mode 100644 index 693c02dbf6eb..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobClient.java +++ /dev/null @@ -1,1575 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpRange; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.PagedResponseBase; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.UrlBuilder; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.models.PageBlobsClearPagesHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsCopyIncrementalHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsCreateHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesDiffHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsResizeHeaders; -import com.azure.storage.blob.implementation.models.PageBlobsUpdateSequenceNumberHeaders; -import com.azure.storage.blob.implementation.models.PageListHelper; -import com.azure.storage.blob.implementation.util.BlobConstants; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.ClearRange; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.PageBlobCopyIncrementalRequestConditions; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.models.PageBlobRequestConditions; -import com.azure.storage.blob.models.PageList; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.models.PageRangeItem; -import com.azure.storage.blob.models.SequenceNumberActionType; -import com.azure.storage.blob.options.ListPageRangesDiffOptions; -import com.azure.storage.blob.options.ListPageRangesOptions; -import com.azure.storage.blob.options.PageBlobCopyIncrementalOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.options.PageBlobUploadPagesFromUrlOptions; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.Callable; -import java.util.function.BiFunction; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static com.azure.storage.common.implementation.StorageImplUtils.sendRequest; - -/** - * Client to a page blob. It may only be instantiated through a {@link SpecializedBlobClientBuilder} or via the method - * {@link BlobClient#getPageBlobClient()}. This class does not hold any state about a particular blob, but is instead a - * convenient way of sending appropriate requests to the resource on the service. - * - *

- * Please refer to the Azure - * Docs for more information. - */ -@ServiceClient(builder = SpecializedBlobClientBuilder.class) -public final class PageBlobClient extends BlobClientBase { - private static final ClientLogger LOGGER = new ClientLogger(PageBlobClient.class); - private final PageBlobAsyncClient pageBlobAsyncClient; - - /** - * Indicates the number of bytes in a page. - */ - public static final int PAGE_BYTES = BlobConstants.PAGE_BYTES; - - /** - * Indicates the maximum number of bytes that may be sent in a call to putPage. - */ - public static final int MAX_PUT_PAGES_BYTES = BlobConstants.MAX_PUT_PAGES_BYTES; - - /** - * Package-private constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pageBlobAsyncClient the async page blob client - */ - PageBlobClient(PageBlobAsyncClient pageBlobAsyncClient) { - this(pageBlobAsyncClient, pageBlobAsyncClient.getHttpPipeline(), pageBlobAsyncClient.getAccountUrl(), - pageBlobAsyncClient.getServiceVersion(), pageBlobAsyncClient.getAccountName(), - pageBlobAsyncClient.getContainerName(), pageBlobAsyncClient.getBlobName(), - pageBlobAsyncClient.getSnapshotId(), pageBlobAsyncClient.getCustomerProvidedKey(), - new EncryptionScope().setEncryptionScope(pageBlobAsyncClient.getEncryptionScope()), - pageBlobAsyncClient.getVersionId()); - } - - /** - * Package-private constructor for use by {@link SpecializedBlobClientBuilder}. - * - * @param pipeline The pipeline used to send and receive service requests. - * @param url The endpoint where to send service requests. - * @param serviceVersion The version of the service to receive requests. - * @param accountName The storage account name. - * @param containerName The container name. - * @param blobName The blob name. - * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly. - * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass - * {@code null} to allow the service to use its own encryption. - * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version. - */ - PageBlobClient(PageBlobAsyncClient pageBlobAsyncClient, HttpPipeline pipeline, String url, - BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, - CpkInfo customerProvidedKey, EncryptionScope encryptionScope, String versionId) { - super(pageBlobAsyncClient, pipeline, url, serviceVersion, accountName, containerName, blobName, snapshot, - customerProvidedKey, encryptionScope, versionId); - this.pageBlobAsyncClient = pageBlobAsyncClient; - } - - /** - * Creates a new {@link PageBlobClient} with the specified {@code encryptionScope}. - * - * @param encryptionScope the encryption scope for the blob, pass {@code null} to use no encryption scope. - * @return a {@link PageBlobClient} with the specified {@code encryptionScope}. - */ - @Override - public PageBlobClient getEncryptionScopeClient(String encryptionScope) { - EncryptionScope finalEncryptionScope = null; - if (encryptionScope != null) { - finalEncryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - PageBlobAsyncClient asyncClient = pageBlobAsyncClient.getEncryptionScopeAsyncClient(encryptionScope); - return new PageBlobClient(asyncClient, getHttpPipeline(), getAccountUrl(), getServiceVersion(), - getAccountName(), getContainerName(), getBlobName(), getSnapshotId(), getCustomerProvidedKey(), - finalEncryptionScope, getVersionId()); - } - - /** - * Creates a new {@link PageBlobClient} with the specified {@code customerProvidedKey}. - * - * @param customerProvidedKey the {@link CustomerProvidedKey} for the blob, - * pass {@code null} to use no customer provided key. - * @return a {@link PageBlobClient} with the specified {@code customerProvidedKey}. - */ - @Override - public PageBlobClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey) { - CpkInfo finalCustomerProvidedKey = null; - if (customerProvidedKey != null) { - finalCustomerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - PageBlobAsyncClient asyncClient = pageBlobAsyncClient.getCustomerProvidedKeyAsyncClient(customerProvidedKey); - return new PageBlobClient(asyncClient, getHttpPipeline(), getAccountUrl(), getServiceVersion(), - getAccountName(), getContainerName(), getBlobName(), getSnapshotId(), finalCustomerProvidedKey, - encryptionScope, getVersionId()); - } - - /** - * Creates and opens an output stream to write data to the page blob. If the blob already exists on the service, it - * will be overwritten. - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream(PageRange pageRange) { - return getBlobOutputStream(pageRange, null); - } - - /** - * Creates and opens an output stream to write data to the page blob. If the blob already exists on the service, it - * will be overwritten. - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @param requestConditions A {@link BlobRequestConditions} object that represents the access conditions for the - * blob. - * @return A {@link BlobOutputStream} object used to write data to the blob. - * @throws BlobStorageException If a storage service error occurred. - */ - public BlobOutputStream getBlobOutputStream(PageRange pageRange, BlobRequestConditions requestConditions) { - return BlobOutputStream.pageBlobOutputStream(pageBlobAsyncClient, pageRange, requestConditions); - } - - /** - * Creates a page blob of the specified length. By default this method will not overwrite an existing blob. - * Call PutPage to upload data data to a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageBlobItem pageBlob = client.create(size);
-     * System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - * @return The information of the created page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageBlobItem create(long size) { - return create(size, false); - } - - /** - * Creates a page blob of the specified length. Call PutPage to upload data data to a page blob. For more - * information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * boolean overwrite = false; // Default value
-     * PageBlobItem pageBlob = client.create(size, overwrite);
-     * System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - * @param overwrite Whether or not to overwrite, should data exist on the blob. - * @return The information of the created page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageBlobItem create(long size, boolean overwrite) { - BlobRequestConditions blobRequestConditions = new BlobRequestConditions(); - if (!overwrite) { - blobRequestConditions.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD); - } - return createWithResponse(size, null, null, null, blobRequestConditions, null, Context.NONE).getValue(); - } - - /** - * Creates a page blob of the specified length. Call PutPage to upload data data to a page blob. For more - * information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * Context context = new Context(key, value);
-     *
-     * PageBlobItem pageBlob = client
-     *     .createWithResponse(size, sequenceNumber, headers, metadata, blobRequestConditions, timeout, context)
-     *     .getValue();
-     *
-     * System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - * @param sequenceNumber A user-controlled value that you can use to track requests. The value of the sequence - * number must be between 0 and 2^63 - 1.The default value is 0. - * @param headers {@link BlobHttpHeaders} - * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any - * metadata key or value, it must be removed or encoded. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The information of the created page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createWithResponse(long size, Long sequenceNumber, BlobHttpHeaders headers, - Map metadata, BlobRequestConditions requestConditions, Duration timeout, Context context) { - return this.createWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber) - .setHeaders(headers) - .setMetadata(metadata) - .setRequestConditions(requestConditions), timeout, context); - } - - /** - * Creates a page blob of the specified length. Call PutPage to upload data data to a page blob. For more - * information, see the - * Azure Docs. - *

- * To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * Context context = new Context(key, value);
-     *
-     * PageBlobItem pageBlob = client
-     *     .createWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber)
-     *             .setHeaders(headers).setMetadata(metadata).setTags(tags)
-     *             .setRequestConditions(blobRequestConditions), timeout,
-     *         context)
-     *     .getValue();
-     *
-     * System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param options {@link PageBlobCreateOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The information of the created page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createWithResponse(PageBlobCreateOptions options, Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", options); - Context finalContext = context == null ? Context.NONE : context; - BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - - if (options.getSize() % PAGE_BYTES != 0) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("size must be a multiple of PageBlobAsyncClient.PAGE_BYTES.")); - } - if (options.getSequenceNumber() != null && options.getSequenceNumber() < 0) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("SequenceNumber must be greater than or equal to 0.")); - } - BlobImmutabilityPolicy immutabilityPolicy - = options.getImmutabilityPolicy() == null ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); - - Callable> operation = () -> this.azureBlobStorage.getPageBlobs() - .createWithResponse(containerName, blobName, 0, options.getSize(), null, null, options.getMetadata(), - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), options.getSequenceNumber(), - null, ModelHelper.tagsToString(options.getTags()), immutabilityPolicy.getExpiryTime(), - immutabilityPolicy.getPolicyMode(), options.isLegalHold(), options.getHeaders(), - getCustomerProvidedKey(), encryptionScope, finalContext); - - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - PageBlobsCreateHeaders hd = response.getDeserializedHeaders(); - PageBlobItem item - = new PageBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), hd.isXMsRequestServerEncrypted(), - hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), null, hd.getXMsVersionId()); - return new SimpleResponse<>(response, item); - } - - /** - * Creates a page blob of the specified length if it does not exist. - * Call PutPage to upload data to a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageBlobItem pageBlob = client.createIfNotExists(size);
-     * System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a - * 512-byte boundary. - * @return {@link PageBlobItem} containing information of the created page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageBlobItem createIfNotExists(long size) { - return createIfNotExistsWithResponse(new PageBlobCreateOptions(size), null, null).getValue(); - } - - /** - * Creates a page blob of the specified length if it does not exist. Call PutPage to upload data to a page blob. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobHttpHeaders headers = new BlobHttpHeaders()
-     *     .setContentLanguage("en-US")
-     *     .setContentType("binary");
-     * Context context = new Context(key, value);
-     *
-     * Response<PageBlobItem> response = client.createIfNotExistsWithResponse(new PageBlobCreateOptions(size)
-     *     .setHeaders(headers).setMetadata(metadata).setTags(tags), timeout, context);
-     *
-     * if (response.getStatusCode() == 409) {
-     *     System.out.println("Already existed.");
-     * } else {
-     *     System.out.printf("Create completed with status %d%n", response.getStatusCode());
-     * }
-     * 
- * - * - * @param options {@link PageBlobCreateOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A reactive {@link Response} signaling completion, whose {@link Response#getValue() value} contains a - * {@link PageBlobItem} containing information about the page blob. If {@link Response}'s status code is 201, a new - * page blob was successfully created. If status code is 409, a page blob already existed at this location. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createIfNotExistsWithResponse(PageBlobCreateOptions options, Duration timeout, - Context context) { - StorageImplUtils.assertNotNull("options", options); - options.setRequestConditions(new BlobRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD) - .setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD)); - try { - return createWithResponse(options, timeout, context); - } catch (BlobStorageException e) { - if (e.getStatusCode() == 409) { - HttpResponse res = e.getResponse(); - return new SimpleResponse<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), null); - } else { - throw LOGGER.logExceptionAsError(e); - } - } catch (RuntimeException e) { - throw LOGGER.logExceptionAsError(e); - } - } - - /** - * Writes one or more pages to the page blob. The write size must be a multiple of 512. For more information, see - * the Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     * InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
-     *
-     * PageBlobItem pageBlob = client.uploadPages(pageRange, dataStream);
-     * System.out.printf("Uploaded page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @param body The data to upload. The data must be markable. This is in order to support retries. If - * the data is not markable, consider using {@link #getBlobOutputStream(PageRange)} and writing to the returned - * OutputStream. Alternatively, consider wrapping your data source in a {@link java.io.BufferedInputStream} to add - * mark support. - * @return The information of the uploaded pages. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageBlobItem uploadPages(PageRange pageRange, InputStream body) { - return uploadPagesWithResponse(pageRange, body, null, null, null, Context.NONE).getValue(); - } - - /** - * Writes one or more pages to the page blob. The write size must be a multiple of 512. For more information, see - * the Azure Docs. - *

- * Note that the data passed must be replayable if retries are enabled (the default). In other words, the - * {@code Flux} must produce the same data each time it is subscribed to. - * - *

Code Samples

- * - * - *
-     * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8));
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     * InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
-     * PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
-     * Context context = new Context(key, value);
-     *
-     * PageBlobItem pageBlob = client
-     *     .uploadPagesWithResponse(pageRange, dataStream, md5, pageBlobRequestConditions, timeout, context).getValue();
-     *
-     * System.out.printf("Uploaded page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @param body The data to upload. The data must be markable. This is in order to support retries. If - * the data is not markable, consider using {@link #getBlobOutputStream(PageRange)} and writing to the returned - * OutputStream. Alternatively, consider wrapping your data source in a {@link java.io.BufferedInputStream} to add - * mark support. - * @param contentMd5 An MD5 hash of the page content. This hash is used to verify the integrity of the page during - * transport. When this header is specified, the storage service compares the hash of the content that has arrived - * with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the - * operation will fail. - * @param pageBlobRequestConditions {@link PageBlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The information of the uploaded pages. - * @throws UnexpectedLengthException when the length of data does not match the input {@code length}. - * @throws NullPointerException if the input data is null. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadPagesWithResponse(PageRange pageRange, InputStream body, byte[] contentMd5, - PageBlobRequestConditions pageBlobRequestConditions, Duration timeout, Context context) { - Objects.requireNonNull(body, "'body' cannot be null."); - final long length = pageRange.getEnd() - pageRange.getStart() + 1; - Flux fbb = Utility.convertStreamToByteBuffer(body, length, PAGE_BYTES, true); - - Mono> response = pageBlobAsyncClient.uploadPagesWithResponse(pageRange, fbb, contentMd5, - pageBlobRequestConditions, context); - return StorageImplUtils.blockWithOptionalTimeout(response, timeout); - } - - /** - * Writes one or more pages from the source page blob to this page blob. The write size must be a multiple of 512. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     *
-     * PageBlobItem pageBlob = client.uploadPagesFromUrl(pageRange, url, sourceOffset);
-     *
-     * System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param range A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceOffset The source offset to copy from. Pass null or 0 to copy from the beginning of source page - * blob. - * @return The information of the uploaded pages. - * @throws IllegalArgumentException If {@code sourceUrl} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageBlobItem uploadPagesFromUrl(PageRange range, String sourceUrl, Long sourceOffset) { - return uploadPagesFromUrlWithResponse(range, sourceUrl, sourceOffset, null, null, null, null, Context.NONE) - .getValue(); - } - - /** - * Writes one or more pages from the source page blob to this page blob. The write size must be a multiple of 512. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     * InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
-     * byte[] sourceContentMD5 = new byte[512];
-     * PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
-     * BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context(key, value);
-     *
-     * PageBlobItem pageBlob = client
-     *     .uploadPagesFromUrlWithResponse(pageRange, url, sourceOffset, sourceContentMD5, pageBlobRequestConditions,
-     *         sourceRequestConditions, timeout, context).getValue();
-     *
-     * System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param range The destination {@link PageRange} range. Given that pages must be aligned with 512-byte boundaries, - * the start offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte - * ranges are 0-511, 512-1023, etc. - * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage - * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob - * must either be public or must be authenticated via a shared access signature. If the source blob is public, no - * authentication is required to perform the operation. - * @param sourceOffset The source offset to copy from. Pass null or 0 to copy from the beginning of source blob. - * @param sourceContentMd5 An MD5 hash of the block content from the source blob. If specified, the service will - * calculate the MD5 of the received data and fail the request if it does not match the provided MD5. - * @param destRequestConditions {@link PageBlobRequestConditions} - * @param sourceRequestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The information of the uploaded pages. - * @throws IllegalArgumentException If {@code sourceUrl} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadPagesFromUrlWithResponse(PageRange range, String sourceUrl, Long sourceOffset, - byte[] sourceContentMd5, PageBlobRequestConditions destRequestConditions, - BlobRequestConditions sourceRequestConditions, Duration timeout, Context context) { - - return uploadPagesFromUrlWithResponse( - new PageBlobUploadPagesFromUrlOptions(range, sourceUrl).setSourceOffset(sourceOffset) - .setSourceContentMd5(sourceContentMd5) - .setDestinationRequestConditions(destRequestConditions) - .setSourceRequestConditions(sourceRequestConditions), - timeout, context); - } - - /** - * Writes one or more pages from the source page blob to this page blob. The write size must be a multiple of 512. - * For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     * InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
-     * byte[] sourceContentMD5 = new byte[512];
-     * PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
-     * BlobRequestConditions sourceRequestConditions = new BlobRequestConditions()
-     *     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
-     * Context context = new Context(key, value);
-     *
-     * PageBlobItem pageBlob = client
-     *     .uploadPagesFromUrlWithResponse(new PageBlobUploadPagesFromUrlOptions(pageRange, url)
-     *         .setSourceOffset(sourceOffset).setSourceContentMd5(sourceContentMD5)
-     *         .setDestinationRequestConditions(pageBlobRequestConditions)
-     *         .setSourceRequestConditions(sourceRequestConditions), timeout, context).getValue();
-     *
-     * System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param options Parameters for the operation. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The information of the uploaded pages. - * @throws IllegalArgumentException If {@code sourceUrl} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadPagesFromUrlWithResponse(PageBlobUploadPagesFromUrlOptions options, - Duration timeout, Context context) { - - Mono> response = pageBlobAsyncClient.uploadPagesFromUrlWithResponse(options, context); - return StorageImplUtils.blockWithOptionalTimeout(response, timeout); - } - - /** - * Frees the specified pages from the page blob. The size of the range must be a multiple of 512. For more - * information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     *
-     * PageBlobItem pageBlob = client.clearPages(pageRange);
-     *
-     * System.out.printf("Cleared page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @return The information of the cleared pages. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageBlobItem clearPages(PageRange pageRange) { - return clearPagesWithResponse(pageRange, null, null, Context.NONE).getValue(); - } - - /** - * Frees the specified pages from the page blob. The size of the range must be a multiple of 512. For more - * information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageRange pageRange = new PageRange()
-     *     .setStart(0)
-     *     .setEnd(511);
-     * PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId);
-     * Context context = new Context(key, value);
-     *
-     * PageBlobItem pageBlob = client
-     *     .clearPagesWithResponse(pageRange, pageBlobRequestConditions, timeout, context).getValue();
-     *
-     * System.out.printf("Cleared page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param pageRange A {@link PageRange} object. Given that pages must be aligned with 512-byte boundaries, the start - * offset must be a modulus of 512 and the end offset must be a modulus of 512 - 1. Examples of valid byte ranges - * are 0-511, 512-1023, etc. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param pageBlobRequestConditions {@link PageBlobRequestConditions} - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The information of the cleared pages. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response clearPagesWithResponse(PageRange pageRange, - PageBlobRequestConditions pageBlobRequestConditions, Duration timeout, Context context) { - PageBlobRequestConditions finalPageBlobRequestConditions - = pageBlobRequestConditions == null ? new PageBlobRequestConditions() : pageBlobRequestConditions; - if (pageRange == null) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError(new IllegalArgumentException("pageRange cannot be null.")); - } - String pageRangeStr = ModelHelper.pageRangeToString(pageRange); - Context finalContext = context == null ? Context.NONE : context; - Callable> operation = () -> this.azureBlobStorage.getPageBlobs() - .clearPagesWithResponse(containerName, blobName, 0, null, pageRangeStr, - finalPageBlobRequestConditions.getLeaseId(), - finalPageBlobRequestConditions.getIfSequenceNumberLessThanOrEqualTo(), - finalPageBlobRequestConditions.getIfSequenceNumberLessThan(), - finalPageBlobRequestConditions.getIfSequenceNumberEqualTo(), - finalPageBlobRequestConditions.getIfModifiedSince(), - finalPageBlobRequestConditions.getIfUnmodifiedSince(), finalPageBlobRequestConditions.getIfMatch(), - finalPageBlobRequestConditions.getIfNoneMatch(), finalPageBlobRequestConditions.getTagsConditions(), - null, getCustomerProvidedKey(), encryptionScope, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - PageBlobsClearPagesHeaders hd = response.getDeserializedHeaders(); - PageBlobItem item = new PageBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), null, hd.getXMsBlobSequenceNumber()); - return new SimpleResponse<>(response, item); - } - - /** - * Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * PageList pageList = client.getPageRanges(blobRange);
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * for (PageRange pageRange : pageList.getPageRange()) {
-     *     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     * }
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @return The information of the cleared pages. - * @deprecated See {@link #listPageRanges(BlobRange)} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public PageList getPageRanges(BlobRange blobRange) { - return getPageRangesWithResponse(blobRange, null, null, Context.NONE).getValue(); - } - - /** - * Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * Context context = new Context(key, value);
-     *
-     * PageList pageList = client
-     *     .getPageRangesWithResponse(blobRange, blobRequestConditions, timeout, context).getValue();
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * for (PageRange pageRange : pageList.getPageRange()) {
-     *     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     * }
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return All the page ranges. - * @deprecated See {@link #listPageRanges(ListPageRangesOptions,Duration,Context)} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public Response getPageRangesWithResponse(BlobRange blobRange, BlobRequestConditions requestConditions, - Duration timeout, Context context) { - BlobRange finalBlobRange = blobRange == null ? new BlobRange(0) : blobRange; - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation - = () -> this.azureBlobStorage.getPageBlobs() - .getPageRangesWithResponse(containerName, blobName, getSnapshotId(), null, - finalBlobRange.toHeaderValue(), finalRequestConditions.getLeaseId(), - finalRequestConditions.getIfModifiedSince(), finalRequestConditions.getIfUnmodifiedSince(), - finalRequestConditions.getIfMatch(), finalRequestConditions.getIfNoneMatch(), - finalRequestConditions.getTagsConditions(), null, null, null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - response.getValue()); - } - - /** - * Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * String prevSnapshot = "previous snapshot";
-     * PagedIterable<PageRangeItem> iterable = client.listPageRanges(blobRange);
-     *
-     * for (PageRangeItem item : iterable) {
-     *     System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(),
-     *         item.getRange().getLength(), item.isClear());
-     * }
-     * 
- * - * - * @param blobRange {@link BlobRange} - * - * @return A reactive response containing the information of the cleared pages. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedIterable listPageRanges(BlobRange blobRange) { - return listPageRanges(new ListPageRangesOptions(blobRange), null, null); - } - - /** - * Returns the list of valid page ranges for a page blob or snapshot of a page blob. For more information, see the - * Azure Docs. - * - *

Code Samples

- * - * - *
-     * ListPageRangesOptions options = new ListPageRangesOptions(new BlobRange(offset))
-     *     .setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId))
-     *     .setMaxResultsPerPage(1000);
-     *
-     * Context context = new Context(key, value);
-     *
-     * PagedIterable<PageRangeItem> iter = client
-     *     .listPageRanges(options, timeout, context);
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * for (PageRangeItem item : iter) {
-     *     System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(),
-     *         item.getRange().getLength(), item.isClear());
-     * }
-     * 
- * - * - * @param options {@link ListPageRangesOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A reactive response emitting all the page ranges. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedIterable listPageRanges(ListPageRangesOptions options, Duration timeout, - Context context) { - Objects.requireNonNull(options, "options must not be null"); - Context finalContext = context == null ? Context.NONE : context; - - // Helper function to retrieve a page of items - BiFunction> pageRetriever = (continuationToken, pageSize) -> { - BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - Integer finalPageSize = pageSize == null ? options.getMaxResultsPerPage() : pageSize; - - // Call the synchronous service method - Callable> operation - = () -> this.azureBlobStorage.getPageBlobs() - .getPageRangesWithResponse(containerName, blobName, getSnapshotId(), null, - options.getRange().toHeaderValue(), requestConditions.getLeaseId(), - requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), - requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), - requestConditions.getTagsConditions(), null, continuationToken, finalPageSize, finalContext); - - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - List value = parsePageRangeItems(response.getValue()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - value, PageListHelper.getNextMarker(response.getValue()), response.getDeserializedHeaders()); - }; - return new PagedIterable<>(pageSize -> pageRetriever.apply(null, pageSize), pageRetriever); - } - - private List parsePageRangeItems(PageList pageList) { - if (pageList == null) { - return Collections.emptyList(); - } - return Stream - .concat(pageList.getPageRange().stream().map(this::toPageBlobRange), - pageList.getClearRange().stream().map(this::toPageBlobRange)) - .collect(Collectors.toList()); - } - - private PageRangeItem toPageBlobRange(PageRange range) { - return new PageRangeItem(new HttpRange(range.getStart(), range.getEnd() - range.getStart() + 1), false); - } - - private PageRangeItem toPageBlobRange(ClearRange range) { - return new PageRangeItem(new HttpRange(range.getStart(), range.getEnd() - range.getStart() + 1), true); - } - - /** - * Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * final String prevSnapshot = "previous snapshot";
-     * PageList pageList = client.getPageRangesDiff(blobRange, prevSnapshot);
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * for (PageRange pageRange : pageList.getPageRange()) {
-     *     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     * }
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshot Specifies that the response will contain only pages that were changed between target blob and - * previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as - * long as the snapshot specified by prevsnapshot is the older of the two. - * @return All the different page ranges. - * @deprecated See {@link #listPageRangesDiff(BlobRange, String)} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public PageList getPageRangesDiff(BlobRange blobRange, String prevSnapshot) { - return getPageRangesDiffWithResponse(blobRange, prevSnapshot, null, null, Context.NONE).getValue(); - } - - /** - * This API only works for managed disk accounts. - *

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs.

- * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * final String prevSnapshot = "previous snapshot";
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * Context context = new Context(key, value);
-     *
-     * PageList pageList = client
-     *     .getPageRangesDiffWithResponse(blobRange, prevSnapshot, blobRequestConditions, timeout, context).getValue();
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * for (PageRange pageRange : pageList.getPageRange()) {
-     *     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     * }
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshot Specifies that the response will contain only pages that were changed between target blob and - * previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as - * long as the snapshot specified by prevsnapshot is the older of the two. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return All the different page ranges. - * @deprecated See {@link #listPageRanges(ListPageRangesOptions,Duration,Context)} )} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - @Deprecated - public Response getPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshot, - BlobRequestConditions requestConditions, Duration timeout, Context context) { - BlobRange finalBlobRange = blobRange == null ? new BlobRange(0) : blobRange; - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - if (prevSnapshot == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("prevSnapshot cannot be null")); - } - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation - = () -> this.azureBlobStorage.getPageBlobs() - .getPageRangesDiffWithResponse(containerName, blobName, getSnapshotId(), null, prevSnapshot, null, - finalBlobRange.toHeaderValue(), finalRequestConditions.getLeaseId(), - finalRequestConditions.getIfModifiedSince(), finalRequestConditions.getIfUnmodifiedSince(), - finalRequestConditions.getIfMatch(), finalRequestConditions.getIfNoneMatch(), - finalRequestConditions.getTagsConditions(), null, null, null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - response.getValue()); - } - - /** - * Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * String prevSnapshot = "previous snapshot";
-     * PagedIterable<PageRangeItem> iterable = client.listPageRangesDiff(blobRange, prevSnapshot);
-     *
-     * for (PageRangeItem item : iterable) {
-     *     System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(),
-     *         item.getRange().getLength(), item.isClear());
-     * }
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshot Specifies that the response will contain only pages that were changed between target blob and - * previous snapshot. Changed pages include both updated and cleared pages. The target blob may be a snapshot, as - * long as the snapshot specified by prevsnapshot is the older of the two. - * - * @return A reactive response emitting all the different page ranges. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedIterable listPageRangesDiff(BlobRange blobRange, String prevSnapshot) { - return listPageRangesDiff(new ListPageRangesDiffOptions(blobRange, prevSnapshot), null, null); - } - - /** - * Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * ListPageRangesDiffOptions options = new ListPageRangesDiffOptions(new BlobRange(offset), "previous snapshot")
-     *     .setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId))
-     *     .setMaxResultsPerPage(1000);
-     *
-     * Context context = new Context(key, value);
-     *
-     * PagedIterable<PageRangeItem> iter = client
-     *     .listPageRangesDiff(options, timeout, context);
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * for (PageRangeItem item : iter) {
-     *     System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(),
-     *         item.getRange().getLength(), item.isClear());
-     * }
-     * 
- * - * - * @param options {@link ListPageRangesDiffOptions}. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A reactive response emitting all the different page ranges. - * - * @throws IllegalArgumentException If {@code prevSnapshot} is {@code null} - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedIterable listPageRangesDiff(ListPageRangesDiffOptions options, Duration timeout, - Context context) { - Objects.requireNonNull(options, "options must not be null"); - Context finalContext = context == null ? Context.NONE : context; - - BiFunction> pageRetriever = (continuationToken, pageSize) -> { - BlobRequestConditions requestConditions - = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); - - // Dynamically use pageSize provided during the iteration if available - Integer finalPageSize = pageSize != null ? pageSize : options.getMaxResultsPerPage(); - - Callable> operation - = () -> this.azureBlobStorage.getPageBlobs() - .getPageRangesDiffWithResponse(containerName, blobName, getSnapshotId(), null, - options.getPreviousSnapshot(), null, options.getRange().toHeaderValue(), - requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), - requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), - requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, - continuationToken, finalPageSize, finalContext); - - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - List value = parsePageRangeItems(response.getValue()); - - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - value, PageListHelper.getNextMarker(response.getValue()), response.getDeserializedHeaders()); - }; - return new PagedIterable<>(pageSize -> pageRetriever.apply(null, pageSize), pageRetriever); - } - - /** - * This API only works for managed disk accounts. - *

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs.

- * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * final String prevSnapshotUrl = "previous snapshot url";
-     * PageList pageList = client.getPageRangesDiff(blobRange, prevSnapshotUrl);
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * for (PageRange pageRange : pageList.getPageRange()) {
-     *     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     * }
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshotUrl Specifies the URL of a previous snapshot of the target blob. Specifies that the - * response will contain only pages that were changed between target blob and previous snapshot. Changed pages - * include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by - * prevsnapshot is the older of the two. - * @return All the different page ranges. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageList getManagedDiskPageRangesDiff(BlobRange blobRange, String prevSnapshotUrl) { - return getManagedDiskPageRangesDiffWithResponse(blobRange, prevSnapshotUrl, null, null, Context.NONE) - .getValue(); - } - - /** - * This API only works for managed disk accounts. - *

Gets the collection of page ranges that differ between a specified snapshot and this page blob. For more - * information, see the Azure - * Docs.

- * - *

Code Samples

- * - * - *
-     * BlobRange blobRange = new BlobRange(offset);
-     * final String prevSnapshotUrl = "previous snapshot url";
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * Context context = new Context(key, value);
-     *
-     * PageList pageList = client
-     *     .getPageRangesDiffWithResponse(blobRange, prevSnapshotUrl, blobRequestConditions, timeout, context).getValue();
-     *
-     * System.out.println("Valid Page Ranges are:");
-     * for (PageRange pageRange : pageList.getPageRange()) {
-     *     System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd());
-     * }
-     * 
- * - * - * @param blobRange {@link BlobRange} - * @param prevSnapshotUrl Specifies the URL of a previous snapshot of the target blob. Specifies that the - * response will contain only pages that were changed between target blob and previous snapshot. Changed pages - * include both updated and cleared pages. The target blob may be a snapshot, as long as the snapshot specified by - * prevsnapshot is the older of the two. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return All the different page ranges. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getManagedDiskPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshotUrl, - BlobRequestConditions requestConditions, Duration timeout, Context context) { - BlobRange finalBlobRange = blobRange == null ? new BlobRange(0) : blobRange; - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - - if (prevSnapshotUrl == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("prevSnapshot cannot be null")); - } - try { - new URL(prevSnapshotUrl); - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'prevSnapshotUrl' is not a valid url.", ex)); - } - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation - = () -> this.azureBlobStorage.getPageBlobs() - .getPageRangesDiffWithResponse(containerName, blobName, getSnapshotId(), null, null, prevSnapshotUrl, - finalBlobRange.toHeaderValue(), finalRequestConditions.getLeaseId(), - finalRequestConditions.getIfModifiedSince(), finalRequestConditions.getIfUnmodifiedSince(), - finalRequestConditions.getIfMatch(), finalRequestConditions.getIfNoneMatch(), - finalRequestConditions.getTagsConditions(), null, null, null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - response.getValue()); - } - - /** - * Resizes the page blob to the specified size (which must be a multiple of 512). For more information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * PageBlobItem pageBlob = client.resize(size);
-     * System.out.printf("Page blob resized with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param size Resizes a page blob to the specified size. If the specified value is less than the current size of - * the blob, then all pages above the specified value are cleared. - * @return The resized page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageBlobItem resize(long size) { - return resizeWithResponse(size, null, null, Context.NONE).getValue(); - } - - /** - * Resizes the page blob to the specified size (which must be a multiple of 512). For more information, see the Azure Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * Context context = new Context(key, value);
-     *
-     * PageBlobItem pageBlob = client
-     *     .resizeWithResponse(size, blobRequestConditions, timeout, context).getValue();
-     * System.out.printf("Page blob resized with sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param size Resizes a page blob to the specified size. If the specified value is less than the current size of - * the blob, then all pages above the specified value are cleared. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The resized page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response resizeWithResponse(long size, BlobRequestConditions requestConditions, - Duration timeout, Context context) { - if (size % PAGE_BYTES != 0) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("size must be a multiple of PageBlobAsyncClient.PAGE_BYTES.")); - } - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation = () -> this.azureBlobStorage.getPageBlobs() - .resizeWithResponse(containerName, blobName, size, null, finalRequestConditions.getLeaseId(), - finalRequestConditions.getIfModifiedSince(), finalRequestConditions.getIfUnmodifiedSince(), - finalRequestConditions.getIfMatch(), finalRequestConditions.getIfNoneMatch(), - finalRequestConditions.getTagsConditions(), null, getCustomerProvidedKey(), encryptionScope, - finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - - PageBlobsResizeHeaders hd = response.getDeserializedHeaders(); - PageBlobItem item = new PageBlobItem(hd.getETag(), hd.getLastModified(), null, null, null, null, - hd.getXMsBlobSequenceNumber()); - return new SimpleResponse<>(response, item); - } - - /** - * Sets the page blob's sequence number. For more information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * PageBlobItem pageBlob = client.updateSequenceNumber(SequenceNumberActionType.INCREMENT, size);
-     *
-     * System.out.printf("Page blob updated to sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param action Indicates how the service should modify the blob's sequence number. - * @param sequenceNumber The blob's sequence number. The sequence number is a user-controlled property that you can - * use to track requests and manage concurrency issues. - * @return The updated page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PageBlobItem updateSequenceNumber(SequenceNumberActionType action, Long sequenceNumber) { - return updateSequenceNumberWithResponse(action, sequenceNumber, null, null, Context.NONE).getValue(); - } - - /** - * Sets the page blob's sequence number. For more information, see the Azure - * Docs. - * - *

Code Samples

- * - * - *
-     * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
-     * Context context = new Context(key, value);
-     *
-     * PageBlobItem pageBlob = client.updateSequenceNumberWithResponse(
-     *     SequenceNumberActionType.INCREMENT, size, blobRequestConditions, timeout, context).getValue();
-     *
-     * System.out.printf("Page blob updated to sequence number %s%n", pageBlob.getBlobSequenceNumber());
-     * 
- * - * - * @param action Indicates how the service should modify the blob's sequence number. - * @param sequenceNumber The blob's sequence number. The sequence number is a user-controlled property that you can - * use to track requests and manage concurrency issues. - * @param requestConditions {@link BlobRequestConditions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The updated page blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateSequenceNumberWithResponse(SequenceNumberActionType action, Long sequenceNumber, - BlobRequestConditions requestConditions, Duration timeout, Context context) { - if (sequenceNumber != null && sequenceNumber < 0) { - // Throwing is preferred to Single.error because this will error out immediately instead of waiting until - // subscription. - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("SequenceNumber must be greater than or equal to 0.")); - } - BlobRequestConditions finalRequestConditions - = requestConditions == null ? new BlobRequestConditions() : requestConditions; - Long finalSequenceNumber = action == SequenceNumberActionType.INCREMENT ? null : sequenceNumber; - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation - = () -> this.azureBlobStorage.getPageBlobs() - .updateSequenceNumberWithResponse(containerName, blobName, action, null, - finalRequestConditions.getLeaseId(), finalRequestConditions.getIfModifiedSince(), - finalRequestConditions.getIfUnmodifiedSince(), finalRequestConditions.getIfMatch(), - finalRequestConditions.getIfNoneMatch(), finalRequestConditions.getTagsConditions(), - finalSequenceNumber, null, finalContext); - - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - PageBlobsUpdateSequenceNumberHeaders hd = response.getDeserializedHeaders(); - PageBlobItem item = new PageBlobItem(hd.getETag(), hd.getLastModified(), null, null, null, null, - hd.getXMsBlobSequenceNumber()); - return new SimpleResponse<>(response, item); - } - - /** - * Begins an operation to start an incremental copy from one page blob's snapshot to this page blob. The snapshot is - * copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. For more information, see the Azure Docs here - * and - * here. - * - *

Code Samples

- * - * - *
-     * final String snapshot = "copy snapshot";
-     * CopyStatusType statusType = client.copyIncremental(url, snapshot);
-     *
-     * switch (statusType) {
-     *     case SUCCESS:
-     *         System.out.println("Page blob copied successfully");
-     *         break;
-     *     case FAILED:
-     *         System.out.println("Page blob copied failed");
-     *         break;
-     *     case ABORTED:
-     *         System.out.println("Page blob copied aborted");
-     *         break;
-     *     case PENDING:
-     *         System.out.println("Page blob copied pending");
-     *         break;
-     *     default:
-     *         break;
-     * }
-     * 
- * - * - * @param source The source page blob. - * @param snapshot The snapshot on the copy source. - * @return The copy status. - * @throws IllegalArgumentException If {@code source} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CopyStatusType copyIncremental(String source, String snapshot) { - return copyIncrementalWithResponse(source, snapshot, null, null, Context.NONE).getValue(); - } - - /** - * Begins an operation to start an incremental copy from one page blob's snapshot to this page blob. The snapshot is - * copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. For more information, see the Azure Docs here - * and - * here. - * - *

Code Samples

- * - * - *
-     * final String snapshot = "copy snapshot";
-     * RequestConditions modifiedRequestConditions = new RequestConditions()
-     *     .setIfNoneMatch("snapshotMatch");
-     * Context context = new Context(key, value);
-     *
-     * CopyStatusType statusType = client
-     *     .copyIncrementalWithResponse(url, snapshot, modifiedRequestConditions, timeout, context).getValue();
-     *
-     * switch (statusType) {
-     *     case SUCCESS:
-     *         System.out.println("Page blob copied successfully");
-     *         break;
-     *     case FAILED:
-     *         System.out.println("Page blob copied failed");
-     *         break;
-     *     case ABORTED:
-     *         System.out.println("Page blob copied aborted");
-     *         break;
-     *     case PENDING:
-     *         System.out.println("Page blob copied pending");
-     *         break;
-     *     default:
-     *         break;
-     * }
-     * 
- * - * - * @param source The source page blob. - * @param snapshot The snapshot on the copy source. - * @param modifiedRequestConditions Standard HTTP Access conditions related to the modification of data. ETag and - * LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given - * request. The request will fail if the specified condition is not satisfied. - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The copy status. - * @throws IllegalArgumentException If {@code source} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response copyIncrementalWithResponse(String source, String snapshot, - RequestConditions modifiedRequestConditions, Duration timeout, Context context) { - return copyIncrementalWithResponse(new PageBlobCopyIncrementalOptions(source, snapshot).setRequestConditions( - ModelHelper.populateBlobDestinationRequestConditions(modifiedRequestConditions)), timeout, context); - } - - /** - * Begins an operation to start an incremental copy from one page blob's snapshot to this page blob. The snapshot is - * copied such that only the differential changes between the previously copied snapshot are transferred to the - * destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as - * usual. For more information, see the Azure Docs here - * and - * here. - * - *

Code Samples

- * - * - *
-     * final String snapshot = "copy snapshot";
-     * PageBlobCopyIncrementalRequestConditions destinationRequestConditions = new PageBlobCopyIncrementalRequestConditions()
-     *     .setIfNoneMatch("snapshotMatch");
-     * Context context = new Context(key, value);
-     *
-     * CopyStatusType statusType = client
-     *     .copyIncrementalWithResponse(new PageBlobCopyIncrementalOptions(url, snapshot)
-     *         .setRequestConditions(destinationRequestConditions), timeout, context).getValue();
-     *
-     * switch (statusType) {
-     *     case SUCCESS:
-     *         System.out.println("Page blob copied successfully");
-     *         break;
-     *     case FAILED:
-     *         System.out.println("Page blob copied failed");
-     *         break;
-     *     case ABORTED:
-     *         System.out.println("Page blob copied aborted");
-     *         break;
-     *     case PENDING:
-     *         System.out.println("Page blob copied pending");
-     *         break;
-     *     default:
-     *         break;
-     * }
-     * 
- * - * - * @param options {@link PageBlobCopyIncrementalOptions} - * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return The copy status. - * @throws IllegalArgumentException If {@code source} is a malformed {@link URL}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response copyIncrementalWithResponse(PageBlobCopyIncrementalOptions options, - Duration timeout, Context context) { - StorageImplUtils.assertNotNull("options", options); - UrlBuilder builder = UrlBuilder.parse(options.getSource()); - builder.setQueryParameter(Constants.UrlConstants.SNAPSHOT_QUERY_PARAMETER, options.getSnapshot()); - PageBlobCopyIncrementalRequestConditions modifiedRequestConditions = (options.getRequestConditions() == null) - ? new PageBlobCopyIncrementalRequestConditions() - : options.getRequestConditions(); - - try { - builder.toUrl(); - } catch (MalformedURLException e) { - // We are parsing a valid url and adding a query parameter. If this fails, we can't recover. - throw LOGGER.logExceptionAsError(new IllegalArgumentException(e)); - } - Context finalContext = context == null ? Context.NONE : context; - - Callable> operation - = () -> this.azureBlobStorage.getPageBlobs() - .copyIncrementalWithResponse(containerName, blobName, builder.toString(), null, - modifiedRequestConditions.getIfModifiedSince(), modifiedRequestConditions.getIfUnmodifiedSince(), - modifiedRequestConditions.getIfMatch(), modifiedRequestConditions.getIfNoneMatch(), - modifiedRequestConditions.getTagsConditions(), null, finalContext); - ResponseBase response - = sendRequest(operation, timeout, BlobStorageException.class); - return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsCopyStatus()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/ReliableDownload.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/ReliableDownload.java deleted file mode 100644 index 884b49b22af2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/ReliableDownload.java +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.rest.StreamResponse; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.HttpGetterInfo; -import com.azure.storage.blob.implementation.models.BlobsDownloadHeaders; -import com.azure.storage.blob.implementation.util.ModelHelper; -import com.azure.storage.blob.models.BlobDownloadHeaders; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.common.implementation.StorageImplUtils; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.concurrent.TimeoutException; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.function.Supplier; - -/** - * This class automatically retries failed reads from a blob download stream. - * - *

- * Failed downloads are automatically retried based on the {@link DownloadRetryOptions download options}, the retry - * will be resumed from the point where the download failed. This allows for the download to be consumed as one - * continuous stream. - *

- * @deprecated use {@link com.azure.core.util.FluxUtil#createRetriableDownloadFlux(Supplier, BiFunction, int)} instead. - */ -@Deprecated -final class ReliableDownload { - private static final ClientLogger LOGGER = new ClientLogger(ReliableDownload.class); - - private final StreamResponse rawResponse; - private final BlobsDownloadHeaders deserializedHeaders; - private final DownloadRetryOptions options; - private final HttpGetterInfo info; - private final Function> getter; - - ReliableDownload(StreamResponse rawResponse, DownloadRetryOptions options, HttpGetterInfo info, - Function> getter) { - StorageImplUtils.assertNotNull("getter", getter); - StorageImplUtils.assertNotNull("info", info); - // Note: We do not check for eTag since it is possible for the service to not return the etag on large downloads. - - this.rawResponse = rawResponse; - this.deserializedHeaders = ModelHelper.transformBlobDownloadHeaders(rawResponse.getHeaders()); - this.options = (options == null) ? new DownloadRetryOptions() : options; - this.info = info; - this.getter = getter; - /* - If the customer did not specify a count, they are reading to the end of the blob. Extract this value - from the response for better book-keeping towards the end. - */ - if (this.info.getCount() == null) { - long blobLength = ModelHelper.getBlobLength(ModelHelper.populateBlobDownloadHeaders(deserializedHeaders, - ModelHelper.getErrorCode(rawResponse.getHeaders()))); - info.setCount(blobLength - info.getOffset()); - } - } - - HttpRequest getRequest() { - return rawResponse.getRequest(); - } - - int getStatusCode() { - return rawResponse.getStatusCode(); - } - - HttpHeaders getHeaders() { - return rawResponse.getHeaders(); - } - - BlobDownloadHeaders getDeserializedHeaders() { - return ModelHelper.populateBlobDownloadHeaders(deserializedHeaders, - ModelHelper.getErrorCode(rawResponse.getHeaders())); - } - - Flux getValue() { - /* - We pass -1 for currentRetryCount because we want tryContinueFlux to receive a value of 0 for number of - retries as we have not actually retried yet, only made the initial try. Because applyReliableDownload() will - add 1 before calling into tryContinueFlux, we set the initial value to -1. - */ - Flux value = (options.getMaxRetryRequests() == 0) - ? rawResponse.getValue() - : applyReliableDownload(rawResponse.getValue(), -1, options); - - return value.switchIfEmpty(Flux.defer(() -> Flux.just(ByteBuffer.wrap(new byte[0])))); - } - - private Flux tryContinueFlux(Throwable t, int retryCount, DownloadRetryOptions options) { - // If all the errors are exhausted or the error is not retryable, return this error to the user. - if (retryCount >= options.getMaxRetryRequests() - || !(t instanceof IOException || t instanceof TimeoutException)) { - return Flux.error(t); - } else { - /* - We wrap this in a try catch because we don't know the behavior of the getter. Most errors would probably - come from an unsuccessful request, which would be propagated through the onError methods. However, it is - possible the method call that returns a Single is what throws (like how our apis throw some exceptions at - call time rather than at subscription time. - */ - try { - /*Get a new stream from the new response and try reading from it. - Do not compound the number of retries by calling getValue on the DownloadResponse; just get - the raw body. - */ - return getter.apply(info) - .flatMapMany( - newResponse -> applyReliableDownload(newResponse.rawResponse.getValue(), retryCount, options)); - } catch (Exception e) { - // If the getter fails, return the getter failure to the user. - return Flux.error(e); - } - } - } - - private Flux applyReliableDownload(Flux data, int currentRetryCount, - DownloadRetryOptions options) { - return data.doOnNext(buffer -> { - /* - Update how much data we have received in case we need to retry and propagate to the user the data we - have received. - */ - this.info.setOffset(this.info.getOffset() + buffer.remaining()); - if (this.info.getCount() != null) { - this.info.setCount(this.info.getCount() - buffer.remaining()); - } - }).onErrorResume(t2 -> { - /* - It is possible that the network stream will throw an error after emitting all data but before - completing. Issuing a retry at this stage would leave the download in a bad state with incorrect count - and offset values. Because we have read the intended amount of data, we can ignore the error at the end - of the stream. - */ - if (this.info.getCount() != null && this.info.getCount() == 0) { - LOGGER.warning("Exception encountered in ReliableDownload after all data read from the network but " - + "but before stream signaled completion. Returning success as all data was downloaded. " - + "Exception message: " + t2.getMessage()); - return Flux.empty(); - } - // Increment the retry count and try again with the new exception. - return tryContinueFlux(t2, currentRetryCount + 1, options); - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/SpecializedBlobClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/SpecializedBlobClientBuilder.java deleted file mode 100644 index 50fea2ae1bd3..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/SpecializedBlobClientBuilder.java +++ /dev/null @@ -1,773 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.AzureNamedKeyCredentialTrait; -import com.azure.core.client.traits.AzureSasCredentialTrait; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.ConnectionStringTrait; -import com.azure.core.client.traits.EndpointTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.client.traits.TokenCredentialTrait; -import com.azure.core.credential.AzureNamedKeyCredential; -import com.azure.core.credential.AzureSasCredential; -import com.azure.core.credential.TokenCredential; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.HttpClientOptions; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobContainerAsyncClient; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobUrlParts; -import com.azure.storage.blob.implementation.models.EncryptionScope; -import com.azure.storage.blob.implementation.util.BuilderHelper; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.connectionstring.StorageAuthenticationSettings; -import com.azure.storage.common.implementation.connectionstring.StorageConnectionString; -import com.azure.storage.common.implementation.connectionstring.StorageEndpoint; -import com.azure.storage.common.policy.RequestRetryOptions; -import reactor.core.publisher.Flux; - -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * This class provides a fluent builder API to help aid the configuration and instantiation of specialized Storage Blob - * clients, {@link AppendBlobClient}, {@link AppendBlobAsyncClient}, {@link BlockBlobClient}, - * {@link BlockBlobAsyncClient}, {@link PageBlobClient}, and {@link PageBlobAsyncClient}. These clients are used to - * perform operations that are specific to the blob type. - * - * @see AppendBlobClient - * @see AppendBlobAsyncClient - * @see BlockBlobClient - * @see BlockBlobAsyncClient - * @see PageBlobClient - * @see PageBlobAsyncClient - */ -@ServiceClientBuilder( - serviceClients = { - AppendBlobClient.class, - AppendBlobAsyncClient.class, - BlockBlobClient.class, - BlockBlobAsyncClient.class, - PageBlobClient.class, - PageBlobAsyncClient.class }) -public final class SpecializedBlobClientBuilder implements TokenCredentialTrait, - ConnectionStringTrait, AzureNamedKeyCredentialTrait, - AzureSasCredentialTrait, HttpTrait, - ConfigurationTrait, EndpointTrait { - private static final ClientLogger LOGGER = new ClientLogger(SpecializedBlobClientBuilder.class); - - private String endpoint; - private String accountName; - private String containerName; - private String blobName; - private String snapshot; - private String versionId; - - private CpkInfo customerProvidedKey; - private EncryptionScope encryptionScope; - private StorageSharedKeyCredential storageSharedKeyCredential; - private TokenCredential tokenCredential; - private AzureSasCredential azureSasCredential; - private String sasToken; - - private HttpClient httpClient; - private final List perCallPolicies = new ArrayList<>(); - private final List perRetryPolicies = new ArrayList<>(); - private HttpLogOptions logOptions = getDefaultHttpLogOptions(); - private RequestRetryOptions retryOptions; - private RetryOptions coreRetryOptions; - private HttpPipeline httpPipeline; - - private ClientOptions clientOptions = new ClientOptions(); - private Configuration configuration; - private BlobServiceVersion version; - private BlobAudience audience; - - /** - * Creates a new instance of {@link SpecializedBlobClientBuilder}. - */ - public SpecializedBlobClientBuilder() { - } - - /** - * Creates a {@link AppendBlobClient} based on options set in the Builder. AppendBlobClients are used to perform - * append blob specific operations such as {@link AppendBlobClient#appendBlock(InputStream, long) append block}, - * only use this when the blob is known to be an append blob. - * - * @return a {@link AppendBlobClient} created from the configurations in this builder. - * @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}. - * @throws IllegalStateException If multiple credentials have been specified. - */ - public AppendBlobClient buildAppendBlobClient() { - return new AppendBlobClient(buildAppendBlobAsyncClient()); - } - - /** - * Creates a {@link AppendBlobAsyncClient} based on options set in the Builder. AppendBlobAsyncClients are used to - * perform append blob specific operations such as {@link AppendBlobAsyncClient#appendBlock(Flux, long) append - * blob}, only use this when the blob is known to be an append blob. - * - * @return a {@link AppendBlobAsyncClient} created from the configurations in this builder. - * @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}. - * @throws IllegalStateException If multiple credentials have been specified. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryOptions(RequestRetryOptions)} have been set. - */ - public AppendBlobAsyncClient buildAppendBlobAsyncClient() { - validateConstruction(); - String containerName = getContainerName(); - - return new AppendBlobAsyncClient(getHttpPipeline(), endpoint, getServiceVersion(), accountName, containerName, - blobName, snapshot, customerProvidedKey, encryptionScope, versionId); - } - - /** - * Creates a {@link BlockBlobClient} based on options set in the Builder. BlockBlobClients are used to perform - * generic upload operations such as {@link BlockBlobClient#upload(InputStream, long) upload from file} and block - * blob specific operations such as {@link BlockBlobClient#stageBlock(String, InputStream, long) stage block} and - * {@link BlockBlobClient#commitBlockList(List)}, only use this when the blob is known to be a block blob. - * - * @return a {@link BlockBlobClient} created from the configurations in this builder. - * @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}. - * @throws IllegalStateException If multiple credentials have been specified. - */ - public BlockBlobClient buildBlockBlobClient() { - return new BlockBlobClient(buildBlockBlobAsyncClient()); - } - - /** - * Creates a {@link BlockBlobAsyncClient} based on options set in the Builder. BlockBlobAsyncClients are used to - * perform generic upload operations such as {@link BlockBlobAsyncClient#upload(Flux, long) upload from file} - * and block blob specific operations such as {@link BlockBlobAsyncClient#stageBlockWithResponse(String, Flux, long, - * byte[], String) stage block} and {@link BlockBlobAsyncClient#commitBlockList(List) commit block list}, only use - * this when the blob is known to be a block blob. - * - * @return a {@link BlockBlobAsyncClient} created from the configurations in this builder. - * @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}. - * @throws IllegalStateException If multiple credentials have been specified. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryOptions(RequestRetryOptions)} have been set. - */ - public BlockBlobAsyncClient buildBlockBlobAsyncClient() { - validateConstruction(); - String containerName = getContainerName(); - - return new BlockBlobAsyncClient(getHttpPipeline(), endpoint, getServiceVersion(), accountName, containerName, - blobName, snapshot, customerProvidedKey, encryptionScope, versionId); - } - - /** - * Creates a {@link PageBlobClient} based on options set in the Builder. PageBlobClients are used to perform page - * blob specific operations such as {@link PageBlobClient#uploadPages(PageRange, InputStream) upload pages} and - * {@link PageBlobClient#clearPages(PageRange) clear pages}, only use this when the blob is known to be a page - * blob. - * - * @return a {@link PageBlobClient} created from the configurations in this builder. - * @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}. - * @throws IllegalStateException If multiple credentials have been specified. - */ - public PageBlobClient buildPageBlobClient() { - return new PageBlobClient(buildPageBlobAsyncClient()); - } - - /** - * Creates a {@link PageBlobAsyncClient} based on options set in the Builder. PageBlobAsyncClients are used to - * perform page blob specific operations such as {@link PageBlobAsyncClient#uploadPages(PageRange, Flux) upload - * pages} and {@link PageBlobAsyncClient#clearPages(PageRange) clear pages}, only use this when the blob is known to - * be a page blob. - * - * @return a {@link PageBlobAsyncClient} created from the configurations in this builder. - * @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}. - * @throws IllegalStateException If multiple credentials have been specified. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryOptions(RequestRetryOptions)} have been set. - */ - public PageBlobAsyncClient buildPageBlobAsyncClient() { - validateConstruction(); - String containerName = getContainerName(); - - return new PageBlobAsyncClient(getHttpPipeline(), endpoint, getServiceVersion(), accountName, containerName, - blobName, snapshot, customerProvidedKey, encryptionScope, versionId); - } - - /* - * Validate that the builder is able to construct a client. - */ - private void validateConstruction() { - Objects.requireNonNull(blobName, "'blobName' cannot be null."); - Objects.requireNonNull(endpoint, "'endpoint' cannot be null"); - - BuilderHelper.httpsValidation(customerProvidedKey, "customer provided key", endpoint, LOGGER); - - if (Objects.nonNull(customerProvidedKey) && Objects.nonNull(encryptionScope)) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("Customer provided key and encryption" + "scope cannot both be set")); - } - } - - /* - * Gets the container name to use in this client, if no container name has been passed the root container will be - * used. - * - * Implicit and explicit root container access are functionally equivalent, but explicit references are easier to - * read and debug. - */ - private String getContainerName() { - return CoreUtils.isNullOrEmpty(containerName) ? BlobContainerAsyncClient.ROOT_CONTAINER_NAME : containerName; - } - - private HttpPipeline getHttpPipeline() { - return (httpPipeline != null) - ? httpPipeline - : BuilderHelper.buildPipeline(storageSharedKeyCredential, tokenCredential, azureSasCredential, sasToken, - endpoint, retryOptions, coreRetryOptions, logOptions, clientOptions, httpClient, perCallPolicies, - perRetryPolicies, configuration, audience, LOGGER); - } - - private BlobServiceVersion getServiceVersion() { - return (version != null) ? version : BlobServiceVersion.getLatest(); - } - - /** - * Configures the builder based on the {@link BlobClientBase}. - * - * @param blobClient The {@code BlobClientBase} used to configure this builder. - * @return the updated SpecializedBlobClientBuilder object. - */ - public SpecializedBlobClientBuilder blobClient(BlobClientBase blobClient) { - pipeline(blobClient.getHttpPipeline()); - endpoint(blobClient.getBlobUrl()); - serviceVersion(blobClient.getServiceVersion()); - this.snapshot = blobClient.getSnapshotId(); - this.versionId = blobClient.getVersionId(); - this.customerProvidedKey = blobClient.getCustomerProvidedKey(); - if (blobClient.getEncryptionScope() != null) { - this.encryptionScope = new EncryptionScope().setEncryptionScope(blobClient.getEncryptionScope()); - } - return this; - } - - /** - * Configures the builder based on the {@link BlobAsyncClientBase}. - * - * @param blobAsyncClient The {@code BlobAsyncClientBase} used to configure this builder. - * @return the updated SpecializedBlobClientBuilder object. - */ - public SpecializedBlobClientBuilder blobAsyncClient(BlobAsyncClientBase blobAsyncClient) { - pipeline(blobAsyncClient.getHttpPipeline()); - endpoint(blobAsyncClient.getBlobUrl()); - serviceVersion(blobAsyncClient.getServiceVersion()); - this.snapshot = blobAsyncClient.getSnapshotId(); - this.versionId = blobAsyncClient.getVersionId(); - this.customerProvidedKey = blobAsyncClient.getCustomerProvidedKey(); - if (blobAsyncClient.getEncryptionScope() != null) { - this.encryptionScope = new EncryptionScope().setEncryptionScope(blobAsyncClient.getEncryptionScope()); - } - return this; - } - - /** - * Configures the builder based on the {@link BlobContainerClient} and appends the blob name to the container's URL. - * - * @param blobContainerClient The {@code ContainerClient} used to configure this builder. - * @param blobName Name of the blob. - * @return the updated SpecializedBlobClientBuilder object. - */ - public SpecializedBlobClientBuilder containerClient(BlobContainerClient blobContainerClient, String blobName) { - pipeline(blobContainerClient.getHttpPipeline()); - endpoint(blobContainerClient.getBlobContainerUrl()); - serviceVersion(blobContainerClient.getServiceVersion()); - blobName(blobName); - this.customerProvidedKey = blobContainerClient.getCustomerProvidedKey(); - if (blobContainerClient.getEncryptionScope() != null) { - this.encryptionScope = new EncryptionScope().setEncryptionScope(blobContainerClient.getEncryptionScope()); - } - return this; - } - - /** - * Configures the builder based on the {@link BlobContainerAsyncClient} and appends the blob name to the container's - * URL. - * - * @param blobContainerAsyncClient The {@code ContainerAsyncClient} used to configure this builder. - * @param blobName Name of the blob. - * @return the updated SpecializedBlobClientBuilder object. - */ - public SpecializedBlobClientBuilder containerAsyncClient(BlobContainerAsyncClient blobContainerAsyncClient, - String blobName) { - pipeline(blobContainerAsyncClient.getHttpPipeline()); - endpoint(blobContainerAsyncClient.getBlobContainerUrl()); - serviceVersion(blobContainerAsyncClient.getServiceVersion()); - blobName(blobName); - this.customerProvidedKey = blobContainerAsyncClient.getCustomerProvidedKey(); - if (blobContainerAsyncClient.getEncryptionScope() != null) { - this.encryptionScope - = new EncryptionScope().setEncryptionScope(blobContainerAsyncClient.getEncryptionScope()); - } - return this; - } - - /** - * Sets the service endpoint, additionally parses it for information (SAS token, container name, blob name) - * - * @param endpoint URL of the service - * @return the updated SpecializedBlobClientBuilder object - * @throws IllegalArgumentException If {@code endpoint} is {@code null} or is a malformed URL. - */ - @Override - public SpecializedBlobClientBuilder endpoint(String endpoint) { - try { - URL url = new URL(endpoint); - BlobUrlParts parts = BlobUrlParts.parse(url); - - this.accountName = parts.getAccountName(); - this.endpoint = BuilderHelper.getEndpoint(parts); - this.containerName - = parts.getBlobContainerName() == null ? this.containerName : parts.getBlobContainerName(); - this.blobName = parts.getBlobName() == null ? this.blobName : parts.getBlobName(); - this.snapshot = parts.getSnapshot(); - this.versionId = parts.getVersionId(); - - String sasToken = parts.getCommonSasQueryParameters().encode(); - if (!CoreUtils.isNullOrEmpty(sasToken)) { - this.sasToken(sasToken); - } - } catch (MalformedURLException ex) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("The Azure Storage Blob endpoint url is malformed.", ex)); - } - return this; - } - - /** - * Sets the {@link CustomerProvidedKey customer provided key} that is used to encrypt blob contents on the server. - * - * @param customerProvidedKey Customer provided key containing the encryption key information. - * @return the updated SpecializedBlobClientBuilder object - */ - public SpecializedBlobClientBuilder customerProvidedKey(CustomerProvidedKey customerProvidedKey) { - if (customerProvidedKey == null) { - this.customerProvidedKey = null; - } else { - this.customerProvidedKey = new CpkInfo().setEncryptionKey(customerProvidedKey.getKey()) - .setEncryptionKeySha256(customerProvidedKey.getKeySha256()) - .setEncryptionAlgorithm(customerProvidedKey.getEncryptionAlgorithm()); - } - - return this; - } - - /** - * Sets the {@code encryption scope} that is used to encrypt blob contents on the server. - * - * @param encryptionScope Encryption scope containing the encryption key information. - * @return the updated BlobClientBuilder object - */ - public SpecializedBlobClientBuilder encryptionScope(String encryptionScope) { - if (encryptionScope == null) { - this.encryptionScope = null; - } else { - this.encryptionScope = new EncryptionScope().setEncryptionScope(encryptionScope); - } - - return this; - } - - /** - * Sets the {@link StorageSharedKeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link StorageSharedKeyCredential}. - * @return the updated SpecializedBlobClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - public SpecializedBlobClientBuilder credential(StorageSharedKeyCredential credential) { - this.storageSharedKeyCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - this.tokenCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the {@link AzureNamedKeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link AzureNamedKeyCredential}. - * @return the updated SpecializedBlobClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public SpecializedBlobClientBuilder credential(AzureNamedKeyCredential credential) { - Objects.requireNonNull(credential, "'credential' cannot be null."); - return credential(StorageSharedKeyCredential.fromAzureNamedKeyCredential(credential)); - } - - /** - * Sets the {@link TokenCredential} used to authorize requests sent to the service. Refer to the Azure SDK for Java - * identity and authentication - * documentation for more details on proper usage of the {@link TokenCredential} type. - * - * @param credential {@link TokenCredential} used to authorize requests sent to the service. - * @return the updated SpecializedBlobClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public SpecializedBlobClientBuilder credential(TokenCredential credential) { - this.tokenCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - this.storageSharedKeyCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the SAS token used to authorize requests sent to the service. - * - * @param sasToken The SAS token to use for authenticating requests. This string should only be the query parameters - * (with or without a leading '?') and not a full url. - * @return the updated SpecializedBlobClientBuilder - * @throws NullPointerException If {@code sasToken} is {@code null}. - */ - public SpecializedBlobClientBuilder sasToken(String sasToken) { - this.sasToken = Objects.requireNonNull(sasToken, "'sasToken' cannot be null."); - this.storageSharedKeyCredential = null; - this.tokenCredential = null; - return this; - } - - /** - * Sets the {@link AzureSasCredential} used to authorize requests sent to the service. - * - * @param credential {@link AzureSasCredential} used to authorize requests sent to the service. - * @return the updated SpecializedBlobClientBuilder - * @throws NullPointerException If {@code credential} is {@code null}. - */ - @Override - public SpecializedBlobClientBuilder credential(AzureSasCredential credential) { - this.azureSasCredential = Objects.requireNonNull(credential, "'credential' cannot be null."); - return this; - } - - /** - * Clears the credential used to authorize the request. - * - *

This is for blobs that are publicly accessible.

- * - * @return the updated SpecializedBlobClientBuilder - */ - public SpecializedBlobClientBuilder setAnonymousAccess() { - this.storageSharedKeyCredential = null; - this.tokenCredential = null; - this.azureSasCredential = null; - this.sasToken = null; - return this; - } - - /** - * Sets the connection string to connect to the service. - * - * @param connectionString Connection string of the storage account. - * @return the updated SpecializedBlobClientBuilder - * @throws IllegalArgumentException If {@code connectionString} in invalid. - */ - @Override - public SpecializedBlobClientBuilder connectionString(String connectionString) { - StorageConnectionString storageConnectionString = StorageConnectionString.create(connectionString, LOGGER); - StorageEndpoint endpoint = storageConnectionString.getBlobEndpoint(); - if (endpoint == null || endpoint.getPrimaryUri() == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException( - "connectionString missing required settings to derive blob service endpoint.")); - } - this.endpoint(endpoint.getPrimaryUri()); - if (storageConnectionString.getAccountName() != null) { - this.accountName = storageConnectionString.getAccountName(); - } - StorageAuthenticationSettings authSettings = storageConnectionString.getStorageAuthSettings(); - if (authSettings.getType() == StorageAuthenticationSettings.Type.ACCOUNT_NAME_KEY) { - this.credential(new StorageSharedKeyCredential(authSettings.getAccount().getName(), - authSettings.getAccount().getAccessKey())); - } else if (authSettings.getType() == StorageAuthenticationSettings.Type.SAS_TOKEN) { - this.sasToken(authSettings.getSasToken()); - } - return this; - } - - /** - * Sets the name of the container that contains the blob. - * - *

Code Samples

- * - * - *
-     * BlobClient client = new BlobClientBuilder()
-     *     .endpoint(endpoint)
-     *     .containerName(containerName)
-     *     .buildClient();
-     * 
- * - * - * @param containerName Name of the container. If the value {@code null} or empty the root container, {@code $root}, - * will be used. - * @return the updated SpecializedBlobClientBuilder object - */ - public SpecializedBlobClientBuilder containerName(String containerName) { - this.containerName = containerName; - return this; - } - - /** - * Sets the name of the blob. - * - * @param blobName Name of the blob. - * @return the updated SpecializedBlobClientBuilder object - * @throws NullPointerException If {@code blobName} is {@code null} - */ - public SpecializedBlobClientBuilder blobName(String blobName) { - this.blobName = Objects.requireNonNull(blobName, "'blobName' cannot be null."); - return this; - } - - /** - * Sets the snapshot identifier of the blob. - * - * @param snapshot Snapshot identifier for the blob. - * @return the updated SpecializedBlobClientBuilder object - */ - public SpecializedBlobClientBuilder snapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - /** - * Sets the version identifier of the blob. - * - * @param versionId Version identifier for the blob, pass {@code null} to interact with the latest blob version. - * @return the updated SpecializedBlobClientBuilder object - */ - public SpecializedBlobClientBuilder versionId(String versionId) { - this.versionId = versionId; - return this; - } - - /** - * Sets the {@link HttpClient} to use for sending and receiving requests to and from the service. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param httpClient The {@link HttpClient} to use for requests. - * @return the updated SpecializedBlobClientBuilder object - */ - @Override - public SpecializedBlobClientBuilder httpClient(HttpClient httpClient) { - if (this.httpClient != null && httpClient == null) { - LOGGER.info("'httpClient' is being set to 'null' when it was previously configured."); - } - - this.httpClient = httpClient; - return this; - } - - /** - * Adds a {@link HttpPipelinePolicy pipeline policy} to apply on each request sent. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param pipelinePolicy A {@link HttpPipelinePolicy pipeline policy}. - * @return the updated SpecializedBlobClientBuilder object - * @throws NullPointerException If {@code pipelinePolicy} is {@code null}. - */ - @Override - public SpecializedBlobClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) { - Objects.requireNonNull(pipelinePolicy, "'pipelinePolicy' cannot be null"); - if (pipelinePolicy.getPipelinePosition() == HttpPipelinePosition.PER_CALL) { - perCallPolicies.add(pipelinePolicy); - } else { - perRetryPolicies.add(pipelinePolicy); - } - return this; - } - - /** - * Sets the {@link HttpLogOptions logging configuration} to use when sending and receiving requests to and from - * the service. If a {@code logLevel} is not provided, default value of {@link HttpLogDetailLevel#NONE} is set. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param logOptions The {@link HttpLogOptions logging configuration} to use when sending and receiving requests to - * and from the service. - * @return the updated SpecializedBlobClientBuilder object - * @throws NullPointerException If {@code logOptions} is {@code null}. - */ - @Override - public SpecializedBlobClientBuilder httpLogOptions(HttpLogOptions logOptions) { - this.logOptions = Objects.requireNonNull(logOptions, "'logOptions' cannot be null."); - return this; - } - - /** - * Gets the default Storage allowlist log headers and query parameters. - * - * @return the default http log options. - */ - public static HttpLogOptions getDefaultHttpLogOptions() { - return BuilderHelper.getDefaultHttpLogOptions(); - } - - /** - * Sets the configuration object used to retrieve environment configuration values during building of the client. - * - * @param configuration Configuration store used to retrieve environment configurations. - * @return the updated SpecializedBlobClientBuilder object - */ - @Override - public SpecializedBlobClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /** - * Sets the request retry options for all the requests made through the client. - * - * Setting this is mutually exclusive with using {@link #retryOptions(RetryOptions)}. - * - * @param retryOptions {@link RequestRetryOptions}. - * @return the updated SpecializedBlobClientBuilder object - */ - public SpecializedBlobClientBuilder retryOptions(RequestRetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * Sets the {@link RetryOptions} for all the requests made through the client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * Setting this is mutually exclusive with using {@link #retryOptions(RequestRetryOptions)}. - * Consider using {@link #retryOptions(RequestRetryOptions)} to also set storage specific options. - * - * @param retryOptions The {@link RetryOptions} to use for all the requests made through the client. - * @return the updated SpecializedBlobClientBuilder object - */ - @Override - public SpecializedBlobClientBuilder retryOptions(RetryOptions retryOptions) { - this.coreRetryOptions = retryOptions; - return this; - } - - /** - * Sets the {@link HttpPipeline} to use for the service client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * The {@link #endpoint(String) endpoint} is not ignored when {@code pipeline} is set. - * - * @param httpPipeline {@link HttpPipeline} to use for sending service requests and receiving responses. - * @return the updated SpecializedBlobClientBuilder object - */ - @Override - public SpecializedBlobClientBuilder pipeline(HttpPipeline httpPipeline) { - if (this.httpPipeline != null && httpPipeline == null) { - LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured."); - } - - this.httpPipeline = httpPipeline; - return this; - } - - /** - * Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is - * recommended that this method be called with an instance of the {@link HttpClientOptions} - * class (a subclass of the {@link ClientOptions} base class). The HttpClientOptions subclass provides more - * configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait - * interface. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param clientOptions A configured instance of {@link HttpClientOptions}. - * @see HttpClientOptions - * @return the updated SpecializedBlobClientBuilder object - * @throws NullPointerException If {@code clientOptions} is {@code null}. - */ - @Override - public SpecializedBlobClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = Objects.requireNonNull(clientOptions, "'clientOptions' cannot be null."); - return this; - } - - /** - * Sets the {@link BlobServiceVersion} that is used when making API requests. - *

- * If a service version is not provided, the service version that will be used will be the latest known service - * version based on the version of the client library being used. If no service version is specified, updating to a - * newer version of the client library will have the result of potentially moving to a newer service version. - *

- * Targeting a specific service version may also mean that the service will return an error for newer APIs. - * - * @param version {@link BlobServiceVersion} of the service to be used when making requests. - * @return the updated SpecializedBlobClientBuilder object - */ - public SpecializedBlobClientBuilder serviceVersion(BlobServiceVersion version) { - this.version = version; - return this; - } - - /** - * Sets the Audience to use for authentication with Azure Active Directory (AAD). The audience is not considered - * when using a shared key. - * @param audience {@link BlobAudience} to be used when requesting a token from Azure Active Directory (AAD). - * @return the updated SpecializedBlobClientBuilder object - */ - public SpecializedBlobClientBuilder audience(BlobAudience audience) { - this.audience = audience; - return this; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlobReadBehavior.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlobReadBehavior.java deleted file mode 100644 index 840dd6dda6be..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlobReadBehavior.java +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.util.CoreUtils; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.util.ByteBufferBackedOutputStreamUtil; -import com.azure.storage.blob.models.BlobDownloadResponse; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.common.implementation.StorageSeekableByteChannel; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.Objects; - -class StorageSeekableByteChannelBlobReadBehavior implements StorageSeekableByteChannel.ReadBehavior { - private static final ClientLogger LOGGER = new ClientLogger(StorageSeekableByteChannelBlobReadBehavior.class); - - private final BlobClientBase client; - private final BlobRequestConditions requestConditions; - - private long resourceLength; - - private ByteBuffer initialBuffer; - private Long initialBufferPosition; - - /** - * Constructs new read behavior for a target blob. Blob clients return blob properties with the channel. They do - * this by fetching an initial range upfront and getting the properties off the response. This class allows that - * range to be cached for an initial call to {@link #read(ByteBuffer, long)} from the - * {@link StorageSeekableByteChannel} this instance powers. - * - * @param client The target blob to read from. - * @param requestConditions Request conditions to use for reading. - * @param initialBuffer An initially downloaded buffer to cache for first call to {@link #read(ByteBuffer, long)}. - * @param initialBufferPosition Position of initialBuffer in the target resource. - * @param resourceLength Length of the target resource. - */ - StorageSeekableByteChannelBlobReadBehavior(BlobClientBase client, ByteBuffer initialBuffer, - long initialBufferPosition, long resourceLength, BlobRequestConditions requestConditions) { - this.client = Objects.requireNonNull(client); - this.initialBuffer = Objects.requireNonNull(initialBuffer); - this.initialBufferPosition = initialBufferPosition; - this.resourceLength = resourceLength; - this.requestConditions = requestConditions; - } - - BlobClientBase getClient() { - return this.client; - } - - BlobRequestConditions getRequestConditions() { - return this.requestConditions; - } - - @Override - public int read(ByteBuffer dst, long sourceOffset) throws IOException { - if (dst.remaining() <= 0) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'dst.remaining()' must be positive.")); - } - if (initialBufferPosition != null && initialBuffer != null && initialBufferPosition == sourceOffset) { - return readFromCache(dst); - } else { - // don't hold onto cache when getting new data, wipe it - initialBuffer = null; - initialBufferPosition = null; - } - - int initialPosition = dst.position(); - - try (ByteBufferBackedOutputStreamUtil dstStream = new ByteBufferBackedOutputStreamUtil(dst)) { - BlobDownloadResponse response - = client.downloadStreamWithResponse(dstStream, new BlobRange(sourceOffset, (long) dst.remaining()), - null /*downloadRetryOptions*/, requestConditions, false, null, null); - resourceLength = CoreUtils.extractSizeFromContentRange(response.getDeserializedHeaders().getContentRange()); - return dst.position() - initialPosition; - } catch (BlobStorageException e) { - if (e.getErrorCode() == BlobErrorCode.INVALID_RANGE) { - String contentRange = e.getResponse().getHeaderValue("Content-Range"); - if (contentRange != null) { - resourceLength = CoreUtils.extractSizeFromContentRange(contentRange); - } - // if requested offset is past updated end of file, then signal end of file. Otherwise, only signal - // that zero bytes were read - return sourceOffset < resourceLength ? 0 : -1; - } - throw LOGGER.logExceptionAsError(e); - } - } - - /** - * Reads the cached byte buffer into the provided byte buffer and clears the cache. - * @param dst Destination for read contents. - * @return Number of bytes read. - */ - private int readFromCache(ByteBuffer dst) { - int read = Math.min(dst.remaining(), initialBuffer.remaining()); - if (read > 0) { - ByteBuffer temp = initialBuffer.duplicate(); - temp.limit(temp.position() + read); - dst.put(temp); - } - initialBuffer = null; - initialBufferPosition = null; - return read; - } - - @Override - public long getResourceLength() { - return resourceLength; - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlockBlobWriteBehavior.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlockBlobWriteBehavior.java deleted file mode 100644 index 71eb080a48cc..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlockBlobWriteBehavior.java +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.util.BinaryData; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockOptions; -import com.azure.storage.common.implementation.StorageSeekableByteChannel; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.nio.charset.StandardCharsets.UTF_8; - -class StorageSeekableByteChannelBlockBlobWriteBehavior implements StorageSeekableByteChannel.WriteBehavior { - private static final ClientLogger LOGGER = new ClientLogger(StorageSeekableByteChannelBlockBlobWriteBehavior.class); - - enum WriteMode { - OVERWRITE, APPEND, PREPEND - } - - private final BlockBlobClient client; - private final BlobHttpHeaders headers; - private final Map metadata; - private final Map tags; - private final AccessTier tier; - private final BlobRequestConditions conditions; - private final WriteMode mode; - private final List existingBlockIds; - private final List newBlockIds = new ArrayList<>(); - - StorageSeekableByteChannelBlockBlobWriteBehavior(BlockBlobClient client, BlobHttpHeaders headers, - Map metadata, Map tags, AccessTier tier, BlobRequestConditions conditions, - WriteMode mode, List existingBlockIds) { - this.client = Objects.requireNonNull(client); - this.headers = headers; - this.metadata = metadata; - this.tags = tags; - this.tier = tier; - this.conditions = conditions; - this.mode = Objects.requireNonNull(mode); - this.existingBlockIds = existingBlockIds != null ? existingBlockIds : Collections.emptyList(); - } - - BlockBlobClient getClient() { - return this.client; - } - - BlobHttpHeaders getHeaders() { - return this.headers; - } - - Map getMetadata() { - return this.metadata != null ? Collections.unmodifiableMap(this.metadata) : null; - } - - Map getTags() { - return this.tags != null ? Collections.unmodifiableMap(this.tags) : null; - } - - AccessTier getTier() { - return this.tier; - } - - BlobRequestConditions getRequestConditions() { - return this.conditions; - } - - WriteMode getWriteMode() { - return this.mode; - } - - List getExistingBlockIds() { - return this.existingBlockIds != null ? Collections.unmodifiableList(existingBlockIds) : null; - } - - List getNewBlockIds() { - return this.newBlockIds != null ? Collections.unmodifiableList(newBlockIds) : null; - } - - @Override - public void write(ByteBuffer src, long destOffset) throws IOException { - String blockId = Base64.getEncoder().encodeToString(CoreUtils.randomUuid().toString().getBytes(UTF_8)); - BlockBlobStageBlockOptions options = new BlockBlobStageBlockOptions(blockId, BinaryData.fromByteBuffer(src)); - if (conditions != null) { - options.setLeaseId(conditions.getLeaseId()); - } - - client.stageBlockWithResponse(options, null, null); - newBlockIds.add(blockId); - } - - @Override - public void commit(long totalLength) { - List commitList; - switch (this.mode) { - case OVERWRITE: - commitList = newBlockIds; - break; - - case APPEND: - commitList - = Stream.of(existingBlockIds, newBlockIds).flatMap(Collection::stream).collect(Collectors.toList()); - break; - - case PREPEND: - commitList - = Stream.of(newBlockIds, existingBlockIds).flatMap(Collection::stream).collect(Collectors.toList()); - break; - - default: - // Unreachable block to satisfy compiler - throw LOGGER.logExceptionAsError(new UnsupportedOperationException( - "Commit not supported with the configured BlockBlobSeekableByteChannelWriteMode.")); - } - - client.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(commitList).setHeaders(headers) - .setMetadata(metadata) - .setTags(tags) - .setTier(tier) - .setRequestConditions(conditions), null, null); - } - - @Override - public void assertCanSeek(long position) { - throw LOGGER.logExceptionAsError( - new UnsupportedOperationException("Block blob write channels support sequential write only.")); - } - - @Override - public void resize(long newSize) { - throw LOGGER - .logExceptionAsError(new UnsupportedOperationException("Block blobs cannot have size explicitly set.")); - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/package-info.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/package-info.java deleted file mode 100644 index 02d6db97aa00..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package containing specialized clients for Azure Storage Blobs. - */ -package com.azure.storage.blob.specialized; diff --git a/sdk/storage/azure-storage-blob/src/main/java/module-info.java b/sdk/storage/azure-storage-blob/src/main/java/module-info.java index 597a417add7f..feb422ca7f5c 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/module-info.java +++ b/sdk/storage/azure-storage-blob/src/main/java/module-info.java @@ -1,29 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. module com.azure.storage.blob { - requires transitive com.azure.storage.common; - - requires com.azure.storage.internal.avro; + requires transitive com.azure.core; exports com.azure.storage.blob; exports com.azure.storage.blob.models; - exports com.azure.storage.blob.options; - exports com.azure.storage.blob.sas; - exports com.azure.storage.blob.specialized; - - // Blob batch needs to interact with the generated layer but shouldn't replicate it. - exports com.azure.storage.blob.implementation - to com.azure.storage.blob.cryptography, com.azure.storage.blob.batch, com.azure.storage.file.datalake; // FIXME this should not be a long-term solution - - exports com.azure.storage.blob.implementation.models - to com.azure.storage.blob.batch, com.azure.storage.blob.cryptography; - - exports com.azure.storage.blob.implementation.util - to com.azure.storage.blob.cryptography, com.azure.storage.file.datalake, com.azure.storage.blob.changefeed, - com.azure.core, com.azure.storage.blob.batch, com.azure.storage.blob.nio; opens com.azure.storage.blob.models to com.azure.core; - opens com.azure.storage.blob.implementation to com.azure.core; opens com.azure.storage.blob.implementation.models to com.azure.core; } diff --git a/sdk/storage/azure-storage-blob/src/main/resources/META-INF/azure-storage-blob_apiview_properties.json b/sdk/storage/azure-storage-blob/src/main/resources/META-INF/azure-storage-blob_apiview_properties.json new file mode 100644 index 000000000000..32b78df1c115 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/resources/META-INF/azure-storage-blob_apiview_properties.json @@ -0,0 +1,362 @@ +{ + "flavor": "azure", + "CrossLanguageDefinitionId": { + "com.azure.storage.blob.AppendBlobAsyncClient": "Storage.Blob.AppendBlob", + "com.azure.storage.blob.AppendBlobAsyncClient.appendBlock": "Storage.Blob.AppendBlob.appendBlock", + "com.azure.storage.blob.AppendBlobAsyncClient.appendBlockFromUrl": "Storage.Blob.AppendBlob.appendBlockFromUrl", + "com.azure.storage.blob.AppendBlobAsyncClient.appendBlockFromUrlWithResponse": "Storage.Blob.AppendBlob.appendBlockFromUrl", + "com.azure.storage.blob.AppendBlobAsyncClient.appendBlockWithResponse": "Storage.Blob.AppendBlob.appendBlock", + "com.azure.storage.blob.AppendBlobAsyncClient.create": "Storage.Blob.AppendBlob.create", + "com.azure.storage.blob.AppendBlobAsyncClient.createWithResponse": "Storage.Blob.AppendBlob.create", + "com.azure.storage.blob.AppendBlobAsyncClient.seal": "Storage.Blob.AppendBlob.seal", + "com.azure.storage.blob.AppendBlobAsyncClient.sealWithResponse": "Storage.Blob.AppendBlob.seal", + "com.azure.storage.blob.AppendBlobClient": "Storage.Blob.AppendBlob", + "com.azure.storage.blob.AppendBlobClient.appendBlock": "Storage.Blob.AppendBlob.appendBlock", + "com.azure.storage.blob.AppendBlobClient.appendBlockFromUrl": "Storage.Blob.AppendBlob.appendBlockFromUrl", + "com.azure.storage.blob.AppendBlobClient.appendBlockFromUrlWithResponse": "Storage.Blob.AppendBlob.appendBlockFromUrl", + "com.azure.storage.blob.AppendBlobClient.appendBlockWithResponse": "Storage.Blob.AppendBlob.appendBlock", + "com.azure.storage.blob.AppendBlobClient.create": "Storage.Blob.AppendBlob.create", + "com.azure.storage.blob.AppendBlobClient.createWithResponse": "Storage.Blob.AppendBlob.create", + "com.azure.storage.blob.AppendBlobClient.seal": "Storage.Blob.AppendBlob.seal", + "com.azure.storage.blob.AppendBlobClient.sealWithResponse": "Storage.Blob.AppendBlob.seal", + "com.azure.storage.blob.BlockBlobAsyncClient": "Storage.Blob.BlockBlob", + "com.azure.storage.blob.BlockBlobAsyncClient.commitBlockList": "Storage.Blob.BlockBlob.commitBlockList", + "com.azure.storage.blob.BlockBlobAsyncClient.commitBlockListWithResponse": "Storage.Blob.BlockBlob.commitBlockList", + "com.azure.storage.blob.BlockBlobAsyncClient.getBlockList": "Storage.Blob.BlockBlob.getBlockList", + "com.azure.storage.blob.BlockBlobAsyncClient.getBlockListWithResponse": "Storage.Blob.BlockBlob.getBlockList", + "com.azure.storage.blob.BlockBlobAsyncClient.putBlobFromUrl": "Storage.Blob.BlockBlob.putBlobFromUrl", + "com.azure.storage.blob.BlockBlobAsyncClient.putBlobFromUrlWithResponse": "Storage.Blob.BlockBlob.putBlobFromUrl", + "com.azure.storage.blob.BlockBlobAsyncClient.query": "Storage.Blob.BlockBlob.query", + "com.azure.storage.blob.BlockBlobAsyncClient.queryWithResponse": "Storage.Blob.BlockBlob.query", + "com.azure.storage.blob.BlockBlobAsyncClient.stageBlock": "Storage.Blob.BlockBlob.stageBlock", + "com.azure.storage.blob.BlockBlobAsyncClient.stageBlockFromUrl": "Storage.Blob.BlockBlob.stageBlockFromUrl", + "com.azure.storage.blob.BlockBlobAsyncClient.stageBlockFromUrlWithResponse": "Storage.Blob.BlockBlob.stageBlockFromUrl", + "com.azure.storage.blob.BlockBlobAsyncClient.stageBlockWithResponse": "Storage.Blob.BlockBlob.stageBlock", + "com.azure.storage.blob.BlockBlobAsyncClient.upload": "Storage.Blob.BlockBlob.upload", + "com.azure.storage.blob.BlockBlobAsyncClient.uploadWithResponse": "Storage.Blob.BlockBlob.upload", + "com.azure.storage.blob.BlockBlobClient": "Storage.Blob.BlockBlob", + "com.azure.storage.blob.BlockBlobClient.commitBlockList": "Storage.Blob.BlockBlob.commitBlockList", + "com.azure.storage.blob.BlockBlobClient.commitBlockListWithResponse": "Storage.Blob.BlockBlob.commitBlockList", + "com.azure.storage.blob.BlockBlobClient.getBlockList": "Storage.Blob.BlockBlob.getBlockList", + "com.azure.storage.blob.BlockBlobClient.getBlockListWithResponse": "Storage.Blob.BlockBlob.getBlockList", + "com.azure.storage.blob.BlockBlobClient.putBlobFromUrl": "Storage.Blob.BlockBlob.putBlobFromUrl", + "com.azure.storage.blob.BlockBlobClient.putBlobFromUrlWithResponse": "Storage.Blob.BlockBlob.putBlobFromUrl", + "com.azure.storage.blob.BlockBlobClient.query": "Storage.Blob.BlockBlob.query", + "com.azure.storage.blob.BlockBlobClient.queryWithResponse": "Storage.Blob.BlockBlob.query", + "com.azure.storage.blob.BlockBlobClient.stageBlock": "Storage.Blob.BlockBlob.stageBlock", + "com.azure.storage.blob.BlockBlobClient.stageBlockFromUrl": "Storage.Blob.BlockBlob.stageBlockFromUrl", + "com.azure.storage.blob.BlockBlobClient.stageBlockFromUrlWithResponse": "Storage.Blob.BlockBlob.stageBlockFromUrl", + "com.azure.storage.blob.BlockBlobClient.stageBlockWithResponse": "Storage.Blob.BlockBlob.stageBlock", + "com.azure.storage.blob.BlockBlobClient.upload": "Storage.Blob.BlockBlob.upload", + "com.azure.storage.blob.BlockBlobClient.uploadWithResponse": "Storage.Blob.BlockBlob.upload", + "com.azure.storage.blob.ContainerAsyncClient": "Storage.Blob.Container", + "com.azure.storage.blob.ContainerAsyncClient.acquireLease": "Storage.Blob.Container.acquireLease", + "com.azure.storage.blob.ContainerAsyncClient.acquireLeaseWithResponse": "Storage.Blob.Container.acquireLease", + "com.azure.storage.blob.ContainerAsyncClient.breakLease": "Storage.Blob.Container.breakLease", + "com.azure.storage.blob.ContainerAsyncClient.breakLeaseWithResponse": "Storage.Blob.Container.breakLease", + "com.azure.storage.blob.ContainerAsyncClient.changeLease": "Storage.Blob.Container.changeLease", + "com.azure.storage.blob.ContainerAsyncClient.changeLeaseWithResponse": "Storage.Blob.Container.changeLease", + "com.azure.storage.blob.ContainerAsyncClient.create": "Storage.Blob.Container.create", + "com.azure.storage.blob.ContainerAsyncClient.createWithResponse": "Storage.Blob.Container.create", + "com.azure.storage.blob.ContainerAsyncClient.delete": "Storage.Blob.Container.delete", + "com.azure.storage.blob.ContainerAsyncClient.deleteWithResponse": "Storage.Blob.Container.delete", + "com.azure.storage.blob.ContainerAsyncClient.filterBlobs": "Storage.Blob.Container.filterBlobs", + "com.azure.storage.blob.ContainerAsyncClient.filterBlobsWithResponse": "Storage.Blob.Container.filterBlobs", + "com.azure.storage.blob.ContainerAsyncClient.getAccessPolicy": "Storage.Blob.Container.getAccessPolicy", + "com.azure.storage.blob.ContainerAsyncClient.getAccessPolicyWithResponse": "Storage.Blob.Container.getAccessPolicy", + "com.azure.storage.blob.ContainerAsyncClient.getAccountInfo": "Storage.Blob.Container.getAccountInfo", + "com.azure.storage.blob.ContainerAsyncClient.getAccountInfoWithResponse": "Storage.Blob.Container.getAccountInfo", + "com.azure.storage.blob.ContainerAsyncClient.getProperties": "Storage.Blob.Container.getProperties", + "com.azure.storage.blob.ContainerAsyncClient.getPropertiesWithResponse": "Storage.Blob.Container.getProperties", + "com.azure.storage.blob.ContainerAsyncClient.listBlobFlatSegment": "Storage.Blob.Container.listBlobFlatSegment", + "com.azure.storage.blob.ContainerAsyncClient.listBlobFlatSegmentWithResponse": "Storage.Blob.Container.listBlobFlatSegment", + "com.azure.storage.blob.ContainerAsyncClient.listBlobHierarchySegment": "Storage.Blob.Container.listBlobHierarchySegment", + "com.azure.storage.blob.ContainerAsyncClient.listBlobHierarchySegmentWithResponse": "Storage.Blob.Container.listBlobHierarchySegment", + "com.azure.storage.blob.ContainerAsyncClient.releaseLease": "Storage.Blob.Container.releaseLease", + "com.azure.storage.blob.ContainerAsyncClient.releaseLeaseWithResponse": "Storage.Blob.Container.releaseLease", + "com.azure.storage.blob.ContainerAsyncClient.rename": "Storage.Blob.Container.rename", + "com.azure.storage.blob.ContainerAsyncClient.renameWithResponse": "Storage.Blob.Container.rename", + "com.azure.storage.blob.ContainerAsyncClient.renewLease": "Storage.Blob.Container.renewLease", + "com.azure.storage.blob.ContainerAsyncClient.renewLeaseWithResponse": "Storage.Blob.Container.renewLease", + "com.azure.storage.blob.ContainerAsyncClient.restore": "Storage.Blob.Container.restore", + "com.azure.storage.blob.ContainerAsyncClient.restoreWithResponse": "Storage.Blob.Container.restore", + "com.azure.storage.blob.ContainerAsyncClient.setAccessPolicy": "Storage.Blob.Container.setAccessPolicy", + "com.azure.storage.blob.ContainerAsyncClient.setAccessPolicyWithResponse": "Storage.Blob.Container.setAccessPolicy", + "com.azure.storage.blob.ContainerAsyncClient.setMetadata": "Storage.Blob.Container.setMetadata", + "com.azure.storage.blob.ContainerAsyncClient.setMetadataWithResponse": "Storage.Blob.Container.setMetadata", + "com.azure.storage.blob.ContainerAsyncClient.submitBatch": "Storage.Blob.Container.submitBatch", + "com.azure.storage.blob.ContainerAsyncClient.submitBatchWithResponse": "Storage.Blob.Container.submitBatch", + "com.azure.storage.blob.ContainerBlobAsyncClient": "Storage.Blob.Container.Blob", + "com.azure.storage.blob.ContainerBlobAsyncClient.abortCopyFromUrl": "Storage.Blob.Container.Blob.abortCopyFromUrl", + "com.azure.storage.blob.ContainerBlobAsyncClient.abortCopyFromUrlWithResponse": "Storage.Blob.Container.Blob.abortCopyFromUrl", + "com.azure.storage.blob.ContainerBlobAsyncClient.acquireLease": "Storage.Blob.Container.Blob.acquireLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.acquireLeaseWithResponse": "Storage.Blob.Container.Blob.acquireLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.breakLease": "Storage.Blob.Container.Blob.breakLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.breakLeaseWithResponse": "Storage.Blob.Container.Blob.breakLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.changeLease": "Storage.Blob.Container.Blob.changeLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.changeLeaseWithResponse": "Storage.Blob.Container.Blob.changeLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.copyFromUrl": "Storage.Blob.Container.Blob.copyFromUrl", + "com.azure.storage.blob.ContainerBlobAsyncClient.copyFromUrlWithResponse": "Storage.Blob.Container.Blob.copyFromUrl", + "com.azure.storage.blob.ContainerBlobAsyncClient.createSnapshot": "Storage.Blob.Container.Blob.createSnapshot", + "com.azure.storage.blob.ContainerBlobAsyncClient.createSnapshotWithResponse": "Storage.Blob.Container.Blob.createSnapshot", + "com.azure.storage.blob.ContainerBlobAsyncClient.delete": "Storage.Blob.Container.Blob.delete", + "com.azure.storage.blob.ContainerBlobAsyncClient.deleteImmutabilityPolicy": "Storage.Blob.Container.Blob.deleteImmutabilityPolicy", + "com.azure.storage.blob.ContainerBlobAsyncClient.deleteImmutabilityPolicyWithResponse": "Storage.Blob.Container.Blob.deleteImmutabilityPolicy", + "com.azure.storage.blob.ContainerBlobAsyncClient.deleteWithResponse": "Storage.Blob.Container.Blob.delete", + "com.azure.storage.blob.ContainerBlobAsyncClient.download": "Storage.Blob.Container.Blob.download", + "com.azure.storage.blob.ContainerBlobAsyncClient.downloadWithResponse": "Storage.Blob.Container.Blob.download", + "com.azure.storage.blob.ContainerBlobAsyncClient.getAccountInfo": "Storage.Blob.Container.Blob.getAccountInfo", + "com.azure.storage.blob.ContainerBlobAsyncClient.getAccountInfoWithResponse": "Storage.Blob.Container.Blob.getAccountInfo", + "com.azure.storage.blob.ContainerBlobAsyncClient.getProperties": "Storage.Blob.Container.Blob.getProperties", + "com.azure.storage.blob.ContainerBlobAsyncClient.getPropertiesWithResponse": "Storage.Blob.Container.Blob.getProperties", + "com.azure.storage.blob.ContainerBlobAsyncClient.getTags": "Storage.Blob.Container.Blob.getTags", + "com.azure.storage.blob.ContainerBlobAsyncClient.getTagsWithResponse": "Storage.Blob.Container.Blob.getTags", + "com.azure.storage.blob.ContainerBlobAsyncClient.releaseLease": "Storage.Blob.Container.Blob.releaseLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.releaseLeaseWithResponse": "Storage.Blob.Container.Blob.releaseLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.renewLease": "Storage.Blob.Container.Blob.renewLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.renewLeaseWithResponse": "Storage.Blob.Container.Blob.renewLease", + "com.azure.storage.blob.ContainerBlobAsyncClient.setExpiry": "Storage.Blob.Container.Blob.setExpiry", + "com.azure.storage.blob.ContainerBlobAsyncClient.setExpiryWithResponse": "Storage.Blob.Container.Blob.setExpiry", + "com.azure.storage.blob.ContainerBlobAsyncClient.setHttpHeaders": "Storage.Blob.Container.Blob.setHttpHeaders", + "com.azure.storage.blob.ContainerBlobAsyncClient.setHttpHeadersWithResponse": "Storage.Blob.Container.Blob.setHttpHeaders", + "com.azure.storage.blob.ContainerBlobAsyncClient.setImmutabilityPolicy": "Storage.Blob.Container.Blob.setImmutabilityPolicy", + "com.azure.storage.blob.ContainerBlobAsyncClient.setImmutabilityPolicyWithResponse": "Storage.Blob.Container.Blob.setImmutabilityPolicy", + "com.azure.storage.blob.ContainerBlobAsyncClient.setLegalHold": "Storage.Blob.Container.Blob.setLegalHold", + "com.azure.storage.blob.ContainerBlobAsyncClient.setLegalHoldWithResponse": "Storage.Blob.Container.Blob.setLegalHold", + "com.azure.storage.blob.ContainerBlobAsyncClient.setMetadata": "Storage.Blob.Container.Blob.setMetadata", + "com.azure.storage.blob.ContainerBlobAsyncClient.setMetadataWithResponse": "Storage.Blob.Container.Blob.setMetadata", + "com.azure.storage.blob.ContainerBlobAsyncClient.setTags": "Storage.Blob.Container.Blob.setTags", + "com.azure.storage.blob.ContainerBlobAsyncClient.setTagsWithResponse": "Storage.Blob.Container.Blob.setTags", + "com.azure.storage.blob.ContainerBlobAsyncClient.setTier": "Storage.Blob.Container.Blob.setTier", + "com.azure.storage.blob.ContainerBlobAsyncClient.setTierWithResponse": "Storage.Blob.Container.Blob.setTier", + "com.azure.storage.blob.ContainerBlobAsyncClient.startCopyFromUrl": "Storage.Blob.Container.Blob.startCopyFromUrl", + "com.azure.storage.blob.ContainerBlobAsyncClient.startCopyFromUrlWithResponse": "Storage.Blob.Container.Blob.startCopyFromUrl", + "com.azure.storage.blob.ContainerBlobAsyncClient.undelete": "Storage.Blob.Container.Blob.undelete", + "com.azure.storage.blob.ContainerBlobAsyncClient.undeleteWithResponse": "Storage.Blob.Container.Blob.undelete", + "com.azure.storage.blob.ContainerBlobClient": "Storage.Blob.Container.Blob", + "com.azure.storage.blob.ContainerBlobClient.abortCopyFromUrl": "Storage.Blob.Container.Blob.abortCopyFromUrl", + "com.azure.storage.blob.ContainerBlobClient.abortCopyFromUrlWithResponse": "Storage.Blob.Container.Blob.abortCopyFromUrl", + "com.azure.storage.blob.ContainerBlobClient.acquireLease": "Storage.Blob.Container.Blob.acquireLease", + "com.azure.storage.blob.ContainerBlobClient.acquireLeaseWithResponse": "Storage.Blob.Container.Blob.acquireLease", + "com.azure.storage.blob.ContainerBlobClient.breakLease": "Storage.Blob.Container.Blob.breakLease", + "com.azure.storage.blob.ContainerBlobClient.breakLeaseWithResponse": "Storage.Blob.Container.Blob.breakLease", + "com.azure.storage.blob.ContainerBlobClient.changeLease": "Storage.Blob.Container.Blob.changeLease", + "com.azure.storage.blob.ContainerBlobClient.changeLeaseWithResponse": "Storage.Blob.Container.Blob.changeLease", + "com.azure.storage.blob.ContainerBlobClient.copyFromUrl": "Storage.Blob.Container.Blob.copyFromUrl", + "com.azure.storage.blob.ContainerBlobClient.copyFromUrlWithResponse": "Storage.Blob.Container.Blob.copyFromUrl", + "com.azure.storage.blob.ContainerBlobClient.createSnapshot": "Storage.Blob.Container.Blob.createSnapshot", + "com.azure.storage.blob.ContainerBlobClient.createSnapshotWithResponse": "Storage.Blob.Container.Blob.createSnapshot", + "com.azure.storage.blob.ContainerBlobClient.delete": "Storage.Blob.Container.Blob.delete", + "com.azure.storage.blob.ContainerBlobClient.deleteImmutabilityPolicy": "Storage.Blob.Container.Blob.deleteImmutabilityPolicy", + "com.azure.storage.blob.ContainerBlobClient.deleteImmutabilityPolicyWithResponse": "Storage.Blob.Container.Blob.deleteImmutabilityPolicy", + "com.azure.storage.blob.ContainerBlobClient.deleteWithResponse": "Storage.Blob.Container.Blob.delete", + "com.azure.storage.blob.ContainerBlobClient.download": "Storage.Blob.Container.Blob.download", + "com.azure.storage.blob.ContainerBlobClient.downloadWithResponse": "Storage.Blob.Container.Blob.download", + "com.azure.storage.blob.ContainerBlobClient.getAccountInfo": "Storage.Blob.Container.Blob.getAccountInfo", + "com.azure.storage.blob.ContainerBlobClient.getAccountInfoWithResponse": "Storage.Blob.Container.Blob.getAccountInfo", + "com.azure.storage.blob.ContainerBlobClient.getProperties": "Storage.Blob.Container.Blob.getProperties", + "com.azure.storage.blob.ContainerBlobClient.getPropertiesWithResponse": "Storage.Blob.Container.Blob.getProperties", + "com.azure.storage.blob.ContainerBlobClient.getTags": "Storage.Blob.Container.Blob.getTags", + "com.azure.storage.blob.ContainerBlobClient.getTagsWithResponse": "Storage.Blob.Container.Blob.getTags", + "com.azure.storage.blob.ContainerBlobClient.releaseLease": "Storage.Blob.Container.Blob.releaseLease", + "com.azure.storage.blob.ContainerBlobClient.releaseLeaseWithResponse": "Storage.Blob.Container.Blob.releaseLease", + "com.azure.storage.blob.ContainerBlobClient.renewLease": "Storage.Blob.Container.Blob.renewLease", + "com.azure.storage.blob.ContainerBlobClient.renewLeaseWithResponse": "Storage.Blob.Container.Blob.renewLease", + "com.azure.storage.blob.ContainerBlobClient.setExpiry": "Storage.Blob.Container.Blob.setExpiry", + "com.azure.storage.blob.ContainerBlobClient.setExpiryWithResponse": "Storage.Blob.Container.Blob.setExpiry", + "com.azure.storage.blob.ContainerBlobClient.setHttpHeaders": "Storage.Blob.Container.Blob.setHttpHeaders", + "com.azure.storage.blob.ContainerBlobClient.setHttpHeadersWithResponse": "Storage.Blob.Container.Blob.setHttpHeaders", + "com.azure.storage.blob.ContainerBlobClient.setImmutabilityPolicy": "Storage.Blob.Container.Blob.setImmutabilityPolicy", + "com.azure.storage.blob.ContainerBlobClient.setImmutabilityPolicyWithResponse": "Storage.Blob.Container.Blob.setImmutabilityPolicy", + "com.azure.storage.blob.ContainerBlobClient.setLegalHold": "Storage.Blob.Container.Blob.setLegalHold", + "com.azure.storage.blob.ContainerBlobClient.setLegalHoldWithResponse": "Storage.Blob.Container.Blob.setLegalHold", + "com.azure.storage.blob.ContainerBlobClient.setMetadata": "Storage.Blob.Container.Blob.setMetadata", + "com.azure.storage.blob.ContainerBlobClient.setMetadataWithResponse": "Storage.Blob.Container.Blob.setMetadata", + "com.azure.storage.blob.ContainerBlobClient.setTags": "Storage.Blob.Container.Blob.setTags", + "com.azure.storage.blob.ContainerBlobClient.setTagsWithResponse": "Storage.Blob.Container.Blob.setTags", + "com.azure.storage.blob.ContainerBlobClient.setTier": "Storage.Blob.Container.Blob.setTier", + "com.azure.storage.blob.ContainerBlobClient.setTierWithResponse": "Storage.Blob.Container.Blob.setTier", + "com.azure.storage.blob.ContainerBlobClient.startCopyFromUrl": "Storage.Blob.Container.Blob.startCopyFromUrl", + "com.azure.storage.blob.ContainerBlobClient.startCopyFromUrlWithResponse": "Storage.Blob.Container.Blob.startCopyFromUrl", + "com.azure.storage.blob.ContainerBlobClient.undelete": "Storage.Blob.Container.Blob.undelete", + "com.azure.storage.blob.ContainerBlobClient.undeleteWithResponse": "Storage.Blob.Container.Blob.undelete", + "com.azure.storage.blob.ContainerClient": "Storage.Blob.Container", + "com.azure.storage.blob.ContainerClient.acquireLease": "Storage.Blob.Container.acquireLease", + "com.azure.storage.blob.ContainerClient.acquireLeaseWithResponse": "Storage.Blob.Container.acquireLease", + "com.azure.storage.blob.ContainerClient.breakLease": "Storage.Blob.Container.breakLease", + "com.azure.storage.blob.ContainerClient.breakLeaseWithResponse": "Storage.Blob.Container.breakLease", + "com.azure.storage.blob.ContainerClient.changeLease": "Storage.Blob.Container.changeLease", + "com.azure.storage.blob.ContainerClient.changeLeaseWithResponse": "Storage.Blob.Container.changeLease", + "com.azure.storage.blob.ContainerClient.create": "Storage.Blob.Container.create", + "com.azure.storage.blob.ContainerClient.createWithResponse": "Storage.Blob.Container.create", + "com.azure.storage.blob.ContainerClient.delete": "Storage.Blob.Container.delete", + "com.azure.storage.blob.ContainerClient.deleteWithResponse": "Storage.Blob.Container.delete", + "com.azure.storage.blob.ContainerClient.filterBlobs": "Storage.Blob.Container.filterBlobs", + "com.azure.storage.blob.ContainerClient.filterBlobsWithResponse": "Storage.Blob.Container.filterBlobs", + "com.azure.storage.blob.ContainerClient.getAccessPolicy": "Storage.Blob.Container.getAccessPolicy", + "com.azure.storage.blob.ContainerClient.getAccessPolicyWithResponse": "Storage.Blob.Container.getAccessPolicy", + "com.azure.storage.blob.ContainerClient.getAccountInfo": "Storage.Blob.Container.getAccountInfo", + "com.azure.storage.blob.ContainerClient.getAccountInfoWithResponse": "Storage.Blob.Container.getAccountInfo", + "com.azure.storage.blob.ContainerClient.getProperties": "Storage.Blob.Container.getProperties", + "com.azure.storage.blob.ContainerClient.getPropertiesWithResponse": "Storage.Blob.Container.getProperties", + "com.azure.storage.blob.ContainerClient.listBlobFlatSegment": "Storage.Blob.Container.listBlobFlatSegment", + "com.azure.storage.blob.ContainerClient.listBlobFlatSegmentWithResponse": "Storage.Blob.Container.listBlobFlatSegment", + "com.azure.storage.blob.ContainerClient.listBlobHierarchySegment": "Storage.Blob.Container.listBlobHierarchySegment", + "com.azure.storage.blob.ContainerClient.listBlobHierarchySegmentWithResponse": "Storage.Blob.Container.listBlobHierarchySegment", + "com.azure.storage.blob.ContainerClient.releaseLease": "Storage.Blob.Container.releaseLease", + "com.azure.storage.blob.ContainerClient.releaseLeaseWithResponse": "Storage.Blob.Container.releaseLease", + "com.azure.storage.blob.ContainerClient.rename": "Storage.Blob.Container.rename", + "com.azure.storage.blob.ContainerClient.renameWithResponse": "Storage.Blob.Container.rename", + "com.azure.storage.blob.ContainerClient.renewLease": "Storage.Blob.Container.renewLease", + "com.azure.storage.blob.ContainerClient.renewLeaseWithResponse": "Storage.Blob.Container.renewLease", + "com.azure.storage.blob.ContainerClient.restore": "Storage.Blob.Container.restore", + "com.azure.storage.blob.ContainerClient.restoreWithResponse": "Storage.Blob.Container.restore", + "com.azure.storage.blob.ContainerClient.setAccessPolicy": "Storage.Blob.Container.setAccessPolicy", + "com.azure.storage.blob.ContainerClient.setAccessPolicyWithResponse": "Storage.Blob.Container.setAccessPolicy", + "com.azure.storage.blob.ContainerClient.setMetadata": "Storage.Blob.Container.setMetadata", + "com.azure.storage.blob.ContainerClient.setMetadataWithResponse": "Storage.Blob.Container.setMetadata", + "com.azure.storage.blob.ContainerClient.submitBatch": "Storage.Blob.Container.submitBatch", + "com.azure.storage.blob.ContainerClient.submitBatchWithResponse": "Storage.Blob.Container.submitBatch", + "com.azure.storage.blob.PageBlobAsyncClient": "Storage.Blob.PageBlob", + "com.azure.storage.blob.PageBlobAsyncClient.clearPages": "Storage.Blob.PageBlob.clearPages", + "com.azure.storage.blob.PageBlobAsyncClient.clearPagesWithResponse": "Storage.Blob.PageBlob.clearPages", + "com.azure.storage.blob.PageBlobAsyncClient.copyIncremental": "Storage.Blob.PageBlob.copyIncremental", + "com.azure.storage.blob.PageBlobAsyncClient.copyIncrementalWithResponse": "Storage.Blob.PageBlob.copyIncremental", + "com.azure.storage.blob.PageBlobAsyncClient.create": "Storage.Blob.PageBlob.create", + "com.azure.storage.blob.PageBlobAsyncClient.createWithResponse": "Storage.Blob.PageBlob.create", + "com.azure.storage.blob.PageBlobAsyncClient.getPageRanges": "Storage.Blob.PageBlob.getPageRanges", + "com.azure.storage.blob.PageBlobAsyncClient.getPageRangesDiff": "Storage.Blob.PageBlob.getPageRangesDiff", + "com.azure.storage.blob.PageBlobAsyncClient.getPageRangesDiffWithResponse": "Storage.Blob.PageBlob.getPageRangesDiff", + "com.azure.storage.blob.PageBlobAsyncClient.getPageRangesWithResponse": "Storage.Blob.PageBlob.getPageRanges", + "com.azure.storage.blob.PageBlobAsyncClient.resize": "Storage.Blob.PageBlob.resize", + "com.azure.storage.blob.PageBlobAsyncClient.resizeWithResponse": "Storage.Blob.PageBlob.resize", + "com.azure.storage.blob.PageBlobAsyncClient.updateSequenceNumber": "Storage.Blob.PageBlob.updateSequenceNumber", + "com.azure.storage.blob.PageBlobAsyncClient.updateSequenceNumberWithResponse": "Storage.Blob.PageBlob.updateSequenceNumber", + "com.azure.storage.blob.PageBlobAsyncClient.uploadPages": "Storage.Blob.PageBlob.uploadPages", + "com.azure.storage.blob.PageBlobAsyncClient.uploadPagesFromUrl": "Storage.Blob.PageBlob.uploadPagesFromUrl", + "com.azure.storage.blob.PageBlobAsyncClient.uploadPagesFromUrlWithResponse": "Storage.Blob.PageBlob.uploadPagesFromUrl", + "com.azure.storage.blob.PageBlobAsyncClient.uploadPagesWithResponse": "Storage.Blob.PageBlob.uploadPages", + "com.azure.storage.blob.PageBlobClient": "Storage.Blob.PageBlob", + "com.azure.storage.blob.PageBlobClient.clearPages": "Storage.Blob.PageBlob.clearPages", + "com.azure.storage.blob.PageBlobClient.clearPagesWithResponse": "Storage.Blob.PageBlob.clearPages", + "com.azure.storage.blob.PageBlobClient.copyIncremental": "Storage.Blob.PageBlob.copyIncremental", + "com.azure.storage.blob.PageBlobClient.copyIncrementalWithResponse": "Storage.Blob.PageBlob.copyIncremental", + "com.azure.storage.blob.PageBlobClient.create": "Storage.Blob.PageBlob.create", + "com.azure.storage.blob.PageBlobClient.createWithResponse": "Storage.Blob.PageBlob.create", + "com.azure.storage.blob.PageBlobClient.getPageRanges": "Storage.Blob.PageBlob.getPageRanges", + "com.azure.storage.blob.PageBlobClient.getPageRangesDiff": "Storage.Blob.PageBlob.getPageRangesDiff", + "com.azure.storage.blob.PageBlobClient.getPageRangesDiffWithResponse": "Storage.Blob.PageBlob.getPageRangesDiff", + "com.azure.storage.blob.PageBlobClient.getPageRangesWithResponse": "Storage.Blob.PageBlob.getPageRanges", + "com.azure.storage.blob.PageBlobClient.resize": "Storage.Blob.PageBlob.resize", + "com.azure.storage.blob.PageBlobClient.resizeWithResponse": "Storage.Blob.PageBlob.resize", + "com.azure.storage.blob.PageBlobClient.updateSequenceNumber": "Storage.Blob.PageBlob.updateSequenceNumber", + "com.azure.storage.blob.PageBlobClient.updateSequenceNumberWithResponse": "Storage.Blob.PageBlob.updateSequenceNumber", + "com.azure.storage.blob.PageBlobClient.uploadPages": "Storage.Blob.PageBlob.uploadPages", + "com.azure.storage.blob.PageBlobClient.uploadPagesFromUrl": "Storage.Blob.PageBlob.uploadPagesFromUrl", + "com.azure.storage.blob.PageBlobClient.uploadPagesFromUrlWithResponse": "Storage.Blob.PageBlob.uploadPagesFromUrl", + "com.azure.storage.blob.PageBlobClient.uploadPagesWithResponse": "Storage.Blob.PageBlob.uploadPages", + "com.azure.storage.blob.ServiceClientAsyncClient": "Storage.Blob", + "com.azure.storage.blob.ServiceClientAsyncClient.filterBlobs": "Storage.Blob.filterBlobs", + "com.azure.storage.blob.ServiceClientAsyncClient.filterBlobsWithResponse": "Storage.Blob.filterBlobs", + "com.azure.storage.blob.ServiceClientAsyncClient.getAccountInfo": "Storage.Blob.getAccountInfo", + "com.azure.storage.blob.ServiceClientAsyncClient.getAccountInfoWithResponse": "Storage.Blob.getAccountInfo", + "com.azure.storage.blob.ServiceClientAsyncClient.getProperties": "Storage.Blob.getProperties", + "com.azure.storage.blob.ServiceClientAsyncClient.getPropertiesWithResponse": "Storage.Blob.getProperties", + "com.azure.storage.blob.ServiceClientAsyncClient.getStatistics": "Storage.Blob.getStatistics", + "com.azure.storage.blob.ServiceClientAsyncClient.getStatisticsWithResponse": "Storage.Blob.getStatistics", + "com.azure.storage.blob.ServiceClientAsyncClient.getUserDelegationKey": "Storage.Blob.getUserDelegationKey", + "com.azure.storage.blob.ServiceClientAsyncClient.getUserDelegationKeyWithResponse": "Storage.Blob.getUserDelegationKey", + "com.azure.storage.blob.ServiceClientAsyncClient.listContainersSegment": "Storage.Blob.listContainersSegment", + "com.azure.storage.blob.ServiceClientAsyncClient.listContainersSegmentWithResponse": "Storage.Blob.listContainersSegment", + "com.azure.storage.blob.ServiceClientAsyncClient.setProperties": "Storage.Blob.setProperties", + "com.azure.storage.blob.ServiceClientAsyncClient.setPropertiesWithResponse": "Storage.Blob.setProperties", + "com.azure.storage.blob.ServiceClientAsyncClient.submitBatch": "Storage.Blob.submitBatch", + "com.azure.storage.blob.ServiceClientAsyncClient.submitBatchWithResponse": "Storage.Blob.submitBatch", + "com.azure.storage.blob.ServiceClientClient": "Storage.Blob", + "com.azure.storage.blob.ServiceClientClient.filterBlobs": "Storage.Blob.filterBlobs", + "com.azure.storage.blob.ServiceClientClient.filterBlobsWithResponse": "Storage.Blob.filterBlobs", + "com.azure.storage.blob.ServiceClientClient.getAccountInfo": "Storage.Blob.getAccountInfo", + "com.azure.storage.blob.ServiceClientClient.getAccountInfoWithResponse": "Storage.Blob.getAccountInfo", + "com.azure.storage.blob.ServiceClientClient.getProperties": "Storage.Blob.getProperties", + "com.azure.storage.blob.ServiceClientClient.getPropertiesWithResponse": "Storage.Blob.getProperties", + "com.azure.storage.blob.ServiceClientClient.getStatistics": "Storage.Blob.getStatistics", + "com.azure.storage.blob.ServiceClientClient.getStatisticsWithResponse": "Storage.Blob.getStatistics", + "com.azure.storage.blob.ServiceClientClient.getUserDelegationKey": "Storage.Blob.getUserDelegationKey", + "com.azure.storage.blob.ServiceClientClient.getUserDelegationKeyWithResponse": "Storage.Blob.getUserDelegationKey", + "com.azure.storage.blob.ServiceClientClient.listContainersSegment": "Storage.Blob.listContainersSegment", + "com.azure.storage.blob.ServiceClientClient.listContainersSegmentWithResponse": "Storage.Blob.listContainersSegment", + "com.azure.storage.blob.ServiceClientClient.setProperties": "Storage.Blob.setProperties", + "com.azure.storage.blob.ServiceClientClient.setPropertiesWithResponse": "Storage.Blob.setProperties", + "com.azure.storage.blob.ServiceClientClient.submitBatch": "Storage.Blob.submitBatch", + "com.azure.storage.blob.ServiceClientClient.submitBatchWithResponse": "Storage.Blob.submitBatch", + "com.azure.storage.blob.ServiceClientClientBuilder": "Storage.Blob", + "com.azure.storage.blob.implementation.models.GetUserDelegationKeyRequest": "Storage.Blob.getUserDelegationKey.Request.anonymous", + "com.azure.storage.blob.implementation.models.SetPropertiesRequest": "Storage.Blob.setProperties.Request.anonymous", + "com.azure.storage.blob.models.AccessPolicy": "Storage.Blob.AccessPolicy", + "com.azure.storage.blob.models.AccessTier": "Storage.Blob.AccessTier", + "com.azure.storage.blob.models.ArchiveStatus": "Storage.Blob.ArchiveStatus", + "com.azure.storage.blob.models.ArrowConfiguration": "Storage.Blob.ArrowConfiguration", + "com.azure.storage.blob.models.ArrowField": "Storage.Blob.ArrowField", + "com.azure.storage.blob.models.BlobDeleteType": "Storage.Blob.BlobDeleteType", + "com.azure.storage.blob.models.BlobExpiryOptions": "Storage.Blob.BlobExpiryOptions", + "com.azure.storage.blob.models.BlobFlatListSegment": "Storage.Blob.BlobFlatListSegment", + "com.azure.storage.blob.models.BlobHierarchyListSegment": "Storage.Blob.BlobHierarchyListSegment", + "com.azure.storage.blob.models.BlobImmutabilityPolicyMode": "Storage.Blob.BlobImmutabilityPolicyMode", + "com.azure.storage.blob.models.BlobItemInternal": "Storage.Blob.BlobItemInternal", + "com.azure.storage.blob.models.BlobMetadata": "Storage.Blob.BlobMetadata", + "com.azure.storage.blob.models.BlobName": "Storage.Blob.BlobName", + "com.azure.storage.blob.models.BlobPrefix": "Storage.Blob.BlobPrefix", + "com.azure.storage.blob.models.BlobPropertiesInternal": "Storage.Blob.BlobPropertiesInternal", + "com.azure.storage.blob.models.BlobTag": "Storage.Blob.BlobTag", + "com.azure.storage.blob.models.BlobTags": "Storage.Blob.BlobTags", + "com.azure.storage.blob.models.BlobType": "Storage.Blob.BlobType", + "com.azure.storage.blob.models.Block": "Storage.Blob.Block", + "com.azure.storage.blob.models.BlockList": "Storage.Blob.BlockList", + "com.azure.storage.blob.models.BlockListType": "Storage.Blob.BlockListType", + "com.azure.storage.blob.models.BlockLookupList": "Storage.Blob.BlockLookupList", + "com.azure.storage.blob.models.ClearRange": "Storage.Blob.ClearRange", + "com.azure.storage.blob.models.ContainerItem": "Storage.Blob.ContainerItem", + "com.azure.storage.blob.models.ContainerProperties": "Storage.Blob.ContainerProperties", + "com.azure.storage.blob.models.CopyStatus": "Storage.Blob.CopyStatus", + "com.azure.storage.blob.models.CorsRule": "Storage.Blob.CorsRule", + "com.azure.storage.blob.models.DeleteSnapshotsOptionType": "Storage.Blob.DeleteSnapshotsOptionType", + "com.azure.storage.blob.models.DelimitedTextConfiguration": "Storage.Blob.DelimitedTextConfiguration", + "com.azure.storage.blob.models.EncryptionAlgorithmType": "Storage.Blob.EncryptionAlgorithmType", + "com.azure.storage.blob.models.FilterBlobItem": "Storage.Blob.FilterBlobItem", + "com.azure.storage.blob.models.FilterBlobSegment": "Storage.Blob.FilterBlobSegment", + "com.azure.storage.blob.models.FilterBlobsIncludeItem": "Storage.Blob.FilterBlobsIncludeItem", + "com.azure.storage.blob.models.GeoReplication": "Storage.Blob.GeoReplication", + "com.azure.storage.blob.models.GeoReplicationStatusType": "Storage.Blob.GeoReplicationStatusType", + "com.azure.storage.blob.models.JsonTextConfiguration": "Storage.Blob.JsonTextConfiguration", + "com.azure.storage.blob.models.LeaseDuration": "Storage.Blob.LeaseDuration", + "com.azure.storage.blob.models.LeaseState": "Storage.Blob.LeaseState", + "com.azure.storage.blob.models.LeaseStatus": "Storage.Blob.LeaseStatus", + "com.azure.storage.blob.models.ListBlobsFlatSegmentResponse": "Storage.Blob.ListBlobsFlatSegmentResponse", + "com.azure.storage.blob.models.ListBlobsHierarchySegmentResponse": "Storage.Blob.ListBlobsHierarchySegmentResponse", + "com.azure.storage.blob.models.ListBlobsIncludeItem": "Storage.Blob.ListBlobsIncludeItem", + "com.azure.storage.blob.models.ListContainersIncludeType": "Storage.Blob.ListContainersIncludeType", + "com.azure.storage.blob.models.ListContainersSegmentResponse": "Storage.Blob.ListContainersSegmentResponse", + "com.azure.storage.blob.models.Logging": "Storage.Blob.Logging", + "com.azure.storage.blob.models.Metrics": "Storage.Blob.Metrics", + "com.azure.storage.blob.models.ObjectReplicationMetadata": "Storage.Blob.ObjectReplicationMetadata", + "com.azure.storage.blob.models.PageList": "Storage.Blob.PageList", + "com.azure.storage.blob.models.PageRange": "Storage.Blob.PageRange", + "com.azure.storage.blob.models.ParquetConfiguration": "Storage.Blob.ParquetConfiguration", + "com.azure.storage.blob.models.PremiumPageBlobAccessTier": "Storage.Blob.PremiumPageBlobAccessTier", + "com.azure.storage.blob.models.PublicAccessType": "Storage.Blob.PublicAccessType", + "com.azure.storage.blob.models.QueryFormat": "Storage.Blob.QueryFormat", + "com.azure.storage.blob.models.QueryRequest": "Storage.Blob.QueryRequest", + "com.azure.storage.blob.models.QueryRequestType": "Storage.Blob.QueryRequestType", + "com.azure.storage.blob.models.QuerySerialization": "Storage.Blob.QuerySerialization", + "com.azure.storage.blob.models.QueryType": "Storage.Blob.QueryType", + "com.azure.storage.blob.models.RehydratePriority": "Storage.Blob.RehydratePriority", + "com.azure.storage.blob.models.RetentionPolicy": "Storage.Blob.RetentionPolicy", + "com.azure.storage.blob.models.SequenceNumberActionType": "Storage.Blob.SequenceNumberActionType", + "com.azure.storage.blob.models.SetPropertiesOptions": null, + "com.azure.storage.blob.models.SignedIdentifier": "Storage.Blob.SignedIdentifier", + "com.azure.storage.blob.models.StaticWebsite": "Storage.Blob.StaticWebsite", + "com.azure.storage.blob.models.StorageServiceProperties": "Storage.Blob.StorageServiceProperties", + "com.azure.storage.blob.models.StorageServiceStats": "Storage.Blob.StorageServiceStats", + "com.azure.storage.blob.models.UserDelegationKey": "Storage.Blob.UserDelegationKey" + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/proxy-config.json b/sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/proxy-config.json deleted file mode 100644 index 3f2f538c965d..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/proxy-config.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - [ - "com.azure.storage.blob.implementation.BlobsImpl$BlobsService" - ], - [ - "com.azure.storage.blob.implementation.AppendBlobsImpl$AppendBlobsService" - ], - [ - "com.azure.storage.blob.implementation.BlockBlobsImpl$BlockBlobsService" - ], - [ - "com.azure.storage.blob.implementation.ContainersImpl$ContainersService" - ], - [ - "com.azure.storage.blob.implementation.PageBlobsImpl$PageBlobsService" - ], - [ - "com.azure.storage.blob.implementation.ServicesImpl$ServicesService" - ] -] diff --git a/sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/reflect-config.json b/sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/reflect-config.json deleted file mode 100644 index 58e67b3640e2..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/reflect-config.json +++ /dev/null @@ -1,1862 +0,0 @@ -[ - { - "name": "com.azure.storage.blob.BlobAsyncClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobClientBuilder", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobContainerAsyncClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobContainerClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobContainerClientBuilder", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobServiceAsyncClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobServiceClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobServiceClientBuilder", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobServiceVersion", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.BlobUrlParts", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.HttpGetterInfo", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.ProgressReceiver", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.ProgressReporter", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.AppendBlobsImpl", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.AzureBlobStorageImpl", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.BlobsImpl", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.BlockBlobsImpl", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.ContainersImpl", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.PageBlobsImpl", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.ServicesImpl", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.SignedIdentifiersWrapper", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.accesshelpers.BlobDownloadAsyncResponseConstructorProxy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.accesshelpers.BlobDownloadHeadersConstructorProxy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.accesshelpers.BlobPropertiesConstructorProxy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.accesshelpers.BlobQueryHeadersConstructorProxy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.AppendBlobsAppendBlockFromUrlHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.AppendBlobsAppendBlockHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.AppendBlobsCreateHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.AppendBlobsSealHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ArrowConfiguration", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ArrowField", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobContainersSegment", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobCopySourceTags", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobDeleteType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobExpiryOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobFlatListSegment", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobHierarchyListSegment", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobItemInternal", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobItemPropertiesInternal", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobName", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobPrefixInternal", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobPropertiesInternal", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobPropertiesInternalConstructorProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobPropertiesInternalDownload", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobPropertiesInternalGetProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsAbortCopyFromURLHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsAcquireLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsBreakLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsChangeLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsCopyFromURLHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsCreateSnapshotHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsDeleteHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsDeleteImmutabilityPolicyHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsDownloadHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsGetAccessControlHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsGetAccountInfoHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsGetPropertiesHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsGetTagsHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsQueryHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsReleaseLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsRenameHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsRenewLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsSetAccessControlHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsSetExpiryHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsSetHttpHeadersHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsSetImmutabilityPolicyHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsSetLegalHoldHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsSetMetadataHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsSetTagsHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsSetTierHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsStartCopyFromURLHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobsUndeleteHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobTag", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlobTags", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlockBlobsCommitBlockListHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlockBlobsGetBlockListHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlockBlobsPutBlobFromUrlHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlockBlobsStageBlockFromURLHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlockBlobsStageBlockHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.BlockBlobsUploadHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersAcquireLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersBreakLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersChangeLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersCreateHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersDeleteHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersFilterBlobsHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersGetAccessPolicyHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersGetAccountInfoHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersGetPropertiesHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersListBlobFlatSegmentHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersListBlobHierarchySegmentHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersReleaseLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersRenameHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersRenewLeaseHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersRestoreHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersSetAccessPolicyHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersSetMetadataHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ContainersSubmitBatchHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DataLakeStorageError", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DataLakeStorageErrorDetails", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DataLakeStorageErrorException", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DelimitedTextConfiguration", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DirectoriesCreateHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DirectoriesDeleteHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DirectoriesGetAccessControlHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DirectoriesRenameHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DirectoriesSetAccessControlHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.DirectoryHttpHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.EncryptionScope", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.FilterBlobItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.FilterBlobSegment", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.FilterBlobsIncludeItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.InternalBlobLegalHoldResult", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.JsonTextConfiguration", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ListBlobsFlatSegmentResponse", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ListBlobsHierarchySegmentResponse", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsClearPagesHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsCopyIncrementalHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsCreateHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesDiffHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesDiffNextHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsGetPageRangesNextHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsResizeHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsUpdateSequenceNumberHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsUploadPagesFromURLHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageBlobsUploadPagesHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageListCollection", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageListHelper", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PageListSegment", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.PremiumPageBlobAccessTier", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.QueryFormat", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.QueryFormatType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.QueryRequest", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.QuerySerialization", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ServicesFilterBlobsHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ServicesGetAccountInfoHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ServicesGetPropertiesHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ServicesGetStatisticsHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ServicesGetUserDelegationKeyHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ServicesListBlobContainersSegmentHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ServicesListBlobContainersSegmentNextHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ServicesSetPropertiesHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.ServicesSubmitBatchHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.StorageError", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.models.StorageErrorException", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.BlobHeadersAndQueryParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.BlobQueryReader", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.BlobRequestConditionProperty", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.BlobSasImplUtil", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.BlobUserAgentModificationPolicy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.BuilderHelper", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.ChunkedDownloadUtils", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.CustomHierarchicalListingDeserializer", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.ModelHelper", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.implementation.util.StorageBlockingSink", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.AccessTier", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.AccountKind", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.AppendBlobItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.AppendBlobRequestConditions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ArchiveStatus", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobAccessPolicy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobAnalyticsLogging", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobContainerAccessPolicies", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobContainerEncryptionScope", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobContainerItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobContainerItemProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobContainerListDetails", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobContainerProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobCopyInfo", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobCopySourceTagsMode", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobCorsRule", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobDownloadAsyncResponse", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobDownloadContentAsyncResponse", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobDownloadContentResponse", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobDownloadHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobDownloadResponse", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobErrorCode", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobHttpHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobImmutabilityPolicy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobImmutabilityPolicyMode", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobItemProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobLeaseRequestConditions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobLegalHoldResult", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobListDetails", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobMetrics", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobPrefix", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryArrowField", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryArrowFieldType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryArrowSerialization", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryAsyncResponse", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryDelimitedSerialization", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryError", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryHeaders", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryJsonSerialization", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryParquetSerialization", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryProgress", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQueryResponse", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobQuerySerialization", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobRange", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobRequestConditions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobRetentionPolicy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobServiceProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobServiceStatistics", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobSignedIdentifier", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobStorageException", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlobType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.Block", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlockBlobItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlockList", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlockListType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.BlockLookupList", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ClearRange", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ConsistentReadControl", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.CopyStatusType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.CpkInfo", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.CustomerProvidedKey", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.DeleteSnapshotsOptionType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.DownloadRetryOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.EncryptionAlgorithmType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.GeoReplication", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.GeoReplicationStatus", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.KeyInfo", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.LeaseDurationType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.LeaseStateType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.LeaseStatusType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ListBlobContainersIncludeType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ListBlobContainersOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ListBlobsIncludeItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ListBlobsOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ObjectReplicationPolicy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ObjectReplicationRule", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ObjectReplicationStatus", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.PageBlobCopyIncrementalRequestConditions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.PageBlobItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.PageBlobRequestConditions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.PageList", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.PageListDeserializer", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.PageRange", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.PageRangeItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.ParallelTransferOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.PathRenameMode", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.PublicAccessType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.RehydratePriority", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.SequenceNumberActionType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.SkuName", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.StaticWebsite", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.StorageAccountInfo", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.SyncCopyStatusType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.TaggedBlobItem", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.models.UserDelegationKey", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.AppendBlobAppendBlockFromUrlOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.AppendBlobCreateOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.AppendBlobSealOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobAcquireLeaseOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobBeginCopyOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobBreakLeaseOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobChangeLeaseOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobContainerCreateOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobContainerRenameOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobCopyFromUrlOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobDownloadToFileOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobGetTagsOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobInputStreamOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobParallelUploadOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobQueryOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobReleaseLeaseOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobRenewLeaseOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobSetAccessTierOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobSetTagsOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobUploadFromFileOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlobUploadFromUrlOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlockBlobCommitBlockListOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlockBlobListBlocksOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlockBlobOutputStreamOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlockBlobSimpleUploadOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlockBlobStageBlockFromUrlOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.BlockBlobStageBlockOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.FindBlobsOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.ListPageRangesDiffOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.ListPageRangesOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.PageBlobCopyIncrementalOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.PageBlobCreateOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.PageBlobUploadPagesFromUrlOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.options.UndeleteBlobContainerOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.sas.BlobContainerSasPermission", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.sas.BlobSasPermission", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.sas.BlobSasServiceVersion", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.sas.BlobServiceSasQueryParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.sas.BlobServiceSasSignatureValues", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.AppendBlobAsyncClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.AppendBlobClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.BlobAsyncClientBase", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.BlobClientBase", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.BlobInputStream", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.BlobLeaseAsyncClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.BlobLeaseClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.BlobLeaseClientBuilder", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.BlobOutputStream", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.BlockBlobAsyncClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.BlockBlobClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.PageBlobAsyncClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.PageBlobClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.ReliableDownload", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.storage.blob.specialized.SpecializedBlobClientBuilder", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - } -] \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/resource-config.json b/sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/resource-config.json deleted file mode 100644 index 8a791a164f4a..000000000000 --- a/sdk/storage/azure-storage-blob/src/main/resources/META-INF/native-image/com.azure/azure-storage-blob/resource-config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "resources": { - "includes": [ - { - "pattern": "\\Qazure-storage-blob.properties\\E" - } - ] - }, - "bundles": [] -} diff --git a/sdk/storage/azure-storage-blob/src/samples/README.md b/sdk/storage/azure-storage-blob/src/samples/README.md deleted file mode 100644 index 360af08a0069..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/README.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -page_type: sample -languages: - - java -products: - - azure - - azure-storage - - azure-blob-storage -urlFragment: storage-blob-samples ---- - -# Azure Storage Blob Samples client library for Java -This document explains samples and how to use them. - -## Key concepts -Key concepts are explained in detail [here][SDK_README_KEY_CONCEPTS]. - -# Samples Azure Storage Blob APIs -This document describes how to use samples and what is done in each sample. - -## Getting started -Getting started explained in detail [here][SDK_README_GETTING_STARTED]. - -For details on including this dependency in other build tools (Gradle, SBT, etc), refer [here](https://central.sonatype.com/artifact/com.azure/azure-core). - -## Examples - Following section document various examples. - -1. [Basic Examples][samples_basic]: Create storage, container and blob clients. Upload, download and list blobs. -2. [File Transfer Examples][samples_file_transfer]: Upload and download a large file through blobs. -3. [Storage Error Examples][samples_storage_error]: Handle the exceptions thrown from the Storage Blob service side. -4. [List Container Examples][samples_list_containers]: Create, list and delete containers. -5. [Set Metadata and HTTPHeaders Examples][samples_metadata]: Set metadata for containers and blobs, and set HTTPHeaders for blobs. -6. [Azure Identity Examples][samples_identity]: Use `DefaultAzureCredential` to do the authentication. - -## Troubleshooting -When interacting with blobs using this Java client library, errors returned by the service correspond to the same HTTP -status codes returned for [REST API][error_codes] requests. For example, if you try to retrieve a container or blob that -doesn't exist in your Storage Account, a `404` error is returned, indicating `Not Found` - -## Next steps -Start using Storage blob Java SDK in your solutions. Our SDK details could be found at [SDK README][BLOB_SDK_README]. - -### Additional Documentation -For more extensive documentation on Azure Storage blob, see the [API reference documentation][storageblob_rest]. - -## Contributing -This project welcomes contributions and suggestions. Find [more contributing][SDK_README_CONTRIBUTING] details here. - - -[BLOB_SDK_README]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/README.md -[SDK_README_CONTRIBUTING]:https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/README.md#contributing -[SDK_README_GETTING_STARTED]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/README.md#getting-started -[SDK_README_KEY_CONCEPTS]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/README.md#key-concepts -[samples_basic]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BasicExample.java -[samples_file_transfer]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/FileTransferExample.java -[samples_storage_error]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageErrorHandlingExample.java -[samples_list_containers]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ListContainersExample.java -[samples_metadata]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/SetMetadataAndHTTPHeadersExample.java -[samples_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/AzureIdentityExample.java -[storageblob_rest]: https://learn.microsoft.com/rest/api/storageservices/blob-service-rest-api -[error_codes]: https://learn.microsoft.com/rest/api/storageservices/blob-service-error-codes - - diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/AsyncBufferedUploadExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/AsyncBufferedUploadExample.java deleted file mode 100644 index 4cca812b1395..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/AsyncBufferedUploadExample.java +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.common.StorageSharedKeyCredential; -import reactor.core.publisher.Flux; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.util.Locale; -import java.util.Random; - -/** - * This example shows how to use the buffered upload method on BlockBlobAsyncClient. - * - * Note that the use of .block() in the method is only used to enable the sample to run effectively in isolation. It is - * not recommended for use in async environments. - */ -public class AsyncBufferedUploadExample { - /** - * Entry point into the basic examples for Storage blobs. - * @param args Unused. Arguments to the program. - * @throws IOException If an I/O error occurs - * @throws RuntimeException If the downloaded data doesn't match the uploaded data - */ - public static void main(String[] args) throws IOException { - - /* - * For more information on this setup, please refer to the BasicExample. - */ - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - String containerName = "myjavacontainerbufferedupload" + System.currentTimeMillis(); - BlobServiceAsyncClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential) - .buildAsyncClient(); - - BlobContainerAsyncClient containerClient = storageClient.getBlobContainerAsyncClient(containerName); - containerClient.create().block(); - - uploadSourceBlob(endpoint, credential, containerName); - BlobAsyncClient blobClient = containerClient.getBlobAsyncClient("HelloWorld.txt"); - - - /* - sourceData has a network stream as its source and therefore likely does not support multiple subscribers. Even - if it did support multiple subscribers, it would not produce the same data each time it was subscribed to. While - we could inspect the http headers for the content-length, let us suppose that this information is unavailable - at this time. All three of these factors would individually make the use of the standard upload method - impossible--the first two because retries would not work and the third one because we could not satisfy the - argument list. - */ - Flux sourceData = getSourceBlobClient(endpoint, credential, containerName).downloadStream() - // Perform some unpredictable transformation. - .map(AsyncBufferedUploadExample::randomTransformation); - - /* - This upload overload permits the use of such unreliable data sources. The length need not be specified, but - the tradeoff is that data must be buffered, so a buffer size and maximum concurrency is required instead. The - Javadoc on the method will give more detailed information on the significance of these parameters, but they are - likely context dependent. - */ - long blockSize = 10 * 1024; - int maxConcurrency = 5; - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() - .setBlockSizeLong(blockSize) - .setMaxConcurrency(maxConcurrency); - blobClient.upload(sourceData, parallelTransferOptions).block(); - } - - @SuppressWarnings("cast") - private static ByteBuffer randomTransformation(ByteBuffer buffer) { - // The JDK changed the return type of ByteBuffer#limit between 8 and 9. In 8 and below it returns Buffer, whereas - // in JDK 9 and later, it returns ByteBuffer. To compile on both, we explicitly cast the returned value to - // ByteBuffer. - // See https://bugs-stage.openjdk.java.net/browse/JDK-8062376 - return (ByteBuffer) buffer.limit(new Random().nextInt(buffer.limit())); - } - - private static void uploadSourceBlob(String endpoint, StorageSharedKeyCredential credential, String containerName) { - getSourceBlobClient(endpoint, credential, containerName) - .upload(Flux.just(ByteBuffer.wrap("Hello world".getBytes(Charset.defaultCharset()))), "Hello world".length()).block(); - } - - private static BlockBlobAsyncClient getSourceBlobClient(String endpoint, StorageSharedKeyCredential credential, - String containerName) { - return new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildAsyncClient() - .getBlobContainerAsyncClient(containerName).getBlobAsyncClient("sourceBlob").getBlockBlobAsyncClient(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/AzureIdentityExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/AzureIdentityExample.java deleted file mode 100644 index d5c581dc9610..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/AzureIdentityExample.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.identity.DefaultAzureCredentialBuilder; - -import java.util.Locale; - -/** - * Creates default DefaultAzureCredential instance to use. This will use AZURE_CLIENT_ID, - * AZURE_CLIENT_SECRET, and AZURE_TENANT_ID environment variables to create a - * ClientSecretCredential. - */ -public class AzureIdentityExample { - - /** - * Entry point into the Azure Identity example for Storage blobs. - * @param args Unused. Arguments to the program. - */ - public static void main(String[] args) { - String accountName = SampleHelper.getAccountName(); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - /* - * Create a storage client using the Azure Identity credentials. - */ - BlobServiceClient storageClient = new BlobServiceClientBuilder() - .endpoint(endpoint) - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); - - System.out.println("Successfully setup client using the Azure Identity, please check the service version: " - + storageClient.getProperties().getDefaultServiceVersion()); - - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BasicExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BasicExample.java deleted file mode 100644 index efa3fbaa2f54..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BasicExample.java +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.common.StorageSharedKeyCredential; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Locale; - -/** - * This example shows how to start using the Azure Storage Blob SDK for Java. - */ -public class BasicExample { - - /** - * Entry point into the basic examples for Storage blobs. - * - * @param args Unused. Arguments to the program. - * @throws IOException If an I/O error occurs - * @throws RuntimeException If the downloaded data doesn't match the uploaded data - */ - public static void main(String[] args) throws IOException { - - /* - * From the Azure portal, get your Storage account's name and account key. - */ - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - - /* - * Use your Storage account's name and key to create a credential object; this is used to access your account. - */ - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - /* - * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. - */ - BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient(); - - /* - * This example shows several common operations just to get you started. - */ - - /* - * Create a client that references a to-be-created container in your Azure Storage account. This returns a - * ContainerClient object that wraps the container's endpoint, credential and a request pipeline (inherited from storageClient). - * Note that container names require lowercase. - */ - BlobContainerClient blobContainerClient = storageClient.getBlobContainerClient("myjavacontainerbasic" + System.currentTimeMillis()); - - /* - * Create a container in Storage blob account. - */ - blobContainerClient.create(); - - /* - * Create a client that references a to-be-created blob in your Azure Storage account's container. - * This returns a BlockBlobClient object that wraps the blob's endpoint, credential and a request pipeline - * (inherited from containerClient). Note that blob names can be mixed case. - */ - BlockBlobClient blobClient = blobContainerClient.getBlobClient("HelloWorld.txt").getBlockBlobClient(); - - String data = "Hello world!"; - InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - - /* - * Create the blob with string (plain text) content. - */ - blobClient.upload(dataStream, data.length()); - - dataStream.close(); - - /* - * Download the blob's content to output stream. - */ - int dataSize = (int) blobClient.getProperties().getBlobSize(); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(dataSize); - blobClient.downloadStream(outputStream); - outputStream.close(); - - /* - * Verify that the blob data round-tripped correctly. - */ - if (!data.equals(new String(outputStream.toByteArray(), StandardCharsets.UTF_8))) { - throw new RuntimeException("The downloaded data does not match the uploaded data."); - } - - /* - * Create more blobs before listing. - */ - for (int i = 0; i < 3; i++) { - String sampleData = "Samples"; - InputStream dataInBlobs = new ByteArrayInputStream(sampleData.getBytes(Charset.defaultCharset())); - blobContainerClient.getBlobClient("myblobsforlisting" + System.currentTimeMillis()).getBlockBlobClient() - .upload(dataInBlobs, sampleData.length()); - dataInBlobs.close(); - } - - /* - * List the blob(s) in our container. - */ - blobContainerClient.listBlobs() - .forEach(blobItem -> System.out.println("Blob name: " + blobItem.getName() + ", Snapshot: " + blobItem.getSnapshot())); - - /* - * Delete the blob we created earlier. - */ - blobClient.delete(); - - /* - * Delete the container we created earlier. - */ - blobContainerClient.delete(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java deleted file mode 100644 index a2225dd325ee..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,623 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.RequestConditions; -import com.azure.core.util.BinaryData; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.options.BlobUploadFromFileOptions; -import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.specialized.BlobAsyncClientBase; -import com.azure.storage.blob.specialized.BlockBlobClient; -import reactor.core.publisher.Flux; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import java.util.Base64; -import java.util.Collections; -import java.util.Map; - -/** - * Code snippets for {@link BlobAsyncClient} - */ -@SuppressWarnings("unused") -public class BlobAsyncClientJavaDocCodeSnippets { - - private BlobAsyncClient client = JavaDocCodeSnippetsHelpers.getBlobAsyncClient("blobName"); - private Flux data = Flux.just(ByteBuffer.wrap("data".getBytes(StandardCharsets.UTF_8))); - private String leaseId = "leaseId"; - private String copyId = "copyId"; - private String url = "https://sample.com"; - private String file = "file"; - private long blockSize = 50; - private int maxConcurrency = 2; - private String filePath = "filePath"; - private UserDelegationKey userDelegationKey = JavaDocCodeSnippetsHelpers.getUserDelegationKey(); - - /** - * Code snippet for {@link BlobAsyncClient#exists()} - */ - public void existsCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.exists - client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response)); - // END: com.azure.storage.blob.BlobAsyncClient.exists - } - - /** - * Code snippets for {@link BlobAsyncClient#abortCopyFromUrl(String)} - */ - public void abortCopyFromUrlCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.abortCopyFromURL#String - client.abortCopyFromUrl(copyId).doOnSuccess(response -> System.out.println("Aborted copy from URL")); - // END: com.azure.storage.blob.BlobAsyncClient.abortCopyFromURL#String - } - - /** - * Code snippets for {@link BlobAsyncClient#copyFromUrl(String)} - */ - public void copyFromUrlCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.copyFromURL#String - client.copyFromUrl(url).subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); - // END: com.azure.storage.blob.BlobAsyncClient.copyFromURL#String - } - - /** - * Code snippets for {@link BlobAsyncClient#download()} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.download - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - client.download().subscribe(piece -> { - try { - downloadData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - // END: com.azure.storage.blob.BlobAsyncClient.download - } - - /** - * Code snippets for {@link BlobAsyncClient#downloadContent()} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadContentCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.downloadContent - client.downloadContent().subscribe(data -> { - System.out.printf("Downloaded %s", data.toString()); - }); - // END: com.azure.storage.blob.BlobAsyncClient.downloadContent - } - - /** - * Code snippets for {@link BlobAsyncClient#downloadWithResponse(BlobRange, DownloadRetryOptions, - * BlobRequestConditions, boolean)} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.download#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - BlobRange range = new BlobRange(1024, 2048L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadWithResponse(range, options, null, false).subscribe(response -> { - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - response.getValue().subscribe(piece -> { - try { - downloadData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - }); - // END: com.azure.storage.blob.BlobAsyncClient.download#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - } - - /** - * Code snippets for {@link BlobAsyncClient#downloadToFile(String)} and {@link BlobAsyncClient#downloadToFileWithResponse( - * String, BlobRange, ParallelTransferOptions, DownloadRetryOptions, BlobRequestConditions, boolean)} - */ - public void downloadToFileCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.downloadToFile#String - client.downloadToFile(file).subscribe(response -> System.out.println("Completed download to file")); - // END: com.azure.storage.blob.BlobAsyncClient.downloadToFile#String - - // BEGIN: com.azure.storage.blob.BlobAsyncClient.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean - BlobRange range = new BlobRange(1024, 2048L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadToFileWithResponse(file, range, null, options, null, false) - .subscribe(response -> System.out.println("Completed download to file")); - // END: com.azure.storage.blob.BlobAsyncClient.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean - } - - /** - * Code snippets for {@link BlobAsyncClient#delete()} - */ - public void deleteCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.delete - client.delete().doOnSuccess(response -> System.out.println("Completed delete")); - // END: com.azure.storage.blob.BlobAsyncClient.delete - } - - /** - * Code snippets for {@link BlobAsyncClient#getProperties()} - */ - public void getPropertiesCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.getProperties - client.getProperties().subscribe(response -> - System.out.printf("Type: %s, Size: %d%n", response.getBlobType(), response.getBlobSize())); - // END: com.azure.storage.blob.BlobAsyncClient.getProperties - } - - /** - * Code snippets for {@link BlobAsyncClient#setHttpHeaders(BlobHttpHeaders)} - */ - public void setHTTPHeadersCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.setHTTPHeaders#BlobHttpHeaders - client.setHttpHeaders(new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary")); - // END: com.azure.storage.blob.BlobAsyncClient.setHTTPHeaders#BlobHttpHeaders - } - - /** - * Code snippets for {@link BlobAsyncClient#setMetadata(Map)} - */ - public void setMetadataCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.setMetadata#Metadata - client.setMetadata(Collections.singletonMap("metadata", "value")); - // END: com.azure.storage.blob.BlobAsyncClient.setMetadata#Metadata - } - - /** - * Code snippets for {@link BlobAsyncClient#createSnapshot()} - */ - public void createSnapshotCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.createSnapshot - client.createSnapshot() - .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n", - response.getSnapshotId())); - // END: com.azure.storage.blob.BlobAsyncClient.createSnapshot - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setAccessTier(AccessTier)} - */ - public void setTierCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.setTier#AccessTier - client.setAccessTier(AccessTier.HOT); - // END: com.azure.storage.blob.BlobAsyncClient.setTier#AccessTier - } - - /** - * Code snippet for {@link BlobAsyncClient#undelete()} - */ - public void undeleteCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.undelete - client.undelete().doOnSuccess(response -> System.out.println("Completed undelete")); - // END: com.azure.storage.blob.BlobAsyncClient.undelete - } - - /** - * Code snippet for {@link BlobAsyncClient#getAccountInfo()} - */ - public void getAccountInfoCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.getAccountInfo - client.getAccountInfo().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n", - response.getAccountKind(), response.getSkuName())); - // END: com.azure.storage.blob.BlobAsyncClient.getAccountInfo - } - - /** - * Code snippet for {@link BlobAsyncClient#existsWithResponse()}abortCopyFromURL - */ - public void existsWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.existsWithResponse - client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue())); - // END: com.azure.storage.blob.BlobAsyncClient.existsWithResponse - } - - /** - * Code snippets for {@link BlobAsyncClient#abortCopyFromUrlWithResponse(String, String)} - */ - public void abortCopyFromUrlWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobAsyncClient.abortCopyFromUrlWithResponse#String-String - client.abortCopyFromUrlWithResponse(copyId, leaseId) - .subscribe( - response -> System.out.printf("Aborted copy completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobAsyncClient.abortCopyFromUrlWithResponse#String-String - } - - /** - * Code snippets for {@link BlobAsyncClient#copyFromUrlWithResponse(String, Map, AccessTier, - * RequestConditions, BlobRequestConditions)} - */ - public void copyFromUrlWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobAsyncClient.copyFromUrlWithResponse#String-Metadata-AccessTier-RequestConditions-BlobRequestConditions - Map metadata = Collections.singletonMap("metadata", "value"); - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions, blobRequestConditions) - .subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); - // END: com.azure.storage.blob.BlobAsyncClient.copyFromUrlWithResponse#String-Metadata-AccessTier-RequestConditions-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClient#downloadWithResponse(BlobRange, DownloadRetryOptions, - * BlobRequestConditions, boolean)} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.downloadWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - BlobRange range = new BlobRange(1024, (long) 2048); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadWithResponse(range, options, null, false).subscribe(response -> { - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - response.getValue().subscribe(piece -> { - try { - downloadData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - }); - // END: com.azure.storage.blob.BlobAsyncClient.downloadWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - } - - /** - * Code snippets for {@link BlobAsyncClient#deleteWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions)} - */ - public void deleteWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobAsyncClient.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions - client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null) - .subscribe(response -> System.out.printf("Delete completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobAsyncClient.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClient#getPropertiesWithResponse(BlobRequestConditions)} - */ - public void getPropertiesWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobAsyncClient.getPropertiesWithResponse#BlobRequestConditions - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.getPropertiesWithResponse(requestConditions).subscribe( - response -> System.out.printf("Type: %s, Size: %d%n", response.getValue().getBlobType(), - response.getValue().getBlobSize())); - // END: com.azure.storage.blob.BlobAsyncClient.getPropertiesWithResponse#BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClient#setHttpHeadersWithResponse(BlobHttpHeaders, BlobRequestConditions)} - */ - public void setHTTPHeadersWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobAsyncClient.setHttpHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.setHttpHeadersWithResponse(new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"), requestConditions).subscribe( - response -> - System.out.printf("Set HTTP headers completed with status %d%n", - response.getStatusCode())); - // END: com.azure.storage.blob.BlobAsyncClient.setHttpHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClient#setMetadataWithResponse(Map, BlobRequestConditions)} - */ - public void setMetadataWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.setMetadataWithResponse#Metadata-BlobRequestConditions - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions) - .subscribe( - response -> System.out.printf("Set metadata completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobAsyncClient.setMetadataWithResponse#Metadata-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClient#createSnapshotWithResponse(Map, BlobRequestConditions)} - */ - public void createSnapshotWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobAsyncClient.createSnapshotWithResponse#Metadata-BlobRequestConditions - Map snapshotMetadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.createSnapshotWithResponse(snapshotMetadata, requestConditions) - .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n", response.getValue())); - // END: com.azure.storage.blob.BlobAsyncClient.createSnapshotWithResponse#Metadata-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setAccessTierWithResponse(AccessTier, RehydratePriority, String)} - */ - public void setTierWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.setTierWithResponse#AccessTier-RehydratePriority-String - client.setAccessTierWithResponse(AccessTier.HOT, RehydratePriority.STANDARD, leaseId) - .subscribe(response -> System.out.printf("Set tier completed with status code %d%n", - response.getStatusCode())); - // END: com.azure.storage.blob.BlobAsyncClient.setTierWithResponse#AccessTier-RehydratePriority-String - } - - /** - * Code snippet for {@link BlobAsyncClient#undeleteWithResponse()} - */ - public void undeleteWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.undeleteWithResponse - client.undeleteWithResponse() - .subscribe(response -> System.out.printf("Undelete completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobAsyncClient.undeleteWithResponse - } - - /** - * Code snippet for {@link BlobAsyncClient#getAccountInfoWithResponse()} - */ - public void getAccountInfoWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.getAccountInfoWithResponse - client.getAccountInfoWithResponse().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n", - response.getValue().getAccountKind(), response.getValue().getSkuName())); - // END: com.azure.storage.blob.BlobAsyncClient.getAccountInfoWithResponse - } - - /** - * Generates a code sample for using {@link BlobAsyncClient#getContainerName()} - */ - public void getContainerName() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.getContainerName - String containerName = client.getContainerName(); - System.out.println("The name of the container is " + containerName); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getContainerName - } - - /** - * Generates a code sample for using {@link BlobAsyncClient#getContainerAsyncClient()} - */ - public void getContainerClient() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.getContainerAsyncClient - BlobContainerAsyncClient containerClient = client.getContainerAsyncClient(); - System.out.println("The name of the container is " + containerClient.getBlobContainerName()); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getContainerAsyncClient - } - - /** - * Generates a code sample for using {@link BlobAsyncClient#getBlobName()} - */ - public void getBlobName() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.getBlobName - String blobName = client.getBlobName(); - System.out.println("The name of the blob is " + blobName); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getBlobName - } - - /** - * Code snippet for {@link BlobAsyncClient#upload(Flux, ParallelTransferOptions)} - */ - public void upload3() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.upload#Flux-ParallelTransferOptions - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() - .setBlockSizeLong(blockSize) - .setMaxConcurrency(maxConcurrency); - client.upload(data, parallelTransferOptions).subscribe(response -> - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.BlobAsyncClient.upload#Flux-ParallelTransferOptions - } - - /** - * Code snippet for {@link BlobAsyncClient#upload(Flux, ParallelTransferOptions, boolean)} - */ - public void uploadOverwrite() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.upload#Flux-ParallelTransferOptions-boolean - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() - .setBlockSizeLong(blockSize) - .setMaxConcurrency(maxConcurrency); - boolean overwrite = false; // Default behavior - client.upload(data, parallelTransferOptions, overwrite).subscribe(response -> - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.BlobAsyncClient.upload#Flux-ParallelTransferOptions-boolean - } - - /** - * Code snippet for {@link BlobAsyncClient#upload(BinaryData)} - */ - public void uploadBinaryData() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.upload#BinaryData - client.upload(BinaryData.fromString("Data!")).subscribe(response -> - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.BlobAsyncClient.upload#BinaryData - } - - /** - * Code snippet for {@link BlobAsyncClient#upload(BinaryData, boolean)} - */ - public void uploadBinaryDataOverwrite() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.upload#BinaryData-boolean - boolean overwrite = false; // Default behavior - client.upload(BinaryData.fromString("Data!"), overwrite).subscribe(response -> - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.BlobAsyncClient.upload#BinaryData-boolean - } - - /** - * Code snippet for {@link BlobAsyncClient#uploadWithResponse(Flux, ParallelTransferOptions, BlobHttpHeaders, Map, AccessTier, BlobRequestConditions)} - */ - public void upload4() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#Flux-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() - .setBlockSizeLong(blockSize) - .setMaxConcurrency(maxConcurrency); - - client.uploadWithResponse(data, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions) - .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); - // END: com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#Flux-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions - } - - /** - * Code snippet for {@link BlobAsyncClient#uploadWithResponse(Flux, ParallelTransferOptions, BlobHttpHeaders, Map, AccessTier, BlobRequestConditions)} - */ - public void upload5() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#Flux-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions.ProgressReporter - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() - .setBlockSizeLong(blockSize) - .setMaxConcurrency(maxConcurrency) - .setProgressListener(bytesTransferred -> System.out.printf("Upload progress: %s bytes sent", bytesTransferred)); - - client.uploadWithResponse(data, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions) - .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); - // END: com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#Flux-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions.ProgressReporter - } - - /** - * Code snippet for {@link BlobAsyncClient#uploadWithResponse(BlobParallelUploadOptions)} - */ - public void upload6() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#BlobParallelUploadOptions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxConcurrency(maxConcurrency).setProgressListener(bytesTransferred -> - System.out.printf("Upload progress: %s bytes sent", bytesTransferred)); - - client.uploadWithResponse(new BlobParallelUploadOptions(data) - .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata).setTags(tags) - .setTier(AccessTier.HOT).setRequestConditions(requestConditions)) - .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); - // END: com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#BlobParallelUploadOptions - } - - /** - * Code snippet for {@link BlobAsyncClient#uploadFromFile(String)} - */ - public void uploadFromFile() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String - client.uploadFromFile(filePath) - .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) - .subscribe(completion -> System.out.println("Upload from file succeeded")); - // END: com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String - } - - /** - * Code snippet for {@link BlobAsyncClient#uploadFromFile(String, boolean)} - */ - public void uploadFromFileOverwrite() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-boolean - boolean overwrite = false; // Default behavior - client.uploadFromFile(filePath, overwrite) - .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) - .subscribe(completion -> System.out.println("Upload from file succeeded")); - // END: com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-boolean - } - - /** - * Code snippet for {@link BlobAsyncClient#uploadFromFile(String, ParallelTransferOptions, BlobHttpHeaders, Map, AccessTier, BlobRequestConditions)} - */ - public void uploadFromFile2() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.uploadFromFile(filePath, - new ParallelTransferOptions().setBlockSizeLong(BlockBlobClient.MAX_STAGE_BLOCK_BYTES_LONG), - headers, metadata, AccessTier.HOT, requestConditions) - .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) - .subscribe(completion -> System.out.println("Upload from file succeeded")); - // END: com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions - } - - /** - * Code snippet for {@link BlobAsyncClient#uploadFromFileWithResponse(BlobUploadFromFileOptions)} - */ - public void uploadFromFile3() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.uploadFromFileWithResponse#BlobUploadFromFileOptions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Long blockSize = 100 * 1024 * 1024L; // 100 MB; - - client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath) - .setParallelTransferOptions( - new ParallelTransferOptions().setBlockSizeLong(blockSize)) - .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT) - .setRequestConditions(requestConditions)) - .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) - .subscribe(completion -> System.out.println("Upload from file succeeded")); - // END: com.azure.storage.blob.BlobAsyncClient.uploadFromFileWithResponse#BlobUploadFromFileOptions - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAudienceExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAudienceExample.java deleted file mode 100644 index 8d614799d085..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAudienceExample.java +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.credential.TokenCredential; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.models.BlobAudience; - -import java.util.Locale; - -/** - * This example shows how to use audience-based authentication with Azure Storage fpr blobs. Audience-based - * authentication requires AAD authentication. The audience is to be used when requesting a token from - * Azure Active Directory (AAD). Note: This audience only has an effect when authenticating a TokenCredential. - */ -public class BlobAudienceExample { - - public static void main(String[] args) { - /* - * From the Azure portal, get your Storage account's name. - */ - String accountName = SampleHelper.getAccountName(); - - /* - * audience will look like: "https://.blob.core.windows.net" - */ - BlobAudience audience = BlobAudience.createBlobServiceAccountAudience(accountName); - - /* The credential used is DefaultAzureCredential because it combines commonly used credentials - * in deployment and development and chooses the credential to used based on its running environment. - * More information can be found at: https://learn.microsoft.com/java/api/overview/azure/identity-readme - * AAD authentication is required for audience-based authentication. - */ - TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - /* - * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. - */ - BlobServiceClient serviceClient = new BlobServiceClientBuilder() - .endpoint(endpoint) - .credential(tokenCredential) - .audience(null) // The default audience is "https://storage.azure.com" - .buildClient(); - - // This call will succeed because the default audience is "https://storage.azure.com" - serviceClient.getProperties(); - - - /* - Now create a BlobContainerClient that takes a specific audience. - */ - BlobContainerClient containerClient = new BlobContainerClientBuilder() - .endpoint(endpoint) - .credential(tokenCredential) - .audience(audience) - .containerName("myContainer") - .buildClient(); - - /* - Any calls to the service should successfully work with the specified audience. - */ - containerClient.create(); - containerClient.getBlobClient("myBlob").uploadFromFile("path/to/file"); - - /* - The storage account name must be a valid name. If an incorrect storage account name is specified, authentication - will fail. - */ - BlobAudience badAudience = BlobAudience.createBlobServiceAccountAudience("invalidAccount"); - BlobContainerClient badContainerClient = new BlobContainerClientBuilder() - .endpoint(endpoint) - .credential(tokenCredential) - .audience(badAudience) // audience will look like: "https://invalidaccount.blob.core.windows.net" - .containerName("myBadContainer") - .buildClient(); - - try { - badContainerClient.create(); - } catch (Exception e) { - System.out.println("Authentication failed with invalid storage account name."); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientBuilderJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientBuilderJavaDocCodeSnippets.java deleted file mode 100644 index 1b6cb0419729..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientBuilderJavaDocCodeSnippets.java +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.policy.AddDatePolicy; -import com.azure.core.http.policy.RequestIdPolicy; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.RequestRetryPolicy; -import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; - -/** - * Code snippets for {@link BlobClientBuilder} - */ -@SuppressWarnings({"unused"}) -public class BlobClientBuilderJavaDocCodeSnippets { - private String connectionString = "AccountName=name;AccountKey=key;DefaultEndpointProtocol=protocol;EndpointSuffix=suffix"; - private String endpoint = "endpointURL"; - private String containerName = "container Name"; - private StorageSharedKeyCredential storageSharedKeyCredential = new StorageSharedKeyCredential("accountName", "accountKey"); - private HttpPipeline httpPipeline = new HttpPipelineBuilder() - .httpClient(HttpClient.createDefault()) - .policies(new AddDatePolicy()) - .policies(new RequestIdPolicy()) - .policies(new StorageSharedKeyCredentialPolicy(storageSharedKeyCredential)) - .policies(new RequestRetryPolicy(new RequestRetryOptions())) - .build(); - - /** - * Code snippet for {@link BlobClientBuilder#buildClient()} using connection string - */ - public void blobClientConnectionString() { - // BEGIN: com.azure.storage.blob.BlobClientBuilder.buildClient - BlobClient client = new BlobClientBuilder() - .connectionString(connectionString) - .buildClient(); - // END: com.azure.storage.blob.BlobClientBuilder.buildClient - } - - /** - * Code snippet for {@link BlobClientBuilder#buildAsyncClient()} using connection string - */ - public void blobAsyncClientConnectionString() { - // BEGIN: com.azure.storage.blob.BlobClientBuilder.buildAsyncClient - BlobAsyncClient client = new BlobClientBuilder() - .connectionString(connectionString) - .buildAsyncClient(); - // END: com.azure.storage.blob.BlobClientBuilder.buildAsyncClient - } - - /** - * Code snippet for {@link BlobClientBuilder#endpoint(String)} using credential and endpoint - */ - public void blobClientCredentialAndEndpoint() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.Builder.endpoint#String - BlobClient client = new BlobClientBuilder() - .endpoint(endpoint) - .credential(storageSharedKeyCredential) - .buildClient(); - // END: com.azure.storage.blob.specialized.BlobClientBase.Builder.endpoint#String - } - - /** - * Code snippet for {@link BlobClientBuilder#containerName(String)} using HttpPipeline - */ - public void blobClientHttpPipeline() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.Builder.containerName#String - BlobClient client = new BlobClientBuilder() - .endpoint(endpoint) - .containerName(containerName) - .buildClient(); - // END: com.azure.storage.blob.specialized.BlobClientBase.Builder.containerName#String - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java deleted file mode 100644 index bd1f0ae8ce79..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,487 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.RequestConditions; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.options.BlobUploadFromFileOptions; -import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.specialized.BlobClientBase; -import com.azure.storage.common.implementation.Constants; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UncheckedIOException; -import java.nio.charset.StandardCharsets; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.Map; - -/** - * Code snippets for {@link BlobClient} - */ -@SuppressWarnings("unused") -public class BlobClientJavaDocCodeSnippets { - private BlobClient client = new BlobClientBuilder().endpoint("https://storageaccount.blob.core.windows.net") - .containerName("containerName").blobName("blobName").sasToken("sasToken").buildClient(); - private String leaseId = "leaseId"; - private String copyId = "copyId"; - private String url = "https://sample.com"; - private String file = "file"; - private Duration timeout = Duration.ofSeconds(30); - private String key1 = "key1"; - private String key2 = "key2"; - private String value1 = "val1"; - private String value2 = "val2"; - private String filePath = "filePath"; - private UserDelegationKey userDelegationKey = JavaDocCodeSnippetsHelpers.getUserDelegationKey(); - - /** - * Code snippets for {@link BlobClient#exists()} - */ - public void existsCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobClient.exists - System.out.printf("Exists? %b%n", client.exists()); - // END: com.azure.storage.blob.BlobClient.exists - } - - /** - * Code snippets for {@link BlobClient#abortCopyFromUrl(String)} - */ - public void abortCopyFromUrl() { - // BEGIN: com.azure.storage.blob.BlobClient.abortCopyFromUrl#String - client.abortCopyFromUrl(copyId); - System.out.println("Aborted copy completed."); - // END: com.azure.storage.blob.BlobClient.abortCopyFromUrl#String - } - - /** - * Code snippets for {@link BlobClient#copyFromUrl(String)} - */ - public void copyFromUrl() { - // BEGIN: com.azure.storage.blob.BlobClient.copyFromUrl#String - System.out.printf("Copy identifier: %s%n", client.copyFromUrl(url)); - // END: com.azure.storage.blob.BlobClient.copyFromUrl#String - } - - /** - * Code snippets for {@link BlobClient#download(OutputStream)} - */ - public void download() { - // BEGIN: com.azure.storage.blob.BlobClient.download#OutputStream - client.download(new ByteArrayOutputStream()); - System.out.println("Download completed."); - // END: com.azure.storage.blob.BlobClient.download#OutputStream - } - - /** - * Code snippets for {@link BlobClient#downloadContent()} - */ - public void downloadContent() { - // BEGIN: com.azure.storage.blob.BlobClient.downloadContent - BinaryData data = client.downloadContent(); - System.out.printf("Downloaded %s", data.toString()); - // END: com.azure.storage.blob.BlobClient.downloadContent - } - - /** - * Code snippets for {@link BlobClient#downloadToFile(String)} and - * {@link BlobClient#downloadToFileWithResponse(String, BlobRange, ParallelTransferOptions, DownloadRetryOptions, BlobRequestConditions, boolean, Duration, Context)} - */ - public void downloadToFile() { - // BEGIN: com.azure.storage.blob.BlobClient.downloadToFile#String - client.downloadToFile(file); - System.out.println("Completed download to file"); - // END: com.azure.storage.blob.BlobClient.downloadToFile#String - - // BEGIN: com.azure.storage.blob.BlobClient.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - BlobRange range = new BlobRange(1024, 2048L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadToFileWithResponse(file, range, new ParallelTransferOptions().setBlockSizeLong(4L * Constants.MB), - options, null, false, timeout, new Context(key2, value2)); - System.out.println("Completed download to file"); - // END: com.azure.storage.blob.BlobClient.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - } - - /** - * Code snippets for {@link BlobClient#delete()} - */ - public void setDelete() { - // BEGIN: com.azure.storage.blob.BlobClient.delete - client.delete(); - System.out.println("Delete completed."); - // END: com.azure.storage.blob.BlobClient.delete - } - - /** - * Code snippets for {@link BlobClient#getProperties()} - */ - public void getProperties() { - // BEGIN: com.azure.storage.blob.BlobClient.getProperties - BlobProperties properties = client.getProperties(); - System.out.printf("Type: %s, Size: %d%n", properties.getBlobType(), properties.getBlobSize()); - // END: com.azure.storage.blob.BlobClient.getProperties - } - - /** - * Code snippets for {@link BlobClient#setHttpHeaders(BlobHttpHeaders)} - */ - public void setHTTPHeaders() { - // BEGIN: com.azure.storage.blob.BlobClient.setHTTPHeaders#BlobHttpHeaders - client.setHttpHeaders(new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary")); - System.out.println("Set HTTP headers completed"); - // END: com.azure.storage.blob.BlobClient.setHTTPHeaders#BlobHttpHeaders - } - - /** - * Code snippets for {@link BlobClient#setMetadata(Map)} - */ - public void setMetadata() { - // BEGIN: com.azure.storage.blob.BlobClient.setMetadata#Metadata - client.setMetadata(Collections.singletonMap("metadata", "value")); - System.out.println("Set metadata completed"); - // END: com.azure.storage.blob.BlobClient.setMetadata#Metadata - } - - /** - * Code snippets for {@link BlobClient#createSnapshot()} - */ - public void createSnapshot() { - // BEGIN: com.azure.storage.blob.BlobClient.createSnapshot - System.out.printf("Identifier for the snapshot is %s%n", client.createSnapshot().getSnapshotId()); - // END: com.azure.storage.blob.BlobClient.createSnapshot - } - - /** - * Code snippets for {@link BlobClientBase#setAccessTier(AccessTier)} - */ - public void setTier() { - // BEGIN: com.azure.storage.blob.BlobClient.setTier#AccessTier - client.setAccessTier(AccessTier.HOT); - System.out.println("Set tier completed."); - // END: com.azure.storage.blob.BlobClient.setTier#AccessTier - - - } - - /** - * Code snippets for {@link BlobClient#undelete()} - */ - public void unsetDelete() { - // BEGIN: com.azure.storage.blob.BlobClient.undelete - client.undelete(); - System.out.println("Undelete completed"); - // END: com.azure.storage.blob.BlobClient.undelete - } - - /** - * Code snippet for {@link BlobClient#getAccountInfo()} - */ - public void getAccountInfo() { - // BEGIN: com.azure.storage.blob.BlobClient.getAccountInfo - StorageAccountInfo accountInfo = client.getAccountInfo(); - System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); - // END: com.azure.storage.blob.BlobClient.getAccountInfo - } - - /** - * Code snippet for {@link BlobClient#existsWithResponse(Duration, Context)} - */ - public void existsWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.BlobClient.existsWithResponse#Duration-Context - System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, new Context(key2, value2)).getValue()); - // END: com.azure.storage.blob.BlobClient.existsWithResponse#Duration-Context - } - - /** - * Code snippets for {@link BlobClient#abortCopyFromUrlWithResponse(String, String, Duration, Context)} - */ - public void abortCopyFromUrlWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobClient.abortCopyFromUrlWithResponse#String-String-Duration-Context - System.out.printf("Aborted copy completed with status %d%n", - client.abortCopyFromUrlWithResponse(copyId, leaseId, timeout, - new Context(key2, value2)).getStatusCode()); - // END: com.azure.storage.blob.BlobClient.abortCopyFromUrlWithResponse#String-String-Duration-Context - } - - /** - * Code snippets for {@link BlobClient#copyFromUrlWithResponse(String, Map, AccessTier, RequestConditions, - * BlobRequestConditions, Duration, Context)} - */ - public void copyFromUrlWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobClient.copyFromUrlWithResponse#String-Metadata-AccessTier-RequestConditions-BlobRequestConditions-Duration-Context - Map metadata = Collections.singletonMap("metadata", "value"); - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - System.out.printf("Copy identifier: %s%n", - client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions, - blobRequestConditions, timeout, - new Context(key1, value1)).getValue()); - // END: com.azure.storage.blob.BlobClient.copyFromUrlWithResponse#String-Metadata-AccessTier-RequestConditions-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClient#downloadWithResponse(OutputStream, BlobRange, DownloadRetryOptions, - * BlobRequestConditions, boolean, Duration, Context)} - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobClient.downloadWithResponse#OutputStream-BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - BlobRange range = new BlobRange(1024, 2048L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - System.out.printf("Download completed with status %d%n", - client.downloadWithResponse(new ByteArrayOutputStream(), range, options, null, false, - timeout, new Context(key2, value2)).getStatusCode()); - // END: com.azure.storage.blob.BlobClient.downloadWithResponse#OutputStream-BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - - } - - /** - * Code snippets for {@link BlobClient#deleteWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions, Duration, - * Context)} - */ - public void deleteWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobClient.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions-Duration-Context - System.out.printf("Delete completed with status %d%n", - client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null, timeout, - new Context(key1, value1)).getStatusCode()); - // END: com.azure.storage.blob.BlobClient.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClient#getPropertiesWithResponse(BlobRequestConditions, Duration, Context)} - */ - public void getPropertiesWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobClient.getPropertiesWithResponse#BlobRequestConditions-Duration-Context - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - BlobProperties properties = client.getPropertiesWithResponse(requestConditions, timeout, - new Context(key2, value2)).getValue(); - System.out.printf("Type: %s, Size: %d%n", properties.getBlobType(), properties.getBlobSize()); - // END: com.azure.storage.blob.BlobClient.getPropertiesWithResponse#BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClient#setHttpHeadersWithResponse(BlobHttpHeaders, BlobRequestConditions, Duration, - * Context)} - */ - public void setHTTPHeadersWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobClient.setHTTPHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions-Duration-Context - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - System.out.printf("Set HTTP headers completed with status %d%n", - client.setHttpHeadersWithResponse(new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"), requestConditions, timeout, new Context(key1, value1)) - .getStatusCode()); - // END: com.azure.storage.blob.BlobClient.setHTTPHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClient#setMetadataWithResponse(Map, BlobRequestConditions, Duration, Context)} - */ - public void setMetadataWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobClient.setMetadataWithResponse#Metadata-BlobRequestConditions-Duration-Context - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - System.out.printf("Set metadata completed with status %d%n", - client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions, timeout, - new Context(key1, value1)).getStatusCode()); - // END: com.azure.storage.blob.BlobClient.setMetadataWithResponse#Metadata-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClient#createSnapshotWithResponse(Map, BlobRequestConditions, Duration, - * Context)} - */ - public void createSnapshotWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.BlobClient.createSnapshotWithResponse#Metadata-BlobRequestConditions-Duration-Context - Map snapshotMetadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - System.out.printf("Identifier for the snapshot is %s%n", - client.createSnapshotWithResponse(snapshotMetadata, requestConditions, timeout, - new Context(key1, value1)).getValue()); - // END: com.azure.storage.blob.BlobClient.createSnapshotWithResponse#Metadata-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#setAccessTierWithResponse(AccessTier, RehydratePriority, String, Duration, Context)} - */ - public void setTierWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobClient.setTierWithResponse#AccessTier-RehydratePriority-String-Duration-Context - System.out.printf("Set tier completed with status code %d%n", - client.setAccessTierWithResponse(AccessTier.HOT, RehydratePriority.STANDARD, leaseId, timeout, - new Context(key2, value2)).getStatusCode()); - // END: com.azure.storage.blob.BlobClient.setTierWithResponse#AccessTier-RehydratePriority-String-Duration-Context - } - - /** - * Code snippet for {@link BlobClient#undeleteWithResponse(Duration, Context)} - */ - public void undeleteWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobClient.undeleteWithResponse#Duration-Context - System.out.printf("Undelete completed with status %d%n", client.undeleteWithResponse(timeout, - new Context(key1, value1)).getStatusCode()); - // END: com.azure.storage.blob.BlobClient.undeleteWithResponse#Duration-Context - } - - /** - * Code snippet for {@link BlobClient#getAccountInfoWithResponse(Duration, Context)} - */ - public void getAccountInfoWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobClient.getAccountInfoWithResponse#Duration-Context - StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, new Context(key1, value1)).getValue(); - System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); - // END: com.azure.storage.blob.BlobClient.getAccountInfoWithResponse#Duration-Context - } - - /** - * Generates a code sample for using {@link BlobClient#getContainerName()} - */ - public void getContainerName() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.getContainerName - String containerName = client.getContainerName(); - System.out.println("The name of the container is " + containerName); - // END: com.azure.storage.blob.specialized.BlobClientBase.getContainerName - } - - /** - * Generates a code sample for using {@link BlobClient#getContainerClient()} - */ - public void getContainerClient() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.getContainerClient - BlobContainerClient containerClient = client.getContainerClient(); - System.out.println("The name of the container is " + containerClient.getBlobContainerName()); - // END: com.azure.storage.blob.specialized.BlobClientBase.getContainerClient - } - - /** - * Generates a code sample for using {@link BlobClient#getBlobName()} - */ - public void getBlobName() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.getBlobName - String blobName = client.getBlobName(); - System.out.println("The name of the blob is " + blobName); - // END: com.azure.storage.blob.specialized.BlobClientBase.getBlobName - } - - /** - * Code snippet for {@link BlobClient#uploadFromFile(String)} - * - * @throws IOException If an I/O error occurs - */ - public void uploadFromFile() throws IOException { - // BEGIN: com.azure.storage.blob.BlobClient.uploadFromFile#String - try { - client.uploadFromFile(filePath); - System.out.println("Upload from file succeeded"); - } catch (UncheckedIOException ex) { - System.err.printf("Failed to upload from file %s%n", ex.getMessage()); - } - // END: com.azure.storage.blob.BlobClient.uploadFromFile#String - } - - /** - * Code snippet for {@link BlobClient#uploadFromFile(String, boolean)} - * - * @throws IOException If an I/O error occurs - */ - public void uploadFromFileOverwrite() throws IOException { - // BEGIN: com.azure.storage.blob.BlobClient.uploadFromFile#String-boolean - try { - boolean overwrite = false; - client.uploadFromFile(filePath, overwrite); - System.out.println("Upload from file succeeded"); - } catch (UncheckedIOException ex) { - System.err.printf("Failed to upload from file %s%n", ex.getMessage()); - } - // END: com.azure.storage.blob.BlobClient.uploadFromFile#String-boolean - } - - /** - * Code snippet for {@link BlobClient#uploadFromFile(String, ParallelTransferOptions, BlobHttpHeaders, Map, AccessTier, BlobRequestConditions, Duration)} - * - * @throws IOException If an I/O error occurs - */ - public void uploadFromFile2() throws IOException { - // BEGIN: com.azure.storage.blob.BlobClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions-Duration - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Long blockSize = 100L * 1024L * 1024L; // 100 MB; - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize); - - try { - client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata, - AccessTier.HOT, requestConditions, timeout); - System.out.println("Upload from file succeeded"); - } catch (UncheckedIOException ex) { - System.err.printf("Failed to upload from file %s%n", ex.getMessage()); - } - // END: com.azure.storage.blob.BlobClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions-Duration - } - - /** - * Code snippet for {@link BlobClient#uploadFromFileWithResponse(BlobUploadFromFileOptions, Duration, Context)} - * - * @throws IOException If an I/O error occurs - */ - public void uploadFromFile3() throws IOException { - // BEGIN: com.azure.storage.blob.BlobClient.uploadFromFileWithResponse#BlobUploadFromFileOptions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Long blockSize = 100 * 1024 * 1024L; // 100 MB; - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize); - - try { - client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath) - .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata) - .setTags(tags).setTier(AccessTier.HOT).setRequestConditions(requestConditions), timeout, - new Context(key2, value2)); - System.out.println("Upload from file succeeded"); - } catch (UncheckedIOException ex) { - System.err.printf("Failed to upload from file %s%n", ex.getMessage()); - } - // END: com.azure.storage.blob.BlobClient.uploadFromFileWithResponse#BlobUploadFromFileOptions-Duration-Context - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java deleted file mode 100644 index 07fab9945be4..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,516 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.Context; -import com.azure.storage.blob.models.BlobAccessPolicy; -import com.azure.storage.blob.models.BlobListDetails; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; - -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Code snippets for {@link BlobContainerAsyncClient} - */ -@SuppressWarnings({"unused"}) -public class BlobContainerAsyncClientJavaDocCodeSnippets { - - private BlobContainerAsyncClient client = JavaDocCodeSnippetsHelpers.getContainerAsyncClient(); - private String blobName = "blobName"; - private String snapshot = "snapshot"; - private String leaseId = "leaseId"; - private String proposedId = "proposedId"; - private int leaseDuration = (int) Duration.ofSeconds(30).getSeconds(); - private String accountName = "accountName"; - private UserDelegationKey userDelegationKey = JavaDocCodeSnippetsHelpers.getUserDelegationKey(); - - /** - * Code snippet for {@link BlobContainerAsyncClient#getBlobAsyncClient(String)} - */ - public void getBlobAsyncClient() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.getBlobAsyncClient#String - BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName); - // END: com.azure.storage.blob.BlobContainerAsyncClient.getBlobAsyncClient#String - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#getBlobAsyncClient(String, String)} - */ - public void getSnapshotBlobAsyncClient() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.getBlobAsyncClient#String-String - BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName, snapshot); - // END: com.azure.storage.blob.BlobContainerAsyncClient.getBlobAsyncClient#String-String - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#exists()} - */ - public void exists() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.exists - client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response)); - // END: com.azure.storage.blob.BlobContainerAsyncClient.exists - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#existsWithResponse()} - */ - public void existsWithResponse() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.existsWithResponse - client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.existsWithResponse - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#create()} - */ - public void setCreate() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.create - client.create().subscribe( - response -> System.out.printf("Create completed%n"), - error -> System.out.printf("Error while creating container %s%n", error)); - // END: com.azure.storage.blob.BlobContainerAsyncClient.create - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#createWithResponse(Map, PublicAccessType)} - */ - public void create2() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.createWithResponse#Map-PublicAccessType - Map metadata = Collections.singletonMap("metadata", "value"); - client.createWithResponse(metadata, PublicAccessType.CONTAINER).subscribe(response -> - System.out.printf("Create completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.createWithResponse#Map-PublicAccessType - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#delete()} - */ - public void setDelete() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.delete - client.delete().subscribe( - response -> System.out.printf("Delete completed%n"), - error -> System.out.printf("Delete failed: %s%n", error)); - // END: com.azure.storage.blob.BlobContainerAsyncClient.delete - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#deleteWithResponse(BlobRequestConditions)} - */ - public void delete2() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.deleteWithResponse#BlobRequestConditions - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.deleteWithResponse(requestConditions).subscribe(response -> - System.out.printf("Delete completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.deleteWithResponse#BlobRequestConditions - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#getProperties()} - */ - public void getProperties() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.getProperties - client.getProperties().subscribe(response -> - System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", - response.getBlobPublicAccess(), - response.hasLegalHold(), - response.hasImmutabilityPolicy())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.getProperties - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#getPropertiesWithResponse(String)} - */ - public void getProperties2() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.getPropertiesWithResponse#String - client.getPropertiesWithResponse(leaseId).subscribe(response -> - System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", - response.getValue().getBlobPublicAccess(), - response.getValue().hasLegalHold(), - response.getValue().hasImmutabilityPolicy())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.getPropertiesWithResponse#String - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#setMetadata(Map)} - */ - public void setMetadata() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.setMetadata#Map - Map metadata = Collections.singletonMap("metadata", "value"); - client.setMetadata(metadata).subscribe( - response -> System.out.printf("Set metadata completed%n"), - error -> System.out.printf("Set metadata failed: %s%n", error)); - // END: com.azure.storage.blob.BlobContainerAsyncClient.setMetadata#Map - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#setMetadataWithResponse(Map, BlobRequestConditions)} - */ - public void setMetadata2() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.setMetadataWithResponse#Map-BlobRequestConditions - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.setMetadataWithResponse(metadata, requestConditions).subscribe(response -> - System.out.printf("Set metadata completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.setMetadataWithResponse#Map-BlobRequestConditions - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#getAccessPolicy()} - */ - public void getAccessPolicy() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.getAccessPolicy - client.getAccessPolicy().subscribe(response -> { - System.out.printf("Blob Access Type: %s%n", response.getBlobAccessType()); - - for (BlobSignedIdentifier identifier : response.getIdentifiers()) { - System.out.printf("Identifier Name: %s, Permissions %s%n", - identifier.getId(), - identifier.getAccessPolicy().getPermissions()); - } - }); - // END: com.azure.storage.blob.BlobContainerAsyncClient.getAccessPolicy - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#getAccessPolicyWithResponse(String)} - */ - public void getAccessPolicy2() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.getAccessPolicyWithResponse#String - client.getAccessPolicyWithResponse(leaseId).subscribe(response -> { - System.out.printf("Blob Access Type: %s%n", response.getValue().getBlobAccessType()); - - for (BlobSignedIdentifier identifier : response.getValue().getIdentifiers()) { - System.out.printf("Identifier Name: %s, Permissions %s%n", - identifier.getId(), - identifier.getAccessPolicy().getPermissions()); - } - }); - // END: com.azure.storage.blob.BlobContainerAsyncClient.getAccessPolicyWithResponse#String - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#setAccessPolicy(PublicAccessType, List)} - */ - public void setAccessPolicy() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.setAccessPolicy#PublicAccessType-List - BlobSignedIdentifier identifier = new BlobSignedIdentifier() - .setId("name") - .setAccessPolicy(new BlobAccessPolicy() - .setStartsOn(OffsetDateTime.now()) - .setExpiresOn(OffsetDateTime.now().plusDays(7)) - .setPermissions("permissionString")); - - client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)).subscribe( - response -> System.out.printf("Set access policy completed%n"), - error -> System.out.printf("Set access policy failed: %s%n", error)); - // END: com.azure.storage.blob.BlobContainerAsyncClient.setAccessPolicy#PublicAccessType-List - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#setAccessPolicyWithResponse(PublicAccessType, List, BlobRequestConditions)} - */ - public void setAccessPolicy2() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.setAccessPolicyWithResponse#PublicAccessType-List-BlobRequestConditions - BlobSignedIdentifier identifier = new BlobSignedIdentifier() - .setId("name") - .setAccessPolicy(new BlobAccessPolicy() - .setStartsOn(OffsetDateTime.now()) - .setExpiresOn(OffsetDateTime.now().plusDays(7)) - .setPermissions("permissionString")); - - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, Collections.singletonList(identifier), requestConditions) - .subscribe(response -> - System.out.printf("Set access policy completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.setAccessPolicyWithResponse#PublicAccessType-List-BlobRequestConditions - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#listBlobs()} - */ - public void listBlobsFlat() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.listBlobs - client.listBlobs().subscribe(blob -> - System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.listBlobs - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#listBlobs(ListBlobsOptions)} - */ - public void listBlobsFlat2() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.listBlobs#ListBlobsOptions - ListBlobsOptions options = new ListBlobsOptions() - .setPrefix("prefixToMatch") - .setDetails(new BlobListDetails() - .setRetrieveDeletedBlobs(true) - .setRetrieveSnapshots(true)); - - client.listBlobs(options).subscribe(blob -> - System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", - blob.getName(), - blob.isPrefix(), - blob.isDeleted(), - blob.getSnapshot())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.listBlobs#ListBlobsOptions - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#listBlobs(ListBlobsOptions, String)} - */ - public void listBlobsFlat3() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.listBlobs#ListBlobsOptions-String - ListBlobsOptions options = new ListBlobsOptions() - .setPrefix("prefixToMatch") - .setDetails(new BlobListDetails() - .setRetrieveDeletedBlobs(true) - .setRetrieveSnapshots(true)); - - String continuationToken = "continuationToken"; - - client.listBlobs(options, continuationToken).subscribe(blob -> - System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", - blob.getName(), - blob.isPrefix(), - blob.isDeleted(), - blob.getSnapshot())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.listBlobs#ListBlobsOptions-String - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#listBlobsByHierarchy(String)} - */ - public void listBlobsHierarchy() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.listBlobsByHierarchy#String - client.listBlobsByHierarchy("directoryName").subscribe(blob -> - System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isDeleted())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.listBlobsByHierarchy#String - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#listBlobsByHierarchy(String, ListBlobsOptions)} - */ - public void listBlobsHierarchy2() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.listBlobsByHierarchy#String-ListBlobsOptions - ListBlobsOptions options = new ListBlobsOptions() - .setPrefix("directoryName") - .setDetails(new BlobListDetails() - .setRetrieveDeletedBlobs(true) - .setRetrieveSnapshots(true)); - - client.listBlobsByHierarchy("/", options).subscribe(blob -> - System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", - blob.getName(), - blob.isPrefix(), - blob.isDeleted(), - blob.getSnapshot())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.listBlobsByHierarchy#String-ListBlobsOptions - } - - /** - * Code snippets for {@link BlobContainerAsyncClient#findBlobsByTags(String)} and - * {@link BlobContainerAsyncClient#findBlobsByTags(FindBlobsOptions)} - */ - public void findBlobsByTag() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.findBlobsByTag#String - client.findBlobsByTags("where=tag=value").subscribe(blob -> System.out.printf("Name: %s%n", blob.getName())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.findBlobsByTag#String - - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.findBlobsByTag#FindBlobsOptions - client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10)) - .subscribe(blob -> System.out.printf("Name: %s%n", blob.getName())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.findBlobsByTag#FindBlobsOptions - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#getAccountInfo()} - */ - public void getAccountInfo() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.getAccountInfo - client.getAccountInfo().subscribe(response -> - System.out.printf("Account Kind: %s, SKU: %s%n", - response.getAccountKind(), - response.getSkuName())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.getAccountInfo - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#getAccountInfoWithResponse()} - */ - public void getAccountInfo2() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.getAccountInfoWithResponse - client.getAccountInfoWithResponse().subscribe(response -> - System.out.printf("Account Kind: %s, SKU: %s%n", - response.getValue().getAccountKind(), - response.getValue().getSkuName())); - // END: com.azure.storage.blob.BlobContainerAsyncClient.getAccountInfoWithResponse - } - - /** - * Generates a code sample for using {@link BlobContainerAsyncClient#getBlobContainerName()} - */ - public void getContainerName() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.getBlobContainerName - String containerName = client.getBlobContainerName(); - System.out.println("The name of the blob is " + containerName); - // END: com.azure.storage.blob.BlobContainerAsyncClient.getBlobContainerName - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} - * and {@link BlobContainerAsyncClient#generateSas(BlobServiceSasSignatureValues)} - */ - public void generateSas() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential - // END: com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues - - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey); - // END: com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey, String, Context)} - * and {@link BlobContainerAsyncClient#generateSas(BlobServiceSasSignatureValues, Context)} - */ - public void generateSasWithContext() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues-Context - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - // Client must be authenticated via StorageSharedKeyCredential - client.generateSas(values, new Context("key", "value")); - // END: com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues-Context - - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value")); - // END: com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#createIfNotExists()} and - * {@link BlobContainerAsyncClient#createIfNotExistsWithResponse(BlobContainerCreateOptions)} - */ - public void createIfNotExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.createIfNotExists - client.createIfNotExists().subscribe(created -> { - if (created) { - System.out.println("successfully created."); - } else { - System.out.println("Already exists."); - } - }); - // END: com.azure.storage.blob.BlobContainerAsyncClient.createIfNotExists - - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.createIfNotExistsWithResponse#Map-PublicAccessType - Map metadata = Collections.singletonMap("metadata", "value"); - BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata) - .setPublicAccessType(PublicAccessType.CONTAINER); - - client.createIfNotExistsWithResponse(options).subscribe(response -> { - if (response.getStatusCode() == 409) { - System.out.println("Already exists."); - } else { - System.out.println("successfully created."); - } - }); - // END: com.azure.storage.blob.BlobContainerAsyncClient.createIfNotExistsWithResponse#Map-PublicAccessType - } - - /** - * Code snippet for {@link BlobContainerAsyncClient#deleteIfExists()} and - * {@link BlobContainerAsyncClient#deleteIfExistsWithResponse(BlobRequestConditions)} - */ - public void deleteIfExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.deleteIfExists - client.deleteIfExists().subscribe(deleted -> { - if (deleted) { - System.out.println("Successfully deleted."); - } else { - System.out.println("Does not exist."); - } - }); - // END: com.azure.storage.blob.BlobContainerAsyncClient.deleteIfExists - - // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.deleteIfExistsWithResponse#BlobRequestConditions - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.deleteIfExistsWithResponse(requestConditions).subscribe(response -> { - if (response.getStatusCode() == 404) { - System.out.println("Does not exist."); - } else { - System.out.println("successfully deleted."); - } - }); - // END: com.azure.storage.blob.BlobContainerAsyncClient.deleteIfExistsWithResponse#BlobRequestConditions - } - -// /** -// * Code snippet for {@link BlobContainerAsyncClient#rename(String)} -// */ -// public void renameContainer() { -// // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.rename#String -// BlobContainerAsyncClient blobContainerAsyncClient = -// client.rename("newContainerName") -// .block(); -// // END: com.azure.storage.blob.BlobContainerAsyncClient.rename#String -// } -// -// /** -// * Code snippet for {@link BlobContainerAsyncClient#renameWithResponse(BlobContainerRenameOptions)} -// */ -// public void renameContainerWithResponse() { -// // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.renameWithResponse#BlobContainerRenameOptions -// BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId("lease-id"); -// BlobContainerAsyncClient containerClient = -// client.renameWithResponse(new BlobContainerRenameOptions("newContainerName") -// .setRequestConditions(requestConditions)).block().getValue(); -// // END: com.azure.storage.blob.BlobContainerAsyncClient.renameWithResponse#BlobContainerRenameOptions -// } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientBuilderJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientBuilderJavaDocCodeSnippets.java deleted file mode 100644 index f7460d418272..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientBuilderJavaDocCodeSnippets.java +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.policy.AddDatePolicy; -import com.azure.core.http.policy.RequestIdPolicy; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.RequestRetryPolicy; -import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; - -/** - * Code snippets for {@link BlobContainerClientBuilder} - */ -@SuppressWarnings({"unused"}) -public class BlobContainerClientBuilderJavaDocCodeSnippets { - private String connectionString = "AccountName=name;AccountKey=key;DefaultEndpointProtocol=protocol;EndpointSuffix=suffix"; - private String endpoint = "endpointURL"; - private String containerName = "container Name"; - private StorageSharedKeyCredential storageSharedKeyCredential = new StorageSharedKeyCredential("accountName", "accountKey"); - private HttpPipeline httpPipeline = new HttpPipelineBuilder() - .httpClient(HttpClient.createDefault()) - .policies(new AddDatePolicy()) - .policies(new RequestIdPolicy()) - .policies(new StorageSharedKeyCredentialPolicy(storageSharedKeyCredential)) - .policies(new RequestRetryPolicy(new RequestRetryOptions())) - .build(); - - /** - * Code snippet for {@link BlobContainerClientBuilder#buildClient()} using connection string - */ - public void containerClientConnectionString() { - // BEGIN: com.azure.storage.blob.BlobContainerClientBuilder.buildClient - BlobContainerClient client = new BlobContainerClientBuilder() - .connectionString(connectionString) - .buildClient(); - // END: com.azure.storage.blob.BlobContainerClientBuilder.buildClient - } - - /** - * Code snippet for {@link BlobContainerClientBuilder#buildAsyncClient()} using connection string - */ - public void containerAsyncClientConnectionString() { - // BEGIN: com.azure.storage.blob.BlobContainerClientBuilder.buildAsyncClient - BlobContainerAsyncClient client = new BlobContainerClientBuilder() - .connectionString(connectionString) - .buildAsyncClient(); - // END: com.azure.storage.blob.BlobContainerClientBuilder.buildAsyncClient - } - - /** - * Code snippet for {@link BlobContainerClientBuilder#buildClient()} using credential and endpoint - */ - public void containerClientCredentialAndEndpoint() { - // BEGIN: com.azure.storage.blob.BlobContainerClientBuilder.endpoint#String - BlobContainerClient client = new BlobContainerClientBuilder() - .endpoint(endpoint) - .credential(storageSharedKeyCredential) - .buildClient(); - // END: com.azure.storage.blob.BlobContainerClientBuilder.endpoint#String - } - - /** - * Code snippet for {@link BlobContainerClientBuilder#buildClient()} using Container Name - */ - public void containerClientContainerName() { - // BEGIN: com.azure.storage.blob.BlobContainerClientBuilder.containerName#String - BlobContainerClient client = new BlobContainerClientBuilder() - .endpoint(endpoint) - .containerName(containerName) - .buildClient(); - // END: com.azure.storage.blob.BlobContainerClientBuilder.containerName#String - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java deleted file mode 100644 index 6ea36fcd0d41..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,537 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; -import com.azure.storage.blob.models.BlobAccessPolicy; -import com.azure.storage.blob.models.BlobContainerAccessPolicies; -import com.azure.storage.blob.models.BlobContainerProperties; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobListDetails; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; - -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -@SuppressWarnings({"unused"}) -public class BlobContainerClientJavaDocCodeSnippets { - - private BlobContainerClient client = JavaDocCodeSnippetsHelpers.getContainerClient(); - private String blobName = "blobName"; - private String snapshot = "snapshot"; - private String leaseId = "leaseId"; - private String proposedId = "proposedId"; - private int leaseDuration = (int) Duration.ofSeconds(30).getSeconds(); - private Duration timeout = Duration.ofSeconds(30); - private String accountName = "accountName"; - private UserDelegationKey userDelegationKey = JavaDocCodeSnippetsHelpers.getUserDelegationKey(); - - /** - * Code snippet for {@link BlobContainerClient#getBlobClient(String)} - */ - public void getBlobClient() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.getBlobClient#String - BlobClient blobClient = client.getBlobClient(blobName); - // END: com.azure.storage.blob.BlobContainerClient.getBlobClient#String - } - - /** - * Code snippet for {@link BlobContainerClient#getBlobClient(String, String)} - */ - public void getSnapshotBlobClient() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.getBlobClient#String-String - BlobClient blobClient = client.getBlobClient(blobName, snapshot); - // END: com.azure.storage.blob.BlobContainerClient.getBlobClient#String-String - } - - /** - * Code snippets for {@link BlobContainerClient#exists()} and {@link BlobContainerClient#existsWithResponse(Duration, - * Context)} - */ - public void exists() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.exists - System.out.printf("Exists? %b%n", client.exists()); - // END: com.azure.storage.blob.BlobContainerClient.exists - - // BEGIN: com.azure.storage.blob.BlobContainerClient.existsWithResponse#Duration-Context - Context context = new Context("Key", "Value"); - System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, context).getValue()); - // END: com.azure.storage.blob.BlobContainerClient.existsWithResponse#Duration-Context - } - - /** - * Code snippet for {@link BlobContainerClient#create()} - */ - public void setCreate() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.create - try { - client.create(); - System.out.printf("Create completed%n"); - } catch (BlobStorageException error) { - if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_ALREADY_EXISTS)) { - System.out.printf("Can't create container. It already exists %n"); - } - } - // END: com.azure.storage.blob.BlobContainerClient.create - } - - /** - * Code snippet for {@link BlobContainerClient#createWithResponse(Map, PublicAccessType, Duration, Context)} - */ - public void create2() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.createWithResponse#Map-PublicAccessType-Duration-Context - Map metadata = Collections.singletonMap("metadata", "value"); - Context context = new Context("Key", "Value"); - - System.out.printf("Create completed with status %d%n", - client.createWithResponse(metadata, PublicAccessType.CONTAINER, timeout, context).getStatusCode()); - // END: com.azure.storage.blob.BlobContainerClient.createWithResponse#Map-PublicAccessType-Duration-Context - } - - /** - * Code snippet for {@link BlobContainerClient#delete()} - */ - public void setDelete() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.delete - try { - client.delete(); - System.out.printf("Delete completed%n"); - } catch (BlobStorageException error) { - if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_NOT_FOUND)) { - System.out.printf("Delete failed. Container was not found %n"); - } - } - // END: com.azure.storage.blob.BlobContainerClient.delete - } - - /** - * Code snippet for {@link BlobContainerClient#deleteWithResponse(BlobRequestConditions, Duration, Context)} - */ - public void delete2() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.deleteWithResponse#BlobRequestConditions-Duration-Context - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("Key", "Value"); - - System.out.printf("Delete completed with status %d%n", client.deleteWithResponse( - requestConditions, timeout, context).getStatusCode()); - // END: com.azure.storage.blob.BlobContainerClient.deleteWithResponse#BlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link BlobContainerClient#getProperties()} - */ - public void getProperties() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.getProperties - BlobContainerProperties properties = client.getProperties(); - System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", - properties.getBlobPublicAccess(), - properties.hasLegalHold(), - properties.hasImmutabilityPolicy()); - // END: com.azure.storage.blob.BlobContainerClient.getProperties - } - - /** - * Code snippet for {@link BlobContainerClient#getPropertiesWithResponse(String, Duration, Context)} - */ - public void getProperties2() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.getPropertiesWithResponse#String-Duration-Context - Context context = new Context("Key", "Value"); - - BlobContainerProperties properties = client.getPropertiesWithResponse(leaseId, timeout, context) - .getValue(); - System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", - properties.getBlobPublicAccess(), - properties.hasLegalHold(), - properties.hasImmutabilityPolicy()); - // END: com.azure.storage.blob.BlobContainerClient.getPropertiesWithResponse#String-Duration-Context - } - - /** - * Code snippet for {@link BlobContainerClient#setMetadata(Map)} - */ - public void setMetadata() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.setMetadata#Map - Map metadata = Collections.singletonMap("metadata", "value"); - try { - client.setMetadata(metadata); - System.out.printf("Set metadata completed with status %n"); - } catch (UnsupportedOperationException error) { - System.out.printf("Fail while setting metadata %n"); - } - // END: com.azure.storage.blob.BlobContainerClient.setMetadata#Map - } - - /** - * Code snippet for {@link BlobContainerClient#setMetadataWithResponse(Map, BlobRequestConditions, Duration, - * Context)} - */ - public void setMetadata2() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.setMetadataWithResponse#Map-BlobRequestConditions-Duration-Context - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("Key", "Value"); - - System.out.printf("Set metadata completed with status %d%n", - client.setMetadataWithResponse(metadata, requestConditions, timeout, context).getStatusCode()); - // END: com.azure.storage.blob.BlobContainerClient.setMetadataWithResponse#Map-BlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link BlobContainerClient#getAccessPolicy()} - */ - public void getAccessPolicy() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.getAccessPolicy - BlobContainerAccessPolicies accessPolicies = client.getAccessPolicy(); - System.out.printf("Blob Access Type: %s%n", accessPolicies.getBlobAccessType()); - - for (BlobSignedIdentifier identifier : accessPolicies.getIdentifiers()) { - System.out.printf("Identifier Name: %s, Permissions %s%n", - identifier.getId(), - identifier.getAccessPolicy().getPermissions()); - } - // END: com.azure.storage.blob.BlobContainerClient.getAccessPolicy - } - - /** - * Code snippet for {@link BlobContainerClient#getAccessPolicyWithResponse(String, Duration, Context)} - */ - public void getAccessPolicy2() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.getAccessPolicyWithResponse#String-Duration-Context - Context context = new Context("Key", "Value"); - BlobContainerAccessPolicies accessPolicies = client.getAccessPolicyWithResponse(leaseId, timeout, context) - .getValue(); - System.out.printf("Blob Access Type: %s%n", accessPolicies.getBlobAccessType()); - - for (BlobSignedIdentifier identifier : accessPolicies.getIdentifiers()) { - System.out.printf("Identifier Name: %s, Permissions %s%n", - identifier.getId(), - identifier.getAccessPolicy().getPermissions()); - } - // END: com.azure.storage.blob.BlobContainerClient.getAccessPolicyWithResponse#String-Duration-Context - } - - /** - * Code snippet for {@link BlobContainerClient#setAccessPolicy(PublicAccessType, List)} - */ - public void setAccessPolicy() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.setAccessPolicy#PublicAccessType-List - BlobSignedIdentifier identifier = new BlobSignedIdentifier() - .setId("name") - .setAccessPolicy(new BlobAccessPolicy() - .setStartsOn(OffsetDateTime.now()) - .setExpiresOn(OffsetDateTime.now().plusDays(7)) - .setPermissions("permissionString")); - - try { - client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)); - System.out.printf("Set Access Policy completed %n"); - } catch (UnsupportedOperationException error) { - System.out.printf("Set Access Policy completed %s%n", error); - } - // END: com.azure.storage.blob.BlobContainerClient.setAccessPolicy#PublicAccessType-List - } - - /** - * Code snippet for {@link BlobContainerClient#setAccessPolicyWithResponse(PublicAccessType, List, - * BlobRequestConditions, Duration, Context)} - */ - public void setAccessPolicy2() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.setAccessPolicyWithResponse#PublicAccessType-List-BlobRequestConditions-Duration-Context - BlobSignedIdentifier identifier = new BlobSignedIdentifier() - .setId("name") - .setAccessPolicy(new BlobAccessPolicy() - .setStartsOn(OffsetDateTime.now()) - .setExpiresOn(OffsetDateTime.now().plusDays(7)) - .setPermissions("permissionString")); - - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - Context context = new Context("Key", "Value"); - - System.out.printf("Set access policy completed with status %d%n", - client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, - Collections.singletonList(identifier), - requestConditions, - timeout, - context).getStatusCode()); - // END: com.azure.storage.blob.BlobContainerClient.setAccessPolicyWithResponse#PublicAccessType-List-BlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link BlobContainerClient#listBlobs()} - */ - public void listBlobsFlat() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.listBlobs - client.listBlobs().forEach(blob -> - System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix())); - // END: com.azure.storage.blob.BlobContainerClient.listBlobs - } - - /** - * Code snippet for {@link BlobContainerClient#listBlobs(ListBlobsOptions, Duration)} - */ - public void listBlobsFlat2() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.listBlobs#ListBlobsOptions-Duration - ListBlobsOptions options = new ListBlobsOptions() - .setPrefix("prefixToMatch") - .setDetails(new BlobListDetails() - .setRetrieveDeletedBlobs(true) - .setRetrieveSnapshots(true)); - - client.listBlobs(options, timeout).forEach(blob -> - System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", - blob.getName(), - blob.isPrefix(), - blob.isDeleted(), - blob.getSnapshot())); - // END: com.azure.storage.blob.BlobContainerClient.listBlobs#ListBlobsOptions-Duration - } - - /** - * Code snippet for {@link BlobContainerClient#listBlobs(ListBlobsOptions, String, Duration)} - */ - public void listBlobsFlat3() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.listBlobs#ListBlobsOptions-String-Duration - ListBlobsOptions options = new ListBlobsOptions() - .setPrefix("prefixToMatch") - .setDetails(new BlobListDetails() - .setRetrieveDeletedBlobs(true) - .setRetrieveSnapshots(true)); - - String continuationToken = "continuationToken"; - - client.listBlobs(options, continuationToken, timeout).forEach(blob -> - System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", - blob.getName(), - blob.isPrefix(), - blob.isDeleted(), - blob.getSnapshot())); - // END: com.azure.storage.blob.BlobContainerClient.listBlobs#ListBlobsOptions-String-Duration - } - - /** - * Code snippet for {@link BlobContainerClient#listBlobsByHierarchy(String)} - */ - public void listBlobsHierarchy() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.listBlobsByHierarchy#String - client.listBlobsByHierarchy("directoryName").forEach(blob -> - System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix())); - // END: com.azure.storage.blob.BlobContainerClient.listBlobsByHierarchy#String - } - - /** - * Code snippet for {@link BlobContainerClient#listBlobsByHierarchy(String, ListBlobsOptions, Duration)} - */ - public void listBlobsHierarchy2() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.listBlobsByHierarchy#String-ListBlobsOptions-Duration - ListBlobsOptions options = new ListBlobsOptions() - .setPrefix("directoryName") - .setDetails(new BlobListDetails() - .setRetrieveDeletedBlobs(true) - .setRetrieveSnapshots(false)); - - client.listBlobsByHierarchy("/", options, timeout).forEach(blob -> - System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", - blob.getName(), - blob.isPrefix(), - blob.isDeleted(), - blob.getSnapshot())); - // END: com.azure.storage.blob.BlobContainerClient.listBlobsByHierarchy#String-ListBlobsOptions-Duration - } - - /** - * Code snippets for {@link BlobContainerClient#findBlobsByTags(String)} and - * {@link BlobContainerClient#findBlobsByTags(FindBlobsOptions, Duration, Context)} - */ - public void findBlobsByTag() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.findBlobsByTag#String - client.findBlobsByTags("where=tag=value").forEach(blob -> System.out.printf("Name: %s%n", blob.getName())); - // END: com.azure.storage.blob.BlobContainerClient.findBlobsByTag#String - - // BEGIN: com.azure.storage.blob.BlobContainerClient.findBlobsByTag#FindBlobsOptions-Duration - Context context = new Context("Key", "Value"); - client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10), timeout, context) - .forEach(blob -> System.out.printf("Name: %s%n", blob.getName())); - // END: com.azure.storage.blob.BlobContainerClient.findBlobsByTag#FindBlobsOptions-Duration - } - - /** - * Code snippet for {@link BlobContainerClient#getAccountInfo(Duration)} - */ - public void getAccountInfo() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.getAccountInfo#Duration - StorageAccountInfo accountInfo = client.getAccountInfo(timeout); - System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); - // END: com.azure.storage.blob.BlobContainerClient.getAccountInfo#Duration - } - - /** - * Code snippet for {@link BlobContainerClient#getAccountInfoWithResponse(Duration, Context)} - */ - public void getAccountInfo2() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.getAccountInfoWithResponse#Duration-Context - Context context = new Context("Key", "Value"); - StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, context).getValue(); - System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); - // END: com.azure.storage.blob.BlobContainerClient.getAccountInfoWithResponse#Duration-Context - } - - /** - * Generates a code sample for using {@link BlobContainerClient#getBlobContainerName()} - */ - public void getContainerName() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.getBlobContainerName - String containerName = client.getBlobContainerName(); - System.out.println("The name of the blob is " + containerName); - // END: com.azure.storage.blob.BlobContainerClient.getBlobContainerName - } - - /** - * Code snippet for {@link BlobContainerClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} - * and {@link BlobContainerClient#generateSas(BlobServiceSasSignatureValues)} - */ - public void generateSas() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential - // END: com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues - - // BEGIN: com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey); - // END: com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - } - - /** - * Code snippet for {@link BlobContainerClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey, String, Context)} - * and {@link BlobContainerClient#generateSas(BlobServiceSasSignatureValues, Context)} - */ - public void generateSasWithContext() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues-Context - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - // Client must be authenticated via StorageSharedKeyCredential - client.generateSas(values, new Context("key", "value")); - // END: com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues-Context - - // BEGIN: com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value")); - // END: com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context - } - - /** - * Code snippet for {@link BlobContainerClient#createIfNotExists()} and - * {@link BlobContainerClient#createIfNotExistsWithResponse(BlobContainerCreateOptions, Duration, Context)} - */ - public void createIfNotExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.createIfNotExists - boolean result = client.createIfNotExists(); - System.out.println("Create completed: " + result); - // END: com.azure.storage.blob.BlobContainerClient.createIfNotExists - - // BEGIN: com.azure.storage.blob.BlobContainerClient.createIfNotExistsWithResponse#BlobContainerCreateOptions-Duration-Context - Map metadata = Collections.singletonMap("metadata", "value"); - Context context = new Context("Key", "Value"); - BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata) - .setPublicAccessType(PublicAccessType.CONTAINER); - - Response response = client.createIfNotExistsWithResponse(options, timeout, context); - if (response.getStatusCode() == 409) { - System.out.println("Already existed."); - } else { - System.out.printf("Create completed with status %d%n", response.getStatusCode()); - } - // END: com.azure.storage.blob.BlobContainerClient.createIfNotExistsWithResponse#BlobContainerCreateOptions-Duration-Context - } - - /** - * Code snippet for {@link BlobContainerClient#deleteIfExists()} and - * {@link BlobContainerClient#deleteIfExistsWithResponse(BlobRequestConditions, Duration, Context)} - */ - public void deleteIfExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobContainerClient.deleteIfExists - boolean result = client.deleteIfExists(); - System.out.println("Delete completed: " + result); - // END: com.azure.storage.blob.BlobContainerClient.deleteIfExists - - // BEGIN: com.azure.storage.blob.BlobContainerClient.deleteIfExistsWithResponse#BlobRequestConditions-Duration-Context - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("Key", "Value"); - - Response response = client.deleteIfExistsWithResponse(requestConditions, timeout, context); - if (response.getStatusCode() == 404) { - System.out.println("Does not exist."); - } else { - System.out.printf("Delete completed with status %d%n", response.getStatusCode()); - } - // END: com.azure.storage.blob.BlobContainerClient.deleteIfExistsWithResponse#BlobRequestConditions-Duration-Context - } - -// /** -// * Code snippet for {@link BlobContainerClient#rename(String)} -// */ -// public void renameContainer() { -// // BEGIN: com.azure.storage.blob.BlobContainerClient.rename#String -// BlobContainerClient blobContainerClient = client.rename("newContainerName"); -// // END: com.azure.storage.blob.BlobContainerClient.rename#String -// } -// -// /** -// * Code snippet for {@link BlobContainerClient#renameWithResponse(BlobContainerRenameOptions, Duration, Context)} -// */ -// public void renameContainerWithResponse() { -// // BEGIN: com.azure.storage.blob.BlobContainerClient.renameWithResponse#BlobContainerRenameOptions-Duration-Context -// BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId("lease-id"); -// Context context = new Context("Key", "Value"); -// -// BlobContainerClient blobContainerClient = client.renameWithResponse( -// new BlobContainerRenameOptions("newContainerName") -// .setRequestConditions(requestConditions), -// Duration.ofSeconds(1), -// context).getValue(); -// // END: com.azure.storage.blob.BlobContainerClient.renameWithResponse#BlobContainerRenameOptions-Duration-Context -// } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceAsyncClientJavaDocCodeSnippets.java deleted file mode 100644 index 6c8c2cb02e50..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceAsyncClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,416 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; -import com.azure.storage.blob.models.BlobAnalyticsLogging; -import com.azure.storage.blob.models.BlobContainerListDetails; -import com.azure.storage.blob.models.BlobMetrics; -import com.azure.storage.blob.models.BlobRetentionPolicy; -import com.azure.storage.blob.models.BlobServiceProperties; -import com.azure.storage.blob.models.ListBlobContainersOptions; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.options.UndeleteBlobContainerOptions; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import reactor.core.publisher.Mono; - -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.Map; - -/** - * Code snippets for {@link BlobServiceAsyncClient} - */ -@SuppressWarnings({"unused"}) -public class BlobServiceAsyncClientJavaDocCodeSnippets { - - private BlobServiceAsyncClient client = JavaDocCodeSnippetsHelpers.getBlobServiceAsyncClient(); - - /** - * Code snippet for {@link BlobServiceAsyncClient#getBlobContainerAsyncClient(String)} - */ - public void getContainerClient() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.getBlobContainerAsyncClient#String - BlobContainerAsyncClient blobContainerAsyncClient = client.getBlobContainerAsyncClient("containerName"); - // END: com.azure.storage.blob.BlobServiceAsyncClient.getBlobContainerAsyncClient#String - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#createBlobContainer(String)} - */ - public void createContainer() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainer#String - BlobContainerAsyncClient blobContainerAsyncClient = - client.createBlobContainer("containerName").block(); - // END: com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainer#String - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#createBlobContainerWithResponse(String, Map, PublicAccessType)} - */ - public void createContainerWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainerWithResponse#String-Map-PublicAccessType - Map metadata = Collections.singletonMap("metadata", "value"); - - BlobContainerAsyncClient containerClient = client - .createBlobContainerWithResponse("containerName", metadata, PublicAccessType.CONTAINER).block().getValue(); - // END: com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainerWithResponse#String-Map-PublicAccessType - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#deleteBlobContainer(String)} - */ - public void deleteContainer() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainer#String - client.deleteBlobContainer("containerName").subscribe( - response -> System.out.printf("Delete container completed%n"), - error -> System.out.printf("Delete container failed: %s%n", error)); - // END: com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainer#String - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#deleteBlobContainerWithResponse(String, Context)} - */ - public void deleteContainerWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainerWithResponse#String-Context - Context context = new Context("Key", "Value"); - client.deleteBlobContainerWithResponse("containerName").subscribe(response -> - System.out.printf("Delete container completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainerWithResponse#String-Context - } - - /** - * Code snippets for {@link BlobServiceAsyncClient#listBlobContainers()} and - * {@link BlobServiceAsyncClient#listBlobContainers(ListBlobContainersOptions)} - */ - public void listContainers() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.listBlobContainers - client.listBlobContainers().subscribe(container -> System.out.printf("Name: %s%n", container.getName())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.listBlobContainers - - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.listBlobContainers#ListBlobContainersOptions - ListBlobContainersOptions options = new ListBlobContainersOptions() - .setPrefix("containerNamePrefixToMatch") - .setDetails(new BlobContainerListDetails().setRetrieveMetadata(true)); - - client.listBlobContainers(options).subscribe(container -> System.out.printf("Name: %s%n", container.getName())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.listBlobContainers#ListBlobContainersOptions - } - - /** - * Code snippets for {@link BlobServiceAsyncClient#findBlobsByTags(String)} and - * {@link BlobServiceAsyncClient#findBlobsByTags(FindBlobsOptions)} - */ - public void findBlobsByTag() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.findBlobsByTag#String - client.findBlobsByTags("where=tag=value").subscribe(blob -> System.out.printf("Name: %s%n", blob.getName())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.findBlobsByTag#String - - // BEGIN: com.azure.storage.blob.BlobAsyncServiceClient.findBlobsByTag#FindBlobsOptions - client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10)) - .subscribe(blob -> System.out.printf("Name: %s%n", blob.getName())); - // END: com.azure.storage.blob.BlobAsyncServiceClient.findBlobsByTag#FindBlobsOptions - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#getProperties()} - */ - public void getProperties() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.getProperties - client.getProperties().subscribe(response -> - System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n", - response.getHourMetrics().isEnabled(), - response.getMinuteMetrics().isEnabled())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.getProperties - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#getPropertiesWithResponse()} - */ - public void getPropertiesWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.getPropertiesWithResponse - client.getPropertiesWithResponse().subscribe(response -> - System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n", - response.getValue().getHourMetrics().isEnabled(), - response.getValue().getMinuteMetrics().isEnabled())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.getPropertiesWithResponse - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#setProperties(BlobServiceProperties)} - */ - public void setProperties() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.setProperties#BlobServiceProperties - BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3); - BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1); - - BlobServiceProperties properties = new BlobServiceProperties() - .setLogging(new BlobAnalyticsLogging() - .setWrite(true) - .setDelete(true) - .setRetentionPolicy(loggingRetentionPolicy)) - .setHourMetrics(new BlobMetrics() - .setEnabled(true) - .setRetentionPolicy(metricsRetentionPolicy)) - .setMinuteMetrics(new BlobMetrics() - .setEnabled(true) - .setRetentionPolicy(metricsRetentionPolicy)); - - client.setProperties(properties).subscribe( - response -> System.out.printf("Setting properties completed%n"), - error -> System.out.printf("Setting properties failed: %s%n", error)); - // END: com.azure.storage.blob.BlobServiceAsyncClient.setProperties#BlobServiceProperties - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#setPropertiesWithResponse(BlobServiceProperties)} - */ - public void setPropertiesWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.setPropertiesWithResponse#BlobServiceProperties - BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3); - BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1); - - BlobServiceProperties properties = new BlobServiceProperties() - .setLogging(new BlobAnalyticsLogging() - .setWrite(true) - .setDelete(true) - .setRetentionPolicy(loggingRetentionPolicy)) - .setHourMetrics(new BlobMetrics() - .setEnabled(true) - .setRetentionPolicy(metricsRetentionPolicy)) - .setMinuteMetrics(new BlobMetrics() - .setEnabled(true) - .setRetentionPolicy(metricsRetentionPolicy)); - - client.setPropertiesWithResponse(properties).subscribe(response -> - System.out.printf("Setting properties completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.setPropertiesWithResponse#BlobServiceProperties - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} - */ - public void getUserDelegationKey() { - OffsetDateTime delegationKeyStartTime = OffsetDateTime.now(); - OffsetDateTime delegationKeyExpiryTime = OffsetDateTime.now().plusDays(7); - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.getUserDelegationKey#OffsetDateTime-OffsetDateTime - client.getUserDelegationKey(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response -> - System.out.printf("User delegation key: %s%n", response.getValue())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.getUserDelegationKey#OffsetDateTime-OffsetDateTime - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#getUserDelegationKeyWithResponse(OffsetDateTime, OffsetDateTime)} - */ - public void getUserDelegationKeyWithResponse() { - OffsetDateTime delegationKeyStartTime = OffsetDateTime.now(); - OffsetDateTime delegationKeyExpiryTime = OffsetDateTime.now().plusDays(7); - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.getUserDelegationKeyWithResponse#OffsetDateTime-OffsetDateTime - client.getUserDelegationKeyWithResponse(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response -> - System.out.printf("User delegation key: %s%n", response.getValue().getValue())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.getUserDelegationKeyWithResponse#OffsetDateTime-OffsetDateTime - } - - /** - * Code snippets for {@link BlobServiceAsyncClient#getStatistics()} - */ - public void getStatistics() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.getStatistics - client.getStatistics().subscribe(response -> - System.out.printf("Geo-replication status: %s%n", response.getGeoReplication().getStatus())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.getStatistics - } - - /** - * Code snippets for {@link BlobServiceAsyncClient#getStatisticsWithResponse()} - */ - public void getStatisticsWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.getStatisticsWithResponse - client.getStatisticsWithResponse().subscribe(response -> - System.out.printf("Geo-replication status: %s%n", response.getValue().getGeoReplication().getStatus())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.getStatisticsWithResponse - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#getAccountInfo} - */ - public void getAccountInfo() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.getAccountInfo - client.getAccountInfo().subscribe(response -> - System.out.printf("Account kind: %s, SKU: %s%n", response.getAccountKind(), response.getSkuName())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.getAccountInfo - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#getAccountInfoWithResponse} - */ - public void getAccountInfoWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.getAccountInfoWithResponse - client.getAccountInfoWithResponse().subscribe(response -> - System.out.printf("Account kind: %s, SKU: %s%n", response.getValue().getAccountKind(), - response.getValue().getSkuName())); - // END: com.azure.storage.blob.BlobServiceAsyncClient.getAccountInfoWithResponse - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#generateAccountSas(AccountSasSignatureValues)} - */ - public void generateAccountSas() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues - AccountSasPermission permissions = new AccountSasPermission() - .setListPermission(true) - .setReadPermission(true); - AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); - AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); - OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); - - AccountSasSignatureValues sasValues = - new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); - - // Client must be authenticated via StorageSharedKeyCredential - String sas = client.generateAccountSas(sasValues); - // END: com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#generateAccountSas(AccountSasSignatureValues, Context)} - */ - public void generateAccountSasWithContext() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues-Context - AccountSasPermission permissions = new AccountSasPermission() - .setListPermission(true) - .setReadPermission(true); - AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); - AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); - OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); - - AccountSasSignatureValues sasValues = - new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); - - // Client must be authenticated via StorageSharedKeyCredential - String sas = client.generateAccountSas(sasValues, new Context("key", "value")); - // END: com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues-Context - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#undeleteBlobContainer(String, String)}. - */ - public void undeleteBlobContainer() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.undeleteBlobContainer#String-String - ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions(); - listBlobContainersOptions.getDetails().setRetrieveDeleted(true); - client.listBlobContainers(listBlobContainersOptions).flatMap( - deletedContainer -> { - Mono blobContainerClient = client.undeleteBlobContainer( - deletedContainer.getName(), deletedContainer.getVersion()); - return blobContainerClient; - } - ).then().block(); - // END: com.azure.storage.blob.BlobServiceAsyncClient.undeleteBlobContainer#String-String - } - - /** - * Code snippet for - * {@link BlobServiceAsyncClient#undeleteBlobContainerWithResponse(UndeleteBlobContainerOptions)}. - */ - public void undeleteBlobContainerWithResponseWithRename() { - Context context = new Context("Key", "Value"); - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.undeleteBlobContainerWithResponse#UndeleteBlobContainerOptions - ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions(); - listBlobContainersOptions.getDetails().setRetrieveDeleted(true); - client.listBlobContainers(listBlobContainersOptions).flatMap( - deletedContainer -> { - Mono blobContainerClient = client.undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(deletedContainer.getName(), deletedContainer.getVersion())) - .map(Response::getValue); - return blobContainerClient; - } - ).then().block(); - // END: com.azure.storage.blob.BlobServiceAsyncClient.undeleteBlobContainerWithResponse#UndeleteBlobContainerOptions - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#createBlobContainerIfNotExists(String)} and - * {@link BlobServiceAsyncClient#createBlobContainerIfNotExistsWithResponse(String, BlobContainerCreateOptions)} - */ - public void createContainerIfNotExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainerIfNotExists#String - BlobContainerAsyncClient blobContainerAsyncClient = - client.createBlobContainerIfNotExists("containerName").block(); - // END: com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainerIfNotExists#String - - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainerIfNotExistsWithResponse#String-BlobContainerCreateOptions - Map metadata = Collections.singletonMap("metadata", "value"); - BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata) - .setPublicAccessType(PublicAccessType.CONTAINER); - - client.createBlobContainerIfNotExistsWithResponse("containerName", options).subscribe(response -> { - if (response.getStatusCode() == 409) { - System.out.println("Already exists."); - } else { - System.out.println("successfully created."); - } - }); - // END: com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainerIfNotExistsWithResponse#String-BlobContainerCreateOptions - } - - /** - * Code snippet for {@link BlobServiceAsyncClient#deleteBlobContainerIfExists(String)} and - * {@link BlobServiceAsyncClient#deleteBlobContainerIfExistsWithResponse(String)} - */ - public void deleteContainerIfExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainerIfExists#String - client.deleteBlobContainerIfExists("containerName").subscribe(deleted -> { - if (deleted) { - System.out.println("Successfully deleted."); - } else { - System.out.println("Does not exist."); - } - }); - // END: com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainerIfExists#String - - // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainerIfExistsWithResponse#String - Context context = new Context("Key", "Value"); - client.deleteBlobContainerIfExistsWithResponse("containerName").subscribe(response -> { - if (response.getStatusCode() == 404) { - System.out.println("Does not exist."); - } else { - System.out.println("successfully deleted."); - } - }); - // END: com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainerIfExistsWithResponse#String - } - - -// /** -// * Code snippet for {@link BlobServiceAsyncClient#renameBlobContainer(String, String)} -// */ -// public void renameContainer() { -// // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.renameBlobContainer#String-String -// BlobContainerAsyncClient blobContainerAsyncClient = -// client.renameBlobContainer("oldContainerName", "newContainerName") -// .block(); -// // END: com.azure.storage.blob.BlobServiceAsyncClient.renameBlobContainer#String-String -// } -// -// /** -// * Code snippet for {@link BlobServiceAsyncClient#renameBlobContainerWithResponse(String, BlobContainerRenameOptions)} -// */ -// public void renameContainerWithResponse() { -// // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.renameBlobContainerWithResponse#String-BlobContainerRenameOptions -// BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId("lease-id"); -// BlobContainerAsyncClient containerClient = client -// .renameBlobContainerWithResponse("oldContainerName", -// new BlobContainerRenameOptions( "newContainerName") -// .setRequestConditions(requestConditions)).block().getValue(); -// // END: com.azure.storage.blob.BlobServiceAsyncClient.renameBlobContainerWithResponse#String-BlobContainerRenameOptions -// } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceClientJavaDocCodeSnippets.java deleted file mode 100644 index 9b43827363d4..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,426 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; -import com.azure.storage.blob.models.BlobAnalyticsLogging; -import com.azure.storage.blob.models.BlobContainerListDetails; -import com.azure.storage.blob.models.BlobMetrics; -import com.azure.storage.blob.models.BlobRetentionPolicy; -import com.azure.storage.blob.models.BlobServiceProperties; -import com.azure.storage.blob.models.ListBlobContainersOptions; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.options.UndeleteBlobContainerOptions; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; - -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.Map; - -/** - * Code snippets for {@link BlobServiceClient} - */ -@SuppressWarnings({"unused"}) -public class BlobServiceClientJavaDocCodeSnippets { - private final BlobServiceClient client = JavaDocCodeSnippetsHelpers.getBlobServiceClient(); - private final Duration timeout = Duration.ofSeconds(30); - - /** - * Code snippet for {@link BlobServiceClient#getBlobContainerClient(String)} - */ - public void getContainerClient() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.getBlobContainerClient#String - BlobContainerClient blobContainerClient = client.getBlobContainerClient("containerName"); - // END: com.azure.storage.blob.BlobServiceClient.getBlobContainerClient#String - } - - /** - * Code snippet for {@link BlobServiceClient#createBlobContainer(String)} - */ - public void createContainer() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.createBlobContainer#String - BlobContainerClient blobContainerClient = client.createBlobContainer("containerName"); - // END: com.azure.storage.blob.BlobServiceClient.createBlobContainer#String - } - - /** - * Code snippet for {@link BlobServiceClient#createBlobContainerWithResponse(String, Map, PublicAccessType, Context)} - */ - public void createContainerWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.createBlobContainerWithResponse#String-Map-PublicAccessType-Context - Map metadata = Collections.singletonMap("metadata", "value"); - Context context = new Context("Key", "Value"); - - BlobContainerClient blobContainerClient = client.createBlobContainerWithResponse( - "containerName", - metadata, - PublicAccessType.CONTAINER, - context).getValue(); - // END: com.azure.storage.blob.BlobServiceClient.createBlobContainerWithResponse#String-Map-PublicAccessType-Context - } - - /** - * Code snippet for {@link BlobServiceClient#deleteBlobContainer(String)} - */ - public void deleteContainer() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.deleteBlobContainer#String - try { - client.deleteBlobContainer("container Name"); - System.out.printf("Delete container completed with status %n"); - } catch (UnsupportedOperationException error) { - System.out.printf("Delete container failed: %s%n", error); - } - // END: com.azure.storage.blob.BlobServiceClient.deleteBlobContainer#String - } - - /** - * Code snippet for {@link BlobServiceClient#deleteBlobContainerWithResponse(String, Context)} - */ - public void deleteContainerWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.deleteBlobContainerWithResponse#String-Context - Context context = new Context("Key", "Value"); - System.out.printf("Delete container completed with status %d%n", - client.deleteBlobContainerWithResponse("containerName", context).getStatusCode()); - // END: com.azure.storage.blob.BlobServiceClient.deleteBlobContainerWithResponse#String-Context - } - - /** - * Code snippets for {@link BlobServiceClient#listBlobContainers()} and - * {@link BlobServiceClient#listBlobContainers(ListBlobContainersOptions, Duration)} - */ - public void listContainers() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.listBlobContainers - client.listBlobContainers().forEach(container -> System.out.printf("Name: %s%n", container.getName())); - // END: com.azure.storage.blob.BlobServiceClient.listBlobContainers - - // BEGIN: com.azure.storage.blob.BlobServiceClient.listBlobContainers#ListBlobContainersOptions-Duration - ListBlobContainersOptions options = new ListBlobContainersOptions() - .setPrefix("containerNamePrefixToMatch") - .setDetails(new BlobContainerListDetails().setRetrieveMetadata(true)); - - client.listBlobContainers(options, timeout).forEach(container -> System.out.printf("Name: %s%n", container.getName())); - // END: com.azure.storage.blob.BlobServiceClient.listBlobContainers#ListBlobContainersOptions-Duration - } - - /** - * Code snippets for {@link BlobServiceClient#findBlobsByTags(String)} and - * {@link BlobServiceClient#findBlobsByTags(FindBlobsOptions, Duration, Context)} - */ - public void findBlobsByTag() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.findBlobsByTag#String - client.findBlobsByTags("where=tag=value").forEach(blob -> System.out.printf("Name: %s%n", blob.getName())); - // END: com.azure.storage.blob.BlobServiceClient.findBlobsByTag#String - - // BEGIN: com.azure.storage.blob.BlobServiceClient.findBlobsByTag#FindBlobsOptions-Duration - Context context = new Context("Key", "Value"); - client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10), timeout, context) - .forEach(blob -> System.out.printf("Name: %s%n", blob.getName())); - // END: com.azure.storage.blob.BlobServiceClient.findBlobsByTag#FindBlobsOptions-Duration - } - - /** - * Code snippet for {@link BlobServiceClient#getProperties()} - */ - public void getProperties() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.getProperties - BlobServiceProperties properties = client.getProperties(); - - System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n", - properties.getHourMetrics().isEnabled(), - properties.getMinuteMetrics().isEnabled()); - // END: com.azure.storage.blob.BlobServiceClient.getProperties - } - - /** - * Code snippet for {@link BlobServiceClient#getPropertiesWithResponse(Duration, Context)} - */ - public void getPropertiesWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.getPropertiesWithResponse#Duration-Context - Context context = new Context("Key", "Value"); - BlobServiceProperties properties = client.getPropertiesWithResponse(timeout, context).getValue(); - - System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n", - properties.getHourMetrics().isEnabled(), - properties.getMinuteMetrics().isEnabled()); - // END: com.azure.storage.blob.BlobServiceClient.getPropertiesWithResponse#Duration-Context - } - - /** - * Code snippet for {@link BlobServiceClient#setProperties(BlobServiceProperties)} - */ - public void setProperties() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.setProperties#BlobServiceProperties - BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3); - BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1); - - BlobServiceProperties properties = new BlobServiceProperties() - .setLogging(new BlobAnalyticsLogging() - .setWrite(true) - .setDelete(true) - .setVersion("1.0") - .setRetentionPolicy(loggingRetentionPolicy)) - .setHourMetrics(new BlobMetrics() - .setEnabled(true) - .setVersion("1.0") - .setIncludeApis(true) - .setRetentionPolicy(metricsRetentionPolicy)) - .setMinuteMetrics(new BlobMetrics() - .setEnabled(true) - .setVersion("1.0") - .setIncludeApis(true) - .setRetentionPolicy(metricsRetentionPolicy)); - - try { - client.setProperties(properties); - System.out.printf("Setting properties completed%n"); - } catch (UnsupportedOperationException error) { - System.out.printf("Setting properties failed: %s%n", error); - } - // END: com.azure.storage.blob.BlobServiceClient.setProperties#BlobServiceProperties - } - - /** - * Code snippet for {@link BlobServiceClient#setPropertiesWithResponse(BlobServiceProperties, Duration, Context)} - */ - public void setPropertiesWithResponse() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.setPropertiesWithResponse#BlobServiceProperties-Duration-Context - BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3); - BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1); - - BlobServiceProperties properties = new BlobServiceProperties() - .setLogging(new BlobAnalyticsLogging() - .setWrite(true) - .setDelete(true) - .setVersion("1.0") - .setRetentionPolicy(loggingRetentionPolicy)) - .setHourMetrics(new BlobMetrics() - .setEnabled(true) - .setVersion("1.0") - .setIncludeApis(true) - .setRetentionPolicy(metricsRetentionPolicy)) - .setMinuteMetrics(new BlobMetrics() - .setEnabled(true) - .setVersion("1.0") - .setIncludeApis(true) - .setRetentionPolicy(metricsRetentionPolicy)); - - Context context = new Context("Key", "Value"); - - System.out.printf("Setting properties completed with status %d%n", - client.setPropertiesWithResponse(properties, timeout, context).getStatusCode()); - // END: com.azure.storage.blob.BlobServiceClient.setPropertiesWithResponse#BlobServiceProperties-Duration-Context - } - - /** - * Code snippets for {@link BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} - * and {@link BlobServiceClient#getUserDelegationKeyWithResponse(OffsetDateTime, OffsetDateTime, Duration, Context)} - */ - public void getUserDelegationKey() { - OffsetDateTime delegationKeyStartTime = OffsetDateTime.now(); - OffsetDateTime delegationKeyExpiryTime = OffsetDateTime.now().plusDays(7); - Context context = new Context("Key", "Value"); - // BEGIN: com.azure.storage.blob.BlobServiceClient.getUserDelegationKey#OffsetDateTime-OffsetDateTime - System.out.printf("User delegation key: %s%n", - client.getUserDelegationKey(delegationKeyStartTime, delegationKeyExpiryTime)); - // END: com.azure.storage.blob.BlobServiceClient.getUserDelegationKey#OffsetDateTime-OffsetDateTime - - // BEGIN: com.azure.storage.blob.BlobServiceClient.getUserDelegationKeyWithResponse#OffsetDateTime-OffsetDateTime-Duration-Context - System.out.printf("User delegation key: %s%n", - client.getUserDelegationKeyWithResponse(delegationKeyStartTime, delegationKeyExpiryTime, timeout, context)); - // END: com.azure.storage.blob.BlobServiceClient.getUserDelegationKeyWithResponse#OffsetDateTime-OffsetDateTime-Duration-Context - } - - /** - * Code snippets for {@link BlobServiceClient#getStatistics()} and {@link BlobServiceClient#getStatisticsWithResponse(Duration, Context)} - */ - public void getStatistics() { - Context context = new Context("Key", "Value"); - // BEGIN: com.azure.storage.blob.BlobServiceClient.getStatistics - System.out.printf("Geo-replication status: %s%n", - client.getStatistics().getGeoReplication().getStatus()); - // END: com.azure.storage.blob.BlobServiceClient.getStatistics - - // BEGIN: com.azure.storage.blob.BlobServiceClient.getStatisticsWithResponse#Duration-Context - System.out.printf("Geo-replication status: %s%n", - client.getStatisticsWithResponse(timeout, context).getValue().getGeoReplication().getStatus()); - // END: com.azure.storage.blob.BlobServiceClient.getStatisticsWithResponse#Duration-Context - } - - /** - * Code snippet for {@link BlobServiceClient#getAccountInfo} - */ - public void getAccountInfo() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.getAccountInfo - StorageAccountInfo accountInfo = client.getAccountInfo(); - - System.out.printf("Account kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); - // END: com.azure.storage.blob.BlobServiceClient.getAccountInfo - } - - /** - * Code snippet for {@link BlobServiceClient#getAccountInfoWithResponse(Duration, Context)} - */ - public void getAccountInfoWithResponse() { - Context context = new Context("Key", "Value"); - // BEGIN: com.azure.storage.blob.BlobServiceClient.getAccountInfoWithResponse#Duration-Context - StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, context).getValue(); - // END: com.azure.storage.blob.BlobServiceClient.getAccountInfoWithResponse#Duration-Context - } - - /** - * Code snippet for {@link BlobServiceClient#generateAccountSas(AccountSasSignatureValues)} - */ - public void generateAccountSas() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues - AccountSasPermission permissions = new AccountSasPermission() - .setListPermission(true) - .setReadPermission(true); - AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); - AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); - OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); - - AccountSasSignatureValues sasValues = - new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); - - // Client must be authenticated via StorageSharedKeyCredential - String sas = client.generateAccountSas(sasValues); - // END: com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues - } - - /** - * Code snippet for {@link BlobServiceClient#generateAccountSas(AccountSasSignatureValues, Context)} - */ - public void generateAccountSasWithContext() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues-Context - AccountSasPermission permissions = new AccountSasPermission() - .setListPermission(true) - .setReadPermission(true); - AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); - AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); - OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); - - AccountSasSignatureValues sasValues = - new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); - - // Client must be authenticated via StorageSharedKeyCredential - String sas = client.generateAccountSas(sasValues, new Context("key", "value")); - // END: com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues-Context - } - - /** - * Code snippet for {@link BlobServiceClient#undeleteBlobContainer(String, String)}. - */ - public void undeleteBlobContainer() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.undeleteBlobContainer#String-String - ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions(); - listBlobContainersOptions.getDetails().setRetrieveDeleted(true); - client.listBlobContainers(listBlobContainersOptions, null).forEach( - deletedContainer -> { - BlobContainerClient blobContainerClient = client.undeleteBlobContainer( - deletedContainer.getName(), deletedContainer.getVersion()); - } - ); - // END: com.azure.storage.blob.BlobServiceClient.undeleteBlobContainer#String-String - } - - /** - * Code snippet for {@link BlobServiceClient#undeleteBlobContainerWithResponse(UndeleteBlobContainerOptions, - * Duration, Context)}. - */ - public void undeleteBlobContainerWithResponseWithRename() { - Context context = new Context("Key", "Value"); - // BEGIN: com.azure.storage.blob.BlobServiceClient.undeleteBlobContainerWithResponse#UndeleteBlobContainerOptions-Duration-Context - ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions(); - listBlobContainersOptions.getDetails().setRetrieveDeleted(true); - client.listBlobContainers(listBlobContainersOptions, null).forEach( - deletedContainer -> { - BlobContainerClient blobContainerClient = client.undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(deletedContainer.getName(), deletedContainer.getVersion()), - timeout, context).getValue(); - } - ); - // END: com.azure.storage.blob.BlobServiceClient.undeleteBlobContainerWithResponse#UndeleteBlobContainerOptions-Duration-Context - } - - /** - * Code snippet for {@link BlobServiceClient#createBlobContainerIfNotExists(String)} and - * {@link BlobServiceClient#createBlobContainerIfNotExistsWithResponse(String, BlobContainerCreateOptions, Context)} - */ - public void createContainerIfNotExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.createBlobContainerIfNotExists#String - BlobContainerClient blobContainerClient = client.createBlobContainerIfNotExists("containerName"); - // END: com.azure.storage.blob.BlobServiceClient.createBlobContainerIfNotExists#String - - // BEGIN: com.azure.storage.blob.BlobServiceClient.createBlobContainerIfNotExistsWithResponse#String-BlobContainerCreateOptions-Context - Map metadata = Collections.singletonMap("metadata", "value"); - Context context = new Context("Key", "Value"); - BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata) - .setPublicAccessType(PublicAccessType.CONTAINER); - - Response response = client.createBlobContainerIfNotExistsWithResponse("containerName", - options, context); - - if (response.getStatusCode() == 409) { - System.out.println("Already existed."); - } else { - System.out.printf("Create completed with status %d%n", response.getStatusCode()); - } - // END: com.azure.storage.blob.BlobServiceClient.createBlobContainerIfNotExistsWithResponse#String-BlobContainerCreateOptions-Context - } - - /** - * Code snippet for {@link BlobServiceClient#deleteBlobContainerIfExists(String)} and - * {@link BlobServiceClient#deleteBlobContainerIfExistsWithResponse(String, Context)} - */ - public void deleteContainerIfExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.BlobServiceClient.deleteBlobContainerIfExists#String - boolean result = client.deleteBlobContainerIfExists("container Name"); - System.out.println("Delete container completed: " + result); - // END: com.azure.storage.blob.BlobServiceClient.deleteBlobContainerIfExists#String - - // BEGIN: com.azure.storage.blob.BlobServiceClient.deleteBlobContainerIfExistsWithResponse#String-Context - Context context = new Context("Key", "Value"); - - Response response = client.deleteBlobContainerIfExistsWithResponse("containerName", context); - if (response.getStatusCode() == 404) { - System.out.println("Does not exist."); - } else { - System.out.printf("Delete completed with status %d%n", response.getStatusCode()); - } - // END: com.azure.storage.blob.BlobServiceClient.deleteBlobContainerIfExistsWithResponse#String-Context - } - -// /** -// * Code snippet for {@link BlobServiceClient#renameBlobContainer(String, String)} -// */ -// public void renameContainer() { -// // BEGIN: com.azure.storage.blob.BlobServiceClient.renameBlobContainer#String-String -// BlobContainerClient blobContainerClient = client.renameBlobContainer("oldContainerName", "newContainerName"); -// // END: com.azure.storage.blob.BlobServiceClient.renameBlobContainer#String-String -// } -// -// /** -// * Code snippet for {@link BlobServiceClient#renameBlobContainerWithResponse(String, BlobContainerRenameOptions, Duration, Context)} -// */ -// public void renameContainerWithResponse() { -// // BEGIN: com.azure.storage.blob.BlobServiceClient.renameBlobContainerWithResponse#String-BlobContainerRenameOptions-Duration-Context -// BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId("lease-id"); -// Context context = new Context("Key", "Value"); -// -// BlobContainerClient blobContainerClient = client.renameBlobContainerWithResponse("oldContainerName", -// new BlobContainerRenameOptions("newContainerName") -// .setRequestConditions(requestConditions), -// Duration.ofSeconds(1), -// context).getValue(); -// // END: com.azure.storage.blob.BlobServiceClient.renameBlobContainerWithResponse#String-BlobContainerRenameOptions-Duration-Context -// } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BufferedUploadWithKnownLengthExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BufferedUploadWithKnownLengthExample.java deleted file mode 100644 index a5eb0bf0c919..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BufferedUploadWithKnownLengthExample.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.BinaryData; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.common.StorageSharedKeyCredential; -import reactor.core.publisher.Flux; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.util.Locale; - -/** - * This example shows how to use the buffered upload method on BlockBlobAsyncClient with a known length. - * - * Note that the use of .block() in the method is only used to enable the sample to run effectively in isolation. It is - * not recommended for use in async environments. - */ -public class BufferedUploadWithKnownLengthExample { - /** - * Entry point into the basic examples for Storage blobs. - * @param args Unused. Arguments to the program. - * @throws IOException If an I/O error occurs - * @throws RuntimeException If the downloaded data doesn't match the uploaded data - */ - public static void main(String[] args) throws IOException { - - /* - * For more information on this setup, please refer to the BasicExample. - */ - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - String containerName = "myjavacontainerbuffereduploadlength" + System.currentTimeMillis(); - BlobServiceAsyncClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential) - .buildAsyncClient(); - - BlobContainerAsyncClient containerClient = storageClient.getBlobContainerAsyncClient(containerName); - containerClient.create().block(); - - uploadSourceBlob(endpoint, credential, containerName); - BlobAsyncClient blobClient = containerClient.getBlobAsyncClient("HelloWorld.txt"); - - - /* - sourceData has a network stream as its source and therefore likely does not support multiple subscribers. Even - if it did support multiple subscribers, it would not produce the same data each time it was subscribed to. While - we could inspect the http headers for the content-length, let us suppose that this information is unavailable - at this time. All three of these factors would individually make the use of the standard upload method - impossible--the first two because retries would not work and the third one because we could not satisfy the - argument list. - */ - Flux sourceData = getSourceBlobClient(endpoint, credential, containerName).downloadStream() - // Perform transformation with length of 1 GB. - .map(BufferedUploadWithKnownLengthExample::bufferTransformation); - - /* - Although this upload overload permits the use of such unreliable data sources, with known length we can speed - up the upload process. A buffer size and maximum concurrency can still be passed in to achieve optimized upload. - */ - long length = 10; - long blockSize = 10 * 1024; - int maxConcurrency = 5; - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() - .setBlockSizeLong(blockSize) - .setMaxConcurrency(maxConcurrency); - - // Since we already know the size of our buffered bytes, we can pass the ByteBuffer and length to the BinaryData. - // This will internally convert the BinaryData to a Flux, but with known length we can optimize the - // upload speed. - // Need to use BinaryData.fromFlux(Flux, Long, Boolean) with bufferContent set to false, this allows - // us to configure the BinaryData to have a specified length set without the BinaryData being infinitely - // subscribed to the Flux. - BinaryData.fromFlux(sourceData, length, false).flatMap(binaryData -> - blobClient.uploadWithResponse(new BlobParallelUploadOptions(binaryData) - .setParallelTransferOptions(parallelTransferOptions))); - } - - @SuppressWarnings("cast") - private static ByteBuffer bufferTransformation(ByteBuffer buffer) { - // The JDK changed the return type of ByteBuffer#limit between 8 and 9. In 8 and below it returns Buffer, whereas - // in JDK 9 and later, it returns ByteBuffer. To compile on both, we explicitly cast the returned value to - // ByteBuffer. - // See https://bugs-stage.openjdk.java.net/browse/JDK-8062376 - int length = 10; - return (ByteBuffer) buffer.limit(length); - } - - private static void uploadSourceBlob(String endpoint, StorageSharedKeyCredential credential, String containerName) { - getSourceBlobClient(endpoint, credential, containerName) - .upload(Flux.just(ByteBuffer.wrap("Hello world".getBytes(Charset.defaultCharset()))), "Hello world".length()).block(); - } - - private static BlockBlobAsyncClient getSourceBlobClient(String endpoint, StorageSharedKeyCredential credential, - String containerName) { - return new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildAsyncClient() - .getBlobContainerAsyncClient(containerName).getBlobAsyncClient("sourceBlob").getBlockBlobAsyncClient(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ConnectionLevelTimeoutExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ConnectionLevelTimeoutExample.java deleted file mode 100644 index b104add5e308..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ConnectionLevelTimeoutExample.java +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.HttpClientOptions; -import com.azure.storage.common.StorageSharedKeyCredential; - -import java.io.IOException; -import java.time.Duration; -import java.util.Locale; -import java.util.concurrent.TimeoutException; - -/** - * This example shows how to use connection level timeouts. These timeouts relate to discrete sections of the - * connection/request/response process such as time to receive headers or time between reading bytes. These options - * offer the most granular control. If one of these values times out, it will be automatically retried. - * Please see {@link HttpClientOptions} for more detailed information on each option. - */ -public class ConnectionLevelTimeoutExample { - - /** - * Entry point into the basic examples for Storage blobs. - * - * @param args Unused. Arguments to the program. - * @throws IOException If an I/O error occurs - * @throws RuntimeException If the downloaded data doesn't match the uploaded data - */ - public static void main(String[] args) throws IOException { - - /* - * From the Azure portal, get your Storage account's name and account key. - */ - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - - /* - * Use your Storage account's name and key to create a credential object; this is used to access your account. - */ - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - /* - * Create clientOptions with application ID and timeouts set - */ - HttpClientOptions clientOptions = new HttpClientOptions() - .setApplicationId("client-options-id") - .setResponseTimeout(Duration.ofNanos(1)) - .setReadTimeout(Duration.ofNanos(1)) - .setWriteTimeout(Duration.ofNanos(1)) - .setConnectTimeout(Duration.ofNanos(1)); - - /* - * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. - */ - BlobServiceClient storageClient = new BlobServiceClientBuilder() - .endpoint(endpoint) - .credential(credential) - .clientOptions(clientOptions) - .buildClient(); - - /* - * Creating a blob container will cause a timeout exception since default duration is passed in when creating - * blob container. - */ - try { - storageClient.createBlobContainer("myjavacontainerbasic" + System.currentTimeMillis()); - } catch (Exception ex) { - if (ex.getCause() instanceof TimeoutException) { - System.out.println("Operation failed due to timeout: " + ex.getMessage()); - } - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/FileTransferExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/FileTransferExample.java deleted file mode 100644 index 8b58a24564d2..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/FileTransferExample.java +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.storage.common.StorageSharedKeyCredential; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Locale; - -/** - * This class shows how to upload the file as fast as possible in parallel using the optimized upload API. - */ -public class FileTransferExample { - private static final String LARGE_TEST_FOLDER = "test-large-files/"; - - /** - * Entry point into the file transfer examples for Storage blobs. - * @param args Unused. Arguments to the program. - * @throws IOException If an I/O error occurs - * @throws NoSuchAlgorithmException If {@code MD5} isn't supported - * @throws RuntimeException If the uploaded or downloaded file wasn't found - */ - public static void main(String[] args) throws IOException, NoSuchAlgorithmException { - - /* - * From the Azure portal, get your Storage account's name and account key. - */ - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - - /* - * Use your Storage account's name and key to create a credential object; this is used to access your account. - */ - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endPoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - /* - * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. - * Now you can use the storageClient to perform various container and blob operations. - */ - BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endPoint).credential(credential).buildClient(); - - - /* - * This example shows several common operations just to get you started. - */ - - - /* - * Create a client that references a to-be-created container in your Azure Storage account. This returns a - * ContainerClient uses the same endpoint, credential and pipeline from storageClient. - * Note that container names require lowercase. - */ - BlobContainerClient blobContainerClient = storageClient.getBlobContainerClient("myjavacontainerparallelupload" + System.currentTimeMillis()); - - /* - * Create a container in Storage blob account. - */ - blobContainerClient.create(); - - /* - * Create a BlockBlobClient object that wraps a blob's endpoint and a default pipeline, the blockBlobClient give us access to upload the file. - */ - String filename = "BigFile.bin"; - BlobClient blobClient = blobContainerClient.getBlobClient(filename); - - /* - * Create the empty uploadFile and downloadFile. - */ - File largeFile = createTempEmptyFile(filename); - - File downloadFile = createTempEmptyFile("downloadFile.bin"); - - Files.deleteIfExists(downloadFile.toPath()); - - /* - * Generate random things to uploadFile, which makes the file with size of 100MB. - */ - long fileSize = 100 * 1024 * 1024L; - createTempFileWithFileSize(largeFile, fileSize); - - /* - * Upload the large file to storage blob. - */ - blobClient.uploadFromFile(largeFile.getPath()); - - /* - * Download the large file from storage blob to the local downloadFile path. - */ - blobClient.downloadToFile(downloadFile.getPath()); - - /* - * Check the files are same after the round-trip. - */ - if (Files.exists(downloadFile.toPath()) && Files.exists(largeFile.toPath())) { - checkTwoFilesAreTheSame(largeFile, downloadFile); - System.out.println("The file we upload is the same as the one we download."); - } else { - throw new RuntimeException("Did not find the upload or download file."); - } - - /* - * Clean up the local files and storage container. - */ - blobContainerClient.delete(); - Files.deleteIfExists(largeFile.toPath()); - Files.deleteIfExists(downloadFile.toPath()); - } - - private static File createTempEmptyFile(String fileName) throws IOException { - String pathName = "./folderPath/" + LARGE_TEST_FOLDER; - - File dirPath = new File(pathName); - - if (dirPath.exists() || dirPath.mkdirs()) { - File f = new File(pathName + fileName); - if (f.exists() || f.createNewFile()) { - return f; - } else { - throw new RuntimeException("Failed to create the large file."); - } - } else { - throw new RuntimeException("Failed to create the large file dir."); - } - } - - private static void createTempFileWithFileSize(File f, long size) throws IOException { - RandomAccessFile raf = new RandomAccessFile(f, "rw"); - raf.setLength(size); - raf.close(); - } - - private static void checkTwoFilesAreTheSame(File f1, File f2) throws IOException, NoSuchAlgorithmException { - String checksumUpload = getFileChecksum(f1); - String checksumDownload = getFileChecksum(f2); - if (!checksumUpload.equals(checksumDownload)) { - throw new RuntimeException("The file upload does not match the file download."); - } - } - - private static String getFileChecksum(File file) throws IOException, NoSuchAlgorithmException { - MessageDigest md = MessageDigest.getInstance("MD5"); - - try (FileInputStream fis = new FileInputStream(file); FileChannel ch = fis.getChannel()) { - final ByteBuffer buf = ByteBuffer.allocateDirect(8192); - int b = ch.read(buf); - while (b != -1 && b != 0) { - buf.flip(); - final byte[] bytes = new byte[b]; - buf.get(bytes); - md.update(bytes, 0, b); - buf.clear(); - b = ch.read(buf); - } - - return new String(md.digest(), StandardCharsets.UTF_8); - } - } - - -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java deleted file mode 100644 index b6b5d8a49e93..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.storage.blob.models.UserDelegationKey; - -final class JavaDocCodeSnippetsHelpers { - static BlobContainerAsyncClient getContainerAsyncClient() { - return new BlobContainerClientBuilder().buildAsyncClient(); - } - - static BlobContainerClient getContainerClient() { - return new BlobContainerClientBuilder().buildClient(); - } - - static BlobAsyncClient getBlobAsyncClient(String blobName) { - return getContainerAsyncClient().getBlobAsyncClient(blobName); - } - - static BlobClient getBlobClient(String blobName) { - return getContainerClient().getBlobClient(blobName); - } - - static BlobServiceAsyncClient getBlobServiceAsyncClient() { - return new BlobServiceClientBuilder().buildAsyncClient(); - } - - static BlobServiceClient getBlobServiceClient() { - return new BlobServiceClientBuilder().buildClient(); - } - - static UserDelegationKey getUserDelegationKey() { - return getBlobServiceClient().getUserDelegationKey(null, null); - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ListContainersExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ListContainersExample.java deleted file mode 100644 index 97d07f8adef3..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ListContainersExample.java +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.storage.common.StorageSharedKeyCredential; - -import java.util.Locale; - -/** - * This example shows how to list all containers with storage client using the Azure Storage Blob SDK for Java. - */ -public class ListContainersExample { - - /** - * Entry point into the list containers examples for Storage blobs. - * @param args Unused. Arguments to the program. - */ - public static void main(String[] args) { - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - - /* - * Use your Storage account's name and key to create a credential object; this is used to access your account. - */ - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - /* - * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. - */ - BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient(); - - /* - * Create 3 different containers from the storageClient. - */ - for (int i = 0; i < 3; i++) { - storageClient.createBlobContainer("mycontainersforlisting" + i + System.currentTimeMillis()); - } - - /* - * List the containers' name under the Azure storage account. - */ - storageClient.listBlobContainers().forEach(containerItem -> { - System.out.println("Container name: " + containerItem.getName()); - - /* - * Clean up the containers at the same time. - */ - storageClient.getBlobContainerClient(containerItem.getName()).delete(); - }); - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/LocationModeExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/LocationModeExample.java deleted file mode 100644 index a58ab7311d56..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/LocationModeExample.java +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.storage.common.policy.RequestRetryOptions; - -import java.time.Duration; - - -/** - * This example shows how to approximate the LocationMode behavior from the track 1 SDK. It is a general translation to - * achieve roughly the same results, but it is not an identical implementation. It may be modified to suit the use case. - * For more information on redundant storage, see here: - * https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy - * - * In a sense, the track 2 SDK is always primary-only or primary-then-secondary. However, by passing the secondary - * endpoint as the primary and the primary as the secondary, the behavior of secondary-only or secondary-then-primary - * can be achieved. To avoid confusion of terms in this example, 'preferred' and 'fallback' will refer to the location - * that is tried by the client first and then second respectively, whereas 'primary' and 'secondary' will refer to the - * Storage concept of primary read-write storage and back-up/redundant/read-only storage respectively. - * - * The general pattern is to create a BlobClient and pass the preferred location to the builder as the endpoint. To - * configure a fallback location, set it as the `secondaryEndpoint` on {@link RequestRetryOptions} and pass the - * configured options to {@link BlobClientBuilder#retryOptions(RequestRetryOptions)}. Switching LocationMode requires - * using a different client that is configured for the new request behavior. In this case, concurrency control should - * be carefully considered to prevent race conditions. - * - * Requests will always go first to the preferred location passed as the endpoint. If a request must be retried, it will - * and the error indicates it may be helped by checking the fallback, a request will immediately be reissued to the - * fallback. If that also fails and still a retry may be helpful, the client will wait for a backoff period specified by - * the retry options before retrying the initial location again. - * - * The client does not internally track the LocationMode or read it from an object that is passed because of how that - * might cause race conditions if it is shared between clients. - * - * Each of the clients constructed in this sample will have behavior according to the variable name. This sample does - * not demonstrate meaningful independent behavior, so running it will do nothing, but these clients can be copied and - * used as a component in other code. - * - * This example can be combined with the StorageEventExample to approximate the Circuit Breaker RAGRS sample here: - * https://github.com/Azure-Samples/storage-dotnet-circuit-breaker-ha-ra-grs/blob/master/storage-dotnet-circuit-breaker-ha-ra-grs/Program.cs - * In this case, in the StorageEvent callback, rather than switching the LocationMode on the DefaultRequestOptions, the - * client should be swapped out to the client with the appropriate LocationMode and the request reissued, alternating - * between a primary only and secondary only client. - * - * The main areas of divergence from the original LocationMode behavior are: - * - There is no LocationMode type - * - The v12 analogue of LocationMode is configured at client build time and is static for a given client; a new client - * must be used if different location behavior is desired. - * - Changing LocationMode entails changing the client being used to issue requests - */ -public class LocationModeExample { - - public static void main(String[] args) { - String primaryEndpoint = ""; - String secondaryEndpoint = ""; - - BlobClient primaryOnlyClient; - BlobClient secondaryOnlyClient; - BlobClient primaryThenSecondaryClient; - BlobClient secondaryThenPrimaryClient; - - BlobClientBuilder builder = new BlobClientBuilder() - .containerName("") - .blobName(""); - - /* - This could be refactored into a helper methods, but it is written out explicitly here for clarity and ease of - comparison. - Null in all cases indicates accepting the default value. - A distinct set of options must be created for each client to prevent overwriting the options held by another - client. - */ - // Create a primary only client by passing the primary endpoint as the preferred and passing no fallback. - RequestRetryOptions primaryOnlyRetryOptions = new RequestRetryOptions(null, null, (Duration) null, null, null, - null); - primaryOnlyClient = builder - .endpoint(primaryEndpoint) - .retryOptions(primaryOnlyRetryOptions) - .buildClient(); - - // Create a secondary only client by passing the secondary as the preferred and passing no fallback. - RequestRetryOptions secondaryOnlyRetryOptions = new RequestRetryOptions(null, null, (Duration) null, null, null, - null); - secondaryOnlyClient = builder - .endpoint(secondaryEndpoint) - .retryOptions(secondaryOnlyRetryOptions) - .buildClient(); - - // Create a primary then secondary by passing a primary as the preferred and secondary as a fallback. - RequestRetryOptions primaryThenSecondaryRetryOptions = new RequestRetryOptions(null, null, (Duration) null, - null, null, secondaryEndpoint); - primaryThenSecondaryClient = builder - .endpoint(primaryEndpoint) - .retryOptions(primaryThenSecondaryRetryOptions) - .buildClient(); - - // Create a secondary then primary by passing a secondary as the preferred and a primary as a fallback. - RequestRetryOptions secondaryThenPrimaryRetryOptions = new RequestRetryOptions(null, null, (Duration) null, - null, null, primaryEndpoint); - secondaryThenPrimaryClient = builder - .endpoint(secondaryEndpoint) - .retryOptions(secondaryThenPrimaryRetryOptions) - .buildClient(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/OperationalLevelTimeoutExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/OperationalLevelTimeoutExample.java deleted file mode 100644 index a551bd548bc6..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/OperationalLevelTimeoutExample.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpPipelineCallContext; -import com.azure.core.http.HttpPipelineNextPolicy; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.common.StorageSharedKeyCredential; -import reactor.core.publisher.Mono; - -import java.io.IOException; -import java.time.Duration; -import java.util.Locale; - -/** - * This example shows how to use connection level timeouts. These timeouts relate to the entire operation to complete - * and return, including retries, so any TimeoutException thrown will not be retried. It may be thought of as the amount - * of time a given sync api call may wait before timing out and allowing the application to proceed. This is - * highest-level form of retries. - */ -public class OperationalLevelTimeoutExample { - - /** - * Entry point into the basic examples for Storage blobs. - * - * @param args Unused. Arguments to the program. - * @throws IOException If an I/O error occurs - * @throws RuntimeException If the downloaded data doesn't match the uploaded data - */ - public static void main(String[] args) throws IOException { - - /* - * From the Azure portal, get your Storage account's name and account key. - */ - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - - /* - * Use your Storage account's name and key to create a credential object; this is used to access your account. - */ - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - /* - * Create a BlobServiceClient object that wraps the service endpoint, credential, policy with - * timeout per call, and a request pipeline. - * Note: this is not necessary to implement timeouts. This is only here to allow the sample to be independently - * runnable and demonstrate behavior. - */ - BlobServiceClient storageClient = new BlobServiceClientBuilder() - .endpoint(endpoint) - .credential(credential) - .addPolicy(new TimeoutPolicy()) - .buildClient(); - - /* - * This example shows how to pass timeouts in call operations. - */ - - /* - * Create a client that references a to-be-created container in your Azure Storage account. This returns a - * ContainerClient object that wraps the container's endpoint, credential and a request pipeline (inherited from storageClient). - * Note that container names require lowercase. - */ - BlobContainerClient blobContainerClient = storageClient.getBlobContainerClient("myjavacontainerbasic" + System.currentTimeMillis()); - - /* - * Create a container in Storage blob account with a timeout duration of 3 seconds. A timeout exception will - * occur if the blob create container call takes longer than 3 seconds to complete as this could not throw if - * it took 2 seconds. - */ - try { - blobContainerClient.createIfNotExistsWithResponse(new BlobContainerCreateOptions(), Duration.ofSeconds(3L), Context.NONE); - } catch (Exception ex) { - System.out.println("Creation failed due to timeout: " + ex.getMessage()); - } - - /* - * Create a client that references a to-be-created container in your Azure Storage account. This returns a - * ContainerClient object that wraps the container's endpoint, credential and a request pipeline (inherited from storageClient). - * Note that container names require lowercase. - */ - blobContainerClient = storageClient.getBlobContainerClient("myjavacontainerbasic" + System.currentTimeMillis()); - - /* - * Create a container in Storage blob account with a timeout duration of 10 seconds, greater the timeout duration - * passed in the policy. This will succeed. - */ - Response response = blobContainerClient.createIfNotExistsWithResponse(new BlobContainerCreateOptions(), Duration.ofSeconds(10L), Context.NONE); - if (response.getValue()) { - System.out.println("Blob container successfully created."); - } - - /* - * Delete the container we created earlier. - */ - blobContainerClient.delete(); - } - - /** - * A simple policy that sets duration timeout per call of 5 seconds. - */ - static class TimeoutPolicy implements HttpPipelinePolicy { - @Override - public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { - return next.process().delayElement(Duration.ofSeconds(5L)); - } - - @Override - public HttpPipelinePosition getPipelinePosition() { - return HttpPipelinePosition.PER_CALL; - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ReadmeSamples.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ReadmeSamples.java index d49b56c1fea8..59e8f0446e1f 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ReadmeSamples.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ReadmeSamples.java @@ -1,382 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.storage.blob; - -import com.azure.core.http.ProxyOptions; -import com.azure.core.http.netty.NettyAsyncHttpClientBuilder; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.HttpClientOptions; -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.BlobInputStream; -import com.azure.storage.blob.specialized.BlobOutputStream; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.time.Duration; -import java.time.OffsetDateTime; - -/** - * WARNING: MODIFYING THIS FILE WILL REQUIRE CORRESPONDING UPDATES TO README.md FILE. LINE NUMBERS ARE USED TO EXTRACT - * APPROPRIATE CODE SEGMENTS FROM THIS FILE. ADD NEW CODE AT THE BOTTOM TO AVOID CHANGING LINE NUMBERS OF EXISTING CODE - * SAMPLES. - * - * Code samples for the README.md - */ -public class ReadmeSamples { - - private final BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().buildClient(); - private final BlobContainerClient blobContainerClient = new BlobContainerClientBuilder().buildClient(); - private final BlobClient blobClient = new BlobClientBuilder().buildClient(); - - public void getBlobServiceClient1() { - // BEGIN: readme-sample-getBlobServiceClient1 - BlobServiceClient blobServiceClient = new BlobServiceClientBuilder() - .endpoint("") - .sasToken("") - .buildClient(); - // END: readme-sample-getBlobServiceClient1 - } - - public void getBlobServiceClient2() { - // BEGIN: readme-sample-getBlobServiceClient2 - // Only one "?" is needed here. If the SAS token starts with "?", please removing one "?". - BlobServiceClient blobServiceClient = new BlobServiceClientBuilder() - .endpoint("" + "?" + "") - .buildClient(); - // END: readme-sample-getBlobServiceClient2 - } - - public void getBlobContainerClient1() { - // BEGIN: readme-sample-getBlobContainerClient1 - BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient("mycontainer"); - // END: readme-sample-getBlobContainerClient1 - } - - public void getBlobContainerClient2() { - // BEGIN: readme-sample-getBlobContainerClient2 - BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() - .endpoint("") - .sasToken("") - .containerName("mycontainer") - .buildClient(); - // END: readme-sample-getBlobContainerClient2 - } - - public void getBlobContainerClient3() { - // BEGIN: readme-sample-getBlobContainerClient3 - // Only one "?" is needed here. If the SAS token starts with "?", please removing one "?". - BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() - .endpoint("" + "/" + "mycontainer" + "?" + "") - .buildClient(); - // END: readme-sample-getBlobContainerClient3 - } - - public void getBlobClient1() { - // BEGIN: readme-sample-getBlobClient1 - BlobClient blobClient = blobContainerClient.getBlobClient("myblob"); - // END: readme-sample-getBlobClient1 - } - - public void getBlobClient2() { - // BEGIN: readme-sample-getBlobClient2 - BlobClient blobClient = new BlobClientBuilder() - .endpoint("") - .sasToken("") - .containerName("mycontainer") - .blobName("myblob") - .buildClient(); - // END: readme-sample-getBlobClient2 - } - - public void getBlobClient3() { - // BEGIN: readme-sample-getBlobClient3 - // Only one "?" is needed here. If the SAS token starts with "?", please removing one "?". - BlobClient blobClient = new BlobClientBuilder() - .endpoint("" + "/" + "mycontainer" + "/" + "myblob" + "?" + "") - .buildClient(); - // END: readme-sample-getBlobClient3 - } - - public void createBlobContainerClient1() { - // BEGIN: readme-sample-createBlobContainerClient1 - blobServiceClient.createBlobContainer("mycontainer"); - // END: readme-sample-createBlobContainerClient1 - } - - public void createBlobContainerClient2() { - // BEGIN: readme-sample-createBlobContainerClient2 - blobContainerClient.create(); - // END: readme-sample-createBlobContainerClient2 - } - - public void uploadBinaryDataToBlob() { - // BEGIN: readme-sample-uploadBinaryDataToBlob - BlobClient blobClient = blobContainerClient.getBlobClient("myblockblob"); - String dataSample = "samples"; - blobClient.upload(BinaryData.fromString(dataSample)); - // END: readme-sample-uploadBinaryDataToBlob - } - - public void uploadBlobFromStream() { - // BEGIN: readme-sample-uploadBlobFromStream - BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient("myblockblob").getBlockBlobClient(); - String dataSample = "samples"; - try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - blockBlobClient.upload(dataStream, dataSample.length()); - } catch (IOException e) { - e.printStackTrace(); - } - // END: readme-sample-uploadBlobFromStream - } - - public void uploadBlobFromFile() { - // BEGIN: readme-sample-uploadBlobFromFile - BlobClient blobClient = blobContainerClient.getBlobClient("myblockblob"); - blobClient.uploadFromFile("local-file.jpg"); - // END: readme-sample-uploadBlobFromFile - } - - public void uploadIfNotExists() { - // BEGIN: readme-sample-uploadIfNotExists - /* - * Rather than use an if block conditioned on an exists call, there are three ways to upload-if-not-exists using - * one network call instead of two. Equivalent options are present on all upload methods. - */ - // 1. The minimal upload method defaults to no overwriting - String dataSample = "samples"; - try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - blobClient.upload(dataStream, dataSample.length()); - } catch (IOException e) { - e.printStackTrace(); - } - - // 2. The overwrite flag can explicitly be set to false to make intention clear - try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - blobClient.upload(dataStream, dataSample.length(), false /* overwrite */); - } catch (IOException e) { - e.printStackTrace(); - } - - // 3. If the max overload is needed, access conditions must be used to prevent overwriting - try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - BlobParallelUploadOptions options = - new BlobParallelUploadOptions(dataStream, dataSample.length()); - // Setting IfNoneMatch="*" ensures the upload will fail if there is already a blob at the destination. - options.setRequestConditions(new BlobRequestConditions().setIfNoneMatch("*")); - blobClient.uploadWithResponse(options, null, Context.NONE); - } catch (IOException e) { - e.printStackTrace(); - } - // END: readme-sample-uploadIfNotExists - } - - public void overwriteBlob() { - // BEGIN: readme-sample-overwriteBlob - /* - * Rather than use an if block conditioned on an exists call, there are three ways to upload-if-exists in one - * network call instead of two. Equivalent options are present on all upload methods. - */ - String dataSample = "samples"; - - // 1. The overwrite flag can explicitly be set to true. This will succeed as a create and overwrite. - try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - blobClient.upload(dataStream, dataSample.length(), true /* overwrite */); - } catch (IOException e) { - e.printStackTrace(); - } - - /* - * 2. If the max overload is needed and no access conditions are passed, the upload will succeed as both a - * create and overwrite. - */ - try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - BlobParallelUploadOptions options = - new BlobParallelUploadOptions(dataStream, dataSample.length()); - blobClient.uploadWithResponse(options, null, Context.NONE); - } catch (IOException e) { - e.printStackTrace(); - } - - /* - * 3. If the max overload is needed, access conditions may be used to assert that the upload is an overwrite and - * not simply a create. - */ - try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBytes())) { - BlobParallelUploadOptions options = - new BlobParallelUploadOptions(dataStream, dataSample.length()); - // Setting IfMatch="*" ensures the upload will succeed only if there is already a blob at the destination. - options.setRequestConditions(new BlobRequestConditions().setIfMatch("*")); - blobClient.uploadWithResponse(options, null, Context.NONE); - } catch (IOException e) { - e.printStackTrace(); - } - // END: readme-sample-overwriteBlob - } - - public void openBlobOutputStream() { - // BEGIN: readme-sample-openBlobOutputStream - /* - * Opening a blob input stream allows you to write to a blob through a normal stream interface. It will not be - * committed until the stream is closed. - * This option is convenient when the length of the data is unknown. - * This can only be done for block blobs. If the target blob already exists as another type of blob, it will - * fail. - */ - try (BlobOutputStream blobOS = blobClient.getBlockBlobClient().getBlobOutputStream()) { - blobOS.write(new byte[0]); - } catch (IOException e) { - e.printStackTrace(); - } - // END: readme-sample-openBlobOutputStream - } - - public void downloadDataFromBlob() { - // BEGIN: readme-sample-downloadDataFromBlob - BinaryData content = blobClient.downloadContent(); - // END: readme-sample-downloadDataFromBlob - } - - public void downloadBlobToStream() { - // BEGIN: readme-sample-downloadBlobToStream - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { - blobClient.downloadStream(outputStream); - } catch (IOException e) { - e.printStackTrace(); - } - // END: readme-sample-downloadBlobToStream - } - - public void downloadBlobToFile() { - // BEGIN: readme-sample-downloadBlobToFile - blobClient.downloadToFile("downloaded-file.jpg"); - // END: readme-sample-downloadBlobToFile - } - - public void openBlobInputStream() { - // BEGIN: readme-sample-openBlobInputStream - /* - * Opening a blob input stream allows you to read from a blob through a normal stream interface. It is also - * mark-able. - */ - try (BlobInputStream blobIS = blobClient.openInputStream()) { - blobIS.read(); - } catch (IOException e) { - e.printStackTrace(); - } - // END: readme-sample-openBlobInputStream - } - - public void enumerateBlobs() { - // BEGIN: readme-sample-enumerateBlobs - for (BlobItem blobItem : blobContainerClient.listBlobs()) { - System.out.println("This is the blob name: " + blobItem.getName()); - } - // END: readme-sample-enumerateBlobs - } - - public void enumerateBlobsCreateClient() { - // BEGIN: readme-sample-enumerateBlobsCreateClient - for (BlobItem blobItem : blobContainerClient.listBlobs()) { - BlobClient blobClient; - if (blobItem.getSnapshot() != null) { - blobClient = blobContainerClient.getBlobClient(blobItem.getName(), blobItem.getSnapshot()); - } else { - blobClient = blobContainerClient.getBlobClient(blobItem.getName()); - } - System.out.println("This is the new blob uri: " + blobClient.getBlobUrl()); - } - // END: readme-sample-enumerateBlobsCreateClient - } - - public void copyBlob() { - // BEGIN: readme-sample-copyBlob - SyncPoller poller = blobClient.beginCopy("", Duration.ofSeconds(1)); - poller.waitForCompletion(); - // END: readme-sample-copyBlob - } - - public void copyBlob2() { - // BEGIN: readme-sample-copyBlob2 - blobClient.copyFromUrl("url-to-blob"); - // END: readme-sample-copyBlob2 - } - - public void generateSas() { - // BEGIN: readme-sample-generateSas - /* - * Generate an account sas. Other samples in this file will demonstrate how to create a client with the sas - * token. - */ - // Configure the sas parameters. This is the minimal set. - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - AccountSasPermission accountSasPermission = new AccountSasPermission().setReadPermission(true); - AccountSasService services = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceTypes = new AccountSasResourceType().setObject(true); - - // Generate the account sas. - AccountSasSignatureValues accountSasValues = - new AccountSasSignatureValues(expiryTime, accountSasPermission, services, resourceTypes); - String sasToken = blobServiceClient.generateAccountSas(accountSasValues); +// Code generated by Microsoft (R) TypeSpec Code Generator. - // Generate a sas using a container client - BlobContainerSasPermission containerSasPermission = new BlobContainerSasPermission().setCreatePermission(true); - BlobServiceSasSignatureValues serviceSasValues = - new BlobServiceSasSignatureValues(expiryTime, containerSasPermission); - blobContainerClient.generateSas(serviceSasValues); - - // Generate a sas using a blob client - BlobSasPermission blobSasPermission = new BlobSasPermission().setReadPermission(true); - serviceSasValues = new BlobServiceSasSignatureValues(expiryTime, blobSasPermission); - blobClient.generateSas(serviceSasValues); - // END: readme-sample-generateSas - } - - public void authWithIdentity() { - // BEGIN: readme-sample-authWithIdentity - BlobServiceClient blobStorageClient = new BlobServiceClientBuilder() - .endpoint("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); - // END: readme-sample-authWithIdentity - } - - public void setProxy() { - // BEGIN: readme-sample-setProxy - ProxyOptions options = new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 888)); - BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("") - .sasToken("") - .httpClient(new NettyAsyncHttpClientBuilder().proxy(options).build()) - .buildClient(); - // END: readme-sample-setProxy - } +package com.azure.storage.blob; - public void setProxy2() { - // BEGIN: readme-sample-setProxy2 - HttpClientOptions clientOptions = new HttpClientOptions() - .setProxyOptions(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 888))); - BlobServiceClient client = new BlobServiceClientBuilder() - .endpoint("") - .sasToken("") - .clientOptions(clientOptions) - .buildClient(); - // END: readme-sample-setProxy2 +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: com.azure.storage.blob.readme + // END: com.azure.storage.blob.readme } } - diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/RequestLevelTimeoutExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/RequestLevelTimeoutExample.java deleted file mode 100644 index efd2ec04d5e3..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/RequestLevelTimeoutExample.java +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpPipelineCallContext; -import com.azure.core.http.HttpPipelineNextPolicy; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.RetryPolicyType; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.IOException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.time.Duration; -import java.util.Locale; -import java.util.concurrent.TimeoutException; - -/** - * This example shows how to use request level timeouts. These timeouts relate to the round trip time for an individual - * request. It is the time between the request leaving the client and the response headers being received by the client. - * These options offer a mid-level granularity. If one of these values times out, it will be automatically retried. - * Note that for write operations in particular, this includes the time it takes to complete writing the body as the - * service will not return a response until this is finished. - */ -public class RequestLevelTimeoutExample { - - /** - * Entry point into the basic examples for Storage blobs. - * - * @param args Unused. Arguments to the program. - * @throws IOException If an I/O error occurs - * @throws RuntimeException If the downloaded data doesn't match the uploaded data - */ - public static void main(String[] args) throws IOException { - - /* - * From the Azure portal, get your Storage account's name and account key. - */ - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - - /* - * Use your Storage account's name and key to create a credential object; this is used to access your account. - */ - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - - /* - Use a Request Retry Policy that has a fixed back-off retry policy. - */ - RequestRetryOptions retryOptions = new RequestRetryOptions(RetryPolicyType.FIXED, 2, 3, 1000L, 1500L, null); - HttpResponse mockHttpResponse = new MockHttpResponse(new HttpRequest(HttpMethod.PUT, new URL("https://www.fake.com")), 202); - - /* - * Create a BlobServiceClient object that wraps the service endpoint, credential, retry options, and a request pipeline. - */ - BlobServiceClient storageClient = new BlobServiceClientBuilder() - .endpoint(endpoint) - .credential(credential) - .retryOptions(retryOptions) - .addPolicy(new TimeoutPolicy(mockHttpResponse)) - .buildClient(); - - /* - * Make a call on the client to trigger the pipeline policy. - */ - try { - storageClient.getProperties(); - } catch (Exception ex) { - if (ex.getCause() instanceof TimeoutException) { - System.out.println("Operation failed due to timeout: " + ex.getMessage()); - } - } - } - - /** - * A simple policy that sets duration timeout per call of 5 seconds. - */ - static class TimeoutPolicy implements HttpPipelinePolicy { - - HttpResponse mockHttpResponse; - int count; - - TimeoutPolicy(HttpResponse httpResponse) { - mockHttpResponse = httpResponse; - count = 0; - } - - @Override - public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { - System.out.println("Number of retries: " + ++count); - return Mono.just(mockHttpResponse).delayElement(Duration.ofSeconds(5L)); - } - - @Override - public HttpPipelinePosition getPipelinePosition() { - return HttpPipelinePosition.PER_CALL; - } - } - - static class MockHttpResponse extends HttpResponse { - int statusCode; - - protected MockHttpResponse(HttpRequest request, int code) { - super(request); - this.statusCode = code; - } - - @Override - public int getStatusCode() { - return statusCode; - } - - @Override - public String getHeaderValue(String s) { - return null; - } - - - @Override - public HttpHeaders getHeaders() { - return new HttpHeaders(); - } - - @Override - public Flux getBody() { - return Flux.empty(); - } - - @Override - public Mono getBodyAsByteArray() { - return Mono.just(new byte[0]); - } - - @Override - public Mono getBodyAsString() { - return Mono.just(""); - } - - @Override - public Mono getBodyAsString(Charset charset) { - return Mono.just(""); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/SampleHelper.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/SampleHelper.java deleted file mode 100644 index b558b188521e..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/SampleHelper.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.Configuration; - -/** - * This is a helper class of frequently used methods for sample codes. - */ -class SampleHelper { - static String getAccountName() { - return Configuration.getGlobalConfiguration().get("PRIMARY_STORAGE_ACCOUNT_NAME"); - } - - static String getAccountKey() { - return Configuration.getGlobalConfiguration().get("PRIMARY_STORAGE_ACCOUNT_KEY"); - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ServiceLevelTimeoutExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ServiceLevelTimeoutExample.java deleted file mode 100644 index ff3307bb23a9..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ServiceLevelTimeoutExample.java +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.Context; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.policy.ServiceTimeoutPolicy; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.time.Duration; -import java.util.Locale; -import java.util.Random; -import java.util.UUID; - -/** - * This example shows how to use service level timeouts. These timeouts are set on the service operation. If the server - * timeout interval elapses before the service has finished processing the request, the service returns an error. - * For more information on setting service timeouts, see here: - * Setting timeouts for blob service operations - * Setting timeouts for file service operations - * Setting timeouts for queue service operations - */ -public class ServiceLevelTimeoutExample { - - /** - * Entry point into the service level timeout examples for Storage blobs. - * - * @param args Unused. Arguments to the program. - * @throws IOException If an I/O error occurs - * @throws RuntimeException If any failure (come back to this) - */ - public static void main(String[] args) { - - /* - * From the Azure portal, get your Storage account's name and account key. - */ - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - - /* - * Use your Storage account's name and key to create a credential object; this is used to access your account. - */ - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - /* - * Create a BlobServiceClient object that wraps the service endpoint, credential, policy with service level - * timeout per call. - * For this example, we'll set the service timeout to 3 seconds. - */ - BlobServiceClient storageClient = new BlobServiceClientBuilder() - .endpoint(endpoint) - .credential(credential) - .addPolicy(new ServiceTimeoutPolicy(Duration.ofSeconds(3))) - .buildClient(); - - BlobContainerClient blobContainerClient = storageClient.getBlobContainerClient("myjavacontainerbasic" + System.currentTimeMillis()); - - /* - * First create the container with the specified timeout. Since create operations are fast, timeout should not - * exceed the 3 seconds specified above. - */ - try { - blobContainerClient.createIfNotExistsWithResponse(new BlobContainerCreateOptions(), null, Context.NONE); - System.out.println("Created"); - } catch (Exception ex) { - System.out.println("Creation failed due to timeout: " + ex.getMessage()); - } - - BlobClient blobClient = blobContainerClient.getBlobClient("myblob" + System.currentTimeMillis()); - - //Create a dataset that is guaranteed to take longer than the specified timeout of 3 seconds - byte[] randomData = getRandomByteArray(16 * Constants.MB); - InputStream input = new ByteArrayInputStream(randomData); - ParallelTransferOptions pto = new ParallelTransferOptions().setMaxSingleUploadSizeLong((long) Constants.MB); - - /* - * making the call to upload will fail since we are using a large dataset which will take longer than the - * specified timeout. - */ - try { - blobClient.uploadWithResponse(new BlobParallelUploadOptions(input).setParallelTransferOptions(pto), null, null); - System.out.println("Upload succeeded."); - } catch (Exception ex) { - System.out.println("Creation failed due to timeout: " + ex.getMessage()); - } - } - - static byte[] getRandomByteArray(int size) { - long seed = UUID.fromString(CoreUtils.randomUuid().toString()).getMostSignificantBits() & Long.MAX_VALUE; - Random rand = new Random(seed); - byte[] data = new byte[size]; - rand.nextBytes(data); - return data; - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ServiceVersionExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ServiceVersionExample.java deleted file mode 100644 index 16a718075451..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/ServiceVersionExample.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.storage.common.StorageSharedKeyCredential; - -import java.util.Locale; - -public class ServiceVersionExample { - - public static void main(String[] args) { - - // More information on these properties can be found in BasicExample.java - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - // Select the desired version and set it on the builder - BlobServiceVersion serviceVersion = BlobServiceVersion.V2019_02_02; - BlobServiceClient storageClient = new BlobServiceClientBuilder() - .serviceVersion(serviceVersion) - .endpoint(endpoint).credential(credential).buildClient(); - - // This service client may now be used as desired, and any service requests will target the specified version. - - /* - If the workload includes generating new SAS tokens using an older format, the version of the sas generation can - also be configured. Before starting the jvm, set the environment variable AZURE_STORAGE_SAS_SERVICE_VERSION or - the JVM system property AZURE_STORAGE_SAS_SERVICE_VERSION (e.g. -DAZURE_STORAGE_SAS_SERVICE_VERSION=2019-12-12) - to the service version which corresponds to the desired SAS format to configure this behavior. - */ - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/SetMetadataAndHTTPHeadersExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/SetMetadataAndHTTPHeadersExample.java deleted file mode 100644 index 3a47878ed8c2..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/SetMetadataAndHTTPHeadersExample.java +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.Context; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.common.StorageSharedKeyCredential; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Collections; -import java.util.Locale; -import java.util.Map; - -/** - * This example shows how to set metadata for containers and blobs and how to set HTTPHeaders for blobs using the Azure - * Storage Blob SDK for Java. - */ -public class SetMetadataAndHTTPHeadersExample { - - /** - * Entry point into the setting metadata examples for Storage blobs. - * - * @param args Unused. Arguments to the program. - * @throws IOException If an I/O error occurs - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public static void main(String[] args) throws IOException, NoSuchAlgorithmException { - String accountName = SampleHelper.getAccountName(); - String accountKey = SampleHelper.getAccountKey(); - - /* - * Use your Storage account's name and key to create a credential object; this is used to access your account. - */ - StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); - - /* - * From the Azure portal, get your Storage account blob service URL endpoint. - * The URL typically looks like this: - */ - String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); - - /* - * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. - */ - BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient(); - - /* - * Create a container client from storageClient. - */ - BlobContainerClient blobContainerClient = storageClient.getBlobContainerClient("mycontainer" + System.currentTimeMillis()); - - /* - * Setup containerMetadata for container. - */ - Map containerMetadata = Collections.singletonMap("mycontainermetadata", "sample"); - - /* - * Create a container with the containerMetadata above. - */ - blobContainerClient.createWithResponse(containerMetadata, null, null, new Context("key1", "value1")); - - /* - * Create a blob client. - */ - BlockBlobClient blobClient = blobContainerClient.getBlobClient("myblob" + System.currentTimeMillis()).getBlockBlobClient(); - - /* - * Create a blob with blob's blobMetadata and BlobHttpHeaders. - */ - Map blobMetadata = Collections.singletonMap("myblobmetadata", "sample"); - BlobHttpHeaders blobHTTPHeaders = new BlobHttpHeaders().setContentDisposition("attachment") - .setContentType("text/html; charset=utf-8"); - - - String data = "Hello world!"; - - /* - * Send an MD5 hash of the content to be validated by the service. - */ - byte[] md5 = MessageDigest.getInstance("MD5").digest(data.getBytes(StandardCharsets.UTF_8)); - - /* - * Data which will upload to block blob. - */ - InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - blobClient.uploadWithResponse(dataStream, data.length(), blobHTTPHeaders, blobMetadata, null, md5, null, null, - null); - - /* - * Clean up the container and blob. - */ - blobClient.delete(); - blobContainerClient.delete(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageErrorHandlingExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageErrorHandlingExample.java deleted file mode 100644 index 7e1d5bba8af1..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageErrorHandlingExample.java +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpResponse; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobStorageException; - -/** - * This example shows how to handle errors thrown by various XxxURL methods. Any client-side error will be - * propagated unmodified. However, any response from the service with an unexpected status code will be wrapped in a - * StorageException. If the pipeline includes the RequestRetryFactory, which is the default, some of these errors - * will be automatically retried if it makes sense to do so. The StorageException type exposes rich error - * information returned by the service. - */ -public class StorageErrorHandlingExample { - - /** - * Entry point into error handling example for Storage blobs. - * @param args Unused. Arguments to the program. - */ - public static void main(String[] args) { - BlobContainerClient blobContainerClient = new BlobContainerClientBuilder().endpoint("https://account.blob.core.windows.net/mycontainer") - .buildClient(); - - try { - - /* - * An error occurred while creating the container. - */ - blobContainerClient.create(); - } catch (BlobStorageException e) { - - /* - * StorageErrorCode defines constants corresponding to all error codes returned by the service. - */ - if (e.getErrorCode() == BlobErrorCode.RESOURCE_NOT_FOUND) { - - /* - * Log more detailed information. - */ - System.out.println("Extended details: " + e.getStatusCode()); - - /* - * Examine the raw response. - */ - HttpResponse response = e.getResponse(); - System.out.println("Error creating the container with status code: " + response.getStatusCode()); - } else if (e.getErrorCode() == BlobErrorCode.CONTAINER_BEING_DELETED) { - - /* - * Log more detailed information. - */ - System.out.println("Extended details: " + e.getServiceMessage()); - - } else if (e.getErrorCode() == BlobErrorCode.CONTAINER_ALREADY_EXISTS) { - - /* - * Process the error. - */ - System.out.println("The container url is " + blobContainerClient.toString()); - } - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageEventExample.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageEventExample.java deleted file mode 100644 index 8fb144e274f5..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/StorageEventExample.java +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpPipelineCallContext; -import com.azure.core.http.HttpPipelineNextPolicy; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.HttpLoggingPolicy; -import com.azure.core.http.policy.HttpPipelinePolicy; -import reactor.core.publisher.Mono; - -import java.io.IOException; -import java.util.Optional; -import java.util.function.BiConsumer; -import java.util.function.Consumer; - -/** - * This examples shows how to approximate the StorageEvent behavior from the track 1 SDK. It is a general translation to - * achieve roughly the same results, but it is not an identical implementation. It may be modified to suit the use case. - * - * The general pattern is to create an {@link HttpPipelinePolicy} that will call the events at appropriate times. All - * requests pass through a pipeline, so any pipeline which contains an instance of this policy will be able to invoke - * the callbacks. Once the policy is defined, it must be set on the builder when constructing the clients. - * - * This sample can be run as is to demonstrate usage. Expected output is a console statement indicating the request - * being sent, the response being received, and (in the async case) the request completing. To demonstrate the retry and - * error handlers, uncomment the line {@code //.addPolicy(new ErrorPolicy())} when configuring the builder and run - * again. This will print out several retries and errors. The async segment will not run in this case as the eventual - * exception will terminate the program. - * - * The main areas of divergence from the original feature are: - * - It is only possible to use the sendingRequestHandler on an async client. - * - The callbacks do not all accept the same type as they did in the track 1 sdk and there is no StorageEvent type. - * - The SendingRequest events come after the signature here. In track 1, they came before the signature. It would be - * possible to create a second, near identical policy to put before the signature specifically for the SendingRequest - * event if that behavior is desirable. The policy shown here should then be modified to not duplicate that event. - * - Global handlers are not demonstrated here. They could be implemented in a very similar fashion by having some - * static fields on the policy object that are called alongside the instance fields. - */ -public class StorageEventExample { - - public static void main(String[] args) { - // Define the event handlers - Consumer sendingRequestHandler = - request -> System.out.println("Sending request " + request.getUrl()); - BiConsumer retryRequestHandler = - (request, retryNumber) -> System.out.println("Retrying request. " + request.getUrl() + " Attempt number " - + retryNumber); - BiConsumer responseReceivedHandler = - (request, response) -> System.out.println("Received response. Request " + request.getUrl() + "\nResponse " - + "status" + response.getStatusCode()); - BiConsumer errorHandler = - (request, t) -> System.out.println("Error. Request " + request.getUrl() + "\n " + t.getMessage()); - /* - If actions specific to the request type must be taken, the consumer type parameter should correspond to the type - returned by the api. - */ - Consumer requestCompleteHandler = - obj -> System.out.println("Request complete"); - - // Instantiate the policy that will invoke the handlers at the proper time - EventHandlerPolicy eventHandlerPolicy = new EventHandlerPolicy(sendingRequestHandler, retryRequestHandler, - responseReceivedHandler, errorHandler); - - // Create clients whose pipeline contains the new policy - BlobClientBuilder builder = new BlobClientBuilder() - .connectionString("") - .addPolicy(eventHandlerPolicy) - .addPolicy(new ErrorPolicy()) - .containerName("") - .blobName(""); - BlobClient bc = builder.buildClient(); - BlobAsyncClient bac = builder.buildAsyncClient(); - - // Use the client as usual, the handlers will now be automatically invoked at the proper times - bc.downloadContent(); - /* - The only way to use a requestCompleteHandler is to use the async client and set a side effect operator on the - return value. - */ - System.out.println("Async"); - bac.downloadWithResponse(null, null, null, false) - .doOnNext(requestCompleteHandler) - .block(); - } - - static class EventHandlerPolicy implements HttpPipelinePolicy { - - private final Consumer sendingRequestEvent; - private final BiConsumer retryRequestEvent; - private final BiConsumer responseReceivedEvent; - private final BiConsumer errorResponseEvent; - - EventHandlerPolicy(Consumer sendingRequestEvent, - BiConsumer retryRequestEvent, - BiConsumer responseReceivedEvent, - BiConsumer errorResponseEvent) { - this.sendingRequestEvent = sendingRequestEvent; - this.retryRequestEvent = retryRequestEvent; - this.responseReceivedEvent = responseReceivedEvent; - this.errorResponseEvent = errorResponseEvent; - } - - @Override - public Mono process(HttpPipelineCallContext httpPipelineCallContext, HttpPipelineNextPolicy httpPipelineNextPolicy) { - HttpRequest request = httpPipelineCallContext.getHttpRequest(); - /* - Check how many retries have gone out. Send an initial sendingRequest event or a retryRequest event as - appropriate. - This value is updated automatically by the retry policy before the request gets here - */ - Optional retryOptional = httpPipelineCallContext.getData(HttpLoggingPolicy.RETRY_COUNT_CONTEXT); - Integer retryCount = retryOptional.map(o -> (Integer) o).orElse(0); - if (retryCount <= 1) { - this.sendingRequestEvent.accept(request); - } else { - this.retryRequestEvent.accept(request, retryCount); - } - - // Set side-effect call backs to process the event without affecting the normal request-response flow - return httpPipelineNextPolicy.process() - .doOnNext(response -> this.responseReceivedEvent.accept(request, response)) - .doOnError(throwable -> this.errorResponseEvent.accept(request, throwable)); - } - - @Override - public HttpPipelinePosition getPipelinePosition() { - // This policy must be in a position to see each retry - return HttpPipelinePosition.PER_RETRY; - } - } - - /** - * A simple policy that always returns a retryable error to demonstrate retry and error event handlers - */ - static class ErrorPolicy implements HttpPipelinePolicy { - @Override - public Mono process(HttpPipelineCallContext httpPipelineCallContext, HttpPipelineNextPolicy httpPipelineNextPolicy) { - return Mono.error(new IOException("Dummy error")); - } - - @Override - public HttpPipelinePosition getPipelinePosition() { - return HttpPipelinePosition.PER_RETRY; - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/AppendBlobAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/AppendBlobAsyncClientJavaDocCodeSnippets.java deleted file mode 100644 index b3803fd60160..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/AppendBlobAsyncClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.storage.blob.options.AppendBlobCreateOptions; -import com.azure.storage.blob.models.AppendBlobRequestConditions; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.options.AppendBlobSealOptions; -import com.azure.storage.blob.options.AppendBlobAppendBlockFromUrlOptions; -import reactor.core.publisher.Flux; - -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.Map; - -/** - * Code snippets for {@link AppendBlobAsyncClient} - */ -public class AppendBlobAsyncClientJavaDocCodeSnippets { - private AppendBlobAsyncClient client = new SpecializedBlobClientBuilder().buildAppendBlobAsyncClient(); - private String leaseId = "leaseId"; - private Flux data = Flux.just(ByteBuffer.wrap("data".getBytes(StandardCharsets.UTF_8))); - private long length = 4L; - private static final Long POSITION = null; - private Long maxSize = length; - private String sourceUrl = "https://example.com"; - private long offset = 1024; - private long count = 1024; - - /** - * Code snippet for {@link AppendBlobAsyncClient#create()} - */ - public void create() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.create - client.create().subscribe(response -> - System.out.printf("Created AppendBlob at %s%n", response.getLastModified())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.create - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#create(boolean)} - */ - public void createWithOverwrite() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.create#boolean - boolean overwrite = false; // Default behavior - client.create(overwrite).subscribe(response -> - System.out.printf("Created AppendBlob at %s%n", response.getLastModified())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.create#boolean - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#createWithResponse(BlobHttpHeaders, Map, BlobRequestConditions)} - */ - public void create2() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.createWithResponse#BlobHttpHeaders-Map-BlobRequestConditions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentType("binary") - .setContentLanguage("en-US"); - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.createWithResponse(headers, metadata, requestConditions).subscribe(response -> - System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.createWithResponse#BlobHttpHeaders-Map-BlobRequestConditions - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#createWithResponse(AppendBlobCreateOptions)} - */ - public void create3() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.createWithResponse#AppendBlobCreateOptions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentType("binary") - .setContentLanguage("en-US"); - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata) - .setTags(tags).setRequestConditions(requestConditions)).subscribe(response -> - System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.createWithResponse#AppendBlobCreateOptions - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#appendBlock(Flux, long)} - */ - public void appendBlock() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlock#Flux-long - client.appendBlock(data, length).subscribe(response -> - System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlock#Flux-long - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#appendBlockWithResponse(Flux, long, byte[], AppendBlobRequestConditions)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void appendBlock2() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockWithResponse#Flux-long-byte-AppendBlobRequestConditions - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions() - .setAppendPosition(POSITION) - .setMaxSize(maxSize); - - client.appendBlockWithResponse(data, length, md5, requestConditions).subscribe(response -> - System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockWithResponse#Flux-long-byte-AppendBlobRequestConditions - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#appendBlockFromUrl(String, BlobRange)} - */ - public void appendBlockFromUrl() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrl#String-BlobRange - client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).subscribe(response -> - System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrl#String-BlobRange - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#appendBlockFromUrlWithResponse(String, BlobRange, byte[], AppendBlobRequestConditions, BlobRequestConditions)} - */ - public void appendBlockFromUrl2() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrlWithResponse#String-BlobRange-byte-AppendBlobRequestConditions-BlobRequestConditions - AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() - .setAppendPosition(POSITION) - .setMaxSize(maxSize); - - BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null, - appendBlobRequestConditions, modifiedRequestConditions).subscribe(response -> - System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrlWithResponse#String-BlobRange-byte-AppendBlobRequestConditions-BlobRequestConditions - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#appendBlockFromUrlWithResponse(String, BlobRange, byte[], AppendBlobRequestConditions, BlobRequestConditions)} - */ - public void appendBlockFromUrlOptionBag() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrlWithResponse#AppendBlobAppendBlockFromUrlOptions - AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() - .setAppendPosition(POSITION) - .setMaxSize(maxSize); - - BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl) - .setSourceRange(new BlobRange(offset, count)) - .setDestinationRequestConditions(appendBlobRequestConditions) - .setSourceRequestConditions(modifiedRequestConditions)).subscribe(response -> - System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrlWithResponse#AppendBlobAppendBlockFromUrlOptions - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#seal()} - */ - public void seal() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.seal - client.seal().subscribe(response -> System.out.println("Sealed AppendBlob")); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.seal - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#sealWithResponse(AppendBlobSealOptions)} - */ - public void seal2() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.sealWithResponse#AppendBlobSealOptions - AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions)) - .subscribe(response -> System.out.println("Sealed AppendBlob")); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.sealWithResponse#AppendBlobSealOptions - } - - /** - * Code snippet for {@link AppendBlobAsyncClient#createIfNotExists()} and - * {@link AppendBlobAsyncClient#createIfNotExistsWithResponse(AppendBlobCreateOptions)} - */ - public void createIfNotExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.createIfNotExists - client.createIfNotExists().subscribe(response -> - System.out.printf("Created AppendBlob at %s%n", response.getLastModified())); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.createIfNotExists - - // BEGIN: com.azure.storage.blob.specialized.AppendBlobAsyncClient.createIfNotExistsWithResponse#AppendBlobCreateOptions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentType("binary") - .setContentLanguage("en-US"); - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - - client.createIfNotExistsWithResponse(new AppendBlobCreateOptions().setHeaders(headers) - .setMetadata(metadata).setTags(tags)).subscribe(response -> { - if (response.getStatusCode() == 409) { - System.out.println("Already exists."); - } else { - System.out.println("successfully created."); - } - }); - // END: com.azure.storage.blob.specialized.AppendBlobAsyncClient.createIfNotExistsWithResponse#AppendBlobCreateOptions - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/AppendBlobClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/AppendBlobClientJavaDocCodeSnippets.java deleted file mode 100644 index e03fef303d9c..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/AppendBlobClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.options.AppendBlobCreateOptions; -import com.azure.storage.blob.models.AppendBlobRequestConditions; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.options.AppendBlobSealOptions; -import com.azure.storage.blob.options.AppendBlobAppendBlockFromUrlOptions; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.Map; - -/** - * Code snippets for {@link AppendBlobClient} - */ -public class AppendBlobClientJavaDocCodeSnippets { - - private AppendBlobClient client = new SpecializedBlobClientBuilder().buildAppendBlobClient(); - private Duration timeout = Duration.ofSeconds(30); - private String leaseId = "leaseId"; - private InputStream data = new ByteArrayInputStream("data".getBytes(StandardCharsets.UTF_8)); - private long length = 4L; - private static final Long POSITION = null; - private Long maxSize = length; - private String sourceUrl = "https://example.com"; - private long offset = 1024; - private long count = 1024; - - /** - * Code snippet for {@link AppendBlobClient#create()} - */ - public void create() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.create - System.out.printf("Created AppendBlob at %s%n", client.create().getLastModified()); - // END: com.azure.storage.blob.specialized.AppendBlobClient.create - } - - /** - * Code snippet for {@link AppendBlobClient#create(boolean)} - */ - public void createWithOverwrite() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.create#boolean - boolean overwrite = false; // Default value - System.out.printf("Created AppendBlob at %s%n", client.create(overwrite).getLastModified()); - // END: com.azure.storage.blob.specialized.AppendBlobClient.create#boolean - } - - /** - * Code snippet for {@link AppendBlobClient#createWithResponse(BlobHttpHeaders, Map, BlobRequestConditions, - * Duration, Context)} - */ - public void createWithResponse() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.createWithResponse#BlobHttpHeaders-Map-BlobRequestConditions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentType("binary") - .setContentLanguage("en-US"); - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - System.out.printf("Created AppendBlob at %s%n", - client.createWithResponse(headers, metadata, requestConditions, timeout, context).getValue() - .getLastModified()); - // END: com.azure.storage.blob.specialized.AppendBlobClient.createWithResponse#BlobHttpHeaders-Map-BlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link AppendBlobClient#createWithResponse(AppendBlobCreateOptions, Duration, Context)} - */ - public void createWithResponse2() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.createWithResponse#AppendBlobCreateOptions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentType("binary") - .setContentLanguage("en-US"); - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tags", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - System.out.printf("Created AppendBlob at %s%n", - client.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata) - .setTags(tags).setRequestConditions(requestConditions), timeout, context).getValue() - .getLastModified()); - // END: com.azure.storage.blob.specialized.AppendBlobClient.createWithResponse#AppendBlobCreateOptions-Duration-Context - } - - /** - * Code snippet for {@link AppendBlobClient#appendBlock(InputStream, long)} - */ - public void appendBlock() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.appendBlock#InputStream-long - System.out.printf("AppendBlob has %d committed blocks%n", - client.appendBlock(data, length).getBlobCommittedBlockCount()); - // END: com.azure.storage.blob.specialized.AppendBlobClient.appendBlock#InputStream-long - } - - /** - * Code snippet for {@link AppendBlobClient#appendBlockWithResponse(InputStream, long, byte[], - * AppendBlobRequestConditions, Duration, Context)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void appendBlock2() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.appendBlockWithResponse#InputStream-long-byte-AppendBlobRequestConditions-Duration-Context - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions() - .setAppendPosition(POSITION) - .setMaxSize(maxSize); - Context context = new Context("key", "value"); - - System.out.printf("AppendBlob has %d committed blocks%n", - client.appendBlockWithResponse(data, length, md5, requestConditions, timeout, context) - .getValue().getBlobCommittedBlockCount()); - // END: com.azure.storage.blob.specialized.AppendBlobClient.appendBlockWithResponse#InputStream-long-byte-AppendBlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link AppendBlobClient#appendBlockFromUrl(String, BlobRange)} - */ - public void appendBlockFromUrl() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrl#String-BlobRange - System.out.printf("AppendBlob has %d committed blocks%n", - client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).getBlobCommittedBlockCount()); - // END: com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrl#String-BlobRange - } - - /** - * Code snippet for {@link AppendBlobClient#appendBlockFromUrlWithResponse(String, BlobRange, byte[], - * AppendBlobRequestConditions, BlobRequestConditions, Duration, Context)} - */ - public void appendBlockFromUrlWithResponse() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrlWithResponse#String-BlobRange-byte-AppendBlobRequestConditions-BlobRequestConditions-Duration-Context - AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() - .setAppendPosition(POSITION) - .setMaxSize(maxSize); - - BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - Context context = new Context("key", "value"); - - System.out.printf("AppendBlob has %d committed blocks%n", - client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null, - appendBlobRequestConditions, modifiedRequestConditions, timeout, - context).getValue().getBlobCommittedBlockCount()); - // END: com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrlWithResponse#String-BlobRange-byte-AppendBlobRequestConditions-BlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link AppendBlobClient#appendBlockFromUrlWithResponse(String, BlobRange, byte[], - * AppendBlobRequestConditions, BlobRequestConditions, Duration, Context)} - */ - public void appendBlockFromUrlOptionsBagWithResponse() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrlWithResponse#AppendBlobAppendBlockFromUrlOptions-Duration-Context - AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() - .setAppendPosition(POSITION) - .setMaxSize(maxSize); - - BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - Context context = new Context("key", "value"); - - System.out.printf("AppendBlob has %d committed blocks%n", - client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl) - .setSourceRange(new BlobRange(offset, count)) - .setDestinationRequestConditions(appendBlobRequestConditions) - .setSourceRequestConditions(modifiedRequestConditions), timeout, - context).getValue().getBlobCommittedBlockCount()); - // END: com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrlWithResponse#AppendBlobAppendBlockFromUrlOptions-Duration-Context - } - - /** - * Code snippet for {@link AppendBlobClient#seal()} - */ - public void seal() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.seal - client.seal(); - System.out.println("Sealed AppendBlob"); - // END: com.azure.storage.blob.specialized.AppendBlobClient.seal - } - - /** - * Code snippet for {@link AppendBlobClient#sealWithResponse(AppendBlobSealOptions, Duration, Context)} - */ - public void seal2() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.sealWithResponse#AppendBlobSealOptions-Duration-Context - AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions), timeout, context); - System.out.println("Sealed AppendBlob"); - // END: com.azure.storage.blob.specialized.AppendBlobClient.sealWithResponse#AppendBlobSealOptions-Duration-Context - } - - /** - * Code snippet for {@link AppendBlobClient#createIfNotExists()} and - * {@link AppendBlobClient#createIfNotExistsWithResponse(AppendBlobCreateOptions, Duration, Context)} - */ - public void createIfNotExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.createIfNotExists - client.createIfNotExists(); - System.out.println("Created AppendBlob"); - // END: com.azure.storage.blob.specialized.AppendBlobClient.createIfNotExists - - // BEGIN: com.azure.storage.blob.specialized.AppendBlobClient.createIfNotExistsWithResponse#AppendBlobCreateOptions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentType("binary") - .setContentLanguage("en-US"); - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tags", "value"); - Context context = new Context("key", "value"); - - Response response = client.createIfNotExistsWithResponse(new AppendBlobCreateOptions() - .setHeaders(headers).setMetadata(metadata).setTags(tags), timeout, context); - if (response.getStatusCode() == 409) { - System.out.println("Already existed."); - } else { - System.out.printf("Create completed with status %d%n", response.getStatusCode()); - } - // END: com.azure.storage.blob.specialized.AppendBlobClient.createIfNotExistsWithResponse#AppendBlobCreateOptions-Duration-Context - - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java deleted file mode 100644 index 80e0fe297a49..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java +++ /dev/null @@ -1,824 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.RequestConditions; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.polling.PollerFlux; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobClientBuilder; -import com.azure.storage.blob.BlobServiceClientBuilder; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.options.BlobBeginCopyOptions; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobQueryDelimitedSerialization; -import com.azure.storage.blob.models.BlobQueryError; -import com.azure.storage.blob.models.BlobQueryJsonSerialization; -import com.azure.storage.blob.options.BlobDownloadToFileOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.BlobQueryOptions; -import com.azure.storage.blob.models.BlobQueryProgress; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobSetAccessTierOptions; -import com.azure.storage.blob.options.BlobSetTagsOptions; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import reactor.core.publisher.Mono; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.file.OpenOption; -import java.nio.file.StandardOpenOption; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -/** - * Code snippets for {@link BlobAsyncClientBase} - */ -@SuppressWarnings("unused") -public class BlobAsyncClientBaseJavaDocCodeSnippets { - private BlobAsyncClient client = new BlobClientBuilder().endpoint("https://storageaccount.blob.core.windows.net") - .containerName("containerName").blobName("blobName").sasToken("sasToken").buildAsyncClient(); - private String leaseId = "leaseId"; - private String tags = "tags"; - private String copyId = "copyId"; - private String url = "https://sample.com"; - private String file = "file"; - private String accountName = "accountName"; - private UserDelegationKey userDelegationKey = new BlobServiceClientBuilder().buildClient().getUserDelegationKey(null, null); - - /** - * Code snippet for {@link BlobAsyncClientBase#exists()} - */ - public void existsCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.exists - client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response)); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.exists - } - - /** - * Code snippets for {@link BlobAsyncClientBase#beginCopy(String, Duration)} - */ - public void beginCopyCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#String-Duration - client.beginCopy(url, Duration.ofSeconds(3)) - .subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#String-Duration - } - - /** - * Code snippets for {@link BlobAsyncClientBase#abortCopyFromUrl(String)} - */ - public void abortCopyFromUrlCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.abortCopyFromUrl#String - client.abortCopyFromUrl(copyId).doOnSuccess(response -> System.out.println("Aborted copy from URL")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.abortCopyFromUrl#String - } - - /** - * Code snippets for {@link BlobAsyncClientBase#copyFromUrl(String)} - */ - public void copyFromUrlCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrl#String - client.copyFromUrl(url).subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrl#String - } - - /** - * Code snippets for {@link BlobAsyncClientBase#download()} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.download - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - client.download().subscribe(piece -> { - try { - downloadData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.download - } - - /** - * Code snippets for {@link BlobAsyncClientBase#downloadStream()} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadStreamCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadStream - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - client.downloadStream().subscribe(piece -> { - try { - downloadData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadStream - } - - /** - * Code snippet for {@link BlobAsyncClientBase#downloadWithResponse(BlobRange, DownloadRetryOptions, - * BlobRequestConditions, boolean)} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.download#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - BlobRange range = new BlobRange(1024, 2048L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadWithResponse(range, options, null, false).subscribe(response -> { - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - response.getValue().subscribe(piece -> { - try { - downloadData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.download#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - } - - /** - * Code snippets for {@link BlobAsyncClientBase#downloadToFile(String)}, {@link BlobAsyncClientBase#downloadToFileWithResponse(String, - * BlobRange, ParallelTransferOptions, DownloadRetryOptions, BlobRequestConditions, boolean)} and - * {@link BlobAsyncClientBase#downloadToFileWithResponse(BlobDownloadToFileOptions)} - */ - public void downloadToFileCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFile#String - client.downloadToFile(file).subscribe(response -> System.out.println("Completed download to file")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFile#String - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFile#String-boolean - boolean overwrite = false; // Default value - client.downloadToFile(file, overwrite).subscribe(response -> System.out.println("Completed download to file")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFile#String-boolean - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean - BlobRange range = new BlobRange(1024, 2048L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadToFileWithResponse(file, range, null, options, null, false) - .subscribe(response -> System.out.println("Completed download to file")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Set - BlobRange blobRange = new BlobRange(1024, 2048L); - DownloadRetryOptions downloadRetryOptions = new DownloadRetryOptions().setMaxRetryRequests(5); - Set openOptions = new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, - StandardOpenOption.WRITE, StandardOpenOption.READ)); // Default options - - client.downloadToFileWithResponse(file, blobRange, null, downloadRetryOptions, null, false, openOptions) - .subscribe(response -> System.out.println("Completed download to file")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Set - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#BlobDownloadToFileOptions - client.downloadToFileWithResponse(new BlobDownloadToFileOptions(file) - .setRange(new BlobRange(1024, 2018L)) - .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(5)) - .setOpenOptions(new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE, - StandardOpenOption.READ)))) - .subscribe(response -> System.out.println("Completed download to file")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#BlobDownloadToFileOptions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#delete()} - */ - public void deleteCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.delete - client.delete().doOnSuccess(response -> System.out.println("Completed delete")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.delete - } - - /** - * Code snippets for {@link BlobAsyncClientBase#getProperties()} - */ - public void getPropertiesCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.getProperties - client.getProperties().subscribe(response -> - System.out.printf("Type: %s, Size: %d%n", response.getBlobType(), response.getBlobSize())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getProperties - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setHttpHeaders(BlobHttpHeaders)} - */ - public void setHTTPHeadersCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setHttpHeaders#BlobHttpHeaders - client.setHttpHeaders(new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setHttpHeaders#BlobHttpHeaders - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setMetadata(Map)} - */ - public void setMetadataCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setMetadata#Map - client.setMetadata(Collections.singletonMap("metadata", "value")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setMetadata#Map - } - - /** - * Code snippets for {@link BlobAsyncClientBase#getTags()} - */ - public void getTagsCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.getTags - client.getTags().subscribe(response -> - System.out.printf("Num tags: %d%n", response.size())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getTags - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setTags(Map)} - */ - public void setTagsCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setTags#Map - client.setTags(Collections.singletonMap("tag", "value")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setTags#Map - } - - /** - * Code snippets for {@link BlobAsyncClientBase#createSnapshot()} - */ - public void createSnapshotCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.createSnapshot - client.createSnapshot() - .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n", - response.getSnapshotId())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.createSnapshot - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setAccessTier(AccessTier)} - */ - public void setTierCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setAccessTier#AccessTier - client.setAccessTier(AccessTier.HOT); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setAccessTier#AccessTier - } - - /** - * Code snippet for {@link BlobAsyncClientBase#undelete()} - */ - public void undeleteCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.undelete - client.undelete().doOnSuccess(response -> System.out.println("Completed undelete")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.undelete - } - - /** - * Code snippet for {@link BlobAsyncClientBase#getAccountInfo()} - */ - public void getAccountInfoCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.getAccountInfo - client.getAccountInfo().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n", - response.getAccountKind(), response.getSkuName())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getAccountInfo - } - - /** - * Code snippet for {@link BlobAsyncClientBase#existsWithResponse()} - */ - public void existsWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.existsWithResponse - client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.existsWithResponse - } - - /** - * Code snippets for {@link BlobAsyncClientBase#beginCopy(String, Map, AccessTier, - * RehydratePriority, RequestConditions, BlobRequestConditions, Duration)} - */ - public void beginCopyCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#String-Map-AccessTier-RehydratePriority-RequestConditions-BlobRequestConditions-Duration - Map metadata = Collections.singletonMap("metadata", "value"); - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.beginCopy(url, metadata, AccessTier.HOT, RehydratePriority.STANDARD, - modifiedRequestConditions, blobRequestConditions, Duration.ofSeconds(2)) - .subscribe(response -> { - BlobCopyInfo info = response.getValue(); - System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus()); - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#String-Map-AccessTier-RehydratePriority-RequestConditions-BlobRequestConditions-Duration - } - - /** - * Code snippets for {@link BlobAsyncClientBase#beginCopy(BlobBeginCopyOptions)} - */ - public void beginCopyCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#BlobBeginCopyOptions - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.beginCopy(new BlobBeginCopyOptions(url).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT) - .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions) - .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2))) - .subscribe(response -> { - BlobCopyInfo info = response.getValue(); - System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus()); - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#BlobBeginCopyOptions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#beginCopy(BlobBeginCopyOptions)} - */ - public void beginCopyFromUrlCancelCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopyFromUrlCancel#BlobBeginCopyOptions - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - PollerFlux poller = client.beginCopy(new BlobBeginCopyOptions(url) - .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT) - .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions) - .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2))); - - poller.take(Duration.ofMinutes(30)) - .last() - .flatMap(asyncPollResponse -> { - if (!asyncPollResponse.getStatus().isComplete()) { - return asyncPollResponse - .cancelOperation() - .then(Mono.error(new RuntimeException("Blob copy taking long time, " - + "operation is cancelled!"))); - } - return Mono.just(asyncPollResponse); - }).block(); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopyFromUrlCancel#BlobBeginCopyOptions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#abortCopyFromUrlWithResponse(String, String)} - */ - public void abortCopyFromUrlWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.abortCopyFromUrlWithResponse#String-String - client.abortCopyFromUrlWithResponse(copyId, leaseId) - .subscribe(response -> System.out.printf("Aborted copy completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.abortCopyFromUrlWithResponse#String-String - } - - /** - * Code snippets for {@link BlobAsyncClientBase#copyFromUrlWithResponse(String, Map, AccessTier, RequestConditions, - * BlobRequestConditions)} - */ - public void copyFromUrlWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrlWithResponse#String-Map-AccessTier-RequestConditions-BlobRequestConditions - Map metadata = Collections.singletonMap("metadata", "value"); - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions, blobRequestConditions) - .subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrlWithResponse#String-Map-AccessTier-RequestConditions-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#copyFromUrlWithResponse(BlobCopyFromUrlOptions)} - */ - public void copyFromUrlWithResponseCodeSnippets2() { - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrlWithResponse#BlobCopyFromUrlOptions - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(url).setMetadata(metadata).setTags(tags) - .setTier(AccessTier.HOT).setSourceRequestConditions(modifiedRequestConditions) - .setDestinationRequestConditions(blobRequestConditions)) - .subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrlWithResponse#BlobCopyFromUrlOptions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#downloadWithResponse(BlobRange, DownloadRetryOptions, - * BlobRequestConditions, boolean)} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - BlobRange range = new BlobRange(1024, (long) 2048); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadWithResponse(range, options, null, false).subscribe(response -> { - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - response.getValue().subscribe(piece -> { - try { - downloadData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - } - - /** - * Code snippets for {@link BlobAsyncClientBase#downloadStreamWithResponse(BlobRange, DownloadRetryOptions, - * BlobRequestConditions, boolean)} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadStreamWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadStreamWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - BlobRange range = new BlobRange(1024, (long) 2048); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadStreamWithResponse(range, options, null, false).subscribe(response -> { - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - response.getValue().subscribe(piece -> { - try { - downloadData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadStreamWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean - } - - /** - * Code snippets for {@link BlobAsyncClientBase#downloadContentWithResponse(DownloadRetryOptions, - * BlobRequestConditions)} - * - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadContentWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadContentWithResponse#DownloadRetryOptions-BlobRequestConditions - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadContentWithResponse(options, null).subscribe(response -> { - BinaryData content = response.getValue(); - System.out.println(content.toString()); - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadContentWithResponse#DownloadRetryOptions-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#deleteWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions)} - */ - public void deleteWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions - client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null) - .subscribe(response -> System.out.printf("Delete completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#getPropertiesWithResponse(BlobRequestConditions)} - */ - public void getPropertiesWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.getPropertiesWithResponse#BlobRequestConditions - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.getPropertiesWithResponse(requestConditions).subscribe( - response -> System.out.printf("Type: %s, Size: %d%n", response.getValue().getBlobType(), - response.getValue().getBlobSize())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getPropertiesWithResponse#BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setHttpHeadersWithResponse(BlobHttpHeaders, BlobRequestConditions)} - */ - public void setHTTPHeadersWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setHttpHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.setHttpHeadersWithResponse(new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"), requestConditions).subscribe( - response -> - System.out.printf("Set HTTP headers completed with status %d%n", - response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setHttpHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setMetadataWithResponse(Map, BlobRequestConditions)} - */ - public void setMetadataWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setMetadataWithResponse#Map-BlobRequestConditions - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions) - .subscribe(response -> System.out.printf("Set metadata completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setMetadataWithResponse#Map-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#getTagsWithResponse(BlobGetTagsOptions)} - */ - public void getTagsWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.getTagsWithResponse#BlobGetTagsOptions - client.getTagsWithResponse(new BlobGetTagsOptions()).subscribe(response -> - System.out.printf("Status code: %d. Num tags: %d%n", response.getStatusCode(), response.getValue().size())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getTagsWithResponse#BlobGetTagsOptions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setTagsWithResponse(BlobSetTagsOptions)} - */ - public void setTagsWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setTagsWithResponse#BlobSetTagsOptions - client.setTagsWithResponse(new BlobSetTagsOptions(Collections.singletonMap("tag", "value"))) - .subscribe(response -> System.out.printf("Set tags completed with stats %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setTagsWithResponse#BlobSetTagsOptions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#createSnapshotWithResponse(Map, BlobRequestConditions)} - */ - public void createSnapshotWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.createSnapshotWithResponse#Map-BlobRequestConditions - Map snapshotMetadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.createSnapshotWithResponse(snapshotMetadata, requestConditions) - .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.createSnapshotWithResponse#Map-BlobRequestConditions - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setAccessTierWithResponse(AccessTier, RehydratePriority, String)} - */ - public void setTierWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setAccessTierWithResponse#AccessTier-RehydratePriority-String - client.setAccessTierWithResponse(AccessTier.HOT, RehydratePriority.STANDARD, leaseId) - .subscribe(response -> System.out.printf("Set tier completed with status code %d%n", - response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setAccessTierWithResponse#AccessTier-RehydratePriority-String - } - - /** - * Code snippets for {@link BlobAsyncClientBase#setAccessTierWithResponse(BlobSetAccessTierOptions)} - */ - public void setTierWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setAccessTierWithResponse#BlobSetAccessTierOptions - client.setAccessTierWithResponse(new BlobSetAccessTierOptions(AccessTier.HOT) - .setPriority(RehydratePriority.STANDARD) - .setLeaseId(leaseId) - .setTagsConditions(tags)) - .subscribe(response -> System.out.printf("Set tier completed with status code %d%n", - response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setAccessTierWithResponse#BlobSetAccessTierOptions - } - - /** - * Code snippet for {@link BlobAsyncClientBase#undeleteWithResponse()} - */ - public void undeleteWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.undeleteWithResponse - client.undeleteWithResponse() - .subscribe(response -> System.out.printf("Undelete completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.undeleteWithResponse - } - - /** - * Code snippet for {@link BlobAsyncClientBase#getAccountInfoWithResponse()} - */ - public void getAccountInfoWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.getAccountInfoWithResponse - client.getAccountInfoWithResponse().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n", - response.getValue().getAccountKind(), response.getValue().getSkuName())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getAccountInfoWithResponse - } - - /** - * Code snippet for {@link BlobAsyncClientBase#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} - * and {@link BlobAsyncClientBase#generateSas(BlobServiceSasSignatureValues)} - */ - public void generateSas() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateSas#BlobServiceSasSignatureValues - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateSas#BlobServiceSasSignatureValues - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - } - - /** - * Code snippet for {@link BlobAsyncClientBase#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey, String, Context)} - * and {@link BlobAsyncClientBase#generateSas(BlobServiceSasSignatureValues, Context)} - */ - public void generateSasWithContext() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateSas#BlobServiceSasSignatureValues-Context - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - // Client must be authenticated via StorageSharedKeyCredential - client.generateSas(values, new Context("key", "value")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateSas#BlobServiceSasSignatureValues-Context - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context - } - - /** - * Code snippet for {@link BlobAsyncClientBase#query(String)} - * @throws UncheckedIOException for IOExceptions. - */ - public void query() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.query#String - ByteArrayOutputStream queryData = new ByteArrayOutputStream(); - String expression = "SELECT * from BlobStorage"; - client.query(expression).subscribe(piece -> { - try { - queryData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.query#String - } - - /** - * Code snippet for {@link BlobAsyncClientBase#queryWithResponse(BlobQueryOptions)} - * @throws UncheckedIOException for IOExceptions. - */ - public void queryWithResponse() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.queryWithResponse#BlobQueryOptions - String expression = "SELECT * from BlobStorage"; - BlobQueryJsonSerialization input = new BlobQueryJsonSerialization() - .setRecordSeparator('\n'); - BlobQueryDelimitedSerialization output = new BlobQueryDelimitedSerialization() - .setEscapeChar('\0') - .setColumnSeparator(',') - .setRecordSeparator('\n') - .setFieldQuote('\'') - .setHeadersPresent(true); - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - Consumer errorConsumer = System.out::println; - Consumer progressConsumer = progress -> System.out.println("total blob bytes read: " - + progress.getBytesScanned()); - BlobQueryOptions queryOptions = new BlobQueryOptions(expression) - .setInputSerialization(input) - .setOutputSerialization(output) - .setRequestConditions(requestConditions) - .setErrorConsumer(errorConsumer) - .setProgressConsumer(progressConsumer); - - client.queryWithResponse(queryOptions) - .subscribe(response -> { - ByteArrayOutputStream queryData = new ByteArrayOutputStream(); - response.getValue().subscribe(piece -> { - try { - queryData.write(piece.array()); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }); - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.queryWithResponse#BlobQueryOptions - } - - /** - * Code snippet for {@link BlobAsyncClientBase#setImmutabilityPolicy(BlobImmutabilityPolicy)} and - * {@link BlobAsyncClientBase#setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy, BlobRequestConditions)} - */ - public void setImmutabilityPolicy() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy - BlobImmutabilityPolicy policy = new BlobImmutabilityPolicy() - .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED) - .setExpiryTime(OffsetDateTime.now().plusDays(1)); - client.setImmutabilityPolicy(policy).subscribe(response -> System.out.println("Completed. Set immutability " - + "policy to " + response.getPolicyMode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions - BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy() - .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED) - .setExpiryTime(OffsetDateTime.now().plusDays(1)); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)); - client.setImmutabilityPolicyWithResponse(immutabilityPolicy, requestConditions).subscribe(response -> - System.out.println("Completed. Set immutability policy to " + response.getValue().getPolicyMode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions - } - - /** - * Code snippet for {@link BlobAsyncClientBase#deleteImmutabilityPolicy()} and - * {@link BlobAsyncClientBase#deleteImmutabilityPolicyWithResponse()} - */ - public void deleteImmutabilityPolicy() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicy - client.deleteImmutabilityPolicy().subscribe(response -> System.out.println("Completed immutability policy" - + " deletion.")); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicy - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicyWithResponse - client.deleteImmutabilityPolicyWithResponse().subscribe(response -> - System.out.println("Delete immutability policy completed with status: " + response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicyWithResponse - } - - /** - * Code snippet for {@link BlobAsyncClientBase#setLegalHold(boolean)} and - * {@link BlobAsyncClientBase#setLegalHoldWithResponse(boolean)} - */ - public void setLegalHold() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHold#boolean - client.setLegalHold(true).subscribe(response -> System.out.println("Legal hold status: " - + response.hasLegalHold())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHold#boolean - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHoldWithResponse#boolean - client.setLegalHoldWithResponse(true).subscribe(response -> - System.out.println("Legal hold status: " + response.getValue().hasLegalHold())); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHoldWithResponse#boolean - } - - /** - * Code snippets for {@link BlobAsyncClientBase#deleteIfExists()} and - * {@link BlobAsyncClientBase#deleteIfExistsWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions)} - */ - public void deleteIfExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteIfExists - client.deleteIfExists().subscribe(deleted -> { - if (deleted) { - System.out.println("Successfully deleted."); - } else { - System.out.println("Does not exist."); - } - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteIfExists - - // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteIfExistsWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions - client.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, null).subscribe(response -> { - if (response.getStatusCode() == 404) { - System.out.println("Does not exist."); - } else { - System.out.println("successfully deleted."); - } - }); - // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteIfExistsWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java deleted file mode 100644 index 216e45dde835..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java +++ /dev/null @@ -1,807 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.SyncPoller; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobClientBuilder; -import com.azure.storage.blob.BlobServiceClientBuilder; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobDownloadContentResponse; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobQueryDelimitedSerialization; -import com.azure.storage.blob.models.BlobQueryError; -import com.azure.storage.blob.models.BlobQueryJsonSerialization; -import com.azure.storage.blob.models.BlobQueryProgress; -import com.azure.storage.blob.models.BlobQuerySerialization; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobBeginCopyOptions; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.options.BlobDownloadToFileOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.BlobQueryOptions; -import com.azure.storage.blob.options.BlobSetAccessTierOptions; -import com.azure.storage.blob.options.BlobSetTagsOptions; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.implementation.Constants; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UncheckedIOException; -import java.nio.file.OpenOption; -import java.nio.file.StandardOpenOption; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -/** - * Code snippets for {@link BlobClientBase} - */ -@SuppressWarnings("unused") -public class BlobClientBaseJavaDocCodeSnippets { - private BlobClient client = new BlobClientBuilder().endpoint("https://storageaccount.blob.core.windows.net") - .containerName("containerName").blobName("blobName").sasToken("sasToken").buildClient(); - private String leaseId = "leaseId"; - private String tags = "tags"; - private String copyId = "copyId"; - private String url = "https://sample.com"; - private String file = "file"; - private Duration timeout = Duration.ofSeconds(30); - private String key1 = "key1"; - private String key2 = "key2"; - private String value1 = "val1"; - private String value2 = "val2"; - private String accountName = "accountName"; - private UserDelegationKey userDelegationKey = new BlobServiceClientBuilder().buildClient().getUserDelegationKey(null, null); - - /** - * Code snippets for {@link BlobClientBase#exists()} - */ - public void existsCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.exists - System.out.printf("Exists? %b%n", client.exists()); - // END: com.azure.storage.blob.specialized.BlobClientBase.exists - } - - /** - * Code snippets for {@link BlobClientBase#beginCopy(String, Duration)} - */ - public void beginCopy() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.beginCopy#String-Duration - final SyncPoller poller = client.beginCopy(url, Duration.ofSeconds(2)); - PollResponse pollResponse = poller.poll(); - System.out.printf("Copy identifier: %s%n", pollResponse.getValue().getCopyId()); - // END: com.azure.storage.blob.specialized.BlobClientBase.beginCopy#String-Duration - } - - /** - * Code snippets for {@link BlobClientBase#abortCopyFromUrl(String)} - */ - public void abortCopyFromUrl() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.abortCopyFromUrl#String - client.abortCopyFromUrl(copyId); - System.out.println("Aborted copy completed."); - // END: com.azure.storage.blob.specialized.BlobClientBase.abortCopyFromUrl#String - } - - /** - * Code snippets for {@link BlobClientBase#copyFromUrl(String)} - */ - public void copyFromUrl() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.copyFromUrl#String - System.out.printf("Copy identifier: %s%n", client.copyFromUrl(url)); - // END: com.azure.storage.blob.specialized.BlobClientBase.copyFromUrl#String - } - - /** - * Code snippets for {@link BlobClientBase#download(OutputStream)} - */ - public void download() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.download#OutputStream - client.download(new ByteArrayOutputStream()); - System.out.println("Download completed."); - // END: com.azure.storage.blob.specialized.BlobClientBase.download#OutputStream - } - - /** - * Code snippets for {@link BlobClientBase#downloadStream(OutputStream)} - */ - public void downloadStream() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadStream#OutputStream - client.downloadStream(new ByteArrayOutputStream()); - System.out.println("Download completed."); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadStream#OutputStream - } - - /** - * Code snippets for {@link BlobClientBase#downloadToFile(String)}, - * {@link BlobClientBase#downloadToFileWithResponse(String, BlobRange, ParallelTransferOptions, DownloadRetryOptions, BlobRequestConditions, - * boolean, Duration, Context)} and {@link BlobClientBase#downloadToFileWithResponse(BlobDownloadToFileOptions, Duration, Context)} - */ - public void downloadToFile() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadToFile#String - client.downloadToFile(file); - System.out.println("Completed download to file"); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadToFile#String - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadToFile#String-boolean - boolean overwrite = false; // Default value - client.downloadToFile(file, overwrite); - System.out.println("Completed download to file"); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadToFile#String-boolean - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - BlobRange range = new BlobRange(1024, 2048L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - client.downloadToFileWithResponse(file, range, new ParallelTransferOptions().setBlockSizeLong(4L * Constants.MB), - options, null, false, timeout, new Context(key2, value2)); - System.out.println("Completed download to file"); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Set-Duration-Context - BlobRange blobRange = new BlobRange(1024, 2048L); - DownloadRetryOptions downloadRetryOptions = new DownloadRetryOptions().setMaxRetryRequests(5); - Set openOptions = new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, - StandardOpenOption.WRITE, StandardOpenOption.READ)); // Default options - - client.downloadToFileWithResponse(file, blobRange, new ParallelTransferOptions().setBlockSizeLong(4L * Constants.MB), - downloadRetryOptions, null, false, openOptions, timeout, new Context(key2, value2)); - System.out.println("Completed download to file"); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Set-Duration-Context - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadToFileWithResponse#BlobDownloadToFileOptions-Duration-Context - client.downloadToFileWithResponse(new BlobDownloadToFileOptions(file) - .setRange(new BlobRange(1024, 2018L)) - .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(5)) - .setOpenOptions(new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE, - StandardOpenOption.READ))), timeout, new Context(key2, value2)); - System.out.println("Completed download to file"); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadToFileWithResponse#BlobDownloadToFileOptions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#delete()} - */ - public void setDelete() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.delete - client.delete(); - System.out.println("Delete completed."); - // END: com.azure.storage.blob.specialized.BlobClientBase.delete - } - - /** - * Code snippets for {@link BlobClientBase#getProperties()} - */ - public void getProperties() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.getProperties - BlobProperties properties = client.getProperties(); - System.out.printf("Type: %s, Size: %d%n", properties.getBlobType(), properties.getBlobSize()); - // END: com.azure.storage.blob.specialized.BlobClientBase.getProperties - } - - /** - * Code snippets for {@link BlobClientBase#setHttpHeaders(BlobHttpHeaders)} - */ - public void setHTTPHeaders() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setHttpHeaders#BlobHttpHeaders - client.setHttpHeaders(new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary")); - System.out.println("Set HTTP headers completed"); - // END: com.azure.storage.blob.specialized.BlobClientBase.setHttpHeaders#BlobHttpHeaders - } - - /** - * Code snippets for {@link BlobClientBase#setMetadata(Map)} - */ - public void setMetadata() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setMetadata#Map - client.setMetadata(Collections.singletonMap("metadata", "value")); - System.out.println("Set metadata completed"); - // END: com.azure.storage.blob.specialized.BlobClientBase.setMetadata#Map - } - - /** - * Code snippets for {@link BlobClientBase#getTags()} - */ - public void getTags() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.getTags - Map tags = client.getTags(); - System.out.printf("Number of tags: %d%n", tags.size()); - // END: com.azure.storage.blob.specialized.BlobClientBase.getTags - } - - /** - * Code snippets for {@link BlobClientBase#setTags(Map)} - */ - public void setTags() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setTags#Map - client.setTags(Collections.singletonMap("tag", "value")); - System.out.println("Set tag completed"); - // END: com.azure.storage.blob.specialized.BlobClientBase.setTags#Map - } - - /** - * Code snippets for {@link BlobClientBase#createSnapshot()} - */ - public void createSnapshot() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.createSnapshot - System.out.printf("Identifier for the snapshot is %s%n", client.createSnapshot().getSnapshotId()); - // END: com.azure.storage.blob.specialized.BlobClientBase.createSnapshot - } - - /** - * Code snippets for {@link BlobClientBase#setAccessTier(AccessTier)} - */ - public void setTier() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setAccessTier#AccessTier - client.setAccessTier(AccessTier.HOT); - System.out.println("Set tier completed."); - // END: com.azure.storage.blob.specialized.BlobClientBase.setAccessTier#AccessTier - } - - /** - * Code snippets for {@link BlobClientBase#undelete()} - */ - public void unsetDelete() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.undelete - client.undelete(); - System.out.println("Undelete completed"); - // END: com.azure.storage.blob.specialized.BlobClientBase.undelete - } - - /** - * Code snippet for {@link BlobClientBase#getAccountInfo()} - */ - public void getAccountInfo() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.getAccountInfo - StorageAccountInfo accountInfo = client.getAccountInfo(); - System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); - // END: com.azure.storage.blob.specialized.BlobClientBase.getAccountInfo - } - - /** - * Code snippet for {@link BlobClientBase#existsWithResponse(Duration, Context)} - */ - public void existsWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.existsWithResponse#Duration-Context - System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, new Context(key2, value2)).getValue()); - // END: com.azure.storage.blob.specialized.BlobClientBase.existsWithResponse#Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#beginCopy(String, Map, AccessTier, RehydratePriority, - * RequestConditions, BlobRequestConditions, Duration)} - */ - public void beginCopyFromUrl() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.beginCopy#String-Map-AccessTier-RehydratePriority-RequestConditions-BlobRequestConditions-Duration - Map metadata = Collections.singletonMap("metadata", "value"); - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - SyncPoller poller = client.beginCopy(url, metadata, AccessTier.HOT, - RehydratePriority.STANDARD, modifiedRequestConditions, blobRequestConditions, Duration.ofSeconds(2)); - - PollResponse response = poller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId()); - // END: com.azure.storage.blob.specialized.BlobClientBase.beginCopy#String-Map-AccessTier-RehydratePriority-RequestConditions-BlobRequestConditions-Duration - } - - /** - * Code snippets for {@link BlobClientBase#beginCopy(BlobBeginCopyOptions)} - */ - public void beginCopyFromUrl2() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.beginCopy#BlobBeginCopyOptions - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - SyncPoller poller = client.beginCopy(new BlobBeginCopyOptions(url).setMetadata(metadata) - .setTags(tags).setTier(AccessTier.HOT).setRehydratePriority(RehydratePriority.STANDARD) - .setSourceRequestConditions(modifiedRequestConditions) - .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2))); - - PollResponse response = poller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId()); - // END: com.azure.storage.blob.specialized.BlobClientBase.beginCopy#BlobBeginCopyOptions - } - - /** - * Code snippets for {@link BlobClientBase#abortCopyFromUrlWithResponse(String, String, Duration, Context)} - */ - public void abortCopyFromUrlWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.abortCopyFromUrlWithResponse#String-String-Duration-Context - System.out.printf("Aborted copy completed with status %d%n", - client.abortCopyFromUrlWithResponse(copyId, leaseId, timeout, - new Context(key2, value2)).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.abortCopyFromUrlWithResponse#String-String-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#copyFromUrlWithResponse(String, Map, AccessTier, RequestConditions, - * BlobRequestConditions, Duration, Context)} - */ - public void copyFromUrlWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.copyFromUrlWithResponse#String-Map-AccessTier-RequestConditions-BlobRequestConditions-Duration-Context - Map metadata = Collections.singletonMap("metadata", "value"); - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - System.out.printf("Copy identifier: %s%n", - client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions, - blobRequestConditions, timeout, - new Context(key1, value1)).getValue()); - // END: com.azure.storage.blob.specialized.BlobClientBase.copyFromUrlWithResponse#String-Map-AccessTier-RequestConditions-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#copyFromUrlWithResponse(BlobCopyFromUrlOptions, Duration, Context)} - */ - public void copyFromUrlWithResponse2CodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.copyFromUrlWithResponse#BlobCopyFromUrlOptions-Duration-Context - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - System.out.printf("Copy identifier: %s%n", - client.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(url).setMetadata(metadata).setTags(tags) - .setTier(AccessTier.HOT).setSourceRequestConditions(modifiedRequestConditions) - .setDestinationRequestConditions(blobRequestConditions), timeout, - new Context(key1, value1)).getValue()); - // END: com.azure.storage.blob.specialized.BlobClientBase.copyFromUrlWithResponse#BlobCopyFromUrlOptions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#downloadWithResponse(OutputStream, BlobRange, DownloadRetryOptions, - * BlobRequestConditions, boolean, Duration, Context)} - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadWithResponse#OutputStream-BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - BlobRange range = new BlobRange(1024, 2048L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - System.out.printf("Download completed with status %d%n", - client.downloadWithResponse(new ByteArrayOutputStream(), range, options, null, false, - timeout, new Context(key2, value2)).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadWithResponse#OutputStream-BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - - } - - /** - * Code snippets for {@link BlobClientBase#downloadStreamWithResponse(OutputStream, BlobRange, DownloadRetryOptions, - * BlobRequestConditions, boolean, Duration, Context)} - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadStreamWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadStreamWithResponse#OutputStream-BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - BlobRange range = new BlobRange(1024, 2048L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - System.out.printf("Download completed with status %d%n", - client.downloadStreamWithResponse(new ByteArrayOutputStream(), range, options, null, false, - timeout, new Context(key2, value2)).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadStreamWithResponse#OutputStream-BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#downloadContentWithResponse(DownloadRetryOptions, BlobRequestConditions, Duration, Context)} - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadContentWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadContentWithResponse#DownloadRetryOptions-BlobRequestConditions-Duration-Context - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - BlobDownloadContentResponse contentResponse = client.downloadContentWithResponse(options, null, - timeout, new Context(key2, value2)); - BinaryData content = contentResponse.getValue(); - System.out.printf("Download completed with status %d and content%s%n", - contentResponse.getStatusCode(), content.toString()); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadContentWithResponse#DownloadRetryOptions-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#downloadContentWithResponse(DownloadRetryOptions, BlobRequestConditions, BlobRange, boolean, Duration, Context)} - * @throws UncheckedIOException If an I/O error occurs - */ - public void downloadContentWithResponse2CodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.downloadContentWithResponse#DownloadRetryOptions-BlobRequestConditions-BlobRange-boolean-Duration-Context - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - BlobRange range = new BlobRange(1024, 2048L); - - BlobDownloadContentResponse contentResponse = client.downloadContentWithResponse(options, null, - range, false, timeout, new Context(key2, value2)); - BinaryData content = contentResponse.getValue(); - System.out.printf("Download completed with status %d and content%s%n", - contentResponse.getStatusCode(), content.toString()); - // END: com.azure.storage.blob.specialized.BlobClientBase.downloadContentWithResponse#DownloadRetryOptions-BlobRequestConditions-BlobRange-boolean-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#deleteWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions, Duration, - * Context)} - */ - public void deleteWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions-Duration-Context - System.out.printf("Delete completed with status %d%n", - client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null, timeout, - new Context(key1, value1)).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#getPropertiesWithResponse(BlobRequestConditions, Duration, Context)} - */ - public void getPropertiesWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.getPropertiesWithResponse#BlobRequestConditions-Duration-Context - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - BlobProperties properties = client.getPropertiesWithResponse(requestConditions, timeout, - new Context(key2, value2)).getValue(); - System.out.printf("Type: %s, Size: %d%n", properties.getBlobType(), properties.getBlobSize()); - // END: com.azure.storage.blob.specialized.BlobClientBase.getPropertiesWithResponse#BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#setHttpHeadersWithResponse(BlobHttpHeaders, BlobRequestConditions, Duration, - * Context)} - */ - public void setHTTPHeadersWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setHttpHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions-Duration-Context - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - System.out.printf("Set HTTP headers completed with status %d%n", - client.setHttpHeadersWithResponse(new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"), requestConditions, timeout, new Context(key1, value1)) - .getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.setHttpHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#setMetadataWithResponse(Map, BlobRequestConditions, Duration, Context)} - */ - public void setMetadataWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setMetadataWithResponse#Map-BlobRequestConditions-Duration-Context - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - System.out.printf("Set metadata completed with status %d%n", - client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions, timeout, - new Context(key1, value1)).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.setMetadataWithResponse#Map-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#getTagsWithResponse(BlobGetTagsOptions, Duration, Context)} - */ - public void getTagsWithResponse() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.getTagsWithResponse#BlobGetTagsOptions-Duration-Context - Map tags = client.getTagsWithResponse(new BlobGetTagsOptions(), timeout, - new Context(key1, value1)).getValue(); - System.out.printf("Number of tags: %d%n", tags.size()); - // END: com.azure.storage.blob.specialized.BlobClientBase.getTagsWithResponse#BlobGetTagsOptions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#setTagsWithResponse(BlobSetTagsOptions, Duration, Context)} - */ - public void setTagsWithResponse() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setTagsWithResponse#BlobSetTagsOptions-Duration-Context - System.out.printf("Set metadata completed with status %d%n", - client.setTagsWithResponse(new BlobSetTagsOptions(Collections.singletonMap("tag", "value")), timeout, - new Context(key1, value1)) - .getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.setTagsWithResponse#BlobSetTagsOptions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#createSnapshotWithResponse(Map, BlobRequestConditions, Duration, - * Context)} - */ - public void createSnapshotWithResponseCodeSnippets() { - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.createSnapshotWithResponse#Map-BlobRequestConditions-Duration-Context - Map snapshotMetadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - System.out.printf("Identifier for the snapshot is %s%n", - client.createSnapshotWithResponse(snapshotMetadata, requestConditions, timeout, - new Context(key1, value1)).getValue()); - // END: com.azure.storage.blob.specialized.BlobClientBase.createSnapshotWithResponse#Map-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#setAccessTierWithResponse(AccessTier, RehydratePriority, String, Duration, Context)} - */ - public void setTierWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setAccessTierWithResponse#AccessTier-RehydratePriority-String-Duration-Context - System.out.printf("Set tier completed with status code %d%n", - client.setAccessTierWithResponse(AccessTier.HOT, RehydratePriority.STANDARD, leaseId, timeout, - new Context(key2, value2)).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.setAccessTierWithResponse#AccessTier-RehydratePriority-String-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#setAccessTierWithResponse(BlobSetAccessTierOptions, Duration, Context)} - */ - public void setTierWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setAccessTierWithResponse#BlobSetAccessTierOptions-Duration-Context - System.out.printf("Set tier completed with status code %d%n", - client.setAccessTierWithResponse(new BlobSetAccessTierOptions(AccessTier.HOT) - .setPriority(RehydratePriority.STANDARD) - .setLeaseId(leaseId) - .setTagsConditions(tags), - timeout, new Context(key2, value2)).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.setAccessTierWithResponse#BlobSetAccessTierOptions-Duration-Context - } - - /** - * Code snippet for {@link BlobClientBase#undeleteWithResponse(Duration, Context)} - */ - public void undeleteWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.undeleteWithResponse#Duration-Context - System.out.printf("Undelete completed with status %d%n", client.undeleteWithResponse(timeout, - new Context(key1, value1)).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.undeleteWithResponse#Duration-Context - } - - /** - * Code snippet for {@link BlobClientBase#getAccountInfoWithResponse(Duration, Context)} - */ - public void getAccountInfoWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.getAccountInfoWithResponse#Duration-Context - StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, new Context(key1, value1)).getValue(); - System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); - // END: com.azure.storage.blob.specialized.BlobClientBase.getAccountInfoWithResponse#Duration-Context - } - - /** - * Code snippet for {@link BlobClientBase#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} - * and {@link BlobClientBase#generateSas(BlobServiceSasSignatureValues)} - */ - public void generateSas() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.generateSas#BlobServiceSasSignatureValues - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential - // END: com.azure.storage.blob.specialized.BlobClientBase.generateSas#BlobServiceSasSignatureValues - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey); - // END: com.azure.storage.blob.specialized.BlobClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - } - - /** - * Code snippet for {@link BlobClientBase#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey, String, Context)} - * and {@link BlobClientBase#generateSas(BlobServiceSasSignatureValues, Context)} - */ - public void generateSasWithContext() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.generateSas#BlobServiceSasSignatureValues-Context - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - // Client must be authenticated via StorageSharedKeyCredential - client.generateSas(values, new Context(key1, value1)); - // END: com.azure.storage.blob.specialized.BlobClientBase.generateSas#BlobServiceSasSignatureValues-Context - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context(key1, value1)); - // END: com.azure.storage.blob.specialized.BlobClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context - } - - /** - * Code snippet for {@link BlobClientBase#openQueryInputStream(String)} - */ - public void openQueryInputStream() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.openQueryInputStream#String - String expression = "SELECT * from BlobStorage"; - InputStream inputStream = client.openQueryInputStream(expression); - // Now you can read from the input stream like you would normally. - // END: com.azure.storage.blob.specialized.BlobClientBase.openQueryInputStream#String - } - - /** - * Code snippet for {@link BlobClientBase#openQueryInputStreamWithResponse(BlobQueryOptions)} - */ - public void openQueryInputStream2() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.openQueryInputStream#BlobQueryOptions - String expression = "SELECT * from BlobStorage"; - BlobQuerySerialization input = new BlobQueryDelimitedSerialization() - .setColumnSeparator(',') - .setEscapeChar('\n') - .setRecordSeparator('\n') - .setHeadersPresent(true) - .setFieldQuote('"'); - BlobQuerySerialization output = new BlobQueryJsonSerialization() - .setRecordSeparator('\n'); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId("leaseId"); - Consumer errorConsumer = System.out::println; - Consumer progressConsumer = progress -> System.out.println("total blob bytes read: " - + progress.getBytesScanned()); - BlobQueryOptions queryOptions = new BlobQueryOptions(expression) - .setInputSerialization(input) - .setOutputSerialization(output) - .setRequestConditions(requestConditions) - .setErrorConsumer(errorConsumer) - .setProgressConsumer(progressConsumer); - - InputStream inputStream = client.openQueryInputStreamWithResponse(queryOptions).getValue(); - // Now you can read from the input stream like you would normally. - // END: com.azure.storage.blob.specialized.BlobClientBase.openQueryInputStream#BlobQueryOptions - } - - /** - * Code snippet for {@link BlobClientBase#query(OutputStream, String)} - */ - public void query() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.query#OutputStream-String - ByteArrayOutputStream queryData = new ByteArrayOutputStream(); - String expression = "SELECT * from BlobStorage"; - client.query(queryData, expression); - System.out.println("Query completed."); - // END: com.azure.storage.blob.specialized.BlobClientBase.query#OutputStream-String - } - - /** - * Code snippet for {@link BlobClientBase#queryWithResponse(BlobQueryOptions, Duration, Context)} - */ - public void queryWithResponse() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.queryWithResponse#BlobQueryOptions-Duration-Context - ByteArrayOutputStream queryData = new ByteArrayOutputStream(); - String expression = "SELECT * from BlobStorage"; - BlobQueryJsonSerialization input = new BlobQueryJsonSerialization() - .setRecordSeparator('\n'); - BlobQueryDelimitedSerialization output = new BlobQueryDelimitedSerialization() - .setEscapeChar('\0') - .setColumnSeparator(',') - .setRecordSeparator('\n') - .setFieldQuote('\'') - .setHeadersPresent(true); - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); - Consumer errorConsumer = System.out::println; - Consumer progressConsumer = progress -> System.out.println("total blob bytes read: " - + progress.getBytesScanned()); - BlobQueryOptions queryOptions = new BlobQueryOptions(expression, queryData) - .setInputSerialization(input) - .setOutputSerialization(output) - .setRequestConditions(requestConditions) - .setErrorConsumer(errorConsumer) - .setProgressConsumer(progressConsumer); - System.out.printf("Query completed with status %d%n", - client.queryWithResponse(queryOptions, timeout, new Context(key1, value1)) - .getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.queryWithResponse#BlobQueryOptions-Duration-Context - } - - /** - * Code snippet for {@link BlobClientBase#setImmutabilityPolicy(BlobImmutabilityPolicy)} and - * {@link BlobClientBase#setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy, BlobRequestConditions, Duration, Context)} - */ - public void setImmutabilityPolicy() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy - BlobImmutabilityPolicy policy = new BlobImmutabilityPolicy() - .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED) - .setExpiryTime(OffsetDateTime.now().plusDays(1)); - BlobImmutabilityPolicy setPolicy = client.setImmutabilityPolicy(policy); - System.out.println("Successfully completed setting the immutability policy"); - // END: com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions-Duration-Context - BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy() - .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED) - .setExpiryTime(OffsetDateTime.now().plusDays(1)); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)); - Response response = client.setImmutabilityPolicyWithResponse(immutabilityPolicy, - requestConditions, timeout, new Context(key1, value1)); - System.out.println("Successfully completed setting the immutability policy"); - // END: com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link BlobClientBase#deleteImmutabilityPolicy()} and - * {@link BlobClientBase#deleteImmutabilityPolicyWithResponse(Duration, Context)} - */ - public void deleteImmutabilityPolicy() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicy - client.deleteImmutabilityPolicy(); - System.out.println("Completed immutability policy deletion."); - // END: com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicy - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicyWithResponse#Duration-Context - System.out.println("Delete immutability policy completed with status: " - + client.deleteImmutabilityPolicyWithResponse(timeout, new Context(key1, value1)).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicyWithResponse#Duration-Context - } - - /** - * Code snippet for {@link BlobClientBase#setLegalHold(boolean)} and - * {@link BlobClientBase#setLegalHoldWithResponse(boolean, Duration, Context)} - */ - public void setLegalHold() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setLegalHold#boolean - System.out.println("Legal hold status: " + client.setLegalHold(true)); - // END: com.azure.storage.blob.specialized.BlobClientBase.setLegalHold#boolean - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setLegalHoldWithResponse#boolean-Duration-Context - System.out.println("Legal hold status: " + client.setLegalHoldWithResponse(true, timeout, - new Context(key1, value1))); - // END: com.azure.storage.blob.specialized.BlobClientBase.setLegalHoldWithResponse#boolean-Duration-Context - } - - /** - * Code snippets for {@link BlobClientBase#deleteIfExists()} and - * {@link BlobClientBase#deleteIfExistsWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions, Duration, Context)} - */ - public void deleteIfExistsCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.deleteIfExists - boolean result = client.deleteIfExists(); - System.out.println("Delete completed: " + result); - // END: com.azure.storage.blob.specialized.BlobClientBase.deleteIfExists - - // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.deleteIfExistsWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions-Duration-Context - Response response = client.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, null, timeout, - new Context(key1, value1)); - if (response.getStatusCode() == 404) { - System.out.println("Does not exist."); - } else { - System.out.printf("Delete completed with status %d%n", response.getStatusCode()); - } - // END: com.azure.storage.blob.specialized.BlobClientBase.deleteIfExistsWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions-Duration-Context - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlockBlobAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlockBlobAsyncClientJavaDocCodeSnippets.java deleted file mode 100644 index ea5f433d6835..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlockBlobAsyncClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,416 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.util.BinaryData; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.options.BlobUploadFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobListBlocksOptions; -import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; -import com.azure.storage.blob.models.BlockList; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.options.BlockBlobStageBlockFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockOptions; -import reactor.core.publisher.Flux; - -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.OffsetDateTime; -import java.util.Base64; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Code snippet for {@link BlockBlobAsyncClient} - */ -@SuppressWarnings({"unused"}) -public class BlockBlobAsyncClientJavaDocCodeSnippets { - private BlockBlobAsyncClient client = new SpecializedBlobClientBuilder().buildBlockBlobAsyncClient(); - private Flux data = Flux.just(ByteBuffer.wrap("data".getBytes(StandardCharsets.UTF_8))); - private long length = 4L; - private String tags = "tags"; - private String leaseId = "leaseId"; - private String base64BlockID = "base64BlockID"; - private String sourceUrl = "https://example.com"; - private long offset = 1024L; - private long count = length; - private byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - - /** - * Constructor for snippets. - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public BlockBlobAsyncClientJavaDocCodeSnippets() throws NoSuchAlgorithmException { - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#upload(Flux, long)} - */ - public void upload() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.upload#Flux-long - client.upload(data, length).subscribe(response -> - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.upload#Flux-long - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#upload(BinaryData)} - */ - public void uploadWithBinaryData() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.upload#BinaryData - BinaryData.fromFlux(data, length, false) - .flatMap(binaryData -> client.upload(binaryData)) - .subscribe(response -> - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.upload#BinaryData - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#upload(Flux, long, boolean)} - */ - public void uploadWithOverwrite() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.upload#Flux-long-boolean - boolean overwrite = false; // Default behavior - client.upload(data, length, overwrite).subscribe(response -> - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.upload#Flux-long-boolean - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#upload(Flux, long, boolean)} - */ - public void uploadWithOverwriteWithBinaryData() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.upload#BinaryData-boolean - boolean overwrite = false; // Default behavior - BinaryData.fromFlux(data, length, false) - .flatMap(binaryData -> client.upload(binaryData, overwrite)) - .subscribe(response -> - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.upload#BinaryData-boolean - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#uploadWithResponse(Flux, long, BlobHttpHeaders, Map, AccessTier, byte[], BlobRequestConditions)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void upload2() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadWithResponse#Flux-long-BlobHttpHeaders-Map-AccessTier-byte-BlobRequestConditions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.uploadWithResponse(data, length, headers, metadata, AccessTier.HOT, md5, requestConditions) - .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadWithResponse#Flux-long-BlobHttpHeaders-Map-AccessTier-byte-BlobRequestConditions - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#uploadWithResponse(BlockBlobSimpleUploadOptions)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void upload3() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadWithResponse#BlockBlobSimpleUploadOptions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.uploadWithResponse(new BlockBlobSimpleUploadOptions(data, length).setHeaders(headers) - .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5) - .setRequestConditions(requestConditions)) - .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadWithResponse#BlockBlobSimpleUploadOptions - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#uploadFromUrl(String)} - */ - public void uploadFromUrlCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadFromUrl#String - client.uploadFromUrl(sourceUrl) - .subscribe(response -> - System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadFromUrl#String - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#uploadFromUrl(String, boolean)} - */ - public void uploadFromUrlWithOverwrite() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadFromUrl#String-boolean - boolean overwrite = false; // Default behavior - client.uploadFromUrl(sourceUrl, overwrite).subscribe(response -> - System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getContentMd5()))); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadFromUrl#String-boolean - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#uploadFromUrlWithResponse(BlobUploadFromUrlOptions)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void uploadFromUrlWithResponse() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadFromUrlWithResponse#BlobUploadFromUrlOptions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.uploadFromUrlWithResponse(new BlobUploadFromUrlOptions(sourceUrl).setHeaders(headers) - .setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5) - .setDestinationRequestConditions(requestConditions)) - .subscribe(response -> System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n", - Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.uploadFromUrlWithResponse#BlobUploadFromUrlOptions - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#stageBlock(String, Flux, long)} - */ - public void stageBlock() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlock#String-Flux-long - client.stageBlock(base64BlockID, data, length) - .subscribe( - response -> System.out.println("Staging block completed"), - error -> System.out.printf("Error when calling stage Block: %s", error)); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlock#String-Flux-long - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#stageBlock(String, BinaryData)} - */ - public void stageBlockBinaryData() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlock#String-BinaryData - BinaryData.fromFlux(data, length, false) - .flatMap(binaryData -> client.stageBlock(base64BlockID, binaryData)) - .subscribe( - response -> System.out.println("Staging block completed"), - error -> System.out.printf("Error when calling stage Block: %s", error)); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlock#String-BinaryData - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#stageBlockWithResponse(String, Flux, long, byte[], String)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void stageBlock2() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockWithResponse#String-Flux-long-byte-String - client.stageBlockWithResponse(base64BlockID, data, length, md5, leaseId).subscribe(response -> - System.out.printf("Staging block completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockWithResponse#String-Flux-long-byte-String - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#stageBlockWithResponse(BlockBlobStageBlockOptions)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void stageBlockBinaryData2() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockWithResponse#BlockBlobStageBlockOptions - BinaryData.fromFlux(data, length, false) - .flatMap(binaryData -> client.stageBlockWithResponse( - new BlockBlobStageBlockOptions(base64BlockID, binaryData) - .setContentMd5(md5) - .setLeaseId(leaseId))) - .subscribe(response -> - System.out.printf("Staging block completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockWithResponse#BlockBlobStageBlockOptions - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#stageBlockFromUrl(String, String, BlobRange)} - */ - public void stageBlockFromUrlCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockFromUrl#String-String-BlobRange - client.stageBlockFromUrl(base64BlockID, sourceUrl, new BlobRange(offset, count)) - .subscribe( - response -> System.out.println("Staging block completed"), - error -> System.out.printf("Error when calling stage Block: %s", error)); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockFromUrl#String-String-BlobRange - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#stageBlockFromUrlWithResponse(String, String, BlobRange, byte[], String, BlobRequestConditions)} - */ - public void stageBlockFromUrl2() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockFromUrlWithResponse#String-String-BlobRange-byte-String-BlobRequestConditions - BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.stageBlockFromUrlWithResponse(base64BlockID, sourceUrl, new BlobRange(offset, count), null, - leaseId, sourceRequestConditions).subscribe(response -> - System.out.printf("Staging block from URL completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockFromUrlWithResponse#String-String-BlobRange-byte-String-BlobRequestConditions - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#stageBlockFromUrlWithResponse(String, String, BlobRange, byte[], String, BlobRequestConditions)} - */ - public void stageBlockFromUrlOptionsBag() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockFromUrlWithResponse#BlockBlobStageBlockFromUrlOptions - BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.stageBlockFromUrlWithResponse(new BlockBlobStageBlockFromUrlOptions(base64BlockID, sourceUrl) - .setSourceRange(new BlobRange(offset, count)).setLeaseId(leaseId) - .setSourceRequestConditions(sourceRequestConditions)).subscribe(response -> - System.out.printf("Staging block from URL completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.stageBlockFromUrlWithResponse#BlockBlobStageBlockFromUrlOptions - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#listBlocks(BlockListType)} - */ - public void listBlocks() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.listBlocks#BlockListType - client.listBlocks(BlockListType.ALL).subscribe(block -> { - System.out.println("Committed Blocks:"); - block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - - System.out.println("Uncommitted Blocks:"); - block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - }); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.listBlocks#BlockListType - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#listBlocksWithResponse(BlockListType, String)} - */ - public void listBlocks2() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.listBlocksWithResponse#BlockListType-String - client.listBlocksWithResponse(BlockListType.ALL, leaseId).subscribe(response -> { - BlockList block = response.getValue(); - System.out.println("Committed Blocks:"); - block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - - System.out.println("Uncommitted Blocks:"); - block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - }); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.listBlocksWithResponse#BlockListType-String - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#listBlocksWithResponse(BlockBlobListBlocksOptions)} - */ - public void listBlocks3() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.listBlocksWithResponse#BlockBlobListBlocksOptions - client.listBlocksWithResponse(new BlockBlobListBlocksOptions(BlockListType.ALL) - .setLeaseId(leaseId) - .setIfTagsMatch(tags)).subscribe(response -> { - BlockList block = response.getValue(); - System.out.println("Committed Blocks:"); - block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), - b.getSizeLong())); - - System.out.println("Uncommitted Blocks:"); - block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), - b.getSizeLong())); - }); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.listBlocksWithResponse#BlockBlobListBlocksOptions - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#commitBlockList(List)} - */ - public void commitBlockList() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.commitBlockList#List - client.commitBlockList(Collections.singletonList(base64BlockID)).subscribe(response -> - System.out.printf("Committing block list completed. Last modified: %s%n", response.getLastModified())); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.commitBlockList#List - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#commitBlockList(List, boolean)} - */ - public void commitBlockListWithOverwrite() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.commitBlockList#List-boolean - boolean overwrite = false; // Default behavior - client.commitBlockList(Collections.singletonList(base64BlockID), overwrite).subscribe(response -> - System.out.printf("Committing block list completed. Last modified: %s%n", response.getLastModified())); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.commitBlockList#List-boolean - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#commitBlockListWithResponse(List, BlobHttpHeaders, Map, AccessTier, BlobRequestConditions)} - */ - public void commitBlockList2() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.commitBlockListWithResponse#List-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - client.commitBlockListWithResponse(Collections.singletonList(base64BlockID), headers, metadata, - AccessTier.HOT, requestConditions).subscribe(response -> - System.out.printf("Committing block list completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.commitBlockListWithResponse#List-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions - } - - /** - * Code snippet for {@link BlockBlobAsyncClient#commitBlockListWithResponse(BlockBlobCommitBlockListOptions)} - */ - public void commitBlockList3() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobAsyncClient.commitBlockListWithResponse#BlockBlobCommitBlockListOptions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - client.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(Collections.singletonList(base64BlockID)) - .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT) - .setRequestConditions(requestConditions)) - .subscribe(response -> - System.out.printf("Committing block list completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlockBlobAsyncClient.commitBlockListWithResponse#BlockBlobCommitBlockListOptions - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlockBlobClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlockBlobClientJavaDocCodeSnippets.java deleted file mode 100644 index 72de4c960478..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlockBlobClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,429 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.options.BlobUploadFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobListBlocksOptions; -import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; -import com.azure.storage.blob.models.BlockList; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.options.BlockBlobStageBlockFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockOptions; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Base64; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Code snippet for {@link BlockBlobClient} - */ -@SuppressWarnings({"unused"}) -public class BlockBlobClientJavaDocCodeSnippets { - private BlockBlobClient client = new SpecializedBlobClientBuilder().buildBlockBlobClient(); - private InputStream data = new ByteArrayInputStream("data".getBytes(StandardCharsets.UTF_8)); - private long length = 4L; - private Duration timeout = Duration.ofSeconds(30); - private String leaseId = "leaseId"; - private String tags = "tags"; - private String base64BlockId = "base64BlockID"; - private String sourceUrl = "https://example.com"; - private long offset = 1024L; - private long count = length; - private byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - - /** - * Constructor for code snippets. - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public BlockBlobClientJavaDocCodeSnippets() throws NoSuchAlgorithmException { - } - - /** - * Code snippet for {@link BlockBlobClient#upload(InputStream, long)} - * - * @throws IOException If an I/O error occurs - */ - public void upload() throws IOException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.upload#InputStream-long - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(client.upload(data, length).getContentMd5())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.upload#InputStream-long - } - - /** - * Code snippet for {@link BlockBlobClient#upload(BinaryData)} - * - * @throws IOException If an I/O error occurs - */ - public void uploadWithBinaryData() throws IOException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.upload#BinaryData - BinaryData binaryData = BinaryData.fromStream(data, length); - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(client.upload(binaryData).getContentMd5())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.upload#BinaryData - } - - /** - * Code snippet for {@link BlockBlobClient#upload(InputStream, long, boolean)} - * - * @throws IOException If an I/O error occurs - */ - public void uploadWithOverwrite() throws IOException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.upload#InputStream-long-boolean - boolean overwrite = false; - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(client.upload(data, length, overwrite).getContentMd5())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.upload#InputStream-long-boolean - } - - /** - * Code snippet for {@link BlockBlobClient#upload(BinaryData, boolean)} - * - * @throws IOException If an I/O error occurs - */ - public void uploadWithOverwriteWithBinaryData() throws IOException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.upload#BinaryData-boolean - boolean overwrite = false; - BinaryData binaryData = BinaryData.fromStream(data, length); - System.out.printf("Uploaded BlockBlob MD5 is %s%n", - Base64.getEncoder().encodeToString(client.upload(binaryData, overwrite).getContentMd5())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.upload#BinaryData-boolean - } - - /** - * Code snippet for {@link BlockBlobClient#uploadWithResponse(InputStream, long, BlobHttpHeaders, Map, AccessTier, byte[], BlobRequestConditions, Duration, Context)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void upload2() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.uploadWithResponse#InputStream-long-BlobHttpHeaders-Map-AccessTier-byte-BlobRequestConditions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5(MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8))) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder() - .encodeToString(client.uploadWithResponse(data, length, headers, metadata, AccessTier.HOT, md5, - requestConditions, timeout, context) - .getValue() - .getContentMd5())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.uploadWithResponse#InputStream-long-BlobHttpHeaders-Map-AccessTier-byte-BlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#uploadWithResponse(BlockBlobSimpleUploadOptions, Duration, Context)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void upload3() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.uploadWithResponse#BlockBlobSimpleUploadOptions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5(MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8))) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder() - .encodeToString(client.uploadWithResponse(new BlockBlobSimpleUploadOptions(data, length) - .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5) - .setRequestConditions(requestConditions), timeout, context) - .getValue() - .getContentMd5())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.uploadWithResponse#BlockBlobSimpleUploadOptions-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#uploadFromUrl(String)} - */ - public void uploadFromUrl() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromUrl#String - System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n", - Base64.getEncoder().encodeToString(client.uploadFromUrl(sourceUrl).getContentMd5())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromUrl#String - } - - /** - * Code snippet for {@link BlockBlobClient#uploadFromUrl(String, boolean)} - */ - public void uploadFromUrlWithOverwrite() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromUrl#String-boolean - boolean overwrite = false; - System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n", - Base64.getEncoder().encodeToString(client.uploadFromUrl(sourceUrl, overwrite).getContentMd5())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromUrl#String-boolean - } - - /** - * Code snippet for {@link BlockBlobClient#uploadFromUrlWithResponse(BlobUploadFromUrlOptions, Duration, Context)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void uploadFromUrlWithResponse() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromUrlWithResponse#BlobUploadFromUrlOptions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5(MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8))) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder() - .encodeToString(client.uploadFromUrlWithResponse(new BlobUploadFromUrlOptions(sourceUrl) - .setHeaders(headers).setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5) - .setDestinationRequestConditions(requestConditions), timeout, context) - .getValue() - .getContentMd5())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromUrlWithResponse#BlobUploadFromUrlOptions-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#stageBlock(String, InputStream, long)} - */ - public void stageBlock() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.stageBlock#String-InputStream-long - client.stageBlock(base64BlockId, data, length); - // END: com.azure.storage.blob.specialized.BlockBlobClient.stageBlock#String-InputStream-long - } - - /** - * Code snippet for {@link BlockBlobClient#stageBlockWithResponse(String, InputStream, long, byte[], String, Duration, Context)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void stageBlock2() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockWithResponse#String-InputStream-long-byte-String-Duration-Context - Context context = new Context("key", "value"); - System.out.printf("Staging block completed with status %d%n", - client.stageBlockWithResponse(base64BlockId, data, length, md5, leaseId, timeout, context).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockWithResponse#String-InputStream-long-byte-String-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#stageBlock(String, BinaryData)} - */ - public void stageBlock3() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.stageBlock#String-BinaryData - BinaryData binaryData = BinaryData.fromStream(data, length); - client.stageBlock(base64BlockId, binaryData); - // END: com.azure.storage.blob.specialized.BlockBlobClient.stageBlock#String-BinaryData - } - - /** - * Code snippet for {@link BlockBlobClient#stageBlockWithResponse(String, InputStream, long, byte[], String, Duration, Context)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void stageBlock4() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockWithResponse#BlockBlobStageBlockOptions-Duration-Context - Context context = new Context("key", "value"); - BinaryData binaryData = BinaryData.fromStream(data, length); - BlockBlobStageBlockOptions options = new BlockBlobStageBlockOptions(base64BlockId, binaryData) - .setContentMd5(md5) - .setLeaseId(leaseId); - System.out.printf("Staging block completed with status %d%n", - client.stageBlockWithResponse(options, timeout, context).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockWithResponse#BlockBlobStageBlockOptions-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#stageBlockFromUrl(String, String, BlobRange)} - */ - public void stageBlockFromUrl() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockFromUrl#String-String-BlobRange - client.stageBlockFromUrl(base64BlockId, sourceUrl, new BlobRange(offset, count)); - // END: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockFromUrl#String-String-BlobRange - } - - /** - * Code snippet for {@link BlockBlobClient#stageBlockFromUrlWithResponse(String, String, BlobRange, byte[], String, BlobRequestConditions, Duration, Context)} - */ - public void stageBlockFromUrl2() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockFromUrlWithResponse#String-String-BlobRange-byte-String-BlobRequestConditions-Duration-Context - BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - System.out.printf("Staging block from URL completed with status %d%n", - client.stageBlockFromUrlWithResponse(base64BlockId, sourceUrl, new BlobRange(offset, count), null, - leaseId, sourceRequestConditions, timeout, context).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockFromUrlWithResponse#String-String-BlobRange-byte-String-BlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#stageBlockFromUrlWithResponse(String, String, BlobRange, byte[], String, BlobRequestConditions, Duration, Context)} - */ - public void stageBlockFromUrlOptionsBag() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockFromUrlWithResponse#BlockBlobStageBlockFromUrlOptions-Duration-Context - BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - System.out.printf("Staging block from URL completed with status %d%n", - client.stageBlockFromUrlWithResponse(new BlockBlobStageBlockFromUrlOptions(base64BlockId, sourceUrl) - .setSourceRange(new BlobRange(offset, count)).setLeaseId(leaseId) - .setSourceRequestConditions(sourceRequestConditions), timeout, context).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlockBlobClient.stageBlockFromUrlWithResponse#BlockBlobStageBlockFromUrlOptions-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#listBlocks(BlockListType)} - */ - public void listBlocks() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.listBlocks#BlockListType - BlockList block = client.listBlocks(BlockListType.ALL); - - System.out.println("Committed Blocks:"); - block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - - System.out.println("Uncommitted Blocks:"); - block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.listBlocks#BlockListType - } - - /** - * Code snippet for {@link BlockBlobClient#listBlocksWithResponse(BlockListType, String, Duration, Context)} - */ - public void listBlocks2() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.listBlocksWithResponse#BlockListType-String-Duration-Context - Context context = new Context("key", "value"); - BlockList block = client.listBlocksWithResponse(BlockListType.ALL, leaseId, timeout, context).getValue(); - - System.out.println("Committed Blocks:"); - block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - - System.out.println("Uncommitted Blocks:"); - block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.listBlocksWithResponse#BlockListType-String-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#listBlocksWithResponse(BlockBlobListBlocksOptions, Duration, Context)} - */ - public void listBlocks3() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.listBlocksWithResponse#BlockBlobListBlocksOptions-Duration-Context - Context context = new Context("key", "value"); - BlockList block = client.listBlocksWithResponse(new BlockBlobListBlocksOptions(BlockListType.ALL) - .setLeaseId(leaseId) - .setIfTagsMatch(tags), timeout, context).getValue(); - - System.out.println("Committed Blocks:"); - block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - - System.out.println("Uncommitted Blocks:"); - block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); - // END: com.azure.storage.blob.specialized.BlockBlobClient.listBlocksWithResponse#BlockBlobListBlocksOptions-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#commitBlockList(List)} - */ - public void commitBlockList() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.commitBlockList#List - System.out.printf("Committing block list completed. Last modified: %s%n", - client.commitBlockList(Collections.singletonList(base64BlockId)).getLastModified()); - // END: com.azure.storage.blob.specialized.BlockBlobClient.commitBlockList#List - } - - /** - * Code snippet for {@link BlockBlobClient#commitBlockList(List, boolean)} - */ - public void commitBlockListWithOverwrite() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.commitBlockList#List-boolean - boolean overwrite = false; // Default behavior - System.out.printf("Committing block list completed. Last modified: %s%n", - client.commitBlockList(Collections.singletonList(base64BlockId), overwrite).getLastModified()); - // END: com.azure.storage.blob.specialized.BlockBlobClient.commitBlockList#List-boolean - } - - /** - * Code snippet for {@link BlockBlobClient#commitBlockListWithResponse(List, BlobHttpHeaders, Map, AccessTier, BlobRequestConditions, Duration, Context)} - */ - public void commitBlockList2() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromFile#List-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5(MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8))) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - System.out.printf("Committing block list completed with status %d%n", - client.commitBlockListWithResponse(Collections.singletonList(base64BlockId), headers, metadata, - AccessTier.HOT, requestConditions, timeout, context).getStatusCode()); - // END: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromFile#List-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions-Duration-Context - } - - /** - * Code snippet for {@link BlockBlobClient#commitBlockListWithResponse(BlockBlobCommitBlockListOptions, Duration, Context)} - */ - public void commitBlockList3() { - // BEGIN: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromFile#BlockBlobCommitBlockListOptions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) - .setContentLanguage("en-US") - .setContentType("binary"); - - Map metadata = Collections.singletonMap("metadata", "value"); - Map tags = Collections.singletonMap("tag", "value"); - BlobRequestConditions requestConditions = new BlobRequestConditions() - .setLeaseId(leaseId) - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context("key", "value"); - - System.out.printf("Committing block list completed with status %d%n", - client.commitBlockListWithResponse( - new BlockBlobCommitBlockListOptions(Collections.singletonList(base64BlockId)).setHeaders(headers) - .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT) - .setRequestConditions(requestConditions), timeout, context) - .getStatusCode()); - // END: com.azure.storage.blob.specialized.BlockBlobClient.uploadFromFile#BlockBlobCommitBlockListOptions-Duration-Context - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseAsyncClientJavaDocCodeSnippets.java deleted file mode 100644 index 4b7a67f1fe32..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseAsyncClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.RequestConditions; -import com.azure.storage.blob.BlobClientBuilder; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; -import com.azure.storage.blob.options.BlobAcquireLeaseOptions; -import com.azure.storage.blob.options.BlobBreakLeaseOptions; -import com.azure.storage.blob.options.BlobChangeLeaseOptions; -import com.azure.storage.blob.options.BlobReleaseLeaseOptions; -import com.azure.storage.blob.options.BlobRenewLeaseOptions; - -import java.time.Duration; -import java.time.OffsetDateTime; - - -public class LeaseAsyncClientJavaDocCodeSnippets { - private BlobLeaseAsyncClient client = new BlobLeaseClientBuilder() - .blobAsyncClient(new BlobClientBuilder().blobName("blob").buildAsyncClient()) - .buildAsyncClient(); - - /** - * Code snippets for {@link BlobLeaseAsyncClient#acquireLease(int)} - */ - public void acquireLeaseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.acquireLease#int - client.acquireLease(60).subscribe(response -> System.out.printf("Lease ID is %s%n", response)); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.acquireLease#int - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#renewLease()} - */ - public void renewLeaseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.renewLease - client.renewLease().subscribe(response -> System.out.printf("Renewed lease ID is %s%n", response)); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.renewLease - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#releaseLease()} - */ - public void releaseLeaseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.releaseLease - client.releaseLease().subscribe(response -> System.out.println("Completed release lease")); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.releaseLease - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#breakLease()} - */ - public void breakLeaseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.breakLease - client.breakLease().subscribe(response -> - System.out.printf("The broken lease has %d seconds remaining on the lease", response)); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.breakLease - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#changeLease(String)} - */ - public void changeLeaseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.changeLease#String - client.changeLease("proposedId").subscribe(response -> System.out.printf("Changed lease ID is %s%n", response)); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.changeLease#String - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#acquireLeaseWithResponse(int, RequestConditions)} - */ - public void acquireLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.acquireLeaseWithResponse#int-RequestConditions - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfModifiedSince(OffsetDateTime.now().minusDays(3)); - - client.acquireLeaseWithResponse(60, modifiedRequestConditions).subscribe(response -> - System.out.printf("Lease ID is %s%n", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.acquireLeaseWithResponse#int-RequestConditions - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#acquireLeaseWithResponse(BlobAcquireLeaseOptions)} - */ - public void acquireLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.acquireLeaseWithResponse#BlobAcquireLeaseOptions - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfModifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobAcquireLeaseOptions options = new BlobAcquireLeaseOptions(60) - .setRequestConditions(requestConditions); - - client.acquireLeaseWithResponse(options).subscribe(response -> - System.out.printf("Lease ID is %s%n", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.acquireLeaseWithResponse#BlobAcquireLeaseOptions - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#renewLeaseWithResponse(RequestConditions)} - */ - public void renewLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.renewLeaseWithResponse#RequestConditions - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.renewLeaseWithResponse(modifiedRequestConditions).subscribe(response -> - System.out.printf("Renewed lease ID is %s%n", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.renewLeaseWithResponse#RequestConditions - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#renewLeaseWithResponse(BlobRenewLeaseOptions)} - */ - public void renewLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.renewLeaseWithResponse#BlobRenewLeaseOptions - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfModifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobRenewLeaseOptions options = new BlobRenewLeaseOptions() - .setRequestConditions(requestConditions); - - client.renewLeaseWithResponse(options).subscribe(response -> - System.out.printf("Lease ID is %s%n", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.renewLeaseWithResponse#BlobRenewLeaseOptions - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#releaseLeaseWithResponse(RequestConditions)} - */ - public void releaseLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.releaseLeaseWithResponse#RequestConditions - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.releaseLeaseWithResponse(modifiedRequestConditions).subscribe(response -> - System.out.printf("Release lease completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.releaseLeaseWithResponse#RequestConditions - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#releaseLeaseWithResponse(RequestConditions)} - */ - public void releaseLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.releaseLeaseWithResponse#BlobReleaseLeaseOptions - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfModifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobReleaseLeaseOptions options = new BlobReleaseLeaseOptions() - .setRequestConditions(requestConditions); - - client.releaseLeaseWithResponse(options).subscribe(response -> - System.out.printf("Release lease completed with status %d%n", response.getStatusCode())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.releaseLeaseWithResponse#BlobReleaseLeaseOptions - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#breakLeaseWithResponse(Integer, RequestConditions)} - */ - public void breakLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.breakLeaseWithResponse#Integer-RequestConditions - Integer retainLeaseInSeconds = 5; - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.breakLeaseWithResponse(retainLeaseInSeconds, modifiedRequestConditions).subscribe(response -> - System.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.breakLeaseWithResponse#Integer-RequestConditions - } - - - /** - * Code snippets for {@link BlobLeaseAsyncClient#breakLeaseWithResponse(BlobBreakLeaseOptions)} - */ - public void breakLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.breakLeaseWithResponse#BlobBreakLeaseOptions - Integer retainLeaseInSeconds = 5; - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobBreakLeaseOptions options = new BlobBreakLeaseOptions() - .setBreakPeriod(Duration.ofSeconds(retainLeaseInSeconds)) - .setRequestConditions(requestConditions); - - client.breakLeaseWithResponse(options).subscribe(response -> - System.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.breakLeaseWithResponse#BlobBreakLeaseOptions - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#changeLeaseWithResponse(String, RequestConditions)} - */ - public void changeLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.changeLeaseWithResponse#String-RequestConditions - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.changeLeaseWithResponse("proposedId", modifiedRequestConditions).subscribe(response -> - System.out.printf("Changed lease ID is %s%n", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.changeLeaseWithResponse#String-RequestConditions - } - - /** - * Code snippets for {@link BlobLeaseAsyncClient#changeLeaseWithResponse(BlobChangeLeaseOptions)} - */ - public void changeLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.changeLeaseWithResponse#BlobChangeLeaseOptions - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobChangeLeaseOptions options = new BlobChangeLeaseOptions("proposedId") - .setRequestConditions(requestConditions); - - client.changeLeaseWithResponse(options).subscribe(response -> - System.out.printf("Changed lease ID is %s%n", response.getValue())); - // END: com.azure.storage.blob.specialized.BlobLeaseAsyncClient.changeLeaseWithResponse#BlobChangeLeaseOptions - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseClientBuilderJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseClientBuilderJavaDocCodeSnippets.java deleted file mode 100644 index d80100c47789..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseClientBuilderJavaDocCodeSnippets.java +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobContainerAsyncClient; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.BlobContainerClientBuilder; - -public class LeaseClientBuilderJavaDocCodeSnippets { - private BlobContainerAsyncClient blobContainerAsyncClient = new BlobContainerClientBuilder() - .containerName("container") - .buildAsyncClient(); - - private BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() - .containerName("container") - .buildClient(); - - private BlobAsyncClient blobAsyncClient = blobContainerAsyncClient.getBlobAsyncClient("blob"); - private BlobClient blobClient = blobContainerClient.getBlobClient("blob"); - - private String leaseId = "leaseId"; - - /** - * Code snippets for {@link BlobLeaseClientBuilder#buildClient()}. - */ - public void syncInstantiationWithBlob() { - // BEGIN: com.azure.storage.blob.specialized.LeaseClientBuilder.syncInstantiationWithBlob - BlobLeaseClient blobLeaseClient = new BlobLeaseClientBuilder() - .blobClient(blobClient) - .buildClient(); - // END: com.azure.storage.blob.specialized.LeaseClientBuilder.syncInstantiationWithBlob - } - - /** - * Code snippets for {@link BlobLeaseClientBuilder#buildClient()}. - */ - public void syncInstantiationWithBlobAndLeaseId() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.syncInstantiationWithBlobAndLeaseId - BlobLeaseClient blobLeaseClient = new BlobLeaseClientBuilder() - .blobClient(blobClient) - .leaseId(leaseId) - .buildClient(); - // END: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.syncInstantiationWithBlobAndLeaseId - } - - /** - * Code snippets for {@link BlobLeaseClientBuilder#buildClient()}. - */ - public void syncInstantiationWithContainer() { - // BEGIN: com.azure.storage.blob.specialized.LeaseClientBuilder.syncInstantiationWithContainer - BlobLeaseClient blobLeaseClient = new BlobLeaseClientBuilder() - .containerClient(blobContainerClient) - .buildClient(); - // END: com.azure.storage.blob.specialized.LeaseClientBuilder.syncInstantiationWithContainer - } - - /** - * Code snippets for {@link BlobLeaseClientBuilder#buildClient()}. - */ - public void syncInstantiationWithContainerAndLeaseId() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.syncInstantiationWithContainerAndLeaseId - BlobLeaseClient blobLeaseClient = new BlobLeaseClientBuilder() - .containerClient(blobContainerClient) - .leaseId(leaseId) - .buildClient(); - // END: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.syncInstantiationWithContainerAndLeaseId - } - - /** - * Code snippets for {@link BlobLeaseClientBuilder#buildAsyncClient()}. - */ - public void asyncInstantiationWithBlob() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.asyncInstantiationWithBlob - BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder() - .blobAsyncClient(blobAsyncClient) - .buildAsyncClient(); - // END: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.asyncInstantiationWithBlob - } - - /** - * Code snippets for {@link BlobLeaseClientBuilder#buildAsyncClient()}. - */ - public void asyncInstantiationWithBlobAndLeaseId() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.asyncInstantiationWithBlobAndLeaseId - BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder() - .blobAsyncClient(blobAsyncClient) - .leaseId(leaseId) - .buildAsyncClient(); - // END: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.asyncInstantiationWithBlobAndLeaseId - } - - /** - * Code snippets for {@link BlobLeaseClientBuilder#buildAsyncClient()}. - */ - public void asyncInstantiationWithContainer() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.asyncInstantiationWithContainer - BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder() - .containerAsyncClient(blobContainerAsyncClient) - .buildAsyncClient(); - // END: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.asyncInstantiationWithContainer - } - - /** - * Code snippets for {@link BlobLeaseClientBuilder#buildAsyncClient()}. - */ - public void asyncInstantiationWithContainerAndLeaseId() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.asyncInstantiationWithContainerAndLeaseId - BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder() - .containerAsyncClient(blobContainerAsyncClient) - .leaseId(leaseId) - .buildAsyncClient(); - // END: com.azure.storage.blob.specialized.BlobLeaseClientBuilder.asyncInstantiationWithContainerAndLeaseId - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseClientJavaDocCodeSnippets.java deleted file mode 100644 index ccc4de392177..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/LeaseClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.RequestConditions; -import com.azure.core.util.Context; -import com.azure.storage.blob.BlobClientBuilder; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; -import com.azure.storage.blob.options.BlobAcquireLeaseOptions; -import com.azure.storage.blob.options.BlobBreakLeaseOptions; -import com.azure.storage.blob.options.BlobChangeLeaseOptions; -import com.azure.storage.blob.options.BlobReleaseLeaseOptions; -import com.azure.storage.blob.options.BlobRenewLeaseOptions; - -import java.time.Duration; -import java.time.OffsetDateTime; - -public class LeaseClientJavaDocCodeSnippets { - private BlobLeaseClient client = new BlobLeaseClientBuilder() - .blobClient(new BlobClientBuilder().blobName("blob").buildClient()) - .buildClient(); - private Duration timeout = Duration.ofSeconds(30); - private String key = "key"; - private String value = "value"; - - /** - * Code snippets for {@link BlobLeaseClient#acquireLease(int)} - */ - public void acquireLease() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.acquireLease#int - System.out.printf("Lease ID is %s%n", client.acquireLease(60)); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.acquireLease#int - } - - /** - * Code snippets for {@link BlobLeaseClient#renewLease()} - */ - public void renewLease() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.renewLease - System.out.printf("Renewed lease ID is %s%n", client.renewLease()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.renewLease - } - - /** - * Code snippets for {@link BlobLeaseClient#releaseLease()} - */ - public void releaseLease() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.releaseLease - client.releaseLease(); - System.out.println("Release lease completed"); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.releaseLease - } - - /** - * Code snippets for {@link BlobLeaseClient#breakLease()} - */ - public void breakLease() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.breakLease - System.out.printf("The broken lease has %d seconds remaining on the lease", client.breakLease()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.breakLease - } - - /** - * Code snippets for {@link BlobLeaseClient#changeLease(String)} - */ - public void changeLease() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.changeLease#String - System.out.printf("Changed lease ID is %s%n", client.changeLease("proposedId")); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.changeLease#String - } - - /** - * Code snippets for {@link BlobLeaseClient#acquireLeaseWithResponse(int, com.azure.core.http.RequestConditions, Duration, Context)} - */ - public void acquireLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.acquireLeaseWithResponse#int-RequestConditions-Duration-Context - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfModifiedSince(OffsetDateTime.now().minusDays(3)); - - System.out.printf("Lease ID is %s%n", client - .acquireLeaseWithResponse(60, modifiedRequestConditions, timeout, new Context(key, value)) - .getValue()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.acquireLeaseWithResponse#int-RequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobLeaseClient#acquireLeaseWithResponse(BlobAcquireLeaseOptions, Duration, Context)} - */ - public void acquireLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.acquireLeaseWithResponse#BlobAcquireLeaseOptions-Duration-Context - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfModifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobAcquireLeaseOptions options = new BlobAcquireLeaseOptions(60) - .setRequestConditions(requestConditions); - - System.out.printf("Lease ID is %s%n", client - .acquireLeaseWithResponse(options, timeout, new Context(key, value)) - .getValue()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.acquireLeaseWithResponse#BlobAcquireLeaseOptions-Duration-Context - } - - /** - * Code snippets for {@link BlobLeaseClient#renewLeaseWithResponse(RequestConditions, Duration, Context)} - */ - public void renewLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.renewLeaseWithResponse#RequestConditions-Duration-Context - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - System.out.printf("Renewed lease ID is %s%n", - client.renewLeaseWithResponse(modifiedRequestConditions, timeout, new Context(key, value)) - .getValue()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.renewLeaseWithResponse#RequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobLeaseClient#renewLeaseWithResponse(BlobRenewLeaseOptions, Duration, Context)} - */ - public void renewLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.renewLeaseWithResponse#BlobRenewLeaseOptions-Duration-Context - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfModifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobRenewLeaseOptions options = new BlobRenewLeaseOptions() - .setRequestConditions(requestConditions); - - System.out.printf("Renewed lease ID is %s%n", - client.renewLeaseWithResponse(options, timeout, new Context(key, value)) - .getValue()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.renewLeaseWithResponse#BlobRenewLeaseOptions-Duration-Context - } - - /** - * Code snippets for {@link BlobLeaseClient#releaseLeaseWithResponse(RequestConditions, Duration, Context)} - */ - public void releaseLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.releaseLeaseWithResponse#RequestConditions-Duration-Context - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - System.out.printf("Release lease completed with status %d%n", - client.releaseLeaseWithResponse(modifiedRequestConditions, timeout, new Context(key, value)) - .getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.releaseLeaseWithResponse#RequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobLeaseClient#releaseLeaseWithResponse(BlobReleaseLeaseOptions, Duration, Context)} - */ - public void releaseLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.releaseLeaseWithResponse#BlobReleaseLeaseOptions-Duration-Context - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfModifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobReleaseLeaseOptions options = new BlobReleaseLeaseOptions() - .setRequestConditions(requestConditions); - - System.out.printf("Release lease completed with status %d%n", - client.releaseLeaseWithResponse(options, timeout, new Context(key, value)) - .getStatusCode()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.releaseLeaseWithResponse#BlobReleaseLeaseOptions-Duration-Context - } - - /** - * Code snippets for {@link BlobLeaseClient#breakLeaseWithResponse(Integer, RequestConditions, Duration, Context)} - */ - public void breakLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.breakLeaseWithResponse#Integer-RequestConditions-Duration-Context - Integer retainLeaseInSeconds = 5; - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - System.out.printf("The broken lease has %d seconds remaining on the lease", client - .breakLeaseWithResponse(retainLeaseInSeconds, modifiedRequestConditions, timeout, new Context(key, value)) - .getValue()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.breakLeaseWithResponse#Integer-RequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobLeaseClient#breakLeaseWithResponse(BlobBreakLeaseOptions, Duration, Context)} - */ - public void breakLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.breakLeaseWithResponse#BlobBreakLeaseOptions-Duration-Context - Integer retainLeaseInSeconds = 5; - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobBreakLeaseOptions options = new BlobBreakLeaseOptions() - .setBreakPeriod(Duration.ofSeconds(retainLeaseInSeconds)) - .setRequestConditions(requestConditions); - - System.out.printf("The broken lease has %d seconds remaining on the lease", client - .breakLeaseWithResponse(options, timeout, new Context(key, value)) - .getValue()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.breakLeaseWithResponse#BlobBreakLeaseOptions-Duration-Context - } - - /** - * Code snippets for {@link BlobLeaseClient#changeLeaseWithResponse(String, RequestConditions, Duration, Context)} - */ - public void changeLeaseWithResponseCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.changeLeaseWithResponse#String-RequestConditions-Duration-Context - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - System.out.printf("Changed lease ID is %s%n", - client.changeLeaseWithResponse("proposedId", modifiedRequestConditions, timeout, new Context(key, value)) - .getValue()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.changeLeaseWithResponse#String-RequestConditions-Duration-Context - } - - /** - * Code snippets for {@link BlobLeaseClient#changeLeaseWithResponse(BlobChangeLeaseOptions, Duration, Context)} - */ - public void changeLeaseWithResponseCodeSnippets2() { - // BEGIN: com.azure.storage.blob.specialized.BlobLeaseClient.changeLeaseWithResponse#BlobChangeLeaseOptions-Duration-Context - BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - BlobChangeLeaseOptions options = new BlobChangeLeaseOptions("proposedId") - .setRequestConditions(requestConditions); - - System.out.printf("Changed lease ID is %s%n", - client.changeLeaseWithResponse(options, timeout, new Context(key, value)) - .getValue()); - // END: com.azure.storage.blob.specialized.BlobLeaseClient.changeLeaseWithResponse#BlobChangeLeaseOptions-Duration-Context - } -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/PageBlobAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/PageBlobAsyncClientJavaDocCodeSnippets.java deleted file mode 100644 index ab7b031ef711..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/PageBlobAsyncClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,558 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.RequestConditions; -import com.azure.storage.blob.models.PageBlobCopyIncrementalRequestConditions; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.options.ListPageRangesDiffOptions; -import com.azure.storage.blob.options.ListPageRangesOptions; -import com.azure.storage.blob.options.PageBlobCopyIncrementalOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.models.PageBlobRequestConditions; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.models.SequenceNumberActionType; -import com.azure.storage.blob.options.PageBlobUploadPagesFromUrlOptions; -import reactor.core.publisher.Flux; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.Map; - -/** - * Code snippets for {@link PageBlobAsyncClient} - */ -@SuppressWarnings("unused") -public class PageBlobAsyncClientJavaDocCodeSnippets { - private PageBlobAsyncClient client = new SpecializedBlobClientBuilder().buildPageBlobAsyncClient(); - private Map metadata = Collections.singletonMap("metadata", "value"); - private Map tags = Collections.singletonMap("tag", "value"); - private ByteBuffer[] bufferData = new ByteBuffer[]{ - ByteBuffer.wrap(new byte[]{1}), - ByteBuffer.wrap(new byte[]{2}) - }; - private Flux body = Flux.fromArray(bufferData); - private long size = 1024; - private String leaseId = "leaseId"; - private long sequenceNumber = 0; - private String url = "https://sample.com"; - private long sourceOffset = 0; - private String data = "data"; - private long offset = 0; - - /** - * Code snippets for {@link PageBlobAsyncClient#create(long)} - */ - public void setCreateCodeSnippet() { - // BEGIN: com.azure.storage.blob.PageBlobAsyncClient.create#long - client.create(size).subscribe(response -> System.out.printf( - "Created page blob with sequence number %s%n", response.getBlobSequenceNumber())); - // END: com.azure.storage.blob.PageBlobAsyncClient.create#long - } - - /** - * Code snippets for {@link PageBlobAsyncClient#create(long, boolean)} - */ - public void createWithOverwrite() { - // BEGIN: com.azure.storage.blob.PageBlobAsyncClient.create#long-boolean - boolean overwrite = false; // Default behavior - client.create(size, overwrite).subscribe(response -> System.out.printf( - "Created page blob with sequence number %s%n", response.getBlobSequenceNumber())); - // END: com.azure.storage.blob.PageBlobAsyncClient.create#long-boolean - } - - /** - * Code snippets for {@link PageBlobAsyncClient#createWithResponse(long, Long, BlobHttpHeaders, Map, BlobRequestConditions)} - */ - public void createWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.createWithResponse#long-Long-BlobHttpHeaders-Map-BlobRequestConditions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.createWithResponse(size, sequenceNumber, headers, metadata, blobRequestConditions) - .subscribe(response -> System.out.printf( - "Created page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber())); - - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.createWithResponse#long-Long-BlobHttpHeaders-Map-BlobRequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#createWithResponse(PageBlobCreateOptions)} - */ - public void createWithResponse2CodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.createWithResponse#PageBlobCreateOptions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.createWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber) - .setHeaders(headers).setMetadata(metadata).setTags(tags).setRequestConditions(blobRequestConditions)) - .subscribe(response -> System.out.printf( - "Created page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber())); - - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.createWithResponse#PageBlobCreateOptions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#uploadPages(PageRange, Flux)} - */ - public void uploadPagesCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPages#PageRange-Flux - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - - client.uploadPages(pageRange, body).subscribe(response -> System.out.printf( - "Uploaded page blob with sequence number %s%n", response.getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPages#PageRange-Flux - } - - /** - * Code snippets for {@link PageBlobAsyncClient#uploadPagesWithResponse(PageRange, Flux, byte[], PageBlobRequestConditions)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void uploadPagesWithResponseCodeSnippet() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPagesWithResponse#PageRange-Flux-byte-PageBlobRequestConditions - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId); - - client.uploadPagesWithResponse(pageRange, body, md5, pageBlobRequestConditions) - .subscribe(response -> System.out.printf( - "Uploaded page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPagesWithResponse#PageRange-Flux-byte-PageBlobRequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#uploadPagesFromUrl(PageRange, String, Long)} - */ - public void uploadPagesFromUrl() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPagesFromUrl#PageRange-String-Long - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - - client.uploadPagesFromUrl(pageRange, url, sourceOffset) - .subscribe(response -> System.out.printf( - "Uploaded page blob from URL with sequence number %s%n", response.getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPagesFromUrl#PageRange-String-Long - } - - /** - * Code snippets for {@link PageBlobAsyncClient#uploadPagesFromUrlWithResponse(PageRange, String, Long, byte[], - * PageBlobRequestConditions, BlobRequestConditions)} - */ - public void uploadPagesFromUrlWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPagesFromUrlWithResponse#PageRange-String-Long-byte-PageBlobRequestConditions-BlobRequestConditions - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - byte[] sourceContentMD5 = new byte[512]; - PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId); - BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.uploadPagesFromUrlWithResponse(pageRange, url, sourceOffset, sourceContentMD5, pageBlobRequestConditions, - sourceRequestConditions) - .subscribe(response -> System.out.printf( - "Uploaded page blob from URL with sequence number %s%n", response.getValue().getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPagesFromUrlWithResponse#PageRange-String-Long-byte-PageBlobRequestConditions-BlobRequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#uploadPagesFromUrlWithResponse(PageBlobUploadPagesFromUrlOptions)} - */ - public void uploadPagesFromUrlWithResponseOptionsBagCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPagesFromUrlWithResponse#PageBlobUploadPagesFromUrlOptions - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - byte[] sourceContentMD5 = new byte[512]; - PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId); - BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - - client.uploadPagesFromUrlWithResponse(new PageBlobUploadPagesFromUrlOptions(pageRange, url) - .setSourceOffset(sourceOffset).setSourceContentMd5(sourceContentMD5) - .setDestinationRequestConditions(pageBlobRequestConditions) - .setSourceRequestConditions(sourceRequestConditions)) - .subscribe(response -> System.out.printf( - "Uploaded page blob from URL with sequence number %s%n", response.getValue().getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.uploadPagesFromUrlWithResponse#PageBlobUploadPagesFromUrlOptions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#clearPages(PageRange)} - */ - public void clearPagesCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.clearPages#PageRange - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - - client.clearPages(pageRange).subscribe(response -> System.out.printf( - "Cleared page blob with sequence number %s%n", response.getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.clearPages#PageRange - } - - /** - * Code snippets for {@link PageBlobAsyncClient#clearPagesWithResponse(PageRange, PageBlobRequestConditions)} - */ - public void clearPagesWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.clearPagesWithResponse#PageRange-PageBlobRequestConditions - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId); - - client.clearPagesWithResponse(pageRange, pageBlobRequestConditions) - .subscribe(response -> System.out.printf( - "Cleared page blob with sequence number %s%n", response.getValue().getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.clearPagesWithResponse#PageRange-PageBlobRequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#getPageRanges(BlobRange)} - */ - public void getPageRangesCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.getPageRanges#BlobRange - BlobRange blobRange = new BlobRange(offset); - - client.getPageRanges(blobRange).subscribe(response -> { - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : response.getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.getPageRanges#BlobRange - } - - /** - * Code snippets for {@link PageBlobAsyncClient#getPageRangesWithResponse(BlobRange, BlobRequestConditions)} - */ - public void getPageRangesWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.getPageRangesWithResponse#BlobRange-BlobRequestConditions - BlobRange blobRange = new BlobRange(offset); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.getPageRangesWithResponse(blobRange, blobRequestConditions) - .subscribe(response -> { - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : response.getValue().getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.getPageRangesWithResponse#BlobRange-BlobRequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#listPageRanges(BlobRange)} and - * {@link PageBlobAsyncClient#listPageRanges(ListPageRangesOptions)} - */ - public void listPageRangesCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.listPageRanges#BlobRange - BlobRange blobRange = new BlobRange(offset); - - System.out.println("Valid Page Ranges are:"); - client.listPageRanges(blobRange).subscribe(rangeItem -> System.out.printf("Offset: %s, Length: %s%n", - rangeItem.getRange().getOffset(), rangeItem.getRange().getLength())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.listPageRanges#BlobRange - - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.listPageRanges#ListPageRangesOptions - ListPageRangesOptions options = new ListPageRangesOptions(new BlobRange(offset)) - .setMaxResultsPerPage(1000).setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId)); - - client.listPageRanges(options) - .subscribe(rangeItem -> System.out.printf("Offset: %s, Length: %s%n", rangeItem.getRange().getOffset(), - rangeItem.getRange().getLength())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.listPageRanges#ListPageRangesOptions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#getPageRangesDiff(BlobRange, String)} - */ - public void getPageRangesDiffCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.getPageRangesDiff#BlobRange-String - BlobRange blobRange = new BlobRange(offset); - final String prevSnapshot = "previous snapshot"; - - client.getPageRangesDiff(blobRange, prevSnapshot).subscribe(response -> { - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : response.getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.getPageRangesDiff#BlobRange-String - } - - /** - * Code snippets for {@link PageBlobAsyncClient#getPageRangesDiffWithResponse(BlobRange, String, - * BlobRequestConditions)} - */ - public void getPageRangesDiffWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.getPageRangesDiffWithResponse#BlobRange-String-BlobRequestConditions - BlobRange blobRange = new BlobRange(offset); - final String prevSnapshot = "previous snapshot"; - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.getPageRangesDiffWithResponse(blobRange, prevSnapshot, blobRequestConditions) - .subscribe(response -> { - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : response.getValue().getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.getPageRangesDiffWithResponse#BlobRange-String-BlobRequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#listPageRangesDiff(BlobRange, String)} and - * {@link PageBlobAsyncClient#listPageRangesDiff(ListPageRangesDiffOptions)} - */ - public void listPageRangesDiffCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.listPageRangesDiff#BlobRange-String - BlobRange blobRange = new BlobRange(offset); - String prevSnapshot = "previous snapshot"; - - System.out.println("Valid Page Ranges are:"); - client.listPageRangesDiff(blobRange, prevSnapshot).subscribe(rangeItem -> - System.out.printf("Offset: %s, Length: %s, isClear: %s%n", - rangeItem.getRange().getOffset(), rangeItem.getRange().getLength(), rangeItem.isClear())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.listPageRangesDiff#BlobRange-String - - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.listPageRangesDiff#ListPageRangesDiffOptions - ListPageRangesDiffOptions options = new ListPageRangesDiffOptions(new BlobRange(offset), "previous snapshot") - .setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId)) - .setMaxResultsPerPage(1000); - - client.listPageRangesDiff(options) - .subscribe(rangeItem -> System.out.printf("Offset: %s, Length: %s, isClear: %s%n", - rangeItem.getRange().getOffset(), rangeItem.getRange().getLength(), rangeItem.isClear())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.listPageRangesDiff#ListPageRangesDiffOptions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#getManagedDiskPageRangesDiff(BlobRange, String)} - */ - public void getPageRangesDiffFromUrlCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.getManagedDiskPageRangesDiff#BlobRange-String - BlobRange blobRange = new BlobRange(offset); - final String prevSnapshotUrl = "previous snapshot url"; - - client.getPageRangesDiff(blobRange, prevSnapshotUrl).subscribe(response -> { - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : response.getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.getManagedDiskPageRangesDiff#BlobRange-String - } - - /** - * Code snippets for {@link PageBlobAsyncClient#getManagedDiskPageRangesDiffWithResponse(BlobRange, String, - * BlobRequestConditions)} - */ - public void getPageRangesDiffFromUrlWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.getManagedDiskPageRangesDiffWithResponse#BlobRange-String-BlobRequestConditions - BlobRange blobRange = new BlobRange(offset); - final String prevSnapshotUrl = "previous snapshot url"; - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.getPageRangesDiffWithResponse(blobRange, prevSnapshotUrl, blobRequestConditions) - .subscribe(response -> { - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : response.getValue().getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.getManagedDiskPageRangesDiffWithResponse#BlobRange-String-BlobRequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#resize(long)} - */ - public void resizeCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.resize#long - client.resize(size).subscribe(response -> System.out.printf( - "Page blob resized with sequence number %s%n", response.getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.resize#long - } - - /** - * Code snippets for {@link PageBlobAsyncClient#resizeWithResponse(long, BlobRequestConditions)} - */ - public void resizeWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.resizeWithResponse#long-BlobRequestConditions - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.resizeWithResponse(size, blobRequestConditions) - .subscribe(response -> System.out.printf( - "Page blob resized with sequence number %s%n", response.getValue().getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.resizeWithResponse#long-BlobRequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#updateSequenceNumber(SequenceNumberActionType, Long)} - */ - public void updateSequenceNumberCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.updateSequenceNumber#SequenceNumberActionType-Long - client.updateSequenceNumber(SequenceNumberActionType.INCREMENT, size) - .subscribe(response -> System.out.printf( - "Page blob updated to sequence number %s%n", response.getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.updateSequenceNumber#SequenceNumberActionType-Long - } - - /** - * Code snippets for {@link PageBlobAsyncClient#updateSequenceNumberWithResponse(SequenceNumberActionType, Long, - * BlobRequestConditions)} - */ - public void updateSequenceNumberWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.updateSequenceNumberWithResponse#SequenceNumberActionType-Long-BlobRequestConditions - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - client.updateSequenceNumberWithResponse(SequenceNumberActionType.INCREMENT, size, blobRequestConditions) - .subscribe(response -> System.out.printf( - "Page blob updated to sequence number %s%n", response.getValue().getBlobSequenceNumber())); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.updateSequenceNumberWithResponse#SequenceNumberActionType-Long-BlobRequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#copyIncremental(String, String)} - */ - public void copyIncrementalCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.copyIncremental#String-String - final String snapshot = "copy snapshot"; - client.copyIncremental(url, snapshot).subscribe(statusType -> { - switch (statusType) { - case SUCCESS: - System.out.println("Page blob copied successfully"); - break; - case FAILED: - System.out.println("Page blob copied failed"); - break; - case ABORTED: - System.out.println("Page blob copied aborted"); - break; - case PENDING: - System.out.println("Page blob copied pending"); - break; - default: - break; - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.copyIncremental#String-String - } - - /** - * Code snippets for {@link PageBlobAsyncClient#copyIncrementalWithResponse(String, String, RequestConditions)} - */ - public void copyIncrementalWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.copyIncrementalWithResponse#String-String-RequestConditions - final String snapshot = "copy snapshot"; - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfNoneMatch("snapshotMatch"); - - client.copyIncrementalWithResponse(url, snapshot, modifiedRequestConditions) - .subscribe(response -> { - CopyStatusType statusType = response.getValue(); - - switch (statusType) { - case SUCCESS: - System.out.println("Page blob copied successfully"); - break; - case FAILED: - System.out.println("Page blob copied failed"); - break; - case ABORTED: - System.out.println("Page blob copied aborted"); - break; - case PENDING: - System.out.println("Page blob copied pending"); - break; - default: - break; - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.copyIncrementalWithResponse#String-String-RequestConditions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#copyIncrementalWithResponse(PageBlobCopyIncrementalOptions)} - */ - public void copyIncrementalWithResponseCodeSnippet2() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.copyIncrementalWithResponse#PageBlobCopyIncrementalOptions - final String snapshot = "copy snapshot"; - PageBlobCopyIncrementalRequestConditions destinationRequestConditions = new PageBlobCopyIncrementalRequestConditions() - .setIfNoneMatch("snapshotMatch"); - - client.copyIncrementalWithResponse(new PageBlobCopyIncrementalOptions(url, snapshot) - .setRequestConditions(destinationRequestConditions)) - .subscribe(response -> { - CopyStatusType statusType = response.getValue(); - - switch (statusType) { - case SUCCESS: - System.out.println("Page blob copied successfully"); - break; - case FAILED: - System.out.println("Page blob copied failed"); - break; - case ABORTED: - System.out.println("Page blob copied aborted"); - break; - case PENDING: - System.out.println("Page blob copied pending"); - break; - default: - break; - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.copyIncrementalWithResponse#PageBlobCopyIncrementalOptions - } - - /** - * Code snippets for {@link PageBlobAsyncClient#createIfNotExists(long)} and - * {@link PageBlobAsyncClient#createIfNotExistsWithResponse(PageBlobCreateOptions)} - */ - public void createIfNotExistsCodeSnippet() { - // BEGIN: com.azure.storage.blob.PageBlobAsyncClient.createIfNotExists#long - client.createIfNotExists(size).subscribe(response -> - System.out.printf("Created page blob with sequence number %s%n", response.getBlobSequenceNumber())); - // END: com.azure.storage.blob.PageBlobAsyncClient.createIfNotExists#long - - // BEGIN: com.azure.storage.blob.specialized.PageBlobAsyncClient.createIfNotExistsWithResponse#PageBlobCreateOptions - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"); - - client.createIfNotExistsWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber) - .setHeaders(headers).setMetadata(metadata).setTags(tags)).subscribe(response -> { - if (response.getStatusCode() == 409) { - System.out.println("Already exists."); - } else { - System.out.println("successfully created."); - } - }); - // END: com.azure.storage.blob.specialized.PageBlobAsyncClient.createIfNotExistsWithResponse#PageBlobCreateOptions - } - -} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/PageBlobClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/PageBlobClientJavaDocCodeSnippets.java deleted file mode 100644 index 33e1cb664ffd..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/PageBlobClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,604 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.RequestConditions; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; -import com.azure.storage.blob.models.PageBlobCopyIncrementalRequestConditions; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.PageRangeItem; -import com.azure.storage.blob.options.ListPageRangesDiffOptions; -import com.azure.storage.blob.options.ListPageRangesOptions; -import com.azure.storage.blob.options.PageBlobCopyIncrementalOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.models.PageBlobRequestConditions; -import com.azure.storage.blob.models.PageList; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.models.SequenceNumberActionType; -import com.azure.storage.blob.options.PageBlobUploadPagesFromUrlOptions; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Collections; -import java.util.Map; - -/** - * Code snippets for {@link PageBlobClient} - */ -@SuppressWarnings("unused") -public class PageBlobClientJavaDocCodeSnippets { - private PageBlobClient client = new SpecializedBlobClientBuilder().buildPageBlobClient(); - private Map metadata = Collections.singletonMap("metadata", "value"); - private Map tags = Collections.singletonMap("tag", "value"); - private String leaseId = "leaseId"; - private Duration timeout = Duration.ofSeconds(30); - private long size = 1024; - private long sequenceNumber = 0; - private long sourceOffset = 0; - private long offset = 0; - private String key = "key"; - private String value = "value"; - private String data = "data"; - private String url = "https://sample.com"; - - /** - * Code snippets for {@link PageBlobClient#create(long)} - */ - public void createCodeSnippet() { - // BEGIN: com.azure.storage.blob.PageBlobClient.create#long - PageBlobItem pageBlob = client.create(size); - System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.PageBlobClient.create#long - } - - /** - * Code snippets for {@link PageBlobClient#create(long, boolean)} - */ - public void createWithOverwrite() { - // BEGIN: com.azure.storage.blob.PageBlobClient.create#long-boolean - boolean overwrite = false; // Default value - PageBlobItem pageBlob = client.create(size, overwrite); - System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.PageBlobClient.create#long-boolean - } - - /** - * Code snippets for {@link PageBlobClient#createWithResponse(long, Long, BlobHttpHeaders, Map, BlobRequestConditions, Duration, Context)} - */ - public void createWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.createWithResponse#long-Long-BlobHttpHeaders-Map-BlobRequestConditions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - Context context = new Context(key, value); - - PageBlobItem pageBlob = client - .createWithResponse(size, sequenceNumber, headers, metadata, blobRequestConditions, timeout, context) - .getValue(); - - System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.createWithResponse#long-Long-BlobHttpHeaders-Map-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#createWithResponse(PageBlobCreateOptions, Duration, Context)} - */ - public void createWithResponse2CodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.createWithResponse#PageBlobCreateOptions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - Context context = new Context(key, value); - - PageBlobItem pageBlob = client - .createWithResponse(new PageBlobCreateOptions(size).setSequenceNumber(sequenceNumber) - .setHeaders(headers).setMetadata(metadata).setTags(tags) - .setRequestConditions(blobRequestConditions), timeout, - context) - .getValue(); - - System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.createWithResponse#PageBlobCreateOptions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#uploadPages(PageRange, InputStream)} - */ - public void uploadPagesCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.uploadPages#PageRange-InputStream - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - - PageBlobItem pageBlob = client.uploadPages(pageRange, dataStream); - System.out.printf("Uploaded page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.uploadPages#PageRange-InputStream - } - - /** - * Code snippets for {@link PageBlobClient#uploadPagesWithResponse(PageRange, InputStream, byte[], - * PageBlobRequestConditions, Duration, Context)} - * - * @throws NoSuchAlgorithmException If Md5 calculation fails - */ - public void uploadPagesWithResponseCodeSnippet() throws NoSuchAlgorithmException { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.uploadPagesWithResponse#PageRange-InputStream-byte-PageBlobRequestConditions-Duration-Context - byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId); - Context context = new Context(key, value); - - PageBlobItem pageBlob = client - .uploadPagesWithResponse(pageRange, dataStream, md5, pageBlobRequestConditions, timeout, context).getValue(); - - System.out.printf("Uploaded page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.uploadPagesWithResponse#PageRange-InputStream-byte-PageBlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#uploadPagesFromUrl(PageRange, String, Long)} - */ - public void uploadPagesFromURLCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.uploadPagesFromUrl#PageRange-String-Long - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - - PageBlobItem pageBlob = client.uploadPagesFromUrl(pageRange, url, sourceOffset); - - System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.uploadPagesFromUrl#PageRange-String-Long - } - - /** - * Code snippets for {@link PageBlobClient#uploadPagesFromUrlWithResponse(PageRange, String, Long, byte[], - * PageBlobRequestConditions, BlobRequestConditions, Duration, Context)} - */ - public void uploadPagesFromUrlWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.uploadPagesFromUrlWithResponse#PageRange-String-Long-byte-PageBlobRequestConditions-BlobRequestConditions-Duration-Context - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - byte[] sourceContentMD5 = new byte[512]; - PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId); - BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context(key, value); - - PageBlobItem pageBlob = client - .uploadPagesFromUrlWithResponse(pageRange, url, sourceOffset, sourceContentMD5, pageBlobRequestConditions, - sourceRequestConditions, timeout, context).getValue(); - - System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.uploadPagesFromUrlWithResponse#PageRange-String-Long-byte-PageBlobRequestConditions-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#uploadPagesFromUrlWithResponse(PageRange, String, Long, byte[], - * PageBlobRequestConditions, BlobRequestConditions, Duration, Context)} - */ - public void uploadPagesFromUrlWithResponseOptionsBagCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.uploadPagesFromUrlWithResponse#PageBlobUploadPagesFromUrlOptions-Duration-Context - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - byte[] sourceContentMD5 = new byte[512]; - PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId); - BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() - .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); - Context context = new Context(key, value); - - PageBlobItem pageBlob = client - .uploadPagesFromUrlWithResponse(new PageBlobUploadPagesFromUrlOptions(pageRange, url) - .setSourceOffset(sourceOffset).setSourceContentMd5(sourceContentMD5) - .setDestinationRequestConditions(pageBlobRequestConditions) - .setSourceRequestConditions(sourceRequestConditions), timeout, context).getValue(); - - System.out.printf("Uploaded page blob from URL with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.uploadPagesFromUrlWithResponse#PageBlobUploadPagesFromUrlOptions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#clearPages(PageRange)} - */ - public void clearPagesCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.clearPages#PageRange - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - - PageBlobItem pageBlob = client.clearPages(pageRange); - - System.out.printf("Cleared page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.clearPages#PageRange - } - - /** - * Code snippets for {@link PageBlobClient#clearPagesWithResponse(PageRange, PageBlobRequestConditions, Duration, - * Context)} - */ - public void clearPagesWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.clearPagesWithResponse#PageRange-PageBlobRequestConditions-Duration-Context - PageRange pageRange = new PageRange() - .setStart(0) - .setEnd(511); - PageBlobRequestConditions pageBlobRequestConditions = new PageBlobRequestConditions().setLeaseId(leaseId); - Context context = new Context(key, value); - - PageBlobItem pageBlob = client - .clearPagesWithResponse(pageRange, pageBlobRequestConditions, timeout, context).getValue(); - - System.out.printf("Cleared page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.clearPagesWithResponse#PageRange-PageBlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#getPageRanges(BlobRange)} - */ - public void getPageRangesCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.getPageRanges#BlobRange - BlobRange blobRange = new BlobRange(offset); - PageList pageList = client.getPageRanges(blobRange); - - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : pageList.getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.getPageRanges#BlobRange - } - - /** - * Code snippets for {@link PageBlobClient#getPageRangesWithResponse(BlobRange, BlobRequestConditions, Duration, - * Context)} - */ - public void getPageRangesWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesWithResponse#BlobRange-BlobRequestConditions-Duration-Context - BlobRange blobRange = new BlobRange(offset); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - Context context = new Context(key, value); - - PageList pageList = client - .getPageRangesWithResponse(blobRange, blobRequestConditions, timeout, context).getValue(); - - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : pageList.getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesWithResponse#BlobRange-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#listPageRanges(ListPageRangesOptions, Duration, Context)} and - * {@link PageBlobClient#listPageRanges(BlobRange)}. - */ - public void listPageRangesCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.listPageRanges#BlobRange - BlobRange blobRange = new BlobRange(offset); - String prevSnapshot = "previous snapshot"; - PagedIterable iterable = client.listPageRanges(blobRange); - - for (PageRangeItem item : iterable) { - System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(), - item.getRange().getLength(), item.isClear()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.listPageRanges#BlobRange - - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesWithResponse#ListPageRangesOptions-Duration-Context - ListPageRangesOptions options = new ListPageRangesOptions(new BlobRange(offset)) - .setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId)) - .setMaxResultsPerPage(1000); - - Context context = new Context(key, value); - - PagedIterable iter = client - .listPageRanges(options, timeout, context); - - System.out.println("Valid Page Ranges are:"); - for (PageRangeItem item : iter) { - System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(), - item.getRange().getLength(), item.isClear()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesWithResponse#ListPageRangesOptions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#getPageRangesDiff(BlobRange, String)} - */ - public void getPageRangesDiffCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesDiff#BlobRange-String - BlobRange blobRange = new BlobRange(offset); - final String prevSnapshot = "previous snapshot"; - PageList pageList = client.getPageRangesDiff(blobRange, prevSnapshot); - - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : pageList.getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesDiff#BlobRange-String - } - - /** - * Code snippets for {@link PageBlobClient#getPageRangesDiffWithResponse(BlobRange, String, BlobRequestConditions, - * Duration, Context)} - */ - public void getPageRangesDiffWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesDiffWithResponse#BlobRange-String-BlobRequestConditions-Duration-Context - BlobRange blobRange = new BlobRange(offset); - final String prevSnapshot = "previous snapshot"; - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - Context context = new Context(key, value); - - PageList pageList = client - .getPageRangesDiffWithResponse(blobRange, prevSnapshot, blobRequestConditions, timeout, context).getValue(); - - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : pageList.getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesDiffWithResponse#BlobRange-String-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#listPageRangesDiff(ListPageRangesDiffOptions, Duration, Context)} and - * {@link PageBlobClient#listPageRangesDiff(BlobRange, String)} - */ - public void listPageRangesDiffCodeSnippets() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.listPageRangesDiff#BlobRange-String - BlobRange blobRange = new BlobRange(offset); - String prevSnapshot = "previous snapshot"; - PagedIterable iterable = client.listPageRangesDiff(blobRange, prevSnapshot); - - for (PageRangeItem item : iterable) { - System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(), - item.getRange().getLength(), item.isClear()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.listPageRangesDiff#BlobRange-String - - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesDiffWithResponse#ListPageRangesDiffOptions-Duration-Context - ListPageRangesDiffOptions options = new ListPageRangesDiffOptions(new BlobRange(offset), "previous snapshot") - .setRequestConditions(new BlobRequestConditions().setLeaseId(leaseId)) - .setMaxResultsPerPage(1000); - - Context context = new Context(key, value); - - PagedIterable iter = client - .listPageRangesDiff(options, timeout, context); - - System.out.println("Valid Page Ranges are:"); - for (PageRangeItem item : iter) { - System.out.printf("Offset: %s, Length: %s, isClear: %s%n", item.getRange().getOffset(), - item.getRange().getLength(), item.isClear()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.getPageRangesDiffWithResponse#ListPageRangesDiffOptions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#getManagedDiskPageRangesDiff(BlobRange, String)} - */ - public void getPageRangesDiffFromUrlCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.getManagedDiskPageRangesDiff#BlobRange-String - BlobRange blobRange = new BlobRange(offset); - final String prevSnapshotUrl = "previous snapshot url"; - PageList pageList = client.getPageRangesDiff(blobRange, prevSnapshotUrl); - - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : pageList.getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.getManagedDiskPageRangesDiff#BlobRange-String - } - - /** - * Code snippets for {@link PageBlobClient#getManagedDiskPageRangesDiffWithResponse(BlobRange, String, BlobRequestConditions, - * Duration, Context)} - */ - public void getPageRangesDiffFromUrlWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.getManagedDiskPageRangesDiffWithResponse#BlobRange-String-BlobRequestConditions-Duration-Context - BlobRange blobRange = new BlobRange(offset); - final String prevSnapshotUrl = "previous snapshot url"; - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - Context context = new Context(key, value); - - PageList pageList = client - .getPageRangesDiffWithResponse(blobRange, prevSnapshotUrl, blobRequestConditions, timeout, context).getValue(); - - System.out.println("Valid Page Ranges are:"); - for (PageRange pageRange : pageList.getPageRange()) { - System.out.printf("Start: %s, End: %s%n", pageRange.getStart(), pageRange.getEnd()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.getManagedDiskPageRangesDiffWithResponse#BlobRange-String-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#resize(long)} - */ - public void resizeCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.resize#long - PageBlobItem pageBlob = client.resize(size); - System.out.printf("Page blob resized with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.resize#long - } - - /** - * Code snippets for {@link PageBlobClient#resizeWithResponse(long, BlobRequestConditions, Duration, Context)} - */ - public void resizeWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.resizeWithResponse#long-BlobRequestConditions-Duration-Context - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - Context context = new Context(key, value); - - PageBlobItem pageBlob = client - .resizeWithResponse(size, blobRequestConditions, timeout, context).getValue(); - System.out.printf("Page blob resized with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.resizeWithResponse#long-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#updateSequenceNumber(SequenceNumberActionType, Long)} - */ - public void updateSequenceNumberCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.updateSequenceNumber#SequenceNumberActionType-Long - PageBlobItem pageBlob = client.updateSequenceNumber(SequenceNumberActionType.INCREMENT, size); - - System.out.printf("Page blob updated to sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.updateSequenceNumber#SequenceNumberActionType-Long - } - - /** - * Code snippets for {@link PageBlobClient#updateSequenceNumberWithResponse(SequenceNumberActionType, Long, - * BlobRequestConditions, Duration, Context)} - */ - public void updateSequenceNumberWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.updateSequenceNumberWithResponse#SequenceNumberActionType-Long-BlobRequestConditions-Duration-Context - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - Context context = new Context(key, value); - - PageBlobItem pageBlob = client.updateSequenceNumberWithResponse( - SequenceNumberActionType.INCREMENT, size, blobRequestConditions, timeout, context).getValue(); - - System.out.printf("Page blob updated to sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.specialized.PageBlobClient.updateSequenceNumberWithResponse#SequenceNumberActionType-Long-BlobRequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#copyIncremental(String, String)} - */ - public void copyIncrementalCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.copyIncremental#String-String - final String snapshot = "copy snapshot"; - CopyStatusType statusType = client.copyIncremental(url, snapshot); - - switch (statusType) { - case SUCCESS: - System.out.println("Page blob copied successfully"); - break; - case FAILED: - System.out.println("Page blob copied failed"); - break; - case ABORTED: - System.out.println("Page blob copied aborted"); - break; - case PENDING: - System.out.println("Page blob copied pending"); - break; - default: - break; - } - // END: com.azure.storage.blob.specialized.PageBlobClient.copyIncremental#String-String - } - - /** - * Code snippets for {@link PageBlobClient#copyIncrementalWithResponse(String, String, RequestConditions, - * Duration, Context)} - */ - public void copyIncrementalWithResponseCodeSnippet() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.copyIncrementalWithResponse#String-String-RequestConditions-Duration-Context - final String snapshot = "copy snapshot"; - RequestConditions modifiedRequestConditions = new RequestConditions() - .setIfNoneMatch("snapshotMatch"); - Context context = new Context(key, value); - - CopyStatusType statusType = client - .copyIncrementalWithResponse(url, snapshot, modifiedRequestConditions, timeout, context).getValue(); - - switch (statusType) { - case SUCCESS: - System.out.println("Page blob copied successfully"); - break; - case FAILED: - System.out.println("Page blob copied failed"); - break; - case ABORTED: - System.out.println("Page blob copied aborted"); - break; - case PENDING: - System.out.println("Page blob copied pending"); - break; - default: - break; - } - // END: com.azure.storage.blob.specialized.PageBlobClient.copyIncrementalWithResponse#String-String-RequestConditions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#copyIncrementalWithResponse(PageBlobCopyIncrementalOptions, - * Duration, Context)} - */ - public void copyIncrementalWithResponseCodeSnippet2() { - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.copyIncrementalWithResponse#PageBlobCopyIncrementalOptions-Duration-Context - final String snapshot = "copy snapshot"; - PageBlobCopyIncrementalRequestConditions destinationRequestConditions = new PageBlobCopyIncrementalRequestConditions() - .setIfNoneMatch("snapshotMatch"); - Context context = new Context(key, value); - - CopyStatusType statusType = client - .copyIncrementalWithResponse(new PageBlobCopyIncrementalOptions(url, snapshot) - .setRequestConditions(destinationRequestConditions), timeout, context).getValue(); - - switch (statusType) { - case SUCCESS: - System.out.println("Page blob copied successfully"); - break; - case FAILED: - System.out.println("Page blob copied failed"); - break; - case ABORTED: - System.out.println("Page blob copied aborted"); - break; - case PENDING: - System.out.println("Page blob copied pending"); - break; - default: - break; - } - // END: com.azure.storage.blob.specialized.PageBlobClient.copyIncrementalWithResponse#PageBlobCopyIncrementalOptions-Duration-Context - } - - /** - * Code snippets for {@link PageBlobClient#createIfNotExists(long)} and - * {@link PageBlobClient#createIfNotExistsWithResponse(PageBlobCreateOptions, Duration, Context)} - */ - public void createIfNotExistsCodeSnippet() { - // BEGIN: com.azure.storage.blob.PageBlobClient.createIfNotExists#long - PageBlobItem pageBlob = client.createIfNotExists(size); - System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber()); - // END: com.azure.storage.blob.PageBlobClient.createIfNotExists#long - - // BEGIN: com.azure.storage.blob.specialized.PageBlobClient.createIfNotExistsWithResponse#PageBlobCreateOptions-Duration-Context - BlobHttpHeaders headers = new BlobHttpHeaders() - .setContentLanguage("en-US") - .setContentType("binary"); - Context context = new Context(key, value); - - Response response = client.createIfNotExistsWithResponse(new PageBlobCreateOptions(size) - .setHeaders(headers).setMetadata(metadata).setTags(tags), timeout, context); - - if (response.getStatusCode() == 409) { - System.out.println("Already existed."); - } else { - System.out.printf("Create completed with status %d%n", response.getStatusCode()); - } - // END: com.azure.storage.blob.specialized.PageBlobClient.createIfNotExistsWithResponse#PageBlobCreateOptions-Duration-Context - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AccessPolicyAsyncTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AccessPolicyAsyncTests.java deleted file mode 100644 index 59269ee7018c..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AccessPolicyAsyncTests.java +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.BinaryData; -import com.azure.storage.blob.models.BlobAccessPolicy; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.PlaybackOnly; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class AccessPolicyAsyncTests extends BlobTestBase { - @Test - @PlaybackOnly - public void setAccessPolicyMinAccess() { - StepVerifier - .create(setAccessPolicySleepAsync(ccAsync, PublicAccessType.CONTAINER, null).then(ccAsync.getProperties())) - .assertNext(r -> assertEquals(PublicAccessType.CONTAINER, r.getBlobPublicAccess())) - .verifyComplete(); - } - - @Test - public void setAccessPolicyMinIds() { - BlobSignedIdentifier identifier = new BlobSignedIdentifier().setId("0000") - .setAccessPolicy(new BlobAccessPolicy() - .setStartsOn(testResourceNamer.now().atZoneSameInstant(ZoneId.of("UTC")).toOffsetDateTime()) - .setExpiresOn( - testResourceNamer.now().atZoneSameInstant(ZoneId.of("UTC")).toOffsetDateTime().plusDays(1)) - .setPermissions("r")); - - List ids = Collections.singletonList(identifier); - - StepVerifier.create(setAccessPolicySleepAsync(ccAsync, null, ids).then(ccAsync.getAccessPolicy())) - .assertNext(r -> assertEquals("0000", r.getIdentifiers().get(0).getId())) - .verifyComplete(); - } - - @Test - public void setAccessPolicyError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - - StepVerifier.create(ccAsync.setAccessPolicy(null, null)).verifyError(BlobStorageException.class); - } - - @Test - @PlaybackOnly - public void getAccessPolicy() { - BlobSignedIdentifier identifier = new BlobSignedIdentifier().setId("0000") - .setAccessPolicy(new BlobAccessPolicy().setStartsOn(testResourceNamer.now()) - .setExpiresOn(testResourceNamer.now().plusDays(1)) - .setPermissions("r")); - List ids = Collections.singletonList(identifier); - - StepVerifier.create(setAccessPolicySleepAsync(ccAsync, PublicAccessType.BLOB, ids) - .then(ccAsync.getAccessPolicyWithResponse(null))).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(PublicAccessType.BLOB, r.getValue().getBlobAccessType()); - assertTrue(validateBasicHeaders(r.getHeaders())); - assertEquals(identifier.getAccessPolicy().getExpiresOn(), - r.getValue().getIdentifiers().get(0).getAccessPolicy().getExpiresOn()); - assertEquals(identifier.getAccessPolicy().getStartsOn(), - r.getValue().getIdentifiers().get(0).getAccessPolicy().getStartsOn()); - assertEquals(identifier.getAccessPolicy().getPermissions(), - r.getValue().getIdentifiers().get(0).getAccessPolicy().getPermissions()); - }).verifyComplete(); - } - - @Test - public void containerSasIdentifierAndPermissions() { - BlobSignedIdentifier identifier = new BlobSignedIdentifier().setId("0000") - .setAccessPolicy( - new BlobAccessPolicy().setPermissions("racwdl").setExpiresOn(testResourceNamer.now().plusDays(1))); - - // Check containerSASPermissions - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setListPermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - if (Constants.SAS_SERVICE_VERSION.compareTo("2019-12-12") >= 0) { - permissions.setDeleteVersionPermission(true).setFilterPermission(true); - } - if (Constants.SAS_SERVICE_VERSION.compareTo("2020-06-12") >= 0) { - permissions.setImmutabilityPolicyPermission(true); - } - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(identifier.getId()); - String sasWithId = ccAsync.generateSas(sasValues); - BlobContainerAsyncClient client1 = getContainerAsyncClient(sasWithId, ccAsync.getBlobContainerUrl()); - StepVerifier - .create(setAccessPolicySleepAsync(ccAsync, null, Arrays.asList(identifier)).thenMany(client1.listBlobs())) - .thenConsumeWhile(r -> true) - .verifyComplete(); - - sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sasWithPermissions = ccAsync.generateSas(sasValues); - BlobContainerAsyncClient client2 = getContainerAsyncClient(sasWithPermissions, ccAsync.getBlobContainerUrl()); - StepVerifier.create(client2.listBlobs()).thenConsumeWhile(r -> true).verifyComplete(); - } - - //service async - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void sasSanitization(boolean unsanitize) { - String identifier = "id with spaces"; - String blobName = generateBlobName(); - - List ids = Collections.singletonList(new BlobSignedIdentifier().setId(identifier) - .setAccessPolicy( - new BlobAccessPolicy().setPermissions("racwdl").setExpiresOn(testResourceNamer.now().plusDays(1)))); - - String sas = ccAsync.generateSas(new BlobServiceSasSignatureValues(identifier)); - if (unsanitize) { - sas = sas.replace("%20", " "); - } - - String finalSas = sas; - Mono response = setAccessPolicySleepAsync(ccAsync, null, ids) - .then(ccAsync.getBlobAsyncClient(blobName).upload(BinaryData.fromBytes("test".getBytes()))) - .flatMap(r -> { - BlobContainerAsyncClient client1 = instrument( - new BlobContainerClientBuilder().endpoint(ccAsync.getBlobContainerUrl() + "?" + finalSas)) - .buildAsyncClient(); - return client1.getBlobAsyncClient(blobName).downloadContent(); - }); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - - String connectionString = "AccountName=" + BlobUrlParts.parse(ccAsync.getAccountUrl()).getAccountName() - + ";SharedAccessSignature=" + sas; - BlobContainerAsyncClient client2 - = instrument(new BlobContainerClientBuilder().connectionString(connectionString) - .containerName(ccAsync.getBlobContainerName())).buildAsyncClient(); - StepVerifier.create(client2.getBlobAsyncClient(blobName).downloadContent()).expectNextCount(1).verifyComplete(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AccessPolicyTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AccessPolicyTests.java deleted file mode 100644 index c8c334f305a1..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AccessPolicyTests.java +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import com.azure.storage.blob.models.BlobAccessPolicy; -import com.azure.storage.blob.models.BlobContainerAccessPolicies; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.PlaybackOnly; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; - -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class AccessPolicyTests extends BlobTestBase { - //ContainerApiTests - @Test - @PlaybackOnly - public void setAccessPolicyMinAccess() { - setAccessPolicySleep(cc, PublicAccessType.CONTAINER, null); - assertEquals(PublicAccessType.CONTAINER, cc.getProperties().getBlobPublicAccess()); - } - - @Test - public void setAccessPolicyMinIds() { - BlobSignedIdentifier identifier = new BlobSignedIdentifier().setId("0000") - .setAccessPolicy(new BlobAccessPolicy() - .setStartsOn(testResourceNamer.now().atZoneSameInstant(ZoneId.of("UTC")).toOffsetDateTime()) - .setExpiresOn( - testResourceNamer.now().atZoneSameInstant(ZoneId.of("UTC")).toOffsetDateTime().plusDays(1)) - .setPermissions("r")); - - List ids = Collections.singletonList(identifier); - - setAccessPolicySleep(cc, null, ids); - - assertEquals("0000", cc.getAccessPolicy().getIdentifiers().get(0).getId()); - } - - @Test - public void setAccessPolicyError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> cc.setAccessPolicy(null, null)); - } - - @Test - @PlaybackOnly - public void getAccessPolicy() { - BlobSignedIdentifier identifier = new BlobSignedIdentifier().setId("0000") - .setAccessPolicy(new BlobAccessPolicy().setStartsOn(testResourceNamer.now()) - .setExpiresOn(testResourceNamer.now().plusDays(1)) - .setPermissions("r")); - List ids = Collections.singletonList(identifier); - setAccessPolicySleep(cc, PublicAccessType.BLOB, ids); - Response response = cc.getAccessPolicyWithResponse(null, null, null); - - assertResponseStatusCode(response, 200); - assertEquals(PublicAccessType.BLOB, response.getValue().getBlobAccessType()); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertEquals(identifier.getAccessPolicy().getExpiresOn(), - response.getValue().getIdentifiers().get(0).getAccessPolicy().getExpiresOn()); - assertEquals(identifier.getAccessPolicy().getStartsOn(), - response.getValue().getIdentifiers().get(0).getAccessPolicy().getStartsOn()); - assertEquals(identifier.getAccessPolicy().getPermissions(), - response.getValue().getIdentifiers().get(0).getAccessPolicy().getPermissions()); - } - - //ServiceApiTests - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void sasSanitization(boolean unsanitize) { - String identifier = "id with spaces"; - String blobName = generateBlobName(); - setAccessPolicySleep(cc, null, Collections.singletonList(new BlobSignedIdentifier().setId(identifier) - .setAccessPolicy( - new BlobAccessPolicy().setPermissions("racwdl").setExpiresOn(testResourceNamer.now().plusDays(1))))); - cc.getBlobClient(blobName).upload(BinaryData.fromBytes("test".getBytes())); - String sas = cc.generateSas(new BlobServiceSasSignatureValues(identifier)); - if (unsanitize) { - sas = sas.replace("%20", " "); - } - - // - - // when: "Endpoint with SAS built in, works as expected" - String finalSas = sas; - assertDoesNotThrow( - () -> instrument(new BlobContainerClientBuilder().endpoint(cc.getBlobContainerUrl() + "?" + finalSas)) - .buildClient() - .getBlobClient(blobName) - .downloadContent()); - - String connectionString = "AccountName=" + BlobUrlParts.parse(cc.getAccountUrl()).getAccountName() - + ";SharedAccessSignature=" + sas; - assertDoesNotThrow(() -> instrument(new BlobContainerClientBuilder().connectionString(connectionString) - .containerName(cc.getBlobContainerName())).buildClient().getBlobClient(blobName).downloadContent()); - } - - //sasClientTests - @Test - public void containerSasIdentifierAndPermissions() { - BlobSignedIdentifier identifier = new BlobSignedIdentifier().setId("0000") - .setAccessPolicy( - new BlobAccessPolicy().setPermissions("racwdl").setExpiresOn(testResourceNamer.now().plusDays(1))); - setAccessPolicySleep(cc, null, Arrays.asList(identifier)); - - // Check containerSASPermissions - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setListPermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - if (Constants.SAS_SERVICE_VERSION.compareTo("2019-12-12") >= 0) { - permissions.setDeleteVersionPermission(true).setFilterPermission(true); - } - if (Constants.SAS_SERVICE_VERSION.compareTo("2020-06-12") >= 0) { - permissions.setImmutabilityPolicyPermission(true); - } - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(identifier.getId()); - String sasWithId = cc.generateSas(sasValues); - BlobContainerClient client1 = getContainerClient(sasWithId, cc.getBlobContainerUrl()); - assertDoesNotThrow(() -> client1.listBlobs().iterator().hasNext()); - - sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sasWithPermissions = cc.generateSas(sasValues); - BlobContainerClient client2 = getContainerClient(sasWithPermissions, cc.getBlobContainerUrl()); - assertDoesNotThrow(() -> client2.listBlobs().iterator().hasNext()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AzuriteTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AzuriteTests.java deleted file mode 100644 index 37ec30e767fd..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/AzuriteTests.java +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.specialized.BlobClientBase; -import com.azure.storage.blob.specialized.BlobLeaseClient; -import com.azure.storage.blob.specialized.BlobLeaseClientBuilder; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.StorageSharedKeyCredential; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class AzuriteTests extends BlobTestBase { - private static final String[] AZURITE_ENDPOINTS = new String[] { - "https://127.0.0.1:10000/devstoreaccount1", - "https://azure-storage-emulator-azurite:10000/devstoreaccount1" }; - - /* - The credential information for Azurite is static and documented in numerous locations, therefore it is okay to - have this "secret" written into public code. - */ - private static final StorageSharedKeyCredential AZURITE_CREDENTIAL = new StorageSharedKeyCredential( - "devstoreaccount1", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="); - - private static String getAzuriteBlobConnectionString(String azuriteEndpoint) { - return "DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=" - + azuriteEndpoint + ";"; - } - - private BlobServiceClient getAzuriteServiceClient(String azuriteEndpoint) { - BlobServiceClientBuilder builder - = new BlobServiceClientBuilder().endpoint(azuriteEndpoint).credential(AZURITE_CREDENTIAL); - - instrument(builder); - - return builder.buildClient(); - } - - private static void validateBlobClient(BlobClientBase client, String blobUrl) { - assertEquals(client.getAccountName(), "devstoreaccount1"); - assertEquals(client.getContainerName(), "container"); - assertEquals(client.getBlobName(), "blob"); - assertEquals(client.getBlobUrl(), blobUrl); - } - - @ParameterizedTest - @MethodSource("azuriteURLParserSupplier") - public void azuriteURLParser(String endpoint, String scheme, String host, String accountName, - String blobContainerName, String blobName, String expectedUrl) throws MalformedURLException { - BlobUrlParts parts = BlobUrlParts.parse(new URL(endpoint)); - - assertEquals(parts.getScheme(), scheme); - assertEquals(parts.getHost(), host); - assertEquals(parts.getAccountName(), accountName); - assertEquals(parts.getBlobContainerName(), blobContainerName); - assertEquals(parts.getBlobName(), blobName); - assertEquals(parts.toUrl().toString(), expectedUrl); - } - - private static Stream azuriteURLParserSupplier() { - return Stream.of( - Arguments.of("http://127.0.0.1:10000/devstoreaccount1", "http", "127.0.0.1:10000", "devstoreaccount1", null, - null, "http://127.0.0.1:10000/devstoreaccount1"), - Arguments.of("http://127.0.0.1:10000/devstoreaccount1/container", "http", "127.0.0.1:10000", - "devstoreaccount1", "container", null, "http://127.0.0.1:10000/devstoreaccount1/container"), - Arguments.of("http://127.0.0.1:10000/devstoreaccount1/container/blob", "http", "127.0.0.1:10000", - "devstoreaccount1", "container", "blob", "http://127.0.0.1:10000/devstoreaccount1/container/blob"), - Arguments.of("http://localhost:10000/devstoreaccount1", "http", "localhost:10000", "devstoreaccount1", null, - null, "http://localhost:10000/devstoreaccount1"), - Arguments.of("http://localhost:10000/devstoreaccount1/container", "http", "localhost:10000", - "devstoreaccount1", "container", null, "http://localhost:10000/devstoreaccount1/container"), - Arguments.of("http://localhost:10000/devstoreaccount1/container/blob", "http", "localhost:10000", - "devstoreaccount1", "container", "blob", "http://localhost:10000/devstoreaccount1/container/blob"), - Arguments.of("http://localhost:10000/devstoreaccount1/container/path/to]a blob", "http", "localhost:10000", - "devstoreaccount1", "container", "path/to]a blob", - "http://localhost:10000/devstoreaccount1/container/path%2Fto%5Da%20blob"), - Arguments.of("http://localhost:10000/devstoreaccount1/container/path%2Fto%5Da%20blob", "http", - "localhost:10000", "devstoreaccount1", "container", "path/to]a blob", - "http://localhost:10000/devstoreaccount1/container/path%2Fto%5Da%20blob"), - Arguments.of("http://localhost:10000/devstoreaccount1/container/斑點", "http", "localhost:10000", - "devstoreaccount1", "container", "斑點", - "http://localhost:10000/devstoreaccount1/container/%E6%96%91%E9%BB%9E"), - Arguments.of("http://localhost:10000/devstoreaccount1/container/%E6%96%91%E9%BB%9E", "http", - "localhost:10000", "devstoreaccount1", "container", "斑點", - "http://localhost:10000/devstoreaccount1/container/%E6%96%91%E9%BB%9E"), - Arguments.of("http://azure-storage-emulator-azurite:10000/devstoreaccount1", "http", - "azure-storage-emulator-azurite:10000", "devstoreaccount1", null, null, - "http://azure-storage-emulator-azurite:10000/devstoreaccount1"), - Arguments.of("http://azure-storage-emulator-azurite:10000/devstoreaccount1/container", "http", - "azure-storage-emulator-azurite:10000", "devstoreaccount1", "container", null, - "http://azure-storage-emulator-azurite:10000/devstoreaccount1/container"), - Arguments.of("http://azure-storage-emulator-azurite:10000/devstoreaccount1/container/blob", "http", - "azure-storage-emulator-azurite:10000", "devstoreaccount1", "container", "blob", - "http://azure-storage-emulator-azurite:10000/devstoreaccount1/container/blob")); - - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void useDevelopmentStorageTrue(int index) { - String originalUseDevelopmentStorage = System.getProperty("UseDevelopmentStorage"); - System.setProperty("UseDevelopmentStorage", "true"); - - BlobServiceClient serviceClient - = new BlobServiceClientBuilder().connectionString(getAzuriteBlobConnectionString(AZURITE_ENDPOINTS[index])) - .httpClient(getHttpClient()) - .buildClient(); - - assertEquals(serviceClient.getAccountUrl(), AZURITE_ENDPOINTS[index]); - assertEquals(serviceClient.getAccountName(), "devstoreaccount1"); - - // cleanup: - if (originalUseDevelopmentStorage != null) { - System.setProperty("UseDevelopmentStorage", originalUseDevelopmentStorage); - } else { - System.clearProperty("UseDevelopmentStorage"); - } - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLConstructingServiceClient(int index) { - BlobServiceClient serviceClient = getAzuriteServiceClient(AZURITE_ENDPOINTS[index]); - - assertEquals(serviceClient.getAccountUrl(), AZURITE_ENDPOINTS[index]); - assertEquals(serviceClient.getAccountName(), "devstoreaccount1"); - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLGetContainerClient(int index) { - BlobContainerClient containerClient - = getAzuriteServiceClient(AZURITE_ENDPOINTS[index]).getBlobContainerClient("container"); - - assertEquals(containerClient.getAccountName(), "devstoreaccount1"); - assertEquals(containerClient.getBlobContainerName(), "container"); - assertEquals(containerClient.getBlobContainerUrl(), AZURITE_ENDPOINTS[index] + "/container"); - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLConstructContainerClient(int index) { - BlobContainerClient containerClient - = new BlobContainerClientBuilder().endpoint(AZURITE_ENDPOINTS[index] + "/container") - .credential(AZURITE_CREDENTIAL) - .httpClient(getHttpClient()) - .buildClient(); - - assertEquals(containerClient.getAccountName(), "devstoreaccount1"); - assertEquals(containerClient.getBlobContainerName(), "container"); - assertEquals(containerClient.getBlobContainerUrl(), AZURITE_ENDPOINTS[index] + "/container"); - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLConstructContainerClientWithDefaultAzureCredential(int index) { - BlobContainerClient containerClient - = new BlobContainerClientBuilder().endpoint(AZURITE_ENDPOINTS[index] + "/container") - .credential(new DefaultAzureCredentialBuilder().build()) - .httpClient(getHttpClient()) - .buildClient(); - - assertEquals(containerClient.getAccountName(), "devstoreaccount1"); - assertEquals(containerClient.getBlobContainerName(), "container"); - assertEquals(containerClient.getBlobContainerUrl(), AZURITE_ENDPOINTS[index] + "/container"); - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLGetBlobClient(int index) { - BlobClient blobClient = getAzuriteServiceClient(AZURITE_ENDPOINTS[index]).getBlobContainerClient("container") - .getBlobClient("blob"); - - validateBlobClient(blobClient, AZURITE_ENDPOINTS[index] + "/container/blob"); - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLConstructBlobClient(int index) { - BlobClient blobClient = new BlobClientBuilder().endpoint(AZURITE_ENDPOINTS[index] + "/container/blob") - .credential(AZURITE_CREDENTIAL) - .httpClient(getHttpClient()) - .buildClient(); - - validateBlobClient(blobClient, AZURITE_ENDPOINTS[index] + "/container/blob"); - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLConstructBlobClientDefaultAzureCredential(int index) { - BlobClient blobClient = new BlobClientBuilder().endpoint(AZURITE_ENDPOINTS[index] + "/container/blob") - .credential(new DefaultAzureCredentialBuilder().build()) - .httpClient(getHttpClient()) - .buildClient(); - - validateBlobClient(blobClient, AZURITE_ENDPOINTS[index] + "/container/blob"); - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLGetSpecializedClients(int index) { - BlobClient blobClient = getAzuriteServiceClient(AZURITE_ENDPOINTS[index]).getBlobContainerClient("container") - .getBlobClient("blob"); - - validateBlobClient(blobClient.getAppendBlobClient(), AZURITE_ENDPOINTS[index] + "/container/blob"); - validateBlobClient(blobClient.getBlockBlobClient(), AZURITE_ENDPOINTS[index] + "/container/blob"); - validateBlobClient(blobClient.getPageBlobClient(), AZURITE_ENDPOINTS[index] + "/container/blob"); - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLConstructSpecializedClient(int index) { - SpecializedBlobClientBuilder specializedClientBuilder - = new SpecializedBlobClientBuilder().endpoint(AZURITE_ENDPOINTS[index] + "/container/blob") - .credential(AZURITE_CREDENTIAL) - .httpClient(getHttpClient()); - - validateBlobClient(specializedClientBuilder.buildAppendBlobClient(), - AZURITE_ENDPOINTS[index] + "/container/blob"); - validateBlobClient(specializedClientBuilder.buildBlockBlobClient(), - AZURITE_ENDPOINTS[index] + "/container/blob"); - validateBlobClient(specializedClientBuilder.buildPageBlobClient(), - AZURITE_ENDPOINTS[index] + "/container/blob"); - } - - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void azuriteURLGetLeaseClient(int index) { - BlobContainerClient containerClient - = getAzuriteServiceClient(AZURITE_ENDPOINTS[index]).getBlobContainerClient("container"); - BlobClient blobClient = containerClient.getBlobClient("blob"); - - BlobLeaseClient containerLeaseClient - = new BlobLeaseClientBuilder().containerClient(containerClient).buildClient(); - - assertEquals(containerLeaseClient.getAccountName(), "devstoreaccount1"); - assertEquals(containerLeaseClient.getResourceUrl(), AZURITE_ENDPOINTS[index] + "/container"); - - BlobLeaseClient blobLeaseClient = new BlobLeaseClientBuilder().blobClient(blobClient).buildClient(); - - assertEquals(blobLeaseClient.getAccountName(), "devstoreaccount1"); - assertEquals(blobLeaseClient.getResourceUrl(), AZURITE_ENDPOINTS[index] + "/container/blob"); - } - - @Disabled("Enable once the April 2023 release of azure-core-http-netty happens") - @Test - public void uploadEmptyFile() throws IOException { - String containerName = generateContainerName(); - BlobServiceClient serviceClient - = getServiceClient(AZURITE_CREDENTIAL, "http://127.0.0.1:10000/devstoreaccount1"); - BlobClient blobClient = serviceClient.createBlobContainer(containerName).getBlobClient(generateBlobName()); - File file = getRandomFile(0); - file.deleteOnExit(); - - assertDoesNotThrow(() -> blobClient.uploadFromFile(file.toPath().toString(), true)); - - // cleanup: - serviceClient.deleteBlobContainer(containerName); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobApiTests.java deleted file mode 100644 index 586a84c29255..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobApiTests.java +++ /dev/null @@ -1,3075 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.RequestConditions; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.rest.Response; -import com.azure.core.test.TestMode; -import com.azure.core.test.utils.MockTokenCredential; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.HttpClientOptions; -import com.azure.core.util.ProgressListener; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.ArchiveStatus; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobCopySourceTagsMode; -import com.azure.storage.blob.models.BlobDownloadContentResponse; -import com.azure.storage.blob.models.BlobDownloadHeaders; -import com.azure.storage.blob.models.BlobDownloadResponse; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.Block; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import com.azure.storage.blob.models.ObjectReplicationPolicy; -import com.azure.storage.blob.models.ObjectReplicationStatus; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.SyncCopyStatusType; -import com.azure.storage.blob.options.BlobBeginCopyOptions; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.options.BlobDownloadToFileOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.BlobSetAccessTierOptions; -import com.azure.storage.blob.options.BlobSetTagsOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlobClientBase; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.test.shared.TestDataFactory; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.PlaybackOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import com.azure.storage.common.test.shared.policy.MockFailureResponsePolicy; -import com.azure.storage.common.test.shared.policy.MockRetryRangeResponsePolicy; -import com.azure.storage.common.test.shared.policy.TransientFailureInjectingHttpPipelinePolicy; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Hooks; -import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.UncheckedIOException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.Files; -import java.nio.file.OpenOption; -import java.nio.file.StandardOpenOption; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.Duration; -import java.time.LocalDate; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BlobApiTests extends BlobTestBase { - private BlobClient bc; - private final List createdFiles = new ArrayList<>(); - - @BeforeEach - public void setup() { - String blobName = generateBlobName(); - bc = cc.getBlobClient(blobName); - bc.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - } - - @AfterEach - public void cleanup() { - createdFiles.forEach(File::delete); - } - - @Test - public void uploadInputStreamMinOverwriteFails() { - assertThrows(BlobStorageException.class, () -> bc.upload(DATA.getDefaultInputStream())); - } - - @Test - public void uploadInputStreamOverwriteFails() { - assertThrows(BlobStorageException.class, - () -> bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize())); - } - - @Test - public void uploadBinaryDataOverwriteFails() { - assertThrows(BlobStorageException.class, () -> bc.upload(DATA.getDefaultBinaryData())); - } - - @Test - public void uploadInputStreamOverwrite() { - byte[] randomData = getRandomByteArray(Constants.KB); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - bc.upload(input, Constants.KB, true); - - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - bc.downloadStreamWithResponse(stream, null, null, null, false, null, null); - TestUtils.assertArraysEqual(stream.toByteArray(), randomData); - } - - @Test - public void uploadBinaryDataOverwrite() { - byte[] randomData = getRandomByteArray(Constants.KB); - - bc.upload(BinaryData.fromBytes(randomData), true); - - BinaryData blobContent = bc.downloadContent(); - TestUtils.assertArraysEqual(blobContent.toBytes(), randomData); - } - - /* Tests an issue found where buffered upload would not deep copy buffers while determining what upload path to - take. */ - @ParameterizedTest - @ValueSource( - ints = { - Constants.KB, /* Less than copyToOutputStream buffer size, Less than maxSingleUploadSize */ - 8 * Constants.KB, /* Equal to copyToOutputStream buffer size, Less than maxSingleUploadSize */ - 20 * Constants.KB }) /* Greater than copyToOutputStream buffer size, Less than maxSingleUploadSize */ - public void uploadInputStreamSingleUpload() { - byte[] randomData = getRandomByteArray(20 * Constants.KB); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - bc.upload(input, 20 * Constants.KB, true); - - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - bc.downloadStreamWithResponse(stream, null, null, null, false, null, null); - TestUtils.assertArraysEqual(stream.toByteArray(), randomData); - } - - /* TODO (gapra): Add more tests to test large data sizes. */ - - @SuppressWarnings("deprecation") - @LiveOnly - @Test - public void uploadInputStreamLargeData() { - byte[] randomData = getRandomByteArray(20 * Constants.MB); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - ParallelTransferOptions pto = new ParallelTransferOptions().setMaxSingleUploadSizeLong((long) Constants.MB); - - // Uses blob output stream under the hood. - assertDoesNotThrow( - () -> bc.uploadWithResponse(input, 20 * Constants.MB, pto, null, null, null, null, null, null)); - } - - @Test - public void uploadIncorrectSize() { - int[] dataSizes = new int[] { DATA.getDefaultDataSize() + 1, DATA.getDefaultDataSize() - 1 }; - for (int dataSize : dataSizes) { - assertThrows(IllegalStateException.class, () -> bc.upload(DATA.getDefaultInputStream(), dataSize, true)); - } - } - - @SuppressWarnings("deprecation") - @LiveOnly - @ParameterizedTest - @MethodSource("uploadNumBlocksSupplier") - public void uploadNumBlocks(int size, Long maxUploadSize, long numBlocks) { - byte[] randomData = getRandomByteArray(size); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - ParallelTransferOptions pto - = new ParallelTransferOptions().setBlockSizeLong(maxUploadSize).setMaxSingleUploadSizeLong(maxUploadSize); - - bc.uploadWithResponse(input, size, pto, null, null, null, null, null, null); - - List blocksUploaded = bc.getBlockBlobClient().listBlocks(BlockListType.ALL).getCommittedBlocks(); - assertEquals(blocksUploaded.size(), numBlocks); - } - - private static Stream uploadNumBlocksSupplier() { - return Stream.of(Arguments.of(0, null, 0), Arguments.of(Constants.KB, null, 0), // default is MAX_UPLOAD_BYTES - Arguments.of(Constants.MB, null, 0), // default is MAX_UPLOAD_BYTES - Arguments.of(3 * Constants.MB, (long) Constants.MB, 3)); - } - - @Test - public void uploadReturnValue() { - assertNotNull(bc.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()), null, null) - .getValue() - .getETag()); - } - - @Test - public void uploadReturnValueBinaryData() { - assertNotNull(bc.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultBinaryData()), null, null) - .getValue() - .getETag()); - } - - @Test - public void uploadInputStreamMin() { - bc = cc.getBlobClient(generateBlobName()); - assertDoesNotThrow(() -> bc.upload(DATA.getDefaultInputStream())); - TestUtils.assertArraysEqual(bc.downloadContent().toBytes(), DATA.getDefaultBytes()); - } - - @SuppressWarnings("deprecation") - @Test - public void uploadInputStreamNoLengthOverwrite() { - byte[] randomData = getRandomByteArray(Constants.KB); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - bc.upload(input, true); - - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - bc.downloadWithResponse(stream, null, null, null, false, null, null); - TestUtils.assertArraysEqual(stream.toByteArray(), randomData); - } - - @Test - public void uploadInputStreamNoLength() { - assertDoesNotThrow( - () -> bc.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()), null, null)); - TestUtils.assertArraysEqual(bc.downloadContent().toBytes(), DATA.getDefaultBytes()); - } - - @SuppressWarnings("deprecation") - @Test - public void uploadInputStreamBadLength() { - long[] badLengths = { 0, -100, DATA.getDefaultDataSize() - 1, DATA.getDefaultDataSize() + 1 }; - for (long length : badLengths) { - assertThrows(Exception.class, () -> bc - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream(), length), null, null)); - } - } - - @Test - public void uploadSuccessfulRetry() { - BlobClient clientWithFailure = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), bc.getBlobUrl(), - new TransientFailureInjectingHttpPipelinePolicy()); - - assertNotNull(clientWithFailure); - clientWithFailure.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()), null, null); - TestUtils.assertArraysEqual(bc.downloadContent().toBytes(), DATA.getDefaultBytes()); - } - - @SuppressWarnings("deprecation") - @LiveOnly - @Test - // Reading from recordings will not allow for the timing of the test to work correctly. - public void uploadTimeout() { - int size = 1024; - byte[] randomData = getRandomByteArray(size); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - assertThrows(IllegalStateException.class, - () -> bc.uploadWithResponse(input, size, null, null, null, null, null, Duration.ofNanos(5L), null)); - } - - @SuppressWarnings("deprecation") - @LiveOnly - @Test - public void uploadFailWithSmallTimeoutsForServiceClient() { - // setting very small timeout values for the service client - liveTestScenarioWithRetry(() -> { - HttpClientOptions clientOptions = new HttpClientOptions().setApplicationId("client-options-id") - .setResponseTimeout(Duration.ofNanos(1)) - .setReadTimeout(Duration.ofNanos(1)) - .setWriteTimeout(Duration.ofNanos(1)) - .setConnectTimeout(Duration.ofNanos(1)); - - BlobServiceClientBuilder clientBuilder - = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .retryOptions(new RequestRetryOptions(null, 1, (Integer) null, null, null, null)) - .clientOptions(clientOptions); - - BlobServiceClient serviceClient = clientBuilder.buildClient(); - - int size = 1024; - byte[] randomData = getRandomByteArray(size); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - BlobContainerClient blobContainer = serviceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainer.getBlobClient(generateBlobName()); - // test whether failure occurs due to small timeout intervals set on the service client - assertThrows(RuntimeException.class, () -> blobClient.uploadWithResponse(input, size, null, null, null, - null, null, Duration.ofSeconds(10), null)); - }); - - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void uploadStreamAccessTierCold() { - byte[] randomData = getRandomByteArray(Constants.KB); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - BlobParallelUploadOptions blobUploadOptions = new BlobParallelUploadOptions(input).setTier(AccessTier.COLD); - - bc.uploadWithResponse(blobUploadOptions, null, null); - BlobProperties properties = bc.getProperties(); - assertEquals(AccessTier.COLD, properties.getAccessTier()); - } - - @LiveOnly - @Test - public void uploadAndDownloadAndUploadAgain() { - byte[] randomData = getRandomByteArray(20 * Constants.MB); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - String blobName = generateBlobName(); - BlobClient blobClient = cc.getBlobClient(blobName); - - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong((long) Constants.MB) - .setMaxSingleUploadSizeLong(2L * Constants.MB) - .setMaxConcurrency(5); - BlobParallelUploadOptions parallelUploadOptions - = new BlobParallelUploadOptions(input).setParallelTransferOptions(parallelTransferOptions); - - blobClient.uploadWithResponse(parallelUploadOptions, null, null); - - InputStream inputStream = blobClient.openInputStream(); - - // Upload the downloaded content to a different location - String blobName2 = generateBlobName(); - - parallelUploadOptions - = new BlobParallelUploadOptions(inputStream).setParallelTransferOptions(parallelTransferOptions); - - BlobClient blobClient2 = cc.getBlobClient(blobName2); - blobClient2.uploadWithResponse(parallelUploadOptions, null, null); - } - - @SuppressWarnings("deprecation") - @LiveOnly - @Test - public void uploadAndDownloadAndUploadAgainWithSize() { - byte[] randomData = getRandomByteArray(20 * Constants.MB); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - String blobName = generateBlobName(); - BlobClient blobClient = cc.getBlobClient(blobName); - - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong((long) Constants.MB) - .setMaxSingleUploadSizeLong(2L * Constants.MB) - .setMaxConcurrency(5); - BlobParallelUploadOptions parallelUploadOptions - = new BlobParallelUploadOptions(input).setParallelTransferOptions(parallelTransferOptions); - - blobClient.uploadWithResponse(parallelUploadOptions, null, null); - - InputStream inputStream = blobClient.openInputStream(); - - // Upload the downloaded content to a different location - String blobName2 = generateBlobName(); - - parallelUploadOptions = new BlobParallelUploadOptions(inputStream, 20 * Constants.MB) - .setParallelTransferOptions(parallelTransferOptions); - - BlobClient blobClient2 = cc.getBlobClient(blobName2); - blobClient2.uploadWithResponse(parallelUploadOptions, null, null); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void downloadAllNull() { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - bc.setTags(Collections.singletonMap("foo", "bar")); - BlobDownloadResponse response = bc.downloadWithResponse(stream, null, null, null, false, null, null); - ByteBuffer body = ByteBuffer.wrap(stream.toByteArray()); - BlobDownloadHeaders headers = response.getDeserializedHeaders(); - - assertEquals(DATA.getDefaultData(), body); - assertTrue(CoreUtils.isNullOrEmpty(headers.getMetadata())); - assertEquals(1, headers.getTagCount()); - assertNotNull(headers.getContentLength()); - assertNotNull(headers.getContentType()); - assertNull(headers.getContentRange()); - assertNotNull(headers.getContentMd5()); - assertNull(headers.getContentEncoding()); - assertNull(headers.getCacheControl()); - assertNull(headers.getContentDisposition()); - assertNull(headers.getContentLanguage()); - assertNull(headers.getBlobSequenceNumber()); - assertEquals(BlobType.BLOCK_BLOB, headers.getBlobType()); - assertNull(headers.getCopyCompletionTime()); - assertNull(headers.getCopyStatusDescription()); - assertNull(headers.getCopyId()); - assertNull(headers.getCopyProgress()); - assertNull(headers.getCopySource()); - assertNull(headers.getCopyStatus()); - assertNull(headers.getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, headers.getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, headers.getLeaseStatus()); - assertEquals("bytes", headers.getAcceptRanges()); - assertNull(headers.getBlobCommittedBlockCount()); - assertNotNull(headers.isServerEncrypted()); - assertNull(headers.getBlobContentMD5()); - assertNotNull(headers.getCreationTime()); - // headers.getLastAccessedTime() /* TODO (gapra): re-enable when last access time enabled. */ - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void downloadAllNullStreaming() { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - bc.setTags(Collections.singletonMap("foo", "bar")); - BlobDownloadResponse response = bc.downloadStreamWithResponse(stream, null, null, null, false, null, null); - ByteBuffer body = ByteBuffer.wrap(stream.toByteArray()); - BlobDownloadHeaders headers = response.getDeserializedHeaders(); - - assertEquals(DATA.getDefaultData(), body); - assertTrue(CoreUtils.isNullOrEmpty(headers.getMetadata())); - assertEquals(1, headers.getTagCount()); - assertNotNull(headers.getContentLength()); - assertNotNull(headers.getContentType()); - assertNull(headers.getContentRange()); - assertNotNull(headers.getContentMd5()); - assertNull(headers.getContentEncoding()); - assertNull(headers.getCacheControl()); - assertNull(headers.getContentDisposition()); - assertNull(headers.getContentLanguage()); - assertNull(headers.getBlobSequenceNumber()); - assertEquals(BlobType.BLOCK_BLOB, headers.getBlobType()); - assertNull(headers.getCopyCompletionTime()); - assertNull(headers.getCopyStatusDescription()); - assertNull(headers.getCopyId()); - assertNull(headers.getCopyProgress()); - assertNull(headers.getCopySource()); - assertNull(headers.getCopyStatus()); - assertNull(headers.getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, headers.getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, headers.getLeaseStatus()); - assertEquals("bytes", headers.getAcceptRanges()); - assertNull(headers.getBlobCommittedBlockCount()); - assertNotNull(headers.isServerEncrypted()); - assertNull(headers.getBlobContentMD5()); - // headers.getLastAccessedTime() /* TODO (gapra): re-enable when last access time enabled. */ - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void downloadAllNullBinaryData() { - bc.setTags(Collections.singletonMap("foo", "bar")); - BlobDownloadContentResponse response = bc.downloadContentWithResponse(null, null, null, null); - BinaryData body = response.getValue(); - BlobDownloadHeaders headers = response.getDeserializedHeaders(); - - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), body.toBytes()); - assertTrue(CoreUtils.isNullOrEmpty(headers.getMetadata())); - assertEquals(1, headers.getTagCount()); - assertNotNull(headers.getContentLength()); - assertNotNull(headers.getContentType()); - assertNull(headers.getContentRange()); - assertNotNull(headers.getContentMd5()); - assertNull(headers.getContentEncoding()); - assertNull(headers.getCacheControl()); - assertNull(headers.getContentDisposition()); - assertNull(headers.getContentLanguage()); - assertNull(headers.getBlobSequenceNumber()); - assertEquals(BlobType.BLOCK_BLOB, headers.getBlobType()); - assertNull(headers.getCopyCompletionTime()); - assertNull(headers.getCopyStatusDescription()); - assertNull(headers.getCopyId()); - assertNull(headers.getCopyProgress()); - assertNull(headers.getCopySource()); - assertNull(headers.getCopyStatus()); - assertNull(headers.getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, headers.getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, headers.getLeaseStatus()); - assertEquals("bytes", headers.getAcceptRanges()); - assertNull(headers.getBlobCommittedBlockCount()); - assertNotNull(headers.isServerEncrypted()); - assertNull(headers.getBlobContentMD5()); - // headers.getLastAccessedTime() /* TODO (gapra): re-enable when last access time enabled. */ - } - - @Test - public void downloadEmptyFile() { - AppendBlobClient bc = cc.getBlobClient("emptyAppendBlob").getAppendBlobClient(); - bc.create(); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - bc.downloadStream(outStream); - byte[] result = outStream.toByteArray(); - assertEquals(0, result.length); - } - - /* - This is to test the appropriate integration of DownloadResponse, including setting the correct range values on - HttpGetterInfo. - */ - - @Test - public void downloadWithRetryRange() { - /* - We are going to make a request for some range on a blob. The output returned will throw an exception, forcing - a retry per the DownloadRetryOptions. The next request should have the same range header, which was generated - from the count and offset values in HttpGetterInfo that was constructed on the initial call to download. We - don't need to check the data here, but we want to ensure that the correct range is set each time. This will - test the correction of a bug that was found which caused HttpGetterInfo to have an incorrect offset when it was - constructed in BlobClient.download(). - */ - BlobClient bu2 = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), bc.getBlobUrl(), - new MockRetryRangeResponsePolicy("bytes=2-6")); - - BlobRange range = new BlobRange(2, 5L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(3); - RuntimeException e = assertThrows(RuntimeException.class, - () -> bu2.downloadStreamWithResponse(new ByteArrayOutputStream(), range, options, null, false, null, null)); - - /* - Because the dummy output always throws an error. This will also validate that an IllegalArgumentException is - NOT thrown because the types would not match. - */ - assertInstanceOf(IOException.class, e.getCause()); - } - - @SuppressWarnings("deprecation") - @Test - public void downloadMin() { - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - bc.download(outStream); - byte[] result = outStream.toByteArray(); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), result); - } - - @Test - public void downloadStreamingMin() { - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - bc.downloadStream(outStream); - byte[] result = outStream.toByteArray(); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), result); - } - - @Test - public void downloadBinaryDataMin() { - BinaryData result = bc.downloadContent(); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), result.toBytes()); - } - - @ParameterizedTest - @MethodSource("downloadRangeSupplier") - public void downloadRange(long offset, Long count, String expectedData) { - BlobRange range = (count == null) ? new BlobRange(offset) : new BlobRange(offset, count); - - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - bc.downloadStreamWithResponse(outStream, range, null, null, false, null, null); - String bodyStr = outStream.toString(); - assertEquals(expectedData, bodyStr); - } - - private static Stream downloadRangeSupplier() { - return Stream.of(Arguments.of(0, null, DATA.getDefaultText()), - Arguments.of(0, 5L, DATA.getDefaultText().substring(0, 5)), - Arguments.of(3, 2L, DATA.getDefaultText().substring(3, 3 + 2))); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void downloadAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - BlobDownloadResponse response - = bc.downloadStreamWithResponse(new ByteArrayOutputStream(), null, null, bac, false, null, null); - assertResponseStatusCode(response, 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void downloadACStreaming(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - BlobDownloadResponse response - = bc.downloadStreamWithResponse(new ByteArrayOutputStream(), null, null, bac, false, null, null); - assertResponseStatusCode(response, 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void downloadACBinaryData(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - BlobDownloadContentResponse response = bc.downloadContentWithResponse(null, bac, null, null); - assertResponseStatusCode(response, 200); - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void downloadACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.downloadWithResponse(new ByteArrayOutputStream(), null, null, bac, false, null, null)); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void downloadACFailStreaming(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.downloadStreamWithResponse(new ByteArrayOutputStream(), null, null, bac, false, null, null)); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void downloadACFailBinaryData(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - assertThrows(BlobStorageException.class, () -> bc.downloadContentWithResponse(null, bac, null, null)); - } - - @Test - public void downloadMd5() throws NoSuchAlgorithmException { - BlobDownloadResponse response = bc.downloadStreamWithResponse(new ByteArrayOutputStream(), new BlobRange(0, 3L), - null, null, true, null, null); - byte[] contentMD5 = response.getDeserializedHeaders().getContentMd5(); - TestUtils.assertArraysEqual( - MessageDigest.getInstance("MD5").digest(DATA.getDefaultText().substring(0, 3).getBytes()), contentMD5); - } - - @Test - public void downloadRetryDefault() { - BlobClient failureBlobClient = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), bc.getBlobUrl(), - new MockFailureResponsePolicy(5)); - - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - failureBlobClient.downloadStream(outStream); - String bodyStr = outStream.toString(); - assertEquals(DATA.getDefaultText(), bodyStr); - } - - @Test - public void downloadError() { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(NullPointerException.class, () -> bc.downloadStream(null)); - } - - @Test - public void downloadSnapshot() { - ByteArrayOutputStream originalStream = new ByteArrayOutputStream(); - bc.downloadStream(originalStream); - - BlobClientBase bc2 = bc.createSnapshot(); - new SpecializedBlobClientBuilder().blobClient(bc) - .buildBlockBlobClient() - .upload(new ByteArrayInputStream("ABC".getBytes()), 3, true); - - ByteArrayOutputStream snapshotStream = new ByteArrayOutputStream(); - bc2.downloadStream(snapshotStream); - TestUtils.assertArraysEqual(originalStream.toByteArray(), snapshotStream.toByteArray()); - } - - @Test - public void downloadSnapshotBinaryData() { - BinaryData originalContent = bc.downloadContent(); - - BlobClientBase bc2 = bc.createSnapshot(); - new SpecializedBlobClientBuilder().blobClient(bc) - .buildBlockBlobClient() - .upload(new ByteArrayInputStream("ABC".getBytes()), 3, true); - - BinaryData snapshotContent = bc2.downloadContent(); - TestUtils.assertArraysEqual(originalContent.toBytes(), snapshotContent.toBytes()); - } - - @Test - public void downloadToFileExists() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (!testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - // Default Overwrite is false so this should fail - UncheckedIOException e = assertThrows(UncheckedIOException.class, () -> bc.downloadToFile(testFile.getPath())); - assertInstanceOf(FileAlreadyExistsException.class, e.getCause()); - // cleanup: - testFile.delete(); - } - - @Test - public void downloadToFileExistsSucceeds() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (!testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - bc.downloadToFile(testFile.getPath(), true); - assertEquals(DATA.getDefaultText(), new String(Files.readAllBytes(testFile.toPath()), StandardCharsets.UTF_8)); - - // cleanup: - testFile.delete(); - } - - @Test - public void downloadToFileDoesNotExist() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - bc.downloadToFile(testFile.getPath()); - assertEquals(DATA.getDefaultText(), new String(Files.readAllBytes(testFile.toPath()), StandardCharsets.UTF_8)); - // cleanup: - testFile.delete(); - } - - @Test - public void downloadFileDoesNotExistOpenOptions() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - Set openOptions = new HashSet<>(); - openOptions.add(StandardOpenOption.CREATE_NEW); - openOptions.add(StandardOpenOption.READ); - openOptions.add(StandardOpenOption.WRITE); - bc.downloadToFileWithResponse(testFile.getPath(), null, null, null, null, false, openOptions, null, null); - - assertEquals(DATA.getDefaultText(), new String(Files.readAllBytes(testFile.toPath()), StandardCharsets.UTF_8)); - - // cleanup: - testFile.delete(); - } - - @Test - public void downloadFileExistOpenOptions() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (!testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - Set openOptions = new HashSet<>(); - openOptions.add(StandardOpenOption.CREATE); - openOptions.add(StandardOpenOption.TRUNCATE_EXISTING); - openOptions.add(StandardOpenOption.READ); - openOptions.add(StandardOpenOption.WRITE); - bc.downloadToFileWithResponse(testFile.getPath(), null, null, null, null, false, openOptions, null, null); - - assertEquals(DATA.getDefaultText(), new String(Files.readAllBytes(testFile.toPath()), StandardCharsets.UTF_8)); - - // cleanup: - testFile.delete(); - } - - @LiveOnly - @ParameterizedTest - @ValueSource( - ints = { - 0, // empty file - 20, // small file - 16 * 1024 * 1024, // medium file in several chunks - 8 * 1026 * 1024 + 10, // medium file not aligned to block - 50 * Constants.MB // large file requiring multiple requests - }) - public void downloadFile(int fileSize) throws IOException { - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - - File outFile = new File(prefix + ".txt"); - createdFiles.add(outFile); - outFile.deleteOnExit(); - Files.deleteIfExists(outFile.toPath()); - - BlobProperties properties = bc - .downloadToFileWithResponse(outFile.toPath().toString(), null, - new ParallelTransferOptions().setBlockSizeLong(4L * 1024 * 1024), null, null, false, null, null) - .getValue(); - - assertTrue(compareFiles(file, outFile, 0, fileSize)); - assertEquals(properties.getBlobType(), BlobType.BLOCK_BLOB); - assertNotNull(properties.getCreationTime()); - } - - /* - * Tests downloading a file using a default client that doesn't have a HttpClient passed to it. - */ - @LiveOnly - @ParameterizedTest - @ValueSource( - ints = { - 0, // empty file - 20, // small file - 16 * 1024 * 1024, // medium file in several chunks - 8 * 1026 * 1024 + 10, // medium file not aligned to block - 50 * Constants.MB // large file requiring multiple requests - }) - public void downloadFileSyncBufferCopy(int fileSize) throws IOException { - String containerName = generateContainerName(); - BlobServiceClient blobServiceClient - = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .buildClient(); - - BlobClient blobClient = blobServiceClient.createBlobContainer(containerName).getBlobClient(generateBlobName()); - - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - blobClient.uploadFromFile(file.toPath().toString(), true); - File outFile = new File(prefix + ".txt"); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - BlobProperties properties = blobClient - .downloadToFileWithResponse(outFile.toPath().toString(), null, - new ParallelTransferOptions().setBlockSizeLong(4L * 1024 * 1024), null, null, false, null, null) - .getValue(); - - assertTrue(compareFiles(file, outFile, 0, fileSize)); - assertEquals(properties.getBlobType(), BlobType.BLOCK_BLOB); - - // cleanup: - blobServiceClient.deleteBlobContainer(containerName); - } - - @LiveOnly - @ParameterizedTest - @MethodSource("downloadFileRangeSupplier") - public void downloadFileRange(BlobRange range) throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - File outFile = new File(generateBlobName()); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - bc.downloadToFileWithResponse(outFile.toPath().toString(), range, null, null, null, false, null, null); - - assertTrue(compareFiles(file, outFile, range.getOffset(), range.getCount())); - } - - private static Stream downloadFileRangeSupplier() { - /* - The last case is to test a range much larger than the size of the file to ensure we don't accidentally - send off parallel requests with invalid ranges. - */ - return Stream.of(Arguments.of(new BlobRange(0, DATA.getDefaultDataSizeLong())), // Exact count - Arguments.of(new BlobRange(1, DATA.getDefaultDataSizeLong() - 1)), // Offset and exact count - Arguments.of(new BlobRange(3, 2L)), // Narrow range in middle - Arguments.of(new BlobRange(0, DATA.getDefaultDataSizeLong() - 1)), // Count less than total - Arguments.of(new BlobRange(0, 10L * 1024))); // Count much larger than remaining data - } - - /* - This is to exercise some additional corner cases and ensure there are no arithmetic errors that give false success. - */ - - @LiveOnly - @Test - public void downloadFileRangeFail() throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - File outFile = new File(prefix); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - assertThrows(BlobStorageException.class, () -> bc.downloadToFileWithResponse(outFile.toPath().toString(), - new BlobRange(DATA.getDefaultDataSize() + 1), null, null, null, false, null, null)); - - } - - @LiveOnly - @Test - public void downloadFileCountNull() throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - File outFile = new File(generateBlobName()); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - bc.downloadToFileWithResponse(outFile.toPath().toString(), new BlobRange(0), null, null, null, false, null, - null); - - assertTrue(compareFiles(file, outFile, 0, DATA.getDefaultDataSize())); - - } - - @LiveOnly - @ParameterizedTest - @MethodSource("downloadFileACSupplier") - public void downloadFileAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID) throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - File outFile = new File(prefix); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bro = new BlobRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setLeaseId(leaseID); - - assertDoesNotThrow( - () -> bc.downloadToFileWithResponse(outFile.toPath().toString(), null, null, null, bro, false, null, null)); - } - - private static Stream downloadFileACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), Arguments.of(OLD_DATE, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null), Arguments.of(null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID)); - } - - @LiveOnly - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#fileACFailSupplier") - public void downloadFileACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID) throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - File outFile = new File(prefix); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bro = new BlobRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setLeaseId(leaseID); - - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> bc.downloadToFileWithResponse(outFile.toPath().toString(), null, null, null, bro, false, null, null)); - assertTrue(e.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET - || e.getErrorCode() == BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION); - } - - @LiveOnly - @Test - public void downloadFileETagLock() throws IOException { - File file = getRandomFile(Constants.MB); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - - File outFile = new File(prefix); - outFile.deleteOnExit(); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - AtomicInteger counter = new AtomicInteger(); - - BlockBlobClient bcUploading = instrument(new BlobClientBuilder().endpoint(bc.getBlobUrl()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential())).buildClient().getBlockBlobClient(); - TestDataFactory dataLocal = DATA; - HttpPipelinePolicy policy = (context, next) -> next.process().doOnNext(r -> { - if (counter.incrementAndGet() == 1) { - /* - * When the download begins trigger an upload to overwrite the downloading blob - * so that the download is able to get an ETag before it is changed. - */ - Mono.fromCallable( - () -> bcUploading.upload(dataLocal.getDefaultInputStream(), dataLocal.getDefaultDataSize(), true)) - .subscribeOn(Schedulers.boundedElastic()) - .thenReturn(r) - .subscribe(); - } - Mono.just(r); - }); - BlockBlobClient bcDownloading = instrument(new BlobClientBuilder().addPolicy(policy) - .endpoint(bc.getBlobUrl()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential())).buildClient().getBlockBlobClient(); - - /* - * Setup the download to happen in small chunks so many requests need to be sent, this will give the upload time - * to change the ETag therefore failing the download. - */ - ParallelTransferOptions options = new ParallelTransferOptions().setBlockSizeLong((long) Constants.KB); - - /* - * This is done to prevent onErrorDropped exceptions from being logged at the error level. If no hook is - * registered for onErrorDropped the error is logged at the ERROR level. - * - * onErrorDropped is triggered once the reactive stream has emitted one element, after that exceptions are - * dropped. - */ - Hooks.onErrorDropped(ignored -> /* do nothing with it */ { - }); - - //sometimes returns a composite exception, so this block handles that - assertThrows(BlobStorageException.class, () -> { - try { - bcDownloading.downloadToFileWithResponse(outFile.toPath().toString(), null, options, null, null, false, - null, null); - } catch (Exception e) { - Throwable cause = e; - while (cause != null) { - if (cause instanceof BlobStorageException - && ((BlobStorageException) cause).getStatusCode() == 412) { - throw cause; - } - cause = cause.getCause(); - } - throw e; - } - }); - - // Give the file a chance to be deleted by the download operation before verifying its deletion - sleepIfRunningAgainstService(500); - assertFalse(outFile.exists()); - } - - @SuppressWarnings("deprecation") - @LiveOnly - @ParameterizedTest - @ValueSource(ints = { 100, 8 * 1026 * 1024 + 10 }) - public void downloadFileProgressReceiver(int fileSize) throws IOException { - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - File outFile = new File(prefix); - outFile.deleteOnExit(); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - MockReceiver mockReceiver = new MockReceiver(); - - bc.downloadToFileWithResponse(outFile.toPath().toString(), null, - new ParallelTransferOptions().setProgressReceiver(mockReceiver), - new DownloadRetryOptions().setMaxRetryRequests(3), null, false, null, null); - - /* - * Should receive at least one notification indicating completed progress, multiple notifications may be - * received if there are empty buffers in the stream. - */ - assertTrue(mockReceiver.progresses.stream().anyMatch(progress -> progress == fileSize)); - - // There should be NO notification with a larger than expected size. - assertFalse(mockReceiver.progresses.stream().anyMatch(progress -> progress > fileSize)); - - /* - We should receive at least one notification reporting an intermediary value per block, but possibly more - notifications will be received depending on the implementation. We specify numBlocks - 1 because the last block - will be the total size as above. Finally, we assert that the number reported monotonically increases. - */ - long prevCount = -1; - for (long progress : mockReceiver.progresses) { - assertTrue(progress >= prevCount, "Reported progress should monotonically increase"); - prevCount = progress; - } - } - - @SuppressWarnings("deprecation") - private static final class MockReceiver implements ProgressReceiver { - List progresses = new ArrayList<>(); - - @Override - public void reportProgress(long bytesTransferred) { - progresses.add(bytesTransferred); - } - } - - @LiveOnly - @ParameterizedTest - @ValueSource(ints = { 100, 8 * 1026 * 1024 + 10 }) - public void downloadFileProgressListener(int fileSize) throws Exception { - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - - File outFile = new File(prefix); - outFile.deleteOnExit(); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - MockProgressListener mockListener = new MockProgressListener(); - - bc.downloadToFileWithResponse(outFile.toPath().toString(), null, - new ParallelTransferOptions().setProgressListener(mockListener), - new DownloadRetryOptions().setMaxRetryRequests(3), null, false, null, null); - - /* - * Should receive at least one notification indicating completed progress, multiple notifications may be - * received if there are empty buffers in the stream. - */ - assertTrue(mockListener.progresses.stream().anyMatch(progress -> progress == fileSize)); - - // There should be NO notification with a larger than expected size. - assertFalse(mockListener.progresses.stream().anyMatch(progress -> progress > fileSize)); - - // We should receive at least one notification reporting an intermediary value per block, but possibly more - // notifications will be received depending on the implementation. We specify numBlocks - 1 because the last - // block will be the total size as above. Finally, we assert that the number reported monotonically increases. - long prevCount = -1; - for (long progress : mockListener.progresses) { - assertTrue(progress >= prevCount, "Reported progress should monotonically increase"); - prevCount = progress; - } - } - - private static final class MockProgressListener implements ProgressListener { - List progresses = new ArrayList<>(); - - @Override - public void handleProgress(long progress) { - progresses.add(progress); - } - } - - @Disabled("Very large data sizes.") - @ParameterizedTest - @MethodSource("downloadToFileBlockSizeSupplier") - /* Enable once we have ability to run large resource heavy tests in CI. */ - public void downloadToFileBlockSize(int sizeOfData, long downloadBlockSize) throws IOException { - File file = getRandomFile(sizeOfData); - file.deleteOnExit(); - createdFiles.add(file); - - bc.uploadFromFile(file.toPath().toString(), true); - File outFile = new File(prefix); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - assertDoesNotThrow( - () -> bc.downloadToFileWithResponse(new BlobDownloadToFileOptions(outFile.toPath().toString()) - .setParallelTransferOptions( - new com.azure.storage.common.ParallelTransferOptions().setBlockSizeLong(downloadBlockSize)) - .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(3)), null, null)); - } - - private static Stream downloadToFileBlockSizeSupplier() { - return Stream.of( - /* This was the default before. */ - Arguments.of(5000L * Constants.MB, 5000L * Constants.MB), - /* Trying to see if we can set it to a number greater than previous default. */ - Arguments.of(6000L * Constants.MB, 6000L * Constants.MB), - /* Testing chunking with a large size */ - Arguments.of(6000L * Constants.MB, 5100L * Constants.MB)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getPropertiesDefault() { - bc.setTags(Collections.singletonMap("foo", "bar")); - Response response = bc.getPropertiesWithResponse(null, null, null); - HttpHeaders headers = response.getHeaders(); - BlobProperties properties = response.getValue(); - - assertTrue(validateBasicHeaders(headers)); - assertTrue(CoreUtils.isNullOrEmpty(properties.getMetadata())); - assertEquals(properties.getBlobType(), BlobType.BLOCK_BLOB); - assertNull(properties.getCopyCompletionTime()); // tested in "copy" - assertNull(properties.getCopyStatusDescription()); // only returned when the service has errors; cannot validate - assertNull(properties.getCopyId()); // tested in "abort copy" - assertNull(properties.getCopyProgress()); // tested in "copy" - assertNull(properties.getCopySource()); // tested in "copy" - assertNull(properties.getCopyStatus()); // tested in "copy" - assertNull(properties.isIncrementalCopy()); // tested in PageBlob."start incremental copy" - assertNull(properties.getCopyDestinationSnapshot()); // tested in PageBlob."start incremental copy" - assertNull(properties.getLeaseDuration()); // tested in "acquire lease" - assertEquals(properties.getLeaseState(), LeaseStateType.AVAILABLE); - assertEquals(properties.getLeaseStatus(), LeaseStatusType.UNLOCKED); - assertTrue(properties.getBlobSize() >= 0); - assertNotNull(properties.getContentType()); - assertNotNull(properties.getContentMd5()); - assertNull(properties.getContentEncoding()); // tested in "set HTTP headers" - assertNull(properties.getContentDisposition()); // tested in "set HTTP headers" - assertNull(properties.getContentLanguage()); // tested in "set HTTP headers" - assertNull(properties.getCacheControl()); // tested in "set HTTP headers" - assertNull(properties.getBlobSequenceNumber()); // tested in PageBlob."create sequence number" - assertEquals(headers.getValue(HttpHeaderName.ACCEPT_RANGES), "bytes"); - assertNull(properties.getCommittedBlockCount()); // tested in AppendBlob."append block" - assertTrue(properties.isServerEncrypted()); - assertEquals(properties.getAccessTier(), AccessTier.HOT); - assertTrue(properties.isAccessTierInferred()); - assertNull(properties.getArchiveStatus()); // tested in "set tier" - assertNotNull(properties.getCreationTime()); - assertEquals(properties.getTagCount(), 1); - assertNull(properties.getRehydratePriority()); // tested in setTier rehydrate priority - assertNull(properties.isSealed()); // tested in AppendBlob. "seal blob" - assertNotNull(properties.getRequestId()); - // properties.getLastAccessedTime() /* TODO: re-enable when last access time enabled. */ - } - - @Test - public void getPropertiesMin() { - assertResponseStatusCode(bc.getPropertiesWithResponse(null, null, null), 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void getPropertiesAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(setupBlobMatchCondition(bc, match)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(bc.getPropertiesWithResponse(bac, null, null), 200); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void getPropertiesACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> bc.getPropertiesWithResponse(bac, null, null)); - } - - /* - This test requires two accounts that are configured in a very specific way. It is not feasible to setup that - relationship programmatically, so we have recorded a successful interaction and only test recordings. - */ - - @SuppressWarnings("deprecation") - @PlaybackOnly - @Test - public void getPropertiesORS() { - BlobClient sourceBlob = primaryBlobServiceClient.getBlobContainerClient("test1") - .getBlobClient("javablobgetpropertiesors2blobapitestgetpropertiesors57d93407b"); - BlobClient destBlob = alternateBlobServiceClient.getBlobContainerClient("test2") - .getBlobClient("javablobgetpropertiesors2blobapitestgetpropertiesors57d93407b"); - - BlobProperties sourceProperties = sourceBlob.getProperties(); - BlobDownloadResponse sourceDownloadHeaders - = sourceBlob.downloadWithResponse(new ByteArrayOutputStream(), null, null, null, false, null, null); - BlobProperties destProperties = destBlob.getProperties(); - BlobDownloadResponse destDownloadHeaders - = destBlob.downloadWithResponse(new ByteArrayOutputStream(), null, null, null, false, null, null); - - assertTrue(validateOR(sourceProperties.getObjectReplicationSourcePolicies())); - validateOR(sourceDownloadHeaders.getDeserializedHeaders().getObjectReplicationSourcePolicies()); - - // There is a sas token attached at the end. Only check that the path is the same. - // disable recording copy source URL since the URL is redacted in playback mode - assertNotNull(destProperties.getCopySource()); - assertEquals(destProperties.getObjectReplicationDestinationPolicyId(), "fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80"); - assertEquals(destDownloadHeaders.getDeserializedHeaders().getObjectReplicationDestinationPolicyId(), - "fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80"); - } - - private static boolean validateOR(List policies) { - return policies.stream() - .filter(policy -> "fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80".equals(policy.getPolicyId())) - .findFirst() - .get() - .getRules() - .stream() - .filter(rule -> "105f9aad-f39b-4064-8e47-ccd7937295ca".equals(rule.getRuleId())) - .findFirst() - .get() - .getStatus() == ObjectReplicationStatus.COMPLETE; - } - - // Test getting the properties from a listing - - @Test - public void getPropertiesError() { - bc = cc.getBlobClient(generateBlobName()); - BlobStorageException ex = assertThrows(BlobStorageException.class, () -> bc.getProperties()); - assertTrue(ex.getMessage().contains("BlobNotFound")); - } - - @Test - public void setHTTPHeadersNull() { - Response response = bc.setHttpHeadersWithResponse(null, null, null, null); - - assertResponseStatusCode(response, 200); - assertTrue(validateBasicHeaders(response.getHeaders())); - } - - @Test - public void setHTTPHeadersMin() throws NoSuchAlgorithmException { - BlobProperties properties = bc.getProperties(); - BlobHttpHeaders headers = new BlobHttpHeaders().setContentEncoding(properties.getContentEncoding()) - .setContentDisposition(properties.getContentDisposition()) - .setContentType("type") - .setCacheControl(properties.getCacheControl()) - .setContentLanguage(properties.getContentLanguage()) - .setContentMd5(Base64.getEncoder().encode(MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()))); - - bc.setHttpHeaders(headers); - assertEquals("type", bc.getProperties().getContentType()); - } - - @ParameterizedTest - @MethodSource("setHTTPHeadersHeadersSupplier") - public void setHTTPHeadersHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - BlobHttpHeaders putHeaders = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - bc.setHttpHeaders(putHeaders); - - assertTrue(validateBlobProperties(bc.getPropertiesWithResponse(null, null, null), cacheControl, - contentDisposition, contentEncoding, contentLanguage, contentMD5, contentType)); - } - - private static Stream setHTTPHeadersHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of("control", "disposition", "encoding", "language", - Base64.getEncoder().encode(MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes())), "type")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void setHTTPHeadersAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(bc.setHttpHeadersWithResponse(null, bac, null, null), 200); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void setHTTPHeadersACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> bc.setHttpHeadersWithResponse(null, bac, null, null)); - } - - @Test - public void setHTTPHeadersError() { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(BlobStorageException.class, () -> bc.setHttpHeaders(null)); - } - - @Test - public void setMetadataAllNull() { - Response response = bc.setMetadataWithResponse(null, null, null, null); - assertEquals(0, bc.getProperties().getMetadata().size()); - assertResponseStatusCode(response, 200); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertTrue(Boolean.parseBoolean(response.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - } - - @Test - public void setMetadataMin() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - bc.setMetadata(metadata); - assertEquals(metadata, bc.getProperties().getMetadata()); - } - - @ParameterizedTest - @MethodSource("setMetadataMetadataSupplier") - public void setMetadataMetadata(String key1, String value1, String key2, String value2, int statusCode) { - Map metadata = new HashMap<>(); - if (key1 != null && value1 != null) { - metadata.put(key1, value1); - } - if (key2 != null && value2 != null) { - metadata.put(key2, value2); - } - - assertResponseStatusCode(bc.setMetadataWithResponse(metadata, null, null, null), statusCode); - assertEquals(metadata, bc.getProperties().getMetadata()); - } - - private static Stream setMetadataMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null, 200), Arguments.of("foo", "bar", "fizz", "buzz", 200), - Arguments.of("i0", "a", "i_", "a", 200), /* Test culture sensitive word sort */ - Arguments.of("foo", "bar0, bar1", null, null, 200)); /* Test comma separated values */ - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("downloadFileACSupplier") - public void setMetadataAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - assertResponseStatusCode(bc.setMetadataWithResponse(null, bac, null, null), 200); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void setMetadataACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> bc.setMetadataWithResponse(null, bac, null, null)); - } - - @ParameterizedTest - @MethodSource("setMetadataWhitespaceErrorSupplier") - public void setMetadataWhitespaceError(String key, String value) { - Map metadata = new HashMap<>(); - metadata.put(key, value); - - assertThrows(Exception.class, () -> bc.setMetadata(metadata)); - // Need this second error type since for the first case, Netty throws IllegalArgumentException, and that is - // recorded in the playback file. On Playback, the framework will throw Exceptions.ReactiveException. - //assertTrue(e instanceof IllegalArgumentException || e instanceof Exceptions.ReactiveException); - } - - private static Stream setMetadataWhitespaceErrorSupplier() { - return Stream.of(Arguments.of(" foo", "bar"), // Leading whitespace key - Arguments.of("foo ", "bar"), // Trailing whitespace key - Arguments.of("foo", " bar"), // Leading whitespace value - Arguments.of("foo", "bar ")); // Trailing whitespace value - } - - @Test - public void setMetadataError() { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(BlobStorageException.class, () -> bc.setMetadata(null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTagsAllNull() { - Response response = bc.setTagsWithResponse(new BlobSetTagsOptions(new HashMap<>()), null, null); - assertEquals(0, bc.getTags().size()); - assertResponseStatusCode(response, 204); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTagsMin() { - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - bc.setTags(tags); - assertEquals(tags, bc.getTags()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("setTagsTagsSupplier") - public void setTagsTags(String key1, String value1, String key2, String value2, int statusCode) { - Map tags = new HashMap<>(); - if (key1 != null && value1 != null) { - tags.put(key1, value1); - } - if (key2 != null && value2 != null) { - tags.put(key2, value2); - } - - assertResponseStatusCode(bc.setTagsWithResponse(new BlobSetTagsOptions(tags), null, null), statusCode); - assertEquals(tags, bc.getTags()); - } - - private static Stream setTagsTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null, 204), Arguments.of("foo", "bar", "fizz", "buzz", 204), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null, 204)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("setTagsACSupplier") - public void setTagsAC(String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - t = new HashMap<>(); - t.put("fizz", "buzz"); - - assertResponseStatusCode(bc.setTagsWithResponse( - new BlobSetTagsOptions(t).setRequestConditions(new BlobRequestConditions().setTagsConditions(tags)), null, - null), 204); - } - - private static Stream setTagsACSupplier() { - return Stream.of(Arguments.of((String) null), Arguments.of("\"foo\" = 'bar'")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-07-07") - @Test - public void setTagsACFail() { - Map t = new HashMap<>(); - t.put("fizz", "buzz"); - String tags = "\"foo\" = 'bar'"; - - assertThrows(BlobStorageException.class, - () -> bc.setTagsWithResponse( - new BlobSetTagsOptions(t).setRequestConditions(new BlobRequestConditions().setTagsConditions(tags)), - null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getTagsAC() { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - String[] tagsList = new String[] { null, "\"foo\" = 'bar'" }; - for (String tags : tagsList) { - assertResponseStatusCode(bc.getTagsWithResponse( - new BlobGetTagsOptions().setRequestConditions(new BlobRequestConditions().setTagsConditions(tags)), - null, null), 200); - } - } - - @Test - public void getTagsACFail() { - String tags = "\"foo\" = 'bar'"; - - assertThrows(BlobStorageException.class, - () -> bc.getTagsWithResponse( - new BlobGetTagsOptions().setRequestConditions(new BlobRequestConditions().setTagsConditions(tags)), - null, null)); - } - - @Test - public void setTagsError() { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(BlobStorageException.class, () -> bc.setTags(new HashMap<>())); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTagsLease() { - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID); - - Response response - = bc.setTagsWithResponse(new BlobSetTagsOptions(tags).setRequestConditions(bac), null, null); - - assertResponseStatusCode(response, 204); - assertEquals(tags, bc.getTags()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getTagsLease() { - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID); - bc.setTagsWithResponse(new BlobSetTagsOptions(tags).setRequestConditions(bac), null, null); - - Response> response - = bc.getTagsWithResponse(new BlobGetTagsOptions().setRequestConditions(bac), null, null); - - assertResponseStatusCode(response, 200); - assertEquals(tags, response.getValue()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTagsLeaseFail() { - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(GARBAGE_LEASE_ID); - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> bc.setTagsWithResponse(new BlobSetTagsOptions(tags).setRequestConditions(bac), null, null)); - assertEquals(412, e.getStatusCode()); - } - - @Test - public void snapshot() { - Response response = bc.createSnapshotWithResponse(null, null, null, null); - assertTrue(response.getValue().exists()); - assertTrue(validateBasicHeaders(response.getHeaders())); - } - - @Test - public void snapshotMin() { - assertResponseStatusCode(bc.createSnapshotWithResponse(null, null, null, null), 201); - } - - @Test - public void getSnapshot() { - byte[] data = "test".getBytes(); - String blobName = generateBlobName(); - BlockBlobClient bu = cc.getBlobClient(blobName).getBlockBlobClient(); - bu.upload(new ByteArrayInputStream(data), data.length); - String snapshotId = bu.createSnapshot().getSnapshotId(); - - BlockBlobClient snapshotBlob = cc.getBlobClient(blobName, snapshotId).getBlockBlobClient(); - assertEquals(snapshotId, snapshotBlob.getSnapshotId()); - assertNull(bu.getSnapshotId()); - } - - @Test - public void isSnapshot() { - byte[] data = "test".getBytes(); - String blobName = generateBlobName(); - BlockBlobClient bu = cc.getBlobClient(blobName).getBlockBlobClient(); - bu.upload(new ByteArrayInputStream(data), data.length); - String snapshotId = bu.createSnapshot().getSnapshotId(); - - BlockBlobClient snapshotBlob = cc.getBlobClient(blobName, snapshotId).getBlockBlobClient(); - assertTrue(snapshotBlob.isSnapshot()); - assertFalse(bu.isSnapshot()); - } - - @ParameterizedTest - @MethodSource("snapshotMetadataSupplier") - public void snapshotMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null && value1 != null) { - metadata.put(key1, value1); - } - if (key2 != null && value2 != null) { - metadata.put(key2, value2); - } - - Response response = bc.createSnapshotWithResponse(metadata, null, null, null); - BlobClientBase bcSnap = response.getValue(); - assertResponseStatusCode(response, 201); - assertEquals(metadata, bcSnap.getProperties().getMetadata()); - } - - private static Stream snapshotMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void snapshotAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(bc.createSnapshotWithResponse(null, bac, null, null), 201); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void snapshotACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> bc.createSnapshotWithResponse(null, bac, null, null)); - } - - @Test - public void snapshotError() { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(BlobStorageException.class, () -> bc.createSnapshot()); - } - - @Test - public void copy() { - BlockBlobClient copyDestBlob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - SyncPoller poller - = setPlaybackSyncPollerPollInterval(copyDestBlob.beginCopy(bc.getBlobUrl(), null)); - - PollResponse response = poller.waitForCompletion(); - BlobProperties properties = copyDestBlob.getProperties(); - - assertEquals(CopyStatusType.SUCCESS, properties.getCopyStatus()); - assertNotNull(properties.getCopyCompletionTime()); - assertNotNull(properties.getCopyProgress()); - assertNotNull(properties.getCopySource()); - assertNotNull(response); - assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, response.getStatus()); - BlobCopyInfo blobInfo = response.getValue(); - assertNotNull(blobInfo); - assertEquals(properties.getCopyId(), blobInfo.getCopyId()); - } - - @Test - public void copyMin() { - BlockBlobClient copyDestBlob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - SyncPoller poller - = setPlaybackSyncPollerPollInterval(copyDestBlob.beginCopy(bc.getBlobUrl(), null)); - - PollResponse response = poller.poll(); - assertNotNull(response.getValue()); - assertNotNull(response.getValue().getCopyId()); - if (ENVIRONMENT.getTestMode() == TestMode.PLAYBACK) { - // disable recording copy source URL since the URL is redacted in playback mode - assertNotNull(response.getValue().getCopySourceUrl()); - } else { - assertEquals(bc.getBlobUrl(), response.getValue().getCopySourceUrl()); - } - assertTrue(response.getStatus() == LongRunningOperationStatus.IN_PROGRESS - || response.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - } - - @Test - public void copyPoller() { - BlockBlobClient copyDestBlob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - SyncPoller poller = setPlaybackSyncPollerPollInterval( - copyDestBlob.beginCopy(bc.getBlobUrl(), null, null, null, null, null, null)); - - PollResponse firstResponse = poller.poll(); - assertNotNull(firstResponse.getValue()); - assertNotNull(firstResponse.getValue().getCopyId()); - if (ENVIRONMENT.getTestMode() == TestMode.PLAYBACK) { - // disable recording copy source URL since the URL is redacted in playback mode - assertNotNull(firstResponse.getValue().getCopySourceUrl()); - } else { - assertEquals(bc.getBlobUrl(), firstResponse.getValue().getCopySourceUrl()); - } - - PollResponse lastResponse = poller.waitForCompletion(); - assertNotNull(lastResponse); - assertNotNull(lastResponse.getValue()); - - BlobProperties properties = copyDestBlob.getProperties(); - assertEquals(lastResponse.getValue().getCopyId(), properties.getCopyId()); - assertEquals(CopyStatusType.SUCCESS, properties.getCopyStatus()); - assertNotNull(properties.getCopyCompletionTime()); - assertNotNull(properties.getCopyProgress()); - assertNotNull(properties.getCopySource()); - assertNotNull(properties.getCopyId()); - } - - @ParameterizedTest - @MethodSource("snapshotMetadataSupplier") - public void copyMetadata(String key1, String value1, String key2, String value2) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - Map metadata = new HashMap<>(); - if (key1 != null && value1 != null) { - metadata.put(key1, value1); - } - if (key2 != null && value2 != null) { - metadata.put(key2, value2); - } - - SyncPoller poller - = setPlaybackSyncPollerPollInterval(bu2.beginCopy(bc.getBlobUrl(), metadata, null, null, null, null, null)); - - poller.waitForCompletion(); - - assertEquals(metadata, bu2.getProperties().getMetadata()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("copyTagsSupplier") - public void copyTags(String key1, String value1, String key2, String value2) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - Map tags = new HashMap<>(); - if (key1 != null && value1 != null) { - tags.put(key1, value1); - } - if (key2 != null && value2 != null) { - tags.put(key2, value2); - } - - SyncPoller poller - = setPlaybackSyncPollerPollInterval(bu2.beginCopy(new BlobBeginCopyOptions(bc.getBlobUrl()).setTags(tags))); - - poller.waitForCompletion(); - - assertEquals(tags, bu2.getTags()); - } - - private static Stream copyTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @CsvSource({ "true,true", "true,false", "false,true", "false,false" }) - public void copySeal(boolean source, boolean destination) { - AppendBlobClient appendBlobClient = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - appendBlobClient.create(); - if (source) { - appendBlobClient.seal(); - } - - AppendBlobClient bu2 = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - - SyncPoller poller = setPlaybackSyncPollerPollInterval( - bu2.beginCopy(new BlobBeginCopyOptions(appendBlobClient.getBlobUrl()).setSealDestination(destination))); - poller.waitForCompletion(); - - assertEquals(destination, Boolean.TRUE.equals(bu2.getProperties().isSealed())); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("copySourceACSupplier") - public void copySourceAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - BlockBlobClient copyDestBlob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - match = setupBlobMatchCondition(bc, match); - BlobBeginCopySourceRequestConditions mac - = new BlobBeginCopySourceRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - SyncPoller poller - = copyDestBlob.beginCopy(new BlobBeginCopyOptions(bc.getBlobUrl()).setSourceRequestConditions(mac)); - PollResponse response = poller.waitForCompletion(); - - assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, response.getStatus()); - } - - private static Stream copySourceACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), Arguments.of(OLD_DATE, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null), Arguments.of(null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null), - Arguments.of(null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("copySourceACFailSupplier") - public void copySourceACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlockBlobClient copyDestBlob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - noneMatch = setupBlobMatchCondition(bc, noneMatch); - BlobBeginCopySourceRequestConditions mac - = new BlobBeginCopySourceRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> copyDestBlob.beginCopy(new BlobBeginCopyOptions(bc.getBlobUrl()).setSourceRequestConditions(mac))); - } - - private static Stream copySourceACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null), Arguments.of(null, OLD_DATE, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null), Arguments.of(null, null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, null, "\"foo\" = 'bar'")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void copyDestAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu2.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - Map t = new HashMap<>(); - t.put("foo", "bar"); - bu2.setTags(t); - match = setupBlobMatchCondition(bu2, match); - leaseID = setupBlobLeaseCondition(bu2, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - SyncPoller poller - = setPlaybackSyncPollerPollInterval(bu2.beginCopy(bc.getBlobUrl(), null, null, null, null, bac, null)); - PollResponse response = poller.waitForCompletion(); - - assertNotNull(response); - assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, response.getStatus()); - } - - @Test - public void syncCopyBaseSimple() { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertNotNull(bu2.copyFromUrl(bc.getBlobUrl() + "?" + sas)); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void copyDestACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu2.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - noneMatch = setupBlobMatchCondition(bu2, noneMatch); - setupBlobLeaseCondition(bu2, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bu2.copyFromUrlWithResponse(bc.getBlobUrl(), null, null, null, bac, null, null)); - } - - @Test - public void abortCopyBaseSimple() { - // Data has to be large enough and copied between accounts to give us enough time to abort - new SpecializedBlobClientBuilder().blobClient(bc) - .buildBlockBlobClient() - .upload(new ByteArrayInputStream(getRandomByteArray(8 * 1024 * 1024)), 8 * 1024 * 1024, true); - - BlobContainerClient cu2 = alternateBlobServiceClient.getBlobContainerClient(generateBlobName()); - cu2.create(); - BlobClient bu2 = cu2.getBlobClient(generateBlobName()); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - SyncPoller poller = setPlaybackSyncPollerPollInterval( - bu2.beginCopy(bc.getBlobUrl() + "?" + sas, null, null, null, null, null, null)); - PollResponse lastResponse = poller.poll(); - assertNotNull(lastResponse); - assertNotNull(lastResponse.getValue()); - bu2.abortCopyFromUrl(lastResponse.getValue().getCopyId()); - BlobStorageException e - = assertThrows(BlobStorageException.class, () -> bu2.abortCopyFromUrl(lastResponse.getValue().getCopyId())); - assertEquals(409, e.getStatusCode()); //no pending copy operation - - // cleanup: - // Normal test cleanup will not clean up containers in the alternate account. - assertResponseStatusCode(cu2.deleteWithResponse(null, null, null), 202); - } - - @Test - public void abortCopyLeaseFail() { - // Data has to be large enough and copied between accounts to give us enough time to abort - new SpecializedBlobClientBuilder().blobClient(bc) - .buildBlockBlobClient() - .upload(new ByteArrayInputStream(getRandomByteArray(8 * 1024 * 1024)), 8 * 1024 * 1024, true); - - BlobContainerClient cu2 = alternateBlobServiceClient.getBlobContainerClient(generateBlobName()); - cu2.create(); - BlockBlobClient bu2 = cu2.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu2.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - String leaseId = setupBlobLeaseCondition(bu2, RECEIVED_LEASE_ID); - BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - SyncPoller poller = setPlaybackSyncPollerPollInterval( - bu2.beginCopy(bc.getBlobUrl() + "?" + sas, null, null, null, null, blobRequestConditions, null)); - PollResponse response = poller.poll(); - assertNotEquals(LongRunningOperationStatus.FAILED, response.getStatus()); - BlobCopyInfo blobCopyInfo = response.getValue(); - - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> bu2.abortCopyFromUrlWithResponse(blobCopyInfo.getCopyId(), GARBAGE_LEASE_ID, null, null)); - assertEquals(412, e.getStatusCode()); - - // cleanup: - cu2.delete(); - } - - @Test - public void abortCopy() { - // Data has to be large enough and copied between accounts to give us enough time to abort - new SpecializedBlobClientBuilder().blobClient(bc) - .buildBlockBlobClient() - .upload(new ByteArrayInputStream(getRandomByteArray(8 * 1024 * 1024)), 8 * 1024 * 1024, true); - - BlobContainerClient cu2 = alternateBlobServiceClient.getBlobContainerClient(generateBlobName()); - cu2.create(); - BlobClient bu2 = cu2.getBlobClient(generateBlobName()); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - SyncPoller poller = setPlaybackSyncPollerPollInterval( - bu2.beginCopy(bc.getBlobUrl() + "?" + sas, null, null, null, null, null, null)); - PollResponse lastResponse = poller.poll(); - assertNotNull(lastResponse); - assertNotNull(lastResponse.getValue()); - Response response - = bu2.abortCopyFromUrlWithResponse(lastResponse.getValue().getCopyId(), null, null, null); - HttpHeaders headers = response.getHeaders(); - assertResponseStatusCode(response, 204); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(HttpHeaderName.DATE)); - // cleanup: - // Normal test cleanup will not clean up containers in the alternate account. - assertResponseStatusCode(cu2.deleteWithResponse(null, null, null), 202); - } - - @Test - public void abortCopyLease() { - // Data has to be large enough and copied between accounts to give us enough time to abort - new SpecializedBlobClientBuilder().blobClient(bc) - .buildBlockBlobClient() - .upload(new ByteArrayInputStream(getRandomByteArray(8 * 1024 * 1024)), 8 * 1024 * 1024, true); - - BlobContainerClient cu2 = alternateBlobServiceClient.getBlobContainerClient(generateContainerName()); - cu2.create(); - BlockBlobClient bu2 = cu2.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu2.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - String leaseId = setupBlobLeaseCondition(bu2, RECEIVED_LEASE_ID); - BlobRequestConditions blobAccess = new BlobRequestConditions().setLeaseId(leaseId); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - SyncPoller poller = setPlaybackSyncPollerPollInterval( - bu2.beginCopy(bc.getBlobUrl() + "?" + sas, null, null, null, null, blobAccess, null)); - PollResponse lastResponse = poller.poll(); - - assertNotNull(lastResponse); - assertNotNull(lastResponse.getValue()); - String copyId = lastResponse.getValue().getCopyId(); - assertResponseStatusCode(bu2.abortCopyFromUrlWithResponse(copyId, leaseId, null, null), 204); - // cleanup: - // Normal test cleanup will not clean up containers in the alternate account. - cu2.delete(); - } - - @Test - public void copyError() { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(BlobStorageException.class, () -> bc.copyFromUrl("http://www.error.com")); - } - - @Test - public void abortCopyError() { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(BlobStorageException.class, () -> bc.abortCopyFromUrl("id")); - } - - @Test - public void syncCopy() { - // Sync copy is a deep copy, which requires either sas or public access. - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - HttpHeaders headers - = bu2.copyFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, null, null, null, null, null).getHeaders(); - - assertEquals(SyncCopyStatusType.SUCCESS.toString(), headers.getValue(X_MS_COPY_STATUS)); - assertNotNull(headers.getValue(X_MS_COPY_ID)); - assertTrue(validateBasicHeaders(headers)); - } - - @Test - public void syncCopyMin() { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertResponseStatusCode( - bu2.copyFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, null, null, null, null, null), 202); - } - - @ParameterizedTest - @MethodSource("snapshotMetadataSupplier") - public void syncCopyMetadata(String key1, String value1, String key2, String value2) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - Map metadata = new HashMap<>(); - if (key1 != null && value1 != null) { - metadata.put(key1, value1); - } - if (key2 != null && value2 != null) { - metadata.put(key2, value2); - } - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - bu2.copyFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, metadata, null, null, null, null, null); - assertEquals(metadata, bu2.getProperties().getMetadata()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("copyTagsSupplier") - public void syncCopyTags(String key1, String value1, String key2, String value2) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - Map tags = new HashMap<>(); - if (key1 != null && value1 != null) { - tags.put(key1, value1); - } - if (key2 != null && value2 != null) { - tags.put(key2, value2); - } - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - bu2.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(bc.getBlobUrl() + "?" + sas).setTags(tags), null, null); - assertEquals(tags, bu2.getTags()); - } - - @ParameterizedTest - @MethodSource("syncCopySourceACSupplier") - public void syncCopySourceAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - match = setupBlobMatchCondition(bc, match); - RequestConditions mac = new RequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertResponseStatusCode( - bu2.copyFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, null, mac, null, null, null), 202); - } - - private static Stream syncCopySourceACSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of(OLD_DATE, null, null, null), - Arguments.of(null, NEW_DATE, null, null), Arguments.of(null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, GARBAGE_ETAG)); - } - - @ParameterizedTest - @MethodSource("syncCopySourceACFailSupplier") - public void syncCopySourceACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - noneMatch = setupBlobMatchCondition(bc, noneMatch); - RequestConditions mac = new RequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertThrows(BlobStorageException.class, - () -> bu2.copyFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, null, mac, null, null, null)); - } - - private static Stream syncCopySourceACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null), Arguments.of(null, OLD_DATE, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null), Arguments.of(null, null, null, RECEIVED_ETAG)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void syncCopyDestAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu2.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - Map t = new HashMap<>(); - t.put("foo", "bar"); - bu2.setTags(t); - match = setupBlobMatchCondition(bu2, match); - leaseID = setupBlobLeaseCondition(bu2, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertResponseStatusCode( - bu2.copyFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, null, null, bac, null, null), 202); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void syncCopyDestACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu2.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - noneMatch = setupBlobMatchCondition(bu2, noneMatch); - setupBlobLeaseCondition(bu2, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertThrows(BlobStorageException.class, - () -> bu2.copyFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, null, null, bac, null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("syncCopySourceTagsSupplier") - public void syncCopySourceTags(BlobCopySourceTagsMode mode) { - Map sourceTags = new HashMap<>(); - sourceTags.put("foo", "bar"); - Map destTags = new HashMap<>(); - destTags.put("fizz", "buzz"); - bc.setTags(sourceTags); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - BlobClient bc2 = cc.getBlobClient(generateBlobName()); - - BlobCopyFromUrlOptions options - = new BlobCopyFromUrlOptions(bc.getBlobUrl() + "?" + sas).setCopySourceTagsMode(mode); - if (BlobCopySourceTagsMode.REPLACE == mode) { - options.setTags(destTags); - } - - bc2.copyFromUrlWithResponse(options, null, null); - Map receivedTags = bc2.getTags(); - - if (BlobCopySourceTagsMode.REPLACE == mode) { - assertEquals(receivedTags, destTags); - } else { - assertEquals(receivedTags, sourceTags); - } - } - - private static Stream syncCopySourceTagsSupplier() { - return Stream.of(Arguments.of(BlobCopySourceTagsMode.COPY), Arguments.of(BlobCopySourceTagsMode.REPLACE)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void syncCopyFromUrlAccessTierCold() { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - BlobCopyFromUrlOptions copyOptions - = new BlobCopyFromUrlOptions(bc.getBlobUrl() + "?" + sas).setTier(AccessTier.COLD); - - assertResponseStatusCode(bu2.copyFromUrlWithResponse(copyOptions, null, null), 202); - assertEquals(bu2.getProperties().getAccessTier(), AccessTier.COLD); - } - - @Test - public void syncCopyError() { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - assertThrows(BlobStorageException.class, () -> bu2.copyFromUrl(bc.getBlobUrl())); - } - - @Test - public void delete() { - Response response = bc.deleteWithResponse(null, null, null, null); - HttpHeaders headers = response.getHeaders(); - - assertResponseStatusCode(response, 202); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(HttpHeaderName.DATE)); - } - - @Test - public void deleteMin() { - assertResponseStatusCode(bc.deleteWithResponse(null, null, null, null), 202); - } - - @ParameterizedTest - @MethodSource("deleteOptionsSupplier") - public void deleteOptions(DeleteSnapshotsOptionType option, int blobsRemaining) { - bc.createSnapshot(); - // Create an extra blob so the list isn't empty (null) when we delete base blob, too - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu2.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - bc.deleteWithResponse(option, null, null, null); - assertEquals(cc.listBlobs().stream().count(), blobsRemaining); - } - - private static Stream deleteOptionsSupplier() { - return Stream.of(Arguments.of(DeleteSnapshotsOptionType.INCLUDE, 1), - Arguments.of(DeleteSnapshotsOptionType.ONLY, 2)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void deleteAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(bc.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, bac, null, null), 202); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void deleteACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, bac, null, null)); - } - - @Test - public void blobDeleteError() { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(BlobStorageException.class, () -> bc.delete()); - } - - @Test - public void deleteIfExistsContainer() { - assertTrue(bc.deleteIfExists()); - } - - @Test - public void deleteIfExists() { - Response response = bc.deleteIfExistsWithResponse(null, null, null, null); - HttpHeaders headers = response.getHeaders(); - - assertTrue(response.getValue()); - assertResponseStatusCode(response, 202); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(HttpHeaderName.DATE)); - } - - @Test - public void deleteIfExistsMin() { - assertResponseStatusCode(bc.deleteIfExistsWithResponse(null, null, null, null), 202); - } - - @Test - public void deleteIfExistsBlobThatDoesNotExist() { - bc = cc.getBlobClient(generateBlobName()); - Response response = bc.deleteIfExistsWithResponse(null, null, null, null); - - assertFalse(response.getValue()); - assertResponseStatusCode(response, 404); - } - - @Test - public void deleteIfExistsContainerThatWasAlreadyDeleted() { - Response initialResponse = bc.deleteIfExistsWithResponse(null, null, null, null); - Response secondResponse = bc.deleteIfExistsWithResponse(null, null, null, null); - - assertTrue(initialResponse.getValue()); - assertResponseStatusCode(initialResponse, 202); - assertFalse(secondResponse.getValue()); - assertResponseStatusCode(secondResponse, 404); - - } - - @ParameterizedTest - @MethodSource("deleteOptionsSupplier") - public void deleteIfExistsOptions(DeleteSnapshotsOptionType option, int blobsRemaining) { - bc.createSnapshot(); - // Create an extra blob so the list isn't empty (null) when we delete base blob, too - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu2.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - bc.deleteIfExistsWithResponse(option, null, null, null); - assertEquals(cc.listBlobs().stream().count(), blobsRemaining); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void deleteIfExistsAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(bc.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, bac, null, null), - 202); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void deleteIfExistsACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, bac, null, null)); - } - - @Test - public void setTierBlockBlob() { - List tiers = Arrays.asList(AccessTier.HOT, AccessTier.COOL, AccessTier.ARCHIVE); - for (AccessTier tier : tiers) { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultData().remaining()); - - Response initialResponse = bc.setAccessTierWithResponse(tier, null, null, null, null); - HttpHeaders headers = initialResponse.getHeaders(); - - assertTrue(initialResponse.getStatusCode() == 200 || initialResponse.getStatusCode() == 202); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertEquals(tier, bc.getProperties().getAccessTier()); - assertEquals(tier, cc.listBlobs().iterator().next().getProperties().getAccessTier()); - - // cleanup: - cc.delete(); - } - } - - @ParameterizedTest - @MethodSource("setTierPageBlobSupplier") - public void setTierPageBlob(AccessTier tier) { - BlobContainerClient cc = premiumBlobServiceClient.createBlobContainer(generateContainerName()); - - PageBlobClient bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - bc.create(512); - - bc.setAccessTier(tier); - assertEquals(tier, bc.getProperties().getAccessTier()); - assertEquals(tier, cc.listBlobs().iterator().next().getProperties().getAccessTier()); - - // cleanup: - cc.delete(); - } - - private static Stream setTierPageBlobSupplier() { - return Stream.of(Arguments.of(AccessTier.P4), Arguments.of(AccessTier.P6), Arguments.of(AccessTier.P10), - Arguments.of(AccessTier.P20), Arguments.of(AccessTier.P30), Arguments.of(AccessTier.P40), - Arguments.of(AccessTier.P50)); - } - - @Test - public void setTierMin() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - BlockBlobClient bu = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu.upload(DATA.getDefaultInputStream(), DATA.getDefaultData().remaining()); - - int statusCode = bc.setAccessTierWithResponse(AccessTier.HOT, null, null, null, null).getStatusCode(); - assertTrue(statusCode == 200 || statusCode == 202); - - // cleanup: - cc.delete(); - } - - @Test - public void setTierInferred() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateBlobName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - Boolean inferred1 = bc.getProperties().isAccessTierInferred(); - Boolean inferredList1 = cc.listBlobs().iterator().next().getProperties().isAccessTierInferred(); - - bc.setAccessTier(AccessTier.HOT); - - Boolean inferred2 = bc.getProperties().isAccessTierInferred(); - Boolean inferredList2 = cc.listBlobs().iterator().next().getProperties().isAccessTierInferred(); - - assertTrue(inferred1); - assertTrue(inferredList1); - assertNull(inferred2); - assertNull(inferredList2); - } - - @ParameterizedTest - @MethodSource("setTierArchiveStatusSupplier") - public void setTierArchiveStatus(AccessTier sourceTier, AccessTier destTier, ArchiveStatus status) { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateBlobName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - bc.setAccessTier(sourceTier); - bc.setAccessTier(destTier); - - assertEquals(status, bc.getProperties().getArchiveStatus()); - assertEquals(status, cc.listBlobs().iterator().next().getProperties().getArchiveStatus()); - } - - private static Stream setTierArchiveStatusSupplier() { - return Stream.of(Arguments.of(AccessTier.ARCHIVE, AccessTier.COOL, ArchiveStatus.REHYDRATE_PENDING_TO_COOL), - Arguments.of(AccessTier.ARCHIVE, AccessTier.HOT, ArchiveStatus.REHYDRATE_PENDING_TO_HOT), - Arguments.of(AccessTier.ARCHIVE, AccessTier.HOT, ArchiveStatus.REHYDRATE_PENDING_TO_HOT)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void setTierCold() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultData().remaining()); - - Response initialResponse = bc.setAccessTierWithResponse(AccessTier.COLD, null, null, null, null); - HttpHeaders headers = initialResponse.getHeaders(); - - assertTrue(initialResponse.getStatusCode() == 200 || initialResponse.getStatusCode() == 202); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertEquals(AccessTier.COLD, bc.getProperties().getAccessTier()); - assertEquals(AccessTier.COLD, cc.listBlobs().iterator().next().getProperties().getAccessTier()); - // cleanup: - cc.delete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void setTierArchiveStatusRehydratePendingToCold() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateBlobName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - bc.setAccessTier(AccessTier.ARCHIVE); - bc.setAccessTier(AccessTier.COLD); - - assertEquals(bc.getProperties().getArchiveStatus(), ArchiveStatus.REHYDRATE_PENDING_TO_COLD); - assertEquals(cc.listBlobs().iterator().next().getProperties().getArchiveStatus(), - ArchiveStatus.REHYDRATE_PENDING_TO_COLD); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("setTierRehydratePrioritySupplier") - public void setTierRehydratePriority(RehydratePriority rehydratePriority) { - if (rehydratePriority != null) { - bc.setAccessTier(AccessTier.ARCHIVE); - bc.setAccessTierWithResponse(new BlobSetAccessTierOptions(AccessTier.HOT).setPriority(rehydratePriority), - null, null); - } - - Response resp = bc.getPropertiesWithResponse(null, null, null); - assertResponseStatusCode(resp, 200); - assertEquals(resp.getValue().getRehydratePriority(), rehydratePriority); - } - - private static Stream setTierRehydratePrioritySupplier() { - return Stream.of(Arguments.of((RehydratePriority) null), Arguments.of(RehydratePriority.STANDARD), - Arguments.of(RehydratePriority.HIGH)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTierSnapshot() { - BlobClientBase bc2 = bc.createSnapshot(); - - bc2.setAccessTier(AccessTier.COOL); - assertEquals(bc2.getProperties().getAccessTier(), AccessTier.COOL); - assertNotEquals(bc.getProperties().getAccessTier(), AccessTier.COOL); - } - - @Test - public void setTierSnapshotError() { - bc.createSnapshotWithResponse(null, null, null, null); - String fakeVersion = "2020-04-17T20:37:16.5129130Z"; - BlobClient bc2 = bc.getSnapshotClient(fakeVersion); - - assertThrows(BlobStorageException.class, () -> bc2.setAccessTier(AccessTier.COOL)); - } - - @Test - public void setTierError() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - BlobStorageException e - = assertThrows(BlobStorageException.class, () -> bc.setAccessTier(AccessTier.fromString("garbage"))); - assertEquals(e.getErrorCode(), BlobErrorCode.INVALID_HEADER_VALUE); - - // cleanup: - cc.delete(); - } - - @Test - public void setTierIllegalArgument() { - assertThrows(NullPointerException.class, () -> bc.setAccessTier(null)); - } - - @Test - public void setTierLease() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - - assertDoesNotThrow(() -> bc.setAccessTierWithResponse(AccessTier.HOT, null, leaseID, null, null)); - - // cleanup: - cc.delete(); - } - - @Test - public void setTierLeaseFail() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - assertThrows(BlobStorageException.class, - () -> bc.setAccessTierWithResponse(AccessTier.HOT, null, "garbage", null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTierTags() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - - assertDoesNotThrow(() -> bc.setAccessTierWithResponse( - new BlobSetAccessTierOptions(AccessTier.HOT).setTagsConditions("\"foo\" = 'bar'"), null, null)); - // cleanup: - cc.delete(); - } - - @Test - public void setTierTagsFail() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - assertThrows(BlobStorageException.class, () -> bc.setAccessTierWithResponse( - new BlobSetAccessTierOptions(AccessTier.HOT).setTagsConditions("\"foo\" = 'bar'"), null, null)); - } - - @ParameterizedTest - @MethodSource("copyWithTierSupplier") - public void copyWithTier(AccessTier tier1, AccessTier tier2) { - String blobName = generateBlobName(); - BlockBlobClient bc = cc.getBlobClient(blobName).getBlockBlobClient(); - bc.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, null, tier1, null, null, - null, null); - BlockBlobClient bcCopy = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - String secondSas = cc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - bcCopy.copyFromUrlWithResponse(bc.getBlobUrl() + "?" + secondSas, null, tier2, null, null, null, null); - - assertEquals(bcCopy.getProperties().getAccessTier(), tier2); - } - - private static Stream copyWithTierSupplier() { - return Stream.of(Arguments.of(AccessTier.HOT, AccessTier.COOL), Arguments.of(AccessTier.COOL, AccessTier.HOT)); - } - - @Test - public void undeleteError() { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(BlobStorageException.class, () -> bc.undelete()); - } - - @Test - public void getAccountInfo() { - Response response = primaryBlobServiceClient.getAccountInfoWithResponse(null, null); - - assertNotNull(response.getHeaders().getValue(HttpHeaderName.DATE)); - assertNotNull(response.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(response.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(response.getValue().getAccountKind()); - assertNotNull(response.getValue().getSkuName()); - assertFalse(response.getValue().isHierarchicalNamespaceEnabled()); - } - - @Test - public void getAccountInfoMin() { - assertResponseStatusCode(bc.getAccountInfoWithResponse(null, null), 200); - } - - @Test - public void getAccountInfoBase() { - StorageAccountInfo info = bc.getAccountInfo(); - - assertNotNull(info.getAccountKind()); - assertNotNull(info.getSkuName()); - assertFalse(info.isHierarchicalNamespaceEnabled()); - } - - @Test - public void getAccountInfoBaseFail() { - BlobServiceClient serviceClient - = instrument(new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(new MockTokenCredential())).buildClient(); - - BlobClient blobClient - = serviceClient.getBlobContainerClient(generateContainerName()).getBlobClient(generateBlobName()); - - BlobStorageException e = assertThrows(BlobStorageException.class, blobClient::getAccountInfo); - assertEquals(BlobErrorCode.INVALID_AUTHENTICATION_INFO, e.getErrorCode()); - - } - - @Test - public void getContainerName() { - assertEquals(containerName, bc.getContainerName()); - } - - @Test - public void getContainerClient() { - String sasToken = cc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(2), - new BlobSasPermission().setReadPermission(true))); - - // Ensure a sas token is also persisted - cc = getContainerClient(sasToken, cc.getBlobContainerUrl()); - - // Ensure the correct endpoint - assertEquals(cc.getBlobContainerUrl(), bc.getContainerClient().getBlobContainerUrl()); - // Ensure it is a functional client - assertNotNull(bc.getContainerClient().getProperties()); - } - - @ParameterizedTest - @MethodSource("getBlobNameSupplier") - public void getBlobName(String inputName, String expectedOutputName) { - bc = cc.getBlobClient(inputName); - assertEquals(expectedOutputName, bc.getBlobName()); - } - - private static Stream getBlobNameSupplier() { - return Stream.of(Arguments.of("blobName", "blobName"), Arguments.of("dir1/a%20b.txt", "dir1/a%20b.txt"), - Arguments.of("path/to]a blob", "path/to]a blob"), - Arguments.of("path%2Fto%5Da%20blob", "path%2Fto%5Da%20blob"), Arguments.of("斑點", "斑點"), - Arguments.of("%E6%96%91%E9%BB%9E", "%E6%96%91%E9%BB%9E"), Arguments.of("斑點", "斑點")); - } - - @ParameterizedTest - @MethodSource("getBlobNameSupplier") - public void getBlobNameAndBuildClient(String originalBlobName, String finalBlobName) { - BlobClient client = cc.getBlobClient(originalBlobName); - BlobClientBase baseClient = cc.getBlobClient(client.getBlobName()).getBlockBlobClient(); - - assertEquals(baseClient.getBlobName(), finalBlobName); - } - - private static Stream getNonEncodedBlobNameSupplier() { - return Stream.of(Arguments.of("test%test"), - Arguments.of("ab2a7d5f-b973-4222-83ba-d0581817a819 %Россия 한국 中国!?/file"), - Arguments.of("%E6%96%91%E9%BB%9E"), Arguments.of("斑點")); - } - - @ParameterizedTest - @MethodSource("getNonEncodedBlobNameSupplier") - public void getNonEncodedBlobName(String originalBlobName) { - BlobClient client = cc.getBlobClient(originalBlobName); - BlockBlobClient blockBlobClient = cc.getBlobClient(client.getBlobName()).getBlockBlobClient(); - assertEquals(blockBlobClient.getBlobName(), originalBlobName); - - // see if the blob name will be properly encoded in the url - String encodedName = Utility.urlEncode(originalBlobName); - assertTrue(cc.getBlobClient(originalBlobName).getBlobUrl().contains(encodedName)); - } - - @Test - public void getNonEncodedSpecializedBlob() { - String originalBlobName = "test%test"; - SpecializedBlobClientBuilder specializedBlobClientBuilder = getSpecializedBuilder(cc.getBlobContainerUrl()); - specializedBlobClientBuilder.containerName(cc.getBlobContainerName()).blobName(originalBlobName); - - BlockBlobClient blockBlobClient = specializedBlobClientBuilder.buildBlockBlobClient(); - assertEquals(blockBlobClient.getBlobName(), originalBlobName); - - // see if the blob name will be properly encoded in the url - String encodedName = Utility.urlEncode(originalBlobName); - assertTrue(cc.getBlobClient(originalBlobName).getBlobUrl().contains(encodedName)); - } - - @Test - public void getNonEncodedBlobClient() { - String originalBlobName = "test%test"; - BlobClientBuilder blobClientBuilder = getBlobClientBuilder(cc.getBlobContainerUrl()); - blobClientBuilder.containerName(cc.getBlobContainerName()).blobName(originalBlobName); - - BlobClient blobClient = blobClientBuilder.buildClient(); - assertEquals(blobClient.getBlobName(), originalBlobName); - - // see if the blob name will be properly encoded in the url - String encodedName = Utility.urlEncode(originalBlobName); - assertTrue(cc.getBlobClient(originalBlobName).getBlobUrl().contains(encodedName)); - } - - @Test - public void builderCpkValidation() { - URL endpoint = BlobUrlParts.parse(bc.getBlobUrl()).setScheme("http").toUrl(); - BlobClientBuilder builder = new BlobClientBuilder() - .customerProvidedKey(new CustomerProvidedKey(Base64.getEncoder().encodeToString(getRandomByteArray(256)))) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildClient); - } - - @Test - public void builderBearerTokenValidation() { - URL endpoint = BlobUrlParts.parse(bc.getBlobUrl()).setScheme("http").toUrl(); - BlobClientBuilder builder = new BlobClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildClient); - } - - @Test - public void parseSasTokenWithStartAndEndTimeDateOnly() { - // sas token's st and se are usually in the following format: st=2021-06-21T00:00:00Z&se=2021-06-22T00:00:00Z - // using a hardcoded url to test the start time and end time parsing without time added - String testUrl - = "https://accountName/containerName?sp=racwdl&st=2023-06-21&se=2023-06-22&spr=https&sv=2022-11-02&sr=c&sig="; - BlobUrlParts parts = BlobUrlParts.parse(testUrl); - - assertEquals(parts.getCommonSasQueryParameters().getStartTime().toLocalDate(), LocalDate.of(2023, 6, 21)); - assertEquals(parts.getCommonSasQueryParameters().getExpiryTime().toLocalDate(), LocalDate.of(2023, 6, 22)); - } - - @Test - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - public void perCallPolicy() { - bc = getBlobClientBuilder(bc.getBlobUrl()).addPolicy(getPerCallVersionPolicy()).buildClient(); - Response response = bc.getPropertiesWithResponse(null, null, null); - assertEquals("2017-11-09", response.getHeaders().getValue(X_MS_VERSION)); - - } - - @Test - public void specializedChildClientGetsCached() { - assertEquals(bc.getBlockBlobClient(), bc.getBlockBlobClient()); - assertEquals(bc.getAppendBlobClient(), bc.getAppendBlobClient()); - assertEquals(bc.getPageBlobClient(), bc.getPageBlobClient()); - } - - @Test - public void defaultAudience() { - BlobClient aadBlob = getBlobClientBuilderWithTokenCredential(bc.getBlobUrl()).audience(null).buildClient(); - - assertTrue(aadBlob.exists()); - } - - @Test - public void storageAccountAudience() { - BlobClient aadBlob = getBlobClientBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(cc.getAccountName())) - .buildClient(); - - assertTrue(aadBlob.exists()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - BlobClient aadBlob = getBlobClientBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildClient(); - - assertNotNull(aadBlob.getProperties()); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", cc.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - BlobClient aadBlob = getBlobClientBuilderWithTokenCredential(bc.getBlobUrl()).audience(audience).buildClient(); - - assertTrue(aadBlob.exists()); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAsyncApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAsyncApiTests.java deleted file mode 100644 index 645000706ad1..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAsyncApiTests.java +++ /dev/null @@ -1,2849 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.rest.Response; -import com.azure.core.test.TestMode; -import com.azure.core.test.utils.MockTokenCredential; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.ProgressListener; -import com.azure.core.util.polling.AsyncPollResponse; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollerFlux; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.ArchiveStatus; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobDownloadAsyncResponse; -import com.azure.storage.blob.models.BlobDownloadContentAsyncResponse; -import com.azure.storage.blob.models.BlobDownloadHeaders; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.blob.models.DownloadRetryOptions; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import com.azure.storage.blob.models.ObjectReplicationPolicy; -import com.azure.storage.blob.models.ObjectReplicationStatus; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.blob.options.BlobBeginCopyOptions; -import com.azure.storage.blob.options.BlobDownloadToFileOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.BlobSetAccessTierOptions; -import com.azure.storage.blob.options.BlobSetTagsOptions; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobAsyncClient; -import com.azure.storage.blob.specialized.BlobAsyncClientBase; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.blob.specialized.PageBlobAsyncClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.TestDataFactory; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.PlaybackOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import com.azure.storage.common.test.shared.policy.MockFailureResponsePolicy; -import com.azure.storage.common.test.shared.policy.MockRetryRangeResponsePolicy; -import com.azure.storage.common.test.shared.policy.TransientFailureInjectingHttpPipelinePolicy; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.Exceptions; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Hooks; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.function.Tuple2; - -import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.Files; -import java.nio.file.OpenOption; -import java.nio.file.StandardOpenOption; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BlobAsyncApiTests extends BlobTestBase { - private BlobAsyncClient bc; - private final List createdFiles = new ArrayList<>(); - - @BeforeEach - public void setup() { - String blobName = generateBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName); - bc.getBlockBlobAsyncClient().upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()).block(); - } - - @AfterEach - public void cleanup() { - createdFiles.forEach(File::delete); - } - - @Test - public void uploadFluxOverwriteFails() { - StepVerifier.create(bc.upload(DATA.getDefaultFlux(), null)).verifyError(IllegalArgumentException.class); - } - - @Test - public void uploadBinaryDataOverwriteFails() { - StepVerifier.create(bc.upload(DATA.getDefaultBinaryData())).verifyError(IllegalArgumentException.class); - } - - @Test - public void uploadFluxOverwrite() { - byte[] randomData = getRandomByteArray(Constants.KB); - Flux input = Flux.just(ByteBuffer.wrap(randomData)); - - StepVerifier - .create(bc.upload(input, null, true) - .then(bc.downloadStreamWithResponse(null, null, null, false)) - .flatMap(r -> FluxUtil.collectBytesInByteBufferStream(r.getValue()))) - .assertNext(r -> TestUtils.assertArraysEqual(r, randomData)) - .verifyComplete(); - } - - @Test - public void uploadBinaryDataOverwrite() { - byte[] randomData = getRandomByteArray(Constants.KB); - - StepVerifier.create(bc.upload(BinaryData.fromBytes(randomData), true).then(bc.downloadContent())) - .assertNext(r -> TestUtils.assertArraysEqual(r.toBytes(), randomData)) - .verifyComplete(); - } - - /* Tests an issue found where buffered upload would not deep copy buffers while determining what upload path to - take. */ - @ParameterizedTest - @ValueSource( - ints = { - Constants.KB, /* Less than copyToOutputStream buffer size, Less than maxSingleUploadSize */ - 8 * Constants.KB, /* Equal to copyToOutputStream buffer size, Less than maxSingleUploadSize */ - 20 * Constants.KB }) /* Greater than copyToOutputStream buffer size, Less than maxSingleUploadSize */ - public void uploadFluxSingleUpload() { - byte[] randomData = getRandomByteArray(20 * Constants.KB); - Flux input = Flux.just(ByteBuffer.wrap(randomData)); - - StepVerifier - .create(bc.upload(input, null, true) - .then(bc.downloadStreamWithResponse(null, null, null, false)) - .flatMap(r -> FluxUtil.collectBytesInByteBufferStream(r.getValue()))) - .assertNext(r -> TestUtils.assertArraysEqual(r, randomData)) - .verifyComplete(); - } - - @LiveOnly - @Test - public void uploadFluxLargeData() { - byte[] randomData = getRandomByteArray(20 * Constants.MB); - Flux input = Flux.just(ByteBuffer.wrap(randomData)); - - ParallelTransferOptions pto = new ParallelTransferOptions().setMaxSingleUploadSizeLong((long) Constants.MB); - - StepVerifier.create(bc.uploadWithResponse(input, pto, null, null, null, null)) - .expectNextCount(1) - .verifyComplete(); - } - - @LiveOnly - @ParameterizedTest - @MethodSource("uploadNumBlocksSupplier") - public void uploadNumBlocks(int size, Long maxUploadSize, long numBlocks) { - byte[] randomData = getRandomByteArray(size); - Flux input = Flux.just(ByteBuffer.wrap(randomData)); - - ParallelTransferOptions pto - = new ParallelTransferOptions().setBlockSizeLong(maxUploadSize).setMaxSingleUploadSizeLong(maxUploadSize); - - StepVerifier - .create(bc.uploadWithResponse(input, pto, null, null, null, null) - .then(bc.getBlockBlobAsyncClient().listBlocks(BlockListType.ALL))) - .assertNext(r -> assertEquals(numBlocks, r.getCommittedBlocks().size())) - .verifyComplete(); - } - - private static Stream uploadNumBlocksSupplier() { - return Stream.of(Arguments.of(0, null, 0), Arguments.of(Constants.KB, null, 0), // default is MAX_UPLOAD_BYTES - Arguments.of(Constants.MB, null, 0), // default is MAX_UPLOAD_BYTES - Arguments.of(3 * Constants.MB, (long) Constants.MB, 3)); - } - - @Test - public void uploadReturnValue() { - StepVerifier.create(bc.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()))) - .assertNext(r -> assertNotNull(r.getValue().getETag())) - .verifyComplete(); - } - - @Test - public void uploadReturnValueBinaryData() { - StepVerifier.create(bc.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultBinaryData()))) - .assertNext(r -> assertNotNull(r.getValue().getETag())) - .verifyComplete(); - } - - @Test - public void uploadFluxMin() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - - StepVerifier.create(bc.upload(DATA.getDefaultFlux(), null)).expectNextCount(1).verifyComplete(); - - StepVerifier.create(bc.downloadContent()) - .assertNext(r -> TestUtils.assertArraysEqual(r.toBytes(), DATA.getDefaultBytes())) - .verifyComplete(); - } - - @Test - public void uploadInputStreamNoLength() { - StepVerifier.create(bc.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()))) - .expectNextCount(1) - .verifyComplete(); - - StepVerifier.create(bc.downloadContent()) - .assertNext(r -> TestUtils.assertArraysEqual(r.toBytes(), DATA.getDefaultBytes())) - .verifyComplete(); - } - - private static Stream uploadInputStreamBadLengthSupplier() { - return Stream.of(Arguments.of(0L, UnexpectedLengthException.class), - Arguments.of(-100L, IllegalArgumentException.class), - Arguments.of(DATA.getDefaultDataSize() - 1L, UnexpectedLengthException.class), - Arguments.of(DATA.getDefaultDataSize() + 1L, UnexpectedLengthException.class)); - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("uploadInputStreamBadLengthSupplier") - public void uploadInputStreamBadLength(long badLength, Class exception) { - try { - StepVerifier - .create(bc.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream(), badLength))) - .verifyError(exception); - } catch (IllegalArgumentException e) { - //StepVerifier cant handle the error in the creation of BlobParallelUploadOptions - assertEquals(e.getMessage(), - "The value of the parameter 'length' should be between 0 and 9223372036854775807."); - } - } - - @Test - public void uploadSuccessfulRetry() { - BlobAsyncClient clientWithFailure = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - bc.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()); - - assertNotNull(clientWithFailure); - StepVerifier - .create(clientWithFailure.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream())) - .then(bc.downloadContent())) - .assertNext(r -> TestUtils.assertArraysEqual(r.toBytes(), DATA.getDefaultBytes())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void uploadStreamAccessTierCold() { - byte[] randomData = getRandomByteArray(Constants.KB); - Flux input = Flux.just(ByteBuffer.wrap(randomData)); - BlobParallelUploadOptions blobUploadOptions = new BlobParallelUploadOptions(input).setTier(AccessTier.COLD); - - StepVerifier.create(bc.uploadWithResponse(blobUploadOptions).then(bc.getProperties())) - .assertNext(r -> assertEquals(AccessTier.COLD, r.getAccessTier())) - .verifyComplete(); - } - - private void assertNullHeaders(BlobDownloadHeaders headers) { - assertTrue(CoreUtils.isNullOrEmpty(headers.getMetadata())); - assertEquals(1, headers.getTagCount()); - assertNotNull(headers.getContentLength()); - assertNotNull(headers.getContentType()); - assertNull(headers.getContentRange()); - assertNotNull(headers.getContentMd5()); - assertNull(headers.getContentEncoding()); - assertNull(headers.getCacheControl()); - assertNull(headers.getContentDisposition()); - assertNull(headers.getContentLanguage()); - assertNull(headers.getBlobSequenceNumber()); - assertEquals(BlobType.BLOCK_BLOB, headers.getBlobType()); - assertNull(headers.getCopyCompletionTime()); - assertNull(headers.getCopyStatusDescription()); - assertNull(headers.getCopyId()); - assertNull(headers.getCopyProgress()); - assertNull(headers.getCopySource()); - assertNull(headers.getCopyStatus()); - assertNull(headers.getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, headers.getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, headers.getLeaseStatus()); - assertEquals("bytes", headers.getAcceptRanges()); - assertNull(headers.getBlobCommittedBlockCount()); - assertNotNull(headers.isServerEncrypted()); - assertNull(headers.getBlobContentMD5()); - assertNotNull(headers.getCreationTime()); - //headers.getLastAccessedTime() /* TODO (gapra): re-enable when last access time enabled. */ - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void downloadAllNull() { - Mono response = bc.setTags(Collections.singletonMap("foo", "bar")) - .then(bc.downloadWithResponse(null, null, null, false)) - .flatMap(r -> { - assertNullHeaders(r.getDeserializedHeaders()); - return FluxUtil.collectBytesInByteBufferStream(r.getValue()); - }); - - StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void downloadAllNullStreaming() { - Mono response = bc.setTags(Collections.singletonMap("foo", "bar")) - .then(bc.downloadStreamWithResponse(null, null, null, false)) - .flatMap(r -> { - assertNullHeaders(r.getDeserializedHeaders()); - return FluxUtil.collectBytesInByteBufferStream(r.getValue()); - }); - - StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void downloadAllNullBinaryData() { - StepVerifier - .create(bc.setTags(Collections.singletonMap("foo", "bar")).then(bc.downloadContentWithResponse(null, null))) - .assertNext(r -> { - assertNullHeaders(r.getDeserializedHeaders()); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r.getValue().toBytes()); - }) - .verifyComplete(); - } - - @Test - public void downloadEmptyFile() { - AppendBlobAsyncClient bc = ccAsync.getBlobAsyncClient("emptyAppendBlob").getAppendBlobAsyncClient(); - StepVerifier.create(bc.create().then(FluxUtil.collectBytesInByteBufferStream(bc.downloadStream()))) - .assertNext(r -> assertEquals(0, r.length)) - .verifyComplete(); - } - - /* - This is to test the appropriate integration of DownloadResponse, including setting the correct range values on - HttpGetterInfo. - */ - - @Test - public void downloadWithRetryRange() { - /* - We are going to make a request for some range on a blob. The Flux returned will throw an exception, forcing - a retry per the DownloadRetryOptions. The next request should have the same range header, which was generated - from the count and offset values in HttpGetterInfo that was constructed on the initial call to download. We - don't need to check the data here, but we want to ensure that the correct range is set each time. This will - test the correction of a bug that was found which caused HttpGetterInfo to have an incorrect offset when it was - constructed in BlobClient.download(). - */ - BlobAsyncClient bu2 = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), bc.getBlobUrl(), - new MockRetryRangeResponsePolicy("bytes=2-6")); - - BlobRange range = new BlobRange(2, 5L); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(3); - StepVerifier.create(bu2.downloadStreamWithResponse(range, options, null, false) - .flatMap(r -> FluxUtil.collectBytesInByteBufferStream(r.getValue()))).verifyErrorSatisfies(r -> { - /* - Because the dummy Flux always throws an error. This will also validate that an IllegalArgumentException is - NOT thrown because the types would not match. - */ - assertInstanceOf(IOException.class, r); - }); - } - - @SuppressWarnings("deprecation") - @Test - public void downloadMin() { - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(bc.download())) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @Test - public void downloadStreamingMin() { - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(bc.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @Test - public void downloadBinaryDataMin() { - StepVerifier.create(bc.downloadContent()) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r.toBytes())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("downloadRangeSupplier") - public void downloadRange(long offset, Long count, String expectedData) { - BlobRange range = (count == null) ? new BlobRange(offset) : new BlobRange(offset, count); - - StepVerifier - .create(bc.downloadStreamWithResponse(range, null, null, false) - .flatMap(r -> FluxUtil.collectBytesInByteBufferStream(r.getValue()))) - .assertNext(r -> TestUtils.assertArraysEqual(expectedData.getBytes(), r)) - .verifyComplete(); - } - - private static Stream downloadRangeSupplier() { - return Stream.of(Arguments.of(0, null, DATA.getDefaultText()), - Arguments.of(0, 5L, DATA.getDefaultText().substring(0, 5)), - Arguments.of(3, 2L, DATA.getDefaultText().substring(3, 3 + 2))); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void downloadAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - Mono response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.downloadWithResponse(null, null, bac, false); - }); - - StepVerifier.create(response).assertNext(r -> assertEquals(200, r.getStatusCode())).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void downloadACStreaming(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - Mono response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.downloadStreamWithResponse(null, null, bac, false); - }); - - StepVerifier.create(response).assertNext(r -> assertEquals(200, r.getStatusCode())).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void downloadACBinaryData(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - Mono response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.downloadContentWithResponse(null, bac); - }); - - StepVerifier.create(response).assertNext(r -> assertEquals(200, r.getStatusCode())).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void downloadACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.downloadWithResponse(null, null, bac, false); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void downloadACFailStreaming(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - Mono response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.downloadStreamWithResponse(null, null, bac, false); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void downloadACFailBinaryData(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - Mono response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.downloadContentWithResponse(null, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void downloadMd5() { - StepVerifier.create(bc.downloadStreamWithResponse(new BlobRange(0, 3L), null, null, true)).assertNext(r -> { - byte[] contentMD5 = r.getDeserializedHeaders().getContentMd5(); - try { - TestUtils.assertArraysEqual( - MessageDigest.getInstance("MD5").digest(DATA.getDefaultText().substring(0, 3).getBytes()), - contentMD5); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } - }).verifyComplete(); - } - - @Test - public void downloadRetryDefault() { - BlobAsyncClient failureBlobClient = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - bc.getBlobUrl(), new MockFailureResponsePolicy(5)); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(failureBlobClient.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @Test - public void downloadSnapshot() { - Flux input = Flux.just(ByteBuffer.wrap("ABC".getBytes())); - BlockBlobAsyncClient specialClient - = new SpecializedBlobClientBuilder().blobAsyncClient(bc).buildBlockBlobAsyncClient(); - - Mono> response = FluxUtil.collectBytesInByteBufferStream(bc.downloadStream()) - .flatMap(originalStream -> bc.createSnapshot() - .flatMap(bc2 -> specialClient.upload(input, 3, true) - .then(Mono.zip(FluxUtil.collectBytesInByteBufferStream(bc2.downloadStream()), - Mono.just(originalStream))))); - - StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(r.getT2(), r.getT1())) - .verifyComplete(); - } - - @Test - public void downloadSnapshotBinaryData() { - Flux input = Flux.just(ByteBuffer.wrap("ABC".getBytes())); - BlockBlobAsyncClient specialClient - = new SpecializedBlobClientBuilder().blobAsyncClient(bc).buildBlockBlobAsyncClient(); - - Mono> response = bc.downloadContent() - .flatMap(originalStream -> bc.createSnapshot() - .flatMap(bc2 -> specialClient.upload(input, 3, true) - .then(Mono.zip(bc2.downloadContent(), Mono.just(originalStream))))); - - StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(r.getT2().toBytes(), r.getT1().toBytes())) - .verifyComplete(); - } - - @Test - public void downloadToFileExists() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (!testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - // Default Overwrite is false so this should fail - StepVerifier.create(bc.downloadToFile(testFile.getPath())).verifyErrorSatisfies(r -> { - UncheckedIOException e = assertInstanceOf(UncheckedIOException.class, r); - assertInstanceOf(FileAlreadyExistsException.class, e.getCause()); - }); - // cleanup: - testFile.delete(); - } - - @Test - public void downloadToFileExistsSucceeds() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (!testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - StepVerifier.create(bc.downloadToFile(testFile.getPath(), true)).expectNextCount(1).verifyComplete(); - - assertEquals(DATA.getDefaultText(), new String(Files.readAllBytes(testFile.toPath()), StandardCharsets.UTF_8)); - - // cleanup: - testFile.delete(); - } - - @Test - public void downloadToFileDoesNotExist() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - StepVerifier.create(bc.downloadToFile(testFile.getPath())).expectNextCount(1).verifyComplete(); - - assertEquals(DATA.getDefaultText(), new String(Files.readAllBytes(testFile.toPath()), StandardCharsets.UTF_8)); - - // cleanup: - testFile.delete(); - } - - @Test - public void downloadFileDoesNotExistOpenOptions() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - Set openOptions = new HashSet<>(); - openOptions.add(StandardOpenOption.CREATE_NEW); - openOptions.add(StandardOpenOption.READ); - openOptions.add(StandardOpenOption.WRITE); - - StepVerifier - .create(bc.downloadToFileWithResponse(testFile.getPath(), null, null, null, null, false, openOptions)) - .expectNextCount(1) - .verifyComplete(); - - assertEquals(DATA.getDefaultText(), new String(Files.readAllBytes(testFile.toPath()), StandardCharsets.UTF_8)); - - // cleanup: - testFile.delete(); - } - - @Test - public void downloadFileExistOpenOptions() throws IOException { - File testFile = new File(generateResourceName(entityNo) + ".txt"); - if (!testFile.exists()) { - assertTrue(testFile.createNewFile()); - } - - Set openOptions = new HashSet<>(); - openOptions.add(StandardOpenOption.CREATE); - openOptions.add(StandardOpenOption.TRUNCATE_EXISTING); - openOptions.add(StandardOpenOption.READ); - openOptions.add(StandardOpenOption.WRITE); - - StepVerifier - .create(bc.downloadToFileWithResponse(testFile.getPath(), null, null, null, null, false, openOptions)) - .expectNextCount(1) - .verifyComplete(); - - assertEquals(DATA.getDefaultText(), new String(Files.readAllBytes(testFile.toPath()), StandardCharsets.UTF_8)); - // cleanup: - testFile.delete(); - } - - @LiveOnly - @ParameterizedTest - @ValueSource( - ints = { - 0, // empty file - 20, // small file - 16 * 1024 * 1024, // medium file in several chunks - 8 * 1026 * 1024 + 10, // medium file not aligned to block - 50 * Constants.MB // large file requiring multiple requests - }) - public void downloadFile(int fileSize) throws IOException { - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(prefix + ".txt"); - createdFiles.add(outFile); - outFile.deleteOnExit(); - Files.deleteIfExists(outFile.toPath()); - - Mono> response = bc.uploadFromFile(file.toPath().toString(), true) - .then(bc.downloadToFileWithResponse(outFile.toPath().toString(), null, - new ParallelTransferOptions().setBlockSizeLong(4L * 1024 * 1024), null, null, false)); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(BlobType.BLOCK_BLOB, r.getValue().getBlobType()); - assertNotNull(r.getValue().getCreationTime()); - }).verifyComplete(); - - assertTrue(compareFiles(file, outFile, 0, fileSize)); - } - - /* - * Tests downloading a file using a default client that doesn't have a HttpClient passed to it. - */ - @LiveOnly - @ParameterizedTest - @ValueSource( - ints = { - 0, // empty file - 20, // small file - 16 * 1024 * 1024, // medium file in several chunks - 8 * 1026 * 1024 + 10, // medium file not aligned to block - 50 * Constants.MB // large file requiring multiple requests - }) - public void downloadFileAsyncBufferCopy(int fileSize) throws IOException { - String containerName = generateContainerName(); - BlobServiceAsyncClient blobServiceAsyncClient - = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .buildAsyncClient(); - - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(prefix + ".txt"); - createdFiles.add(outFile); - outFile.deleteOnExit(); - - Mono> response - = blobServiceAsyncClient.createBlobContainer(containerName).flatMap(r -> { - Objects.requireNonNull(r); - BlobAsyncClient blobAsyncClient = r.getBlobAsyncClient(generateBlobName()); - return blobAsyncClient.uploadFromFile(file.toPath().toString(), true) - .then(blobAsyncClient.downloadToFileWithResponse(outFile.toPath().toString(), null, - new ParallelTransferOptions().setBlockSizeLong(4L * 1024 * 1024), null, null, false)); - }); - - StepVerifier.create(response) - .assertNext(it -> assertEquals(BlobType.BLOCK_BLOB, it.getValue().getBlobType())) - .verifyComplete(); - - assertTrue(compareFiles(file, outFile, 0, fileSize)); - } - - @LiveOnly - @ParameterizedTest - @MethodSource("downloadFileRangeSupplier") - public void downloadFileRange(BlobRange range) throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(generateBlobName()); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - Mono> response = bc.uploadFromFile(file.toPath().toString(), true) - .then(bc.downloadToFileWithResponse(outFile.toPath().toString(), range, null, null, null, false)); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - - assertTrue(compareFiles(file, outFile, range.getOffset(), range.getCount())); - } - - private static Stream downloadFileRangeSupplier() { - /* - The last case is to test a range much larger than the size of the file to ensure we don't accidentally - send off parallel requests with invalid ranges. - */ - return Stream.of(Arguments.of(new BlobRange(0, DATA.getDefaultDataSizeLong())), // Exact count - Arguments.of(new BlobRange(1, DATA.getDefaultDataSizeLong() - 1)), // Offset and exact count - Arguments.of(new BlobRange(3, 2L)), // Narrow range in middle - Arguments.of(new BlobRange(0, DATA.getDefaultDataSizeLong() - 1)), // Count less than total - Arguments.of(new BlobRange(0, 10L * 1024))); // Count much larger than remaining data - } - - /* - This is to exercise some additional corner cases and ensure there are no arithmetic errors that give false success. - */ - - @LiveOnly - @Test - public void downloadFileRangeFail() throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(prefix); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - Mono> response = bc.uploadFromFile(file.toPath().toString(), true) - .then(bc.downloadToFileWithResponse(outFile.toPath().toString(), - new BlobRange(DATA.getDefaultDataSize() + 1), null, null, null, false)); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @LiveOnly - @Test - public void downloadFileCountNull() throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(generateBlobName()); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - Mono> response = bc.uploadFromFile(file.toPath().toString(), true) - .then( - bc.downloadToFileWithResponse(outFile.toPath().toString(), new BlobRange(0), null, null, null, false)); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - - assertTrue(compareFiles(file, outFile, 0, DATA.getDefaultDataSize())); - } - - @LiveOnly - @ParameterizedTest - @MethodSource("downloadFileACSupplier") - public void downloadFileAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID) throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(prefix); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - Mono> response = bc.uploadFromFile(file.toPath().toString(), true) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bro = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfNoneMatch(noneMatch); - - return bc.downloadToFileWithResponse(outFile.toPath().toString(), null, null, null, bro, false); - }); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - private static Stream downloadFileACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), Arguments.of(OLD_DATE, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null), Arguments.of(null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID)); - } - - @LiveOnly - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#fileACFailSupplier") - public void downloadFileACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID) throws IOException { - File file = getRandomFile(DATA.getDefaultDataSize()); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(prefix); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - Mono> response = bc.uploadFromFile(file.toPath().toString(), true) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bro = new BlobRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setLeaseId(leaseID); - - return bc.downloadToFileWithResponse(outFile.toPath().toString(), null, null, null, bro, false); - }); - - StepVerifier.create(response).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertTrue(e.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET - || e.getErrorCode() == BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION); - }); - } - - @LiveOnly - @Test - public void downloadFileETagLock() throws IOException { - File file = getRandomFile(Constants.MB); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(prefix); - outFile.deleteOnExit(); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - AtomicInteger counter = new AtomicInteger(); - - BlockBlobAsyncClient bacUploading = instrument(new BlobClientBuilder().endpoint(bc.getBlobUrl()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential())).buildAsyncClient().getBlockBlobAsyncClient(); - TestDataFactory dataLocal = DATA; - HttpPipelinePolicy policy = (context, next) -> next.process().flatMap(r -> { - if (counter.incrementAndGet() == 1) { - /* - * When the download begins trigger an upload to overwrite the downloading blob - * so that the download is able to get an ETag before it is changed. - */ - return bacUploading.upload(dataLocal.getDefaultFlux(), dataLocal.getDefaultDataSize(), true) - .thenReturn(r); - } - return Mono.just(r); - }); - BlockBlobAsyncClient bacDownloading = instrument(new BlobClientBuilder().addPolicy(policy) - .endpoint(bc.getBlobUrl()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential())).buildAsyncClient().getBlockBlobAsyncClient(); - - /* - * Setup the download to happen in small chunks so many requests need to be sent, this will give the upload time - * to change the ETag therefore failing the download. - */ - ParallelTransferOptions options = new ParallelTransferOptions().setBlockSizeLong((long) Constants.KB); - - /* - * This is done to prevent onErrorDropped exceptions from being logged at the error level. If no hook is - * registered for onErrorDropped the error is logged at the ERROR level. - * - * onErrorDropped is triggered once the reactive stream has emitted one element, after that exceptions are - * dropped. - */ - Hooks.onErrorDropped(ignored -> /* do nothing with it */ { - }); - StepVerifier - .create( - bc.uploadFromFile(file.toPath().toString(), true) - .then(bacDownloading.downloadToFileWithResponse(outFile.toPath().toString(), null, options, null, - null, false))) - .verifyErrorSatisfies(it -> { - /* - * If an operation is running on multiple threads and multiple return an exception Reactor will combine - * them into a CompositeException which needs to be unwrapped. If there is only a single exception - * 'Exceptions.unwrapMultiple' will return a singleton list of the exception it was passed. - * - * These exceptions may be wrapped exceptions where the exception we are expecting is contained within - * ReactiveException that needs to be unwrapped. If the passed exception isn't a 'ReactiveException' it - * will be returned unmodified by 'Exceptions.unwrap'. - */ - assertTrue(Exceptions.unwrapMultiple(it).stream().anyMatch(it2 -> { - Throwable exception = Exceptions.unwrap(it2); - if (exception instanceof BlobStorageException) { - assertEquals(412, ((BlobStorageException) exception).getStatusCode()); - return true; - } - return false; - })); - }); - - // Give the file a chance to be deleted by the download operation before verifying its deletion - sleepIfRunningAgainstService(500); - assertFalse(outFile.exists()); - } - - @SuppressWarnings("deprecation") - @LiveOnly - @ParameterizedTest - @ValueSource(ints = { 100, 8 * 1026 * 1024 + 10 }) - public void downloadFileProgressReceiver(int fileSize) throws IOException { - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(prefix); - outFile.deleteOnExit(); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - MockReceiver mockReceiver = new MockReceiver(); - - Mono> response = bc.uploadFromFile(file.toPath().toString(), true) - .then(bc.downloadToFileWithResponse(outFile.toPath().toString(), null, - new ParallelTransferOptions().setProgressReceiver(mockReceiver), - new DownloadRetryOptions().setMaxRetryRequests(3), null, false)); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - - /* - * Should receive at least one notification indicating completed progress, multiple notifications may be - * received if there are empty buffers in the stream. - */ - assertTrue(mockReceiver.progresses.stream().anyMatch(progress -> progress == fileSize)); - - // There should be NO notification with a larger than expected size. - assertFalse(mockReceiver.progresses.stream().anyMatch(progress -> progress > fileSize)); - - /* - We should receive at least one notification reporting an intermediary value per block, but possibly more - notifications will be received depending on the implementation. We specify numBlocks - 1 because the last block - will be the total size as above. Finally, we assert that the number reported monotonically increases. - */ - long prevCount = -1; - for (long progress : mockReceiver.progresses) { - assertTrue(progress >= prevCount, "Reported progress should monotonically increase"); - prevCount = progress; - } - } - - @SuppressWarnings("deprecation") - private static final class MockReceiver implements ProgressReceiver { - List progresses = new ArrayList<>(); - - @Override - public void reportProgress(long bytesTransferred) { - progresses.add(bytesTransferred); - } - } - - @LiveOnly - @ParameterizedTest - @ValueSource(ints = { 100, 8 * 1026 * 1024 + 10 }) - public void downloadFileProgressListener(int fileSize) throws Exception { - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(prefix); - outFile.deleteOnExit(); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - MockProgressListener mockListener = new MockProgressListener(); - - Mono> response = bc.uploadFromFile(file.toPath().toString(), true) - .then(bc.downloadToFileWithResponse(outFile.toPath().toString(), null, - new ParallelTransferOptions().setProgressListener(mockListener), - new DownloadRetryOptions().setMaxRetryRequests(3), null, false)); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - - /* - * Should receive at least one notification indicating completed progress, multiple notifications may be - * received if there are empty buffers in the stream. - */ - assertTrue(mockListener.progresses.stream().anyMatch(progress -> progress == fileSize)); - - // There should be NO notification with a larger than expected size. - assertFalse(mockListener.progresses.stream().anyMatch(progress -> progress > fileSize)); - - // We should receive at least one notification reporting an intermediary value per block, but possibly more - // notifications will be received depending on the implementation. We specify numBlocks - 1 because the last - // block will be the total size as above. Finally, we assert that the number reported monotonically increases. - long prevCount = -1; - for (long progress : mockListener.progresses) { - assertTrue(progress >= prevCount, "Reported progress should monotonically increase"); - prevCount = progress; - } - } - - private static final class MockProgressListener implements ProgressListener { - List progresses = new ArrayList<>(); - - @Override - public void handleProgress(long progress) { - progresses.add(progress); - } - } - - @Disabled("Very large data sizes.") - @ParameterizedTest - @MethodSource("downloadToFileBlockSizeSupplier") - /* Enable once we have ability to run large resource heavy tests in CI. */ - public void downloadToFileBlockSize(int sizeOfData, long downloadBlockSize) throws IOException { - File file = getRandomFile(sizeOfData); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = new File(prefix); - createdFiles.add(outFile); - Files.deleteIfExists(outFile.toPath()); - - BlobDownloadToFileOptions options = new BlobDownloadToFileOptions(outFile.toPath().toString()) - .setParallelTransferOptions( - new com.azure.storage.common.ParallelTransferOptions().setBlockSizeLong(downloadBlockSize)) - .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(3)); - - Mono> response - = bc.uploadFromFile(file.toPath().toString(), true).then(bc.downloadToFileWithResponse(options)); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - private static Stream downloadToFileBlockSizeSupplier() { - return Stream.of( - /* This was the default before. */ - Arguments.of(5000L * Constants.MB, 5000L * Constants.MB), - /* Trying to see if we can set it to a number greater than previous default. */ - Arguments.of(6000L * Constants.MB, 6000L * Constants.MB), - /* Testing chunking with a large size */ - Arguments.of(6000L * Constants.MB, 5100L * Constants.MB)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getPropertiesDefault() { - StepVerifier.create(bc.setTags(Collections.singletonMap("foo", "bar")).then(bc.getPropertiesWithResponse(null))) - .assertNext(r -> { - HttpHeaders headers = r.getHeaders(); - BlobProperties properties = r.getValue(); - - assertTrue(validateBasicHeaders(headers)); - assertTrue(CoreUtils.isNullOrEmpty(properties.getMetadata())); - assertEquals(BlobType.BLOCK_BLOB, properties.getBlobType()); - assertNull(properties.getCopyCompletionTime()); // tested in "copy" - assertNull(properties.getCopyStatusDescription()); // only returned when the service has errors; cannot validate - assertNull(properties.getCopyId()); // tested in "abort copy" - assertNull(properties.getCopyProgress()); // tested in "copy" - assertNull(properties.getCopySource()); // tested in "copy" - assertNull(properties.getCopyStatus()); // tested in "copy" - assertNull(properties.isIncrementalCopy()); // tested in PageBlob."start incremental copy" - assertNull(properties.getCopyDestinationSnapshot()); // tested in PageBlob."start incremental copy" - assertNull(properties.getLeaseDuration()); // tested in "acquire lease" - assertEquals(LeaseStateType.AVAILABLE, properties.getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, properties.getLeaseStatus()); - assertTrue(properties.getBlobSize() >= 0); - assertNotNull(properties.getContentType()); - assertNotNull(properties.getContentMd5()); - assertNull(properties.getContentEncoding()); // tested in "set HTTP headers" - assertNull(properties.getContentDisposition()); // tested in "set HTTP headers" - assertNull(properties.getContentLanguage()); // tested in "set HTTP headers" - assertNull(properties.getCacheControl()); // tested in "set HTTP headers" - assertNull(properties.getBlobSequenceNumber()); // tested in PageBlob."create sequence number" - assertEquals("bytes", headers.getValue(HttpHeaderName.ACCEPT_RANGES)); - assertNull(properties.getCommittedBlockCount()); // tested in AppendBlob."append block" - assertTrue(properties.isServerEncrypted()); - assertEquals(AccessTier.HOT, properties.getAccessTier()); - assertTrue(properties.isAccessTierInferred()); - assertNull(properties.getArchiveStatus()); // tested in "set tier" - assertNotNull(properties.getCreationTime()); - assertEquals(1, properties.getTagCount()); - assertNull(properties.getRehydratePriority()); // tested in setTier rehydrate priority - assertNull(properties.isSealed()); // tested in AppendBlob. "seal blob" - assertNotNull(properties.getRequestId()); - //properties.getLastAccessedTime() /* TODO: re-enable when last access time enabled. */ - }) - .verifyComplete(); - } - - @Test - public void getPropertiesMin() { - assertAsyncResponseStatusCode(bc.getPropertiesWithResponse(null), 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void getPropertiesAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.getPropertiesWithResponse(bac); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void getPropertiesACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.getPropertiesWithResponse(bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - /* - This test requires two accounts that are configured in a very specific way. It is not feasible to setup that - relationship programmatically, so we have recorded a successful interaction and only test recordings. - */ - @SuppressWarnings("deprecation") - @Test - @PlaybackOnly - public void getPropertiesORS() { - BlobAsyncClient sourceBlob = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient("test1") - .getBlobAsyncClient("javablobgetpropertiesors2blobapitestgetpropertiesors57d93407b"); - BlobAsyncClient destBlob = alternateBlobServiceAsyncClient.getBlobContainerAsyncClient("test2") - .getBlobAsyncClient("javablobgetpropertiesors2blobapitestgetpropertiesors57d93407b"); - - StepVerifier.create(sourceBlob.getProperties()) - .assertNext(r -> assertTrue(validateOR(r.getObjectReplicationSourcePolicies()))) - .verifyComplete(); - StepVerifier.create(sourceBlob.downloadWithResponse(null, null, null, false)) - .assertNext(r -> assertTrue(validateOR(r.getDeserializedHeaders().getObjectReplicationSourcePolicies()))) - .verifyComplete(); - - // There is a sas token attached at the end. Only check that the path is the same. - StepVerifier.create(destBlob.getProperties()).assertNext(r -> { - // disable recording copy source URL since the URL is redacted in playback mode - assertNotNull(r.getCopySource()); - assertEquals("fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80", r.getObjectReplicationDestinationPolicyId()); - }).verifyComplete(); - - StepVerifier.create(destBlob.downloadWithResponse(null, null, null, false)) - .assertNext(r -> assertEquals("fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80", - r.getDeserializedHeaders().getObjectReplicationDestinationPolicyId())) - .verifyComplete(); - } - - private static boolean validateOR(List policies) { - return policies.stream() - .filter(policy -> "fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80".equals(policy.getPolicyId())) - .findFirst() - .get() - .getRules() - .stream() - .filter(rule -> "105f9aad-f39b-4064-8e47-ccd7937295ca".equals(rule.getRuleId())) - .findFirst() - .get() - .getStatus() == ObjectReplicationStatus.COMPLETE; - } - - // Test getting the properties from a listing - - @Test - public void getPropertiesError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - StepVerifier.create(bc.getProperties()).verifyErrorSatisfies(r -> { - BlobStorageException ex = assertInstanceOf(BlobStorageException.class, r); - assertTrue(ex.getMessage().contains("BlobNotFound")); - }); - } - - @Test - public void setHTTPHeadersNull() { - StepVerifier.create(bc.setHttpHeadersWithResponse(null, null)).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertTrue(validateBasicHeaders(r.getHeaders())); - }).verifyComplete(); - } - - @Test - public void setHTTPHeadersMin() throws NoSuchAlgorithmException { - Mono response = bc.getProperties().flatMap(properties -> { - BlobHttpHeaders headers; - try { - headers = new BlobHttpHeaders().setContentEncoding(properties.getContentEncoding()) - .setContentDisposition(properties.getContentDisposition()) - .setContentType("type") - .setCacheControl(properties.getCacheControl()) - .setContentLanguage(properties.getContentLanguage()) - .setContentMd5( - Base64.getEncoder().encode(MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()))); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } - - return bc.setHttpHeaders(headers).then(bc.getProperties()); - }); - - StepVerifier.create(response).assertNext(r -> assertEquals("type", r.getContentType())).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("setHTTPHeadersHeadersSupplier") - public void setHTTPHeadersHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - BlobHttpHeaders putHeaders = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - StepVerifier.create(bc.setHttpHeaders(putHeaders).then(bc.getPropertiesWithResponse(null))) - .assertNext(r -> assertTrue(validateBlobProperties(r, cacheControl, contentDisposition, contentEncoding, - contentLanguage, contentMD5, contentType))) - .verifyComplete(); - } - - private static Stream setHTTPHeadersHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of("control", "disposition", "encoding", "language", - Base64.getEncoder().encode(MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes())), "type")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void setHTTPHeadersAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.setHttpHeadersWithResponse(null, bac); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void setHTTPHeadersACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.setHttpHeadersWithResponse(null, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void setHTTPHeadersError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - StepVerifier.create(bc.setHttpHeaders(null)).verifyError(BlobStorageException.class); - } - - @Test - public void setMetadataAllNull() { - StepVerifier.create(bc.setMetadataWithResponse(null, null)).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertTrue(validateBasicHeaders(r.getHeaders())); - assertTrue(Boolean.parseBoolean(r.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - }).verifyComplete(); - - StepVerifier.create(bc.getProperties()) - .assertNext(r -> assertEquals(0, r.getMetadata().size())) - .verifyComplete(); - } - - @Test - public void setMetadataMin() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - - StepVerifier.create(bc.setMetadata(metadata).then(bc.getProperties())) - .assertNext(r -> assertEquals(metadata, r.getMetadata())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("setMetadataMetadataSupplier") - public void setMetadataMetadata(String key1, String value1, String key2, String value2, int statusCode) { - Map metadata = new HashMap<>(); - if (key1 != null && value1 != null) { - metadata.put(key1, value1); - } - if (key2 != null && value2 != null) { - metadata.put(key2, value2); - } - - assertAsyncResponseStatusCode(bc.setMetadataWithResponse(metadata, null), statusCode); - StepVerifier.create(bc.getProperties()) - .assertNext(r -> assertEquals(metadata, r.getMetadata())) - .verifyComplete(); - } - - private static Stream setMetadataMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null, 200), Arguments.of("foo", "bar", "fizz", "buzz", 200), - Arguments.of("i0", "a", "i_", "a", 200), /* Test culture sensitive word sort */ - Arguments.of("foo", "bar0, bar1", null, null, 200)); /* Test comma separated values */ - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("downloadFileACSupplier") - public void setMetadataAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - return bc.setMetadataWithResponse(null, bac); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void setMetadataACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.setMetadataWithResponse(null, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("setMetadataWhitespaceErrorSupplier") - public void setMetadataWhitespaceError(String key, String value) { - Map metadata = new HashMap<>(); - metadata.put(key, value); - - StepVerifier.create(bc.setMetadata(metadata)).verifyError(Exception.class); - - // Need this second error type since for the first case, Netty throws IllegalArgumentException, and that is - // recorded in the playback file. On Playback, the framework will throw Exceptions.ReactiveException. - //assertTrue(e instanceof IllegalArgumentException || e instanceof Exceptions.ReactiveException); - } - - private static Stream setMetadataWhitespaceErrorSupplier() { - return Stream.of(Arguments.of(" foo", "bar"), // Leading whitespace key - Arguments.of("foo ", "bar"), // Trailing whitespace key - Arguments.of("foo", " bar"), // Leading whitespace value - Arguments.of("foo", "bar ")); // Trailing whitespace value - } - - @Test - public void setMetadataError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - - StepVerifier.create(bc.setMetadata(null)).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTagsAllNull() { - assertAsyncResponseStatusCode(bc.setTagsWithResponse(new BlobSetTagsOptions(new HashMap<>())), 204); - StepVerifier.create(bc.getTags()).assertNext(r -> assertEquals(0, r.size())).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTagsMin() { - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - StepVerifier.create(bc.setTags(tags).then(bc.getTags())) - .assertNext(r -> assertEquals(tags, r)) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("setTagsTagsSupplier") - public void setTagsTags(String key1, String value1, String key2, String value2, int statusCode) { - Map tags = new HashMap<>(); - if (key1 != null && value1 != null) { - tags.put(key1, value1); - } - if (key2 != null && value2 != null) { - tags.put(key2, value2); - } - assertAsyncResponseStatusCode(bc.setTagsWithResponse(new BlobSetTagsOptions(tags)), statusCode); - StepVerifier.create(bc.getTags()).assertNext(r -> assertEquals(tags, r)).verifyComplete(); - } - - private static Stream setTagsTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null, 204), Arguments.of("foo", "bar", "fizz", "buzz", 204), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null, 204)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("setTagsACSupplier") - public void setTagsAC(String tags) { - Map t = new HashMap<>(); - Map t2 = new HashMap<>(); - - t.put("foo", "bar"); - t2.put("fizz", "buzz"); - - Mono> response = bc.setTags(t) - .then(bc.setTagsWithResponse( - new BlobSetTagsOptions(t2).setRequestConditions(new BlobRequestConditions().setTagsConditions(tags)))); - - assertAsyncResponseStatusCode(response, 204); - } - - private static Stream setTagsACSupplier() { - return Stream.of(Arguments.of((String) null), Arguments.of("\"foo\" = 'bar'")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-07-07") - @Test - public void setTagsACFail() { - Map t = new HashMap<>(); - t.put("fizz", "buzz"); - String tags = "\"foo\" = 'bar'"; - - StepVerifier - .create(bc.setTagsWithResponse( - new BlobSetTagsOptions(t).setRequestConditions(new BlobRequestConditions().setTagsConditions(tags)))) - .verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getTagsAC() { - Map t = new HashMap<>(); - t.put("foo", "bar"); - String[] tagsList = new String[] { "null", "\"foo\" = 'bar'" }; - - Flux>> response = bc.setTags(t).thenMany(Flux.fromArray(tagsList).flatMap(tags -> { - if (Objects.equals(tags, "null")) { - // Handle the null case separately, Flux.fromArray doesn't like the null value - return bc.getTagsWithResponse( - new BlobGetTagsOptions().setRequestConditions(new BlobRequestConditions().setTagsConditions(null))); - } else { - return bc.getTagsWithResponse( - new BlobGetTagsOptions().setRequestConditions(new BlobRequestConditions().setTagsConditions(tags))); - } - })); - - StepVerifier.create(response).thenConsumeWhile(r -> { - assertEquals(200, r.getStatusCode()); - return true; - }).verifyComplete(); - } - - @Test - public void getTagsACFail() { - String tags = "\"foo\" = 'bar'"; - - StepVerifier - .create(bc.getTagsWithResponse( - new BlobGetTagsOptions().setRequestConditions(new BlobRequestConditions().setTagsConditions(tags)))) - .verifyError(BlobStorageException.class); - } - - @Test - public void setTagsError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - StepVerifier.create(bc.setTags(new HashMap<>())).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTagsLease() { - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - Mono> response = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID).flatMap(condition -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(convertNull(condition)); - return bc.setTagsWithResponse(new BlobSetTagsOptions(tags).setRequestConditions(bac)); - }).flatMap(r -> { - assertEquals(204, r.getStatusCode()); - return bc.getTags(); - }); - - StepVerifier.create(response).assertNext(r -> assertEquals(tags, r)).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getTagsLease() { - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - Mono>> response - = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID).flatMap(condition -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(convertNull(condition)); - return bc.setTagsWithResponse(new BlobSetTagsOptions(tags).setRequestConditions(bac)) - .then(bc.getTagsWithResponse(new BlobGetTagsOptions().setRequestConditions(bac))); - }); - - StepVerifier.create(response).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(tags, r.getValue()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTagsLeaseFail() { - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(GARBAGE_LEASE_ID); - - StepVerifier.create(bc.setTagsWithResponse(new BlobSetTagsOptions(tags).setRequestConditions(bac))) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(412, e.getStatusCode()); - }); - } - - @Test - public void snapshot() { - StepVerifier.create(bc.createSnapshotWithResponse(null, null).flatMap(r -> { - assertTrue(validateBasicHeaders(r.getHeaders())); - return r.getValue().exists(); - })).assertNext(Assertions::assertTrue).verifyComplete(); - } - - @Test - public void snapshotMin() { - assertAsyncResponseStatusCode(bc.createSnapshotWithResponse(null, null), 201); - } - - @Test - public void getSnapshot() { - byte[] data = "test".getBytes(); - String blobName = generateBlobName(); - BlockBlobAsyncClient bu = ccAsync.getBlobAsyncClient(blobName).getBlockBlobAsyncClient(); - - Mono response - = bu.upload(Flux.just(ByteBuffer.wrap(data)), data.length).then(bu.createSnapshot()); - - StepVerifier.create(response).assertNext(r -> { - BlockBlobAsyncClient snapshotBlob - = ccAsync.getBlobAsyncClient(blobName, r.getSnapshotId()).getBlockBlobAsyncClient(); - assertEquals(r.getSnapshotId(), snapshotBlob.getSnapshotId()); - assertNull(bu.getSnapshotId()); - }); - } - - @Test - public void isSnapshot() { - byte[] data = "test".getBytes(); - String blobName = generateBlobName(); - BlockBlobAsyncClient bu = ccAsync.getBlobAsyncClient(blobName).getBlockBlobAsyncClient(); - - Mono response - = bu.upload(Flux.just(ByteBuffer.wrap(data)), data.length).then(bu.createSnapshot()); - - StepVerifier.create(response).assertNext(r -> { - BlockBlobAsyncClient snapshotBlob - = ccAsync.getBlobAsyncClient(blobName, r.getSnapshotId()).getBlockBlobAsyncClient(); - assertTrue(snapshotBlob.isSnapshot()); - assertFalse(bu.isSnapshot()); - }); - } - - @ParameterizedTest - @MethodSource("snapshotMetadataSupplier") - public void snapshotMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null && value1 != null) { - metadata.put(key1, value1); - } - if (key2 != null && value2 != null) { - metadata.put(key2, value2); - } - - StepVerifier.create(bc.createSnapshotWithResponse(metadata, null).flatMap(r -> { - assertEquals(201, r.getStatusCode()); - return r.getValue().getProperties(); - })).assertNext(r -> assertEquals(metadata, r.getMetadata())).verifyComplete(); - } - - private static Stream snapshotMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void snapshotAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.createSnapshotWithResponse(null, bac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void snapshotACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.createSnapshotWithResponse(null, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void snapshotError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - StepVerifier.create(bc.createSnapshot()).verifyError(BlobStorageException.class); - } - - @Test - public void copy() { - BlockBlobAsyncClient copyDestBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - PollerFlux poller - = setPlaybackPollerFluxPollInterval(copyDestBlob.beginCopy(bc.getBlobUrl(), null)); - - Mono response = poller.last().flatMap(r -> { - assertNotNull(r); - assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, r.getStatus()); - BlobCopyInfo blobInfo = r.getValue(); - assertNotNull(blobInfo); - return copyDestBlob.getProperties().flatMap(properties -> { - assertEquals(properties.getCopyId(), blobInfo.getCopyId()); - return Mono.just(properties); - }); - }); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(CopyStatusType.SUCCESS, r.getCopyStatus()); - assertNotNull(r.getCopyCompletionTime()); - assertNotNull(r.getCopyProgress()); - assertNotNull(r.getCopySource()); - }).verifyComplete(); - } - - @Test - public void copyMin() { - BlockBlobAsyncClient copyDestBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - PollerFlux poller - = setPlaybackPollerFluxPollInterval(copyDestBlob.beginCopy(bc.getBlobUrl(), null)); - StepVerifier.create(poller.take(1)).assertNext(it -> { - assertNotNull(it.getValue()); - assertNotNull(it.getValue().getCopyId()); - if (ENVIRONMENT.getTestMode() == TestMode.PLAYBACK) { - // disable recording copy source URL since the URL is redacted in playback mode - assertNotNull(it.getValue().getCopySourceUrl()); - } else { - assertEquals(bc.getBlobUrl(), it.getValue().getCopySourceUrl()); - } - assertTrue(it.getStatus() == LongRunningOperationStatus.IN_PROGRESS - || it.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - }).verifyComplete(); - } - - @Test - public void copyPoller() { - BlockBlobAsyncClient copyDestBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - PollerFlux poller = setPlaybackPollerFluxPollInterval( - copyDestBlob.beginCopy(bc.getBlobUrl(), null, null, null, null, null, null)); - - Mono> lastResponse = poller.doOnNext(it -> { - assertNotNull(it.getValue()); - assertNotNull(it.getValue().getCopyId()); - if (ENVIRONMENT.getTestMode() == TestMode.PLAYBACK) { - // disable recording copy source URL since the URL is redacted in playback mode - assertNotNull(it.getValue().getCopySourceUrl()); - } else { - assertEquals(bc.getBlobUrl(), it.getValue().getCopySourceUrl()); - } - }).last(); - - Mono, BlobProperties>> response - = lastResponse.flatMap(r -> Mono.zip(Mono.just(r), copyDestBlob.getProperties())); - - StepVerifier.create(response).assertNext(it -> { - assertEquals(it.getT1().getValue().getCopyId(), it.getT2().getCopyId()); - assertEquals(CopyStatusType.SUCCESS, it.getT2().getCopyStatus()); - assertNotNull(it.getT2().getCopyCompletionTime()); - assertNotNull(it.getT2().getCopyProgress()); - assertNotNull(it.getT2().getCopySource()); - assertNotNull(it.getT2().getCopyId()); - }).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("snapshotMetadataSupplier") - public void copyMetadata(String key1, String value1, String key2, String value2) { - BlockBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - Map metadata = new HashMap<>(); - if (key1 != null && value1 != null) { - metadata.put(key1, value1); - } - if (key2 != null && value2 != null) { - metadata.put(key2, value2); - } - - PollerFlux poller - = setPlaybackPollerFluxPollInterval(bu2.beginCopy(bc.getBlobUrl(), metadata, null, null, null, null, null)); - - StepVerifier.create(poller.last().then(bu2.getProperties())) - .assertNext(it -> assertEquals(metadata, it.getMetadata())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("copyTagsSupplier") - public void copyTags(String key1, String value1, String key2, String value2) { - BlockBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - Map tags = new HashMap<>(); - if (key1 != null && value1 != null) { - tags.put(key1, value1); - } - if (key2 != null && value2 != null) { - tags.put(key2, value2); - } - - PollerFlux poller - = setPlaybackPollerFluxPollInterval(bu2.beginCopy(new BlobBeginCopyOptions(bc.getBlobUrl()).setTags(tags))); - - StepVerifier.create(poller.last().then(bu2.getTags())) - .assertNext(it -> assertEquals(tags, it)) - .verifyComplete(); - } - - private static Stream copyTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @CsvSource({ "true,true", "true,false", "false,true", "false,false" }) - public void copySeal(boolean source, boolean destination) { - AppendBlobAsyncClient appendBlobClient - = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - AppendBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - Mono response = appendBlobClient.create().flatMap(r -> { - Mono seal = Mono.empty(); - if (source) { - seal = appendBlobClient.seal(); - } - PollerFlux poller = setPlaybackPollerFluxPollInterval( - bu2.beginCopy(new BlobBeginCopyOptions(appendBlobClient.getBlobUrl()).setSealDestination(destination))); - return seal.then(poller.last()).then(bu2.getProperties()); - }); - - StepVerifier.create(response) - .assertNext(it -> assertEquals(Boolean.TRUE.equals(it.isSealed()), destination)) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("copySourceACSupplier") - public void copySourceAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - BlockBlobAsyncClient copyDestBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - Mono> response - = bc.setTags(t).then(setupBlobMatchCondition(bc, match)).flatMap(condition -> { - BlobBeginCopySourceRequestConditions mac - = new BlobBeginCopySourceRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(convertNull(condition)) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - PollerFlux poller - = copyDestBlob.beginCopy(new BlobBeginCopyOptions(bc.getBlobUrl()).setSourceRequestConditions(mac)); - return poller.last(); - }); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, r.getStatus())) - .verifyComplete(); - } - - private static Stream copySourceACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), Arguments.of(OLD_DATE, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null), Arguments.of(null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null), - Arguments.of(null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("copySourceACFailSupplier") - public void copySourceACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlockBlobAsyncClient copyDestBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - Mono> response - = setupBlobMatchCondition(bc, noneMatch).flatMap(condition -> { - BlobBeginCopySourceRequestConditions mac - = new BlobBeginCopySourceRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(convertNull(condition)) - .setTagsConditions(tags); - - PollerFlux poller - = copyDestBlob.beginCopy(new BlobBeginCopyOptions(bc.getBlobUrl()).setSourceRequestConditions(mac)); - return poller.last(); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream copySourceACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null), Arguments.of(null, OLD_DATE, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null), Arguments.of(null, null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, null, "\"foo\" = 'bar'")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void copyDestAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlockBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response - = bu2.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(bu2.setTags(t)) - .then(Mono.zip(setupBlobLeaseCondition(bu2, leaseID), setupBlobMatchCondition(bu2, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - PollerFlux poller = setPlaybackPollerFluxPollInterval( - bu2.beginCopy(bc.getBlobUrl(), null, null, null, null, bac, null)); - return poller.last(); - }); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, r.getStatus())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void copyDestACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlockBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - Mono> response - = bu2.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(Mono.zip(setupBlobLeaseCondition(bu2, leaseID), setupBlobMatchCondition(bu2, noneMatch), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - PollerFlux poller = setPlaybackPollerFluxPollInterval( - bu2.beginCopy(bc.getBlobUrl(), null, null, null, null, bac, null)); - return poller.last(); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void delete() { - StepVerifier.create(bc.deleteWithResponse(null, null)).assertNext(r -> { - HttpHeaders headers = r.getHeaders(); - - assertResponseStatusCode(r, 202); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(HttpHeaderName.DATE)); - }).verifyComplete(); - } - - @Test - public void deleteMin() { - assertAsyncResponseStatusCode(bc.deleteWithResponse(null, null), 202); - } - - @ParameterizedTest - @MethodSource("deleteOptionsSupplier") - public void deleteOptions(DeleteSnapshotsOptionType option, int blobsRemaining) { - // Create an extra blob so the list isn't empty (null) when we delete base blob, too - BlockBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - Mono response = bc.createSnapshot() - .then(bu2.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .then(bc.deleteWithResponse(option, null)) - .then(ccAsync.listBlobs().count()); - - StepVerifier.create(response).assertNext(r -> assertEquals(blobsRemaining, r)).verifyComplete(); - } - - private static Stream deleteOptionsSupplier() { - return Stream.of(Arguments.of(DeleteSnapshotsOptionType.INCLUDE, 1), - Arguments.of(DeleteSnapshotsOptionType.ONLY, 2)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void deleteAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, bac); - }); - - assertAsyncResponseStatusCode(response, 202); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void deleteACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void blobDeleteError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - StepVerifier.create(bc.delete()).verifyError(BlobStorageException.class); - } - - @Test - public void deleteIfExistsContainer() { - StepVerifier.create(bc.deleteIfExists()).assertNext(Assertions::assertTrue).verifyComplete(); - } - - @Test - public void deleteIfExists() { - - StepVerifier.create(bc.deleteIfExistsWithResponse(null, null)).assertNext(r -> { - HttpHeaders headers = r.getHeaders(); - - assertTrue(r.getValue()); - assertResponseStatusCode(r, 202); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(HttpHeaderName.DATE)); - }).verifyComplete(); - } - - @Test - public void deleteIfExistsMin() { - assertAsyncResponseStatusCode(bc.deleteIfExistsWithResponse(null, null), 202); - } - - @Test - public void deleteIfExistsBlobThatDoesNotExist() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - StepVerifier.create(bc.deleteIfExistsWithResponse(null, null)).assertNext(r -> { - assertFalse(r.getValue()); - assertEquals(404, r.getStatusCode()); - }).verifyComplete(); - } - - @Test - public void deleteIfExistsContainerThatWasAlreadyDeleted() { - StepVerifier.create(bc.deleteIfExistsWithResponse(null, null)).assertNext(r -> { - assertTrue(r.getValue()); - assertEquals(202, r.getStatusCode()); - }).verifyComplete(); - - StepVerifier.create(bc.deleteIfExistsWithResponse(null, null)).assertNext(r -> { - assertFalse(r.getValue()); - assertEquals(404, r.getStatusCode()); - }).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("deleteOptionsSupplier") - public void deleteIfExistsOptions(DeleteSnapshotsOptionType option, int blobsRemaining) { - // Create an extra blob so the list isn't empty (null) when we delete base blob, too - BlockBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - Mono response = bc.createSnapshot() - .then(bu2.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .then(bc.deleteIfExistsWithResponse(option, null)) - .then(ccAsync.listBlobs().count()); - - StepVerifier.create(response).assertNext(r -> assertEquals(blobsRemaining, r)).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void deleteIfExistsAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, bac); - }); - - assertAsyncResponseStatusCode(response, 202); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void deleteIfExistsACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream setTierBlockBlobSupplier() { - return Stream.of(Arguments.of(AccessTier.HOT), Arguments.of(AccessTier.COOL), Arguments.of(AccessTier.ARCHIVE)); - } - - @ParameterizedTest - @MethodSource("setTierBlockBlobSupplier") - public void setTierBlockBlob(AccessTier tier) { - Flux response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMapMany(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultData().remaining()) - .then(bc.setAccessTierWithResponse(tier, null, null)) - .flatMapMany(r -> { - HttpHeaders headers = r.getHeaders(); - - assertTrue(r.getStatusCode() == 200 || r.getStatusCode() == 202); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - return bc.getProperties().flatMapMany(props -> { - assertEquals(tier, props.getAccessTier()); - return cc.listBlobs(); - }); - }); - }); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(tier, r.getProperties().getAccessTier())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("setTierPageBlobSupplier") - public void setTierPageBlob(AccessTier tier) { - String containerName = generateContainerName(); - Flux response = premiumBlobServiceAsyncClient.createBlobContainer(containerName).flatMapMany(cc -> { - PageBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - return bc.create(512).then(bc.setAccessTier(tier)).then(bc.getProperties()).flatMapMany(r -> { - assertEquals(tier, r.getAccessTier()); - return cc.listBlobs(); - }); - }); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(tier, r.getProperties().getAccessTier())) - .verifyComplete(); - - //cleanup - premiumBlobServiceAsyncClient.deleteBlobContainer(containerName).block(); - } - - private static Stream setTierPageBlobSupplier() { - return Stream.of(Arguments.of(AccessTier.P4), Arguments.of(AccessTier.P6), Arguments.of(AccessTier.P10), - Arguments.of(AccessTier.P20), Arguments.of(AccessTier.P30), Arguments.of(AccessTier.P40), - Arguments.of(AccessTier.P50)); - } - - @Test - public void setTierMin() { - Mono> response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMap(cc -> { - BlockBlobAsyncClient bu = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bu.upload(DATA.getDefaultFlux(), DATA.getDefaultData().remaining()) - .then(bc.setAccessTierWithResponse(AccessTier.HOT, null, null)); - }); - - StepVerifier.create(response) - .assertNext(r -> assertTrue(r.getStatusCode() == 200 || r.getStatusCode() == 202)) - .verifyComplete(); - } - - @Test - public void setTierInferred() { - Flux response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMapMany(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(bc.getProperties()) - .flatMap(r -> { - assertTrue(r.isAccessTierInferred()); - return Mono.empty(); - }) - .thenMany(cc.listBlobs()) - .flatMap(r -> { - assertTrue(r.getProperties().isAccessTierInferred()); - return Mono.empty(); - }) - .then(bc.setAccessTier(AccessTier.HOT)) - .then(bc.getProperties()) - .flatMap(r -> { - assertNull(r.isAccessTierInferred()); - return Mono.empty(); - }) - .thenMany(cc.listBlobs()); - }); - - StepVerifier.create(response) - .assertNext(r -> assertNull(r.getProperties().isAccessTierInferred())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("setTierArchiveStatusSupplier") - public void setTierArchiveStatus(AccessTier sourceTier, AccessTier destTier, ArchiveStatus status) { - Flux response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMapMany(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(bc.setAccessTier(sourceTier)) - .then(bc.setAccessTier(destTier)) - .then(bc.getProperties()) - .flatMap(r -> { - assertEquals(status, r.getArchiveStatus()); - return Mono.empty(); - }) - .thenMany(cc.listBlobs()); - }); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(status, r.getProperties().getArchiveStatus())) - .verifyComplete(); - } - - private static Stream setTierArchiveStatusSupplier() { - return Stream.of(Arguments.of(AccessTier.ARCHIVE, AccessTier.COOL, ArchiveStatus.REHYDRATE_PENDING_TO_COOL), - Arguments.of(AccessTier.ARCHIVE, AccessTier.HOT, ArchiveStatus.REHYDRATE_PENDING_TO_HOT), - Arguments.of(AccessTier.ARCHIVE, AccessTier.HOT, ArchiveStatus.REHYDRATE_PENDING_TO_HOT)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void setTierCold() { - Flux response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMapMany(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultData().remaining()) - .then(bc.setAccessTierWithResponse(AccessTier.COLD, null, null)) - .flatMap(r -> { - HttpHeaders headers = r.getHeaders(); - - assertTrue(r.getStatusCode() == 200 || r.getStatusCode() == 202); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - return Mono.empty(); - }) - .then(bc.getProperties()) - .flatMap(r -> { - assertEquals(AccessTier.COLD, r.getAccessTier()); - return Mono.empty(); - }) - .thenMany(cc.listBlobs()); - }); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(AccessTier.COLD, r.getProperties().getAccessTier())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void setTierArchiveStatusRehydratePendingToCold() { - Flux response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMapMany(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(bc.setAccessTier(AccessTier.ARCHIVE)) - .then(bc.setAccessTier(AccessTier.COLD)) - .then(bc.getProperties()) - .flatMap(r -> { - assertEquals(ArchiveStatus.REHYDRATE_PENDING_TO_COLD, r.getArchiveStatus()); - return Mono.empty(); - }) - .thenMany(cc.listBlobs()); - }); - - StepVerifier.create(response) - .assertNext( - r -> assertEquals(ArchiveStatus.REHYDRATE_PENDING_TO_COLD, r.getProperties().getArchiveStatus())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("setTierRehydratePrioritySupplier") - public void setTierRehydratePriority(RehydratePriority rehydratePriority) { - Mono> rehydrate = Mono.empty(); - if (rehydratePriority != null) { - rehydrate = bc.setAccessTier(AccessTier.ARCHIVE) - .then(bc.setAccessTierWithResponse( - new BlobSetAccessTierOptions(AccessTier.HOT).setPriority(rehydratePriority))); - } - - StepVerifier.create(rehydrate.then(bc.getPropertiesWithResponse(null))).assertNext(r -> { - assertEquals(200, r.getStatusCode()); - assertEquals(rehydratePriority, r.getValue().getRehydratePriority()); - }).verifyComplete(); - } - - private static Stream setTierRehydratePrioritySupplier() { - return Stream.of(Arguments.of((RehydratePriority) null), Arguments.of(RehydratePriority.STANDARD), - Arguments.of(RehydratePriority.HIGH)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTierSnapshot() { - Mono response - = bc.createSnapshot().flatMap(bc2 -> bc2.setAccessTier(AccessTier.COOL).then(bc2.getProperties())); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(AccessTier.COOL, r.getAccessTier())) - .verifyComplete(); - - StepVerifier.create(bc.getProperties()) - .assertNext(r -> assertNotEquals(AccessTier.COOL, r.getAccessTier())) - .verifyComplete(); - } - - @Test - public void setTierSnapshotError() { - String fakeVersion = "2020-04-17T20:37:16.5129130Z"; - BlobAsyncClient bc2 = bc.getSnapshotClient(fakeVersion); - - StepVerifier.create(bc.createSnapshotWithResponse(null, null).then(bc2.setAccessTier(AccessTier.COOL))) - .verifyError(BlobStorageException.class); - } - - @Test - public void setTierError() { - Mono response = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMap(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(bc.setAccessTier(AccessTier.fromString("garbage"))); - }); - - StepVerifier.create(response).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.INVALID_HEADER_VALUE, e.getErrorCode()); - }); - } - - @Test - public void setTierIllegalArgument() { - StepVerifier.create(bc.setAccessTier(null)).verifyError(NullPointerException.class); - } - - @Test - public void setTierLease() { - Mono> response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMap(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID)) - .flatMap(condition -> bc.setAccessTierWithResponse(AccessTier.HOT, null, convertNull(condition))); - }); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @Test - public void setTierLeaseFail() { - Mono> response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMap(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(bc.setAccessTierWithResponse(AccessTier.HOT, null, "garbage")); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void setTierTags() { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMap(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(bc.setTags(t)) - .then(bc.setAccessTierWithResponse( - new BlobSetAccessTierOptions(AccessTier.HOT).setTagsConditions("\"foo\" = 'bar'"))); - }); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @Test - public void setTierTagsFail() { - Mono> response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMap(cc -> { - BlockBlobAsyncClient bc = cc.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(bc.setAccessTierWithResponse( - new BlobSetAccessTierOptions(AccessTier.HOT).setTagsConditions("\"foo\" = 'bar'"))); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("copyWithTierSupplier") - public void copyWithTier(AccessTier tier1, AccessTier tier2) { - String blobName = generateBlobName(); - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(blobName).getBlockBlobAsyncClient(); - BlockBlobAsyncClient bcCopy = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - String secondSas = ccAsync.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - Mono response - = bc.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null, tier1, null, null) - .then(bcCopy.copyFromUrlWithResponse(bc.getBlobUrl() + "?" + secondSas, null, tier2, null, null)) - .then(bcCopy.getProperties()); - - StepVerifier.create(response).assertNext(r -> assertEquals(tier2, r.getAccessTier())).verifyComplete(); - } - - private static Stream copyWithTierSupplier() { - return Stream.of(Arguments.of(AccessTier.HOT, AccessTier.COOL), Arguments.of(AccessTier.COOL, AccessTier.HOT)); - } - - @Test - public void undeleteError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - StepVerifier.create(bc.undelete()).verifyError(BlobStorageException.class); - } - - @Test - public void getAccountInfo() { - StepVerifier.create(primaryBlobServiceAsyncClient.getAccountInfoWithResponse()).assertNext(r -> { - assertNotNull(r.getHeaders().getValue(HttpHeaderName.DATE)); - assertNotNull(r.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(r.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(r.getValue().getAccountKind()); - assertNotNull(r.getValue().getSkuName()); - assertFalse(r.getValue().isHierarchicalNamespaceEnabled()); - }).verifyComplete(); - } - - @Test - public void getAccountInfoMin() { - assertAsyncResponseStatusCode(bc.getAccountInfoWithResponse(), 200); - } - - @Test - public void getAccountInfoBase() { - StepVerifier.create(bc.getAccountInfo()).assertNext(r -> { - assertNotNull(r.getAccountKind()); - assertNotNull(r.getSkuName()); - assertFalse(r.isHierarchicalNamespaceEnabled()); - }).verifyComplete(); - } - - @Test - public void getAccountInfoBaseFail() { - BlobServiceAsyncClient serviceClient - = instrument(new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(new MockTokenCredential())).buildAsyncClient(); - - BlobAsyncClient blobClient - = serviceClient.getBlobContainerAsyncClient(generateContainerName()).getBlobAsyncClient(generateBlobName()); - - StepVerifier.create(blobClient.getAccountInfo()).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.INVALID_AUTHENTICATION_INFO, e.getErrorCode()); - }); - } - - @Test - public void getContainerName() { - assertEquals(containerName, bc.getContainerName()); - } - - @Test - public void getContainerClient() { - String sasToken = ccAsync.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(2), - new BlobSasPermission().setReadPermission(true))); - - // Ensure a sas token is also persisted - ccAsync = getContainerAsyncClient(sasToken, ccAsync.getBlobContainerUrl()); - - // Ensure the correct endpoint - assertEquals(ccAsync.getBlobContainerUrl(), bc.getContainerAsyncClient().getBlobContainerUrl()); - // Ensure it is a functional client - StepVerifier.create(bc.getContainerAsyncClient().getProperties()) - .assertNext(Assertions::assertNotNull) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("getBlobNameSupplier") - public void getBlobName(String inputName, String expectedOutputName) { - bc = ccAsync.getBlobAsyncClient(inputName); - assertEquals(expectedOutputName, bc.getBlobName()); - } - - private static Stream getBlobNameSupplier() { - return Stream.of(Arguments.of("blobName", "blobName"), Arguments.of("dir1/a%20b.txt", "dir1/a%20b.txt"), - Arguments.of("path/to]a blob", "path/to]a blob"), - Arguments.of("path%2Fto%5Da%20blob", "path%2Fto%5Da%20blob"), Arguments.of("斑點", "斑點"), - Arguments.of("%E6%96%91%E9%BB%9E", "%E6%96%91%E9%BB%9E"), Arguments.of("斑點", "斑點")); - } - - @ParameterizedTest - @MethodSource("getBlobNameSupplier") - public void getBlobNameAndBuildClient(String originalBlobName, String finalBlobName) { - BlobAsyncClient client = ccAsync.getBlobAsyncClient(originalBlobName); - BlobAsyncClientBase baseClient = ccAsync.getBlobAsyncClient(client.getBlobName()).getBlockBlobAsyncClient(); - - assertEquals(finalBlobName, baseClient.getBlobName()); - } - - private static Stream getNonEncodedBlobNameSupplier() { - return Stream.of(Arguments.of("test%test"), - Arguments.of("ab2a7d5f-b973-4222-83ba-d0581817a819 %Россия 한국 中国!?/file"), - Arguments.of("%E6%96%91%E9%BB%9E"), Arguments.of("斑點")); - } - - @ParameterizedTest - @MethodSource("getNonEncodedBlobNameSupplier") - public void getNonEncodedBlobName(String originalBlobName) { - BlobAsyncClient client = ccAsync.getBlobAsyncClient(originalBlobName); - BlockBlobAsyncClient blockBlobClient - = ccAsync.getBlobAsyncClient(client.getBlobName()).getBlockBlobAsyncClient(); - assertEquals(blockBlobClient.getBlobName(), originalBlobName); - - // see if the blob name will be properly encoded in the url - String encodedName = Utility.urlEncode(originalBlobName); - assertTrue(ccAsync.getBlobAsyncClient(originalBlobName).getBlobUrl().contains(encodedName)); - } - - @Test - public void getNonEncodedSpecializedBlob() { - String originalBlobName = "test%test"; - SpecializedBlobClientBuilder specializedBlobClientBuilder - = getSpecializedBuilder(ccAsync.getBlobContainerUrl()); - specializedBlobClientBuilder.containerName(ccAsync.getBlobContainerName()).blobName(originalBlobName); - - BlockBlobAsyncClient blockBlobClient = specializedBlobClientBuilder.buildBlockBlobAsyncClient(); - assertEquals(blockBlobClient.getBlobName(), originalBlobName); - - // see if the blob name will be properly encoded in the url - String encodedName = Utility.urlEncode(originalBlobName); - assertTrue(ccAsync.getBlobAsyncClient(originalBlobName).getBlobUrl().contains(encodedName)); - } - - @Test - public void getNonEncodedBlobClient() { - String originalBlobName = "test%test"; - BlobClientBuilder blobClientBuilder = getBlobClientBuilder(ccAsync.getBlobContainerUrl()); - blobClientBuilder.containerName(ccAsync.getBlobContainerName()).blobName(originalBlobName); - - BlobAsyncClient blobClient = blobClientBuilder.buildAsyncClient(); - assertEquals(blobClient.getBlobName(), originalBlobName); - - // see if the blob name will be properly encoded in the url - String encodedName = Utility.urlEncode(originalBlobName); - assertTrue(ccAsync.getBlobAsyncClient(originalBlobName).getBlobUrl().contains(encodedName)); - } - - @Test - public void builderCpkValidation() { - URL endpoint = BlobUrlParts.parse(bc.getBlobUrl()).setScheme("http").toUrl(); - BlobClientBuilder builder = new BlobClientBuilder() - .customerProvidedKey(new CustomerProvidedKey(Base64.getEncoder().encodeToString(getRandomByteArray(256)))) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildAsyncClient); - } - - @Test - public void builderBearerTokenValidation() { - URL endpoint = BlobUrlParts.parse(bc.getBlobUrl()).setScheme("http").toUrl(); - BlobClientBuilder builder = new BlobClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildAsyncClient); - } - - @Test - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - public void perCallPolicy() { - bc = getBlobClientBuilder(bc.getBlobUrl()).addPolicy(getPerCallVersionPolicy()).buildAsyncClient(); - StepVerifier.create(bc.getPropertiesWithResponse(null)) - .assertNext(r -> assertEquals("2017-11-09", r.getHeaders().getValue(X_MS_VERSION))) - .verifyComplete(); - } - - @Test - public void specializedChildClientGetsCached() { - assertEquals(bc.getBlockBlobAsyncClient(), bc.getBlockBlobAsyncClient()); - assertEquals(bc.getAppendBlobAsyncClient(), bc.getAppendBlobAsyncClient()); - assertEquals(bc.getPageBlobAsyncClient(), bc.getPageBlobAsyncClient()); - } - - @Test - public void defaultAudience() { - BlobAsyncClient aadBlob - = getBlobClientBuilderWithTokenCredential(bc.getBlobUrl()).audience(null).buildAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - - @Test - public void storageAccountAudience() { - BlobAsyncClient aadBlob = getBlobClientBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(ccAsync.getAccountName())) - .buildAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - BlobAsyncClient aadBlob = getBlobClientBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildAsyncClient(); - - StepVerifier.create(aadBlob.getProperties()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", ccAsync.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - BlobAsyncClient aadBlob - = getBlobClientBuilderWithTokenCredential(bc.getBlobUrl()).audience(audience).buildAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobErrorDeserializationTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobErrorDeserializationTests.java deleted file mode 100644 index a9561ee4882f..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobErrorDeserializationTests.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.test.http.MockHttpResponse; -import com.azure.core.test.utils.MockTokenCredential; -import com.azure.storage.blob.models.BlobStorageException; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; - -import java.nio.charset.StandardCharsets; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Tests cases where the service returns a response that would result in a {@link BlobStorageException} being thrown - * with a response body that needs to be deserialized. - */ -public class BlobErrorDeserializationTests { - @Test - public void errorResponseBody() { - String errorResponse = "ContainerAlreadyExists" - + "The specified container already exists."; - HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just( - new MockHttpResponse(request, 409, new HttpHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/xml"), - errorResponse.getBytes(StandardCharsets.UTF_8)))) - .build(); - BlobContainerClient containerClient - = new BlobContainerClientBuilder().endpoint("https://account.blob.core.windows.net/container") - .credential(new MockTokenCredential()) - .pipeline(httpPipeline) - .buildClient(); - - BlobStorageException exception = assertThrows(BlobStorageException.class, containerClient::create); - assertTrue(exception.getMessage().contains("The specified container already exists.")); - // assertEquals(BlobErrorCode.CONTAINER_ALREADY_EXISTS, exception.getErrorCode()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobOutputStreamTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobOutputStreamTests.java deleted file mode 100644 index 769ad30eb5bf..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobOutputStreamTests.java +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpClient; -import com.azure.core.http.policy.FixedDelayOptions; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.test.utils.TestUtils; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.options.BlockBlobOutputStreamOptions; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlobOutputStream; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Mono; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.time.Duration; -import java.util.Arrays; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertThrows; - -@LiveOnly -public class BlobOutputStreamTests extends BlobTestBase { - private static final int FOUR_MB = 4 * Constants.MB; - - @Test - public void blockBlobOutputStream() throws IOException { - byte[] data = getRandomByteArray(10 * Constants.MB); - BlockBlobClient blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - BlobOutputStream outputStream = blockBlobClient.getBlobOutputStream(); - outputStream.write(data); - outputStream.close(); - - assertEquals(data.length, blockBlobClient.getProperties().getBlobSize()); - TestUtils.assertArraysEqual(convertInputStreamToByteArray(blockBlobClient.openInputStream()), data); - } - - @Test - public void blockBlobOutputStreamWithCloseMultipleTimes() throws IOException { - byte[] data = getRandomByteArray(10 * Constants.MB); - BlockBlobClient blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - // set option for allowing multiple close() calls - BlobOutputStream outputStream = blockBlobClient.getBlobOutputStream(new BlockBlobOutputStreamOptions()); - - outputStream.write(data); - outputStream.close(); - String etag = blockBlobClient.getProperties().getETag(); - - assertEquals(etag, blockBlobClient.getProperties().getETag()); - // call again, no exceptions should be thrown - outputStream.close(); - assertEquals(etag, blockBlobClient.getProperties().getETag()); - outputStream.close(); - assertEquals(etag, blockBlobClient.getProperties().getETag()); - - assertEquals(data.length, blockBlobClient.getProperties().getBlobSize()); - TestUtils.assertArraysEqual(convertInputStreamToByteArray(blockBlobClient.openInputStream()), data); - } - - @Test - public void blockBlobOutputStreamDefaultNoOverwrite() throws IOException { - byte[] data = getRandomByteArray(10 * Constants.MB); - BlockBlobClient blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - BlobOutputStream outputStream1 = blockBlobClient.getBlobOutputStream(); - outputStream1.write(data); - outputStream1.close(); - - assertThrows(IllegalArgumentException.class, blockBlobClient::getBlobOutputStream); - } - - @Test - public void blockBlobOutputStreamDefaultNoOverwriteInterrupted() throws IOException { - byte[] data = getRandomByteArray(10 * Constants.MB); - BlockBlobClient blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - BlobOutputStream outputStream1 = blockBlobClient.getBlobOutputStream(); - BlobOutputStream outputStream2 = blockBlobClient.getBlobOutputStream(); - outputStream2.write(data); - outputStream2.close(); - - outputStream1.write(data); - IOException e = assertThrows(IOException.class, outputStream1::close); - - assertInstanceOf(BlobStorageException.class, e.getCause()); - assertEquals(BlobErrorCode.BLOB_ALREADY_EXISTS, ((BlobStorageException) e.getCause()).getErrorCode()); - } - - @Test - public void blockBlobOutputStreamOverwrite() throws IOException { - byte[] randomData = getRandomByteArray(10 * Constants.MB); - BlockBlobClient blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - blockBlobClient.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - BlobOutputStream outputStream = blockBlobClient.getBlobOutputStream(true); - outputStream.write(randomData); - outputStream.close(); - - assertEquals(blockBlobClient.getProperties().getBlobSize(), randomData.length); - TestUtils.assertArraysEqual(convertInputStreamToByteArray(blockBlobClient.openInputStream()), randomData); - } - - @ParameterizedTest - @MethodSource("blockBlobOutputStreamErrorSupplier") - public void blockBlobOutputStreamError(Exception exception, Class expectedExceptionClass) { - StorageSharedKeyCredential credentials = new StorageSharedKeyCredential("accountName", "accountKey"); - String endpoint = "https://account.blob.core.windows.net/"; - byte[] data = getRandomByteArray(10 * Constants.MB); - HttpClient httpClient = httpRequest -> Mono.error(exception); - BlockBlobClient blockBlobClient = new SpecializedBlobClientBuilder().endpoint(endpoint) - .containerName("container") - .blobName("blob") - .retryOptions(new RetryOptions(new FixedDelayOptions(0, Duration.ofMillis(1)))) - .credential(credentials) - .httpClient(httpClient) - .buildBlockBlobClient(); - - BlobOutputStream outputStream = blockBlobClient.getBlobOutputStream(true); - outputStream.write(data); - Exception e = assertThrows(IOException.class, outputStream::close); - - if (expectedExceptionClass != IOException.class) { /* IOExceptions are not wrapped. */ - //assertEquals(exception, e); - assertInstanceOf(expectedExceptionClass, e.getCause()); - } - } - - private static Stream blockBlobOutputStreamErrorSupplier() { - return Stream.of(Arguments.of(new BlobStorageException(null, null, null), BlobStorageException.class), - Arguments.of(new IllegalArgumentException(), IllegalArgumentException.class), - Arguments.of(new IOException(), IOException.class)); - } - - @Test - public void blockBlobOutputStreamBufferReuse() throws IOException { - byte[] data = getRandomByteArray(10 * Constants.KB); - ByteArrayInputStream inputStream = new ByteArrayInputStream(data); - byte[] buffer = new byte[1024]; - BlockBlobClient blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - BlobOutputStream outputStream = blockBlobClient.getBlobOutputStream(); - for (int i = 0; i < 10; i++) { - inputStream.read(buffer); - outputStream.write(buffer); - } - outputStream.close(); - - assertEquals(data.length, blockBlobClient.getProperties().getBlobSize()); - TestUtils.assertArraysEqual(convertInputStreamToByteArray(blockBlobClient.openInputStream()), data); - } - - @Test - public void pageBlobOutputStream() throws IOException { - byte[] data = getRandomByteArray(16 * Constants.MB - 512); - PageBlobClient pageBlobClient = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - pageBlobClient.create(data.length); - - BlobOutputStream outputStream - = pageBlobClient.getBlobOutputStream(new PageRange().setStart(0).setEnd(16 * Constants.MB - 1)); - outputStream.write(data); - outputStream.close(); - - TestUtils.assertArraysEqual(convertInputStreamToByteArray(pageBlobClient.openInputStream()), data); - } - - @Test - public void appendBlobOutputStream() throws IOException { - byte[] data = getRandomByteArray(4 * FOUR_MB); - AppendBlobClient appendBlobClient = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - appendBlobClient.create(); - - BlobOutputStream outputStream = appendBlobClient.getBlobOutputStream(); - for (int i = 0; i != 4; i++) { - outputStream.write(Arrays.copyOfRange(data, i * FOUR_MB, ((i + 1) * FOUR_MB))); - } - outputStream.close(); - - assertEquals(appendBlobClient.getProperties().getBlobSize(), data.length); - TestUtils.assertArraysEqual(convertInputStreamToByteArray(appendBlobClient.openInputStream()), data); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2022-11-02") - @Test - public void appendBlobOutputStreamHighThroughput() throws IOException { - // using data greater than 4MB and service versions above 2022_11_02 to test uploading up to 100MB per block - byte[] data = getRandomByteArray(2 * FOUR_MB); - AppendBlobClient appendBlobClient = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - appendBlobClient.create(); - - BlobOutputStream outputStream = appendBlobClient.getBlobOutputStream(); - outputStream.write(data); - outputStream.close(); - - TestUtils.assertArraysEqual(convertInputStreamToByteArray(appendBlobClient.openInputStream()), data); - } - - @Test - public void appendBlobOutputStreamOverwrite() throws IOException { - byte[] data = getRandomByteArray(FOUR_MB); - AppendBlobClient appendBlobClient = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - appendBlobClient.create(); - - BlobOutputStream outputStream = appendBlobClient.getBlobOutputStream(); - outputStream.write(data); - outputStream.close(); - - TestUtils.assertArraysEqual(convertInputStreamToByteArray(appendBlobClient.openInputStream()), data); - - byte[] data2 = getRandomByteArray(FOUR_MB); - - BlobOutputStream outputStream2 = appendBlobClient.getBlobOutputStream(true); - outputStream2.write(data2); - outputStream2.close(); - - assertEquals(appendBlobClient.getProperties().getBlobSize(), data2.length); - TestUtils.assertArraysEqual(convertInputStreamToByteArray(appendBlobClient.openInputStream()), data2); - } - - @Test - public void appendBlobOutputStreamOverwriteFalse() throws IOException { - byte[] data = getRandomByteArray(Constants.MB); - AppendBlobClient appendBlobClient = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - appendBlobClient.create(); - - BlobOutputStream outputStream = appendBlobClient.getBlobOutputStream(); - outputStream.write(data); - outputStream.close(); - - TestUtils.assertArraysEqual(convertInputStreamToByteArray(appendBlobClient.openInputStream()), data); - - byte[] data2 = getRandomByteArray(Constants.MB); - outputStream = appendBlobClient.getBlobOutputStream(false); - outputStream.write(data2); - outputStream.close(); - - byte[] finalData = new byte[2 * Constants.MB]; - System.arraycopy(data, 0, finalData, 0, data.length); - System.arraycopy(data2, 0, finalData, data.length, data2.length); - TestUtils.assertArraysEqual(convertInputStreamToByteArray(appendBlobClient.openInputStream()), finalData); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceClientBuilderTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceClientBuilderTests.java deleted file mode 100644 index 3f20f32ce134..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceClientBuilderTests.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.test.http.NoOpHttpClient; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class BlobServiceClientBuilderTests { - - @Test - public void createBlobServiceClientWithEndpoint() { - BlobServiceClient client = new BlobServiceClientBuilder().endpoint("https://127.0.0.1:10000") - .httpClient(new NoOpHttpClient()) - .buildClient(); - - assertEquals(client.getAccountUrl(), "https://127.0.0.1:10000/"); - } - - @Test - public void createBlobServiceClientWithConnectionString() { - BlobServiceClient client = new BlobServiceClientBuilder().connectionString( - "DefaultEndpointsProtocol=https;AccountName=test;AccountKey=test;EndpointSuffix=ignored;BlobEndpoint=https://127.0.0.1:10000") - .httpClient(new NoOpHttpClient()) - .buildClient(); - - assertEquals(client.getAccountUrl(), "https://127.0.0.1:10000/"); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceSasModelsTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceSasModelsTests.java deleted file mode 100644 index 9de688690e50..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceSasModelsTests.java +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.Context; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BlobServiceSasModelsTests extends BlobTestBase { - - @ParameterizedTest - @MethodSource("blobSASPermissionsToStringSupplier") - public void blobSASPermissionsToString(boolean read, boolean write, boolean delete, boolean create, boolean add, - boolean deleteVersion, boolean tags, boolean list, boolean move, boolean execute, boolean setImmutabilityPolicy, - String expectedString) { - BlobSasPermission perms = new BlobSasPermission().setReadPermission(read) - .setWritePermission(write) - .setDeletePermission(delete) - .setCreatePermission(create) - .setAddPermission(add) - .setDeleteVersionPermission(deleteVersion) - .setTagsPermission(tags) - .setListPermission(list) - .setMovePermission(move) - .setExecutePermission(execute) - .setImmutabilityPolicyPermission(setImmutabilityPolicy); - - assertEquals(perms.toString(), expectedString); - } - - private static Stream blobSASPermissionsToStringSupplier() { - return Stream.of(Arguments.of(true, false, false, false, false, false, false, false, false, false, false, "r"), - Arguments.of(false, true, false, false, false, false, false, false, false, false, false, "w"), - Arguments.of(false, false, true, false, false, false, false, false, false, false, false, "d"), - Arguments.of(false, false, false, true, false, false, false, false, false, false, false, "c"), - Arguments.of(false, false, false, false, true, false, false, false, false, false, false, "a"), - Arguments.of(false, false, false, false, false, true, false, false, false, false, false, "x"), - Arguments.of(false, false, false, false, false, false, true, false, false, false, false, "t"), - Arguments.of(false, false, false, false, false, false, false, true, false, false, false, "l"), - Arguments.of(false, false, false, false, false, false, false, false, true, false, false, "m"), - Arguments.of(false, false, false, false, false, false, false, false, false, true, false, "e"), - Arguments.of(false, false, false, false, false, false, false, false, false, false, true, "i"), - Arguments.of(true, true, true, true, true, true, true, true, true, true, true, "racwdxltmei")); - } - - @ParameterizedTest - @MethodSource("blobSASPermissionsParseSupplier") - public void blobSASPermissionsParse(boolean read, boolean write, boolean delete, boolean create, boolean add, - boolean deleteVersion, boolean tags, boolean list, boolean move, boolean execute, boolean setImmutabilityPolicy, - String expectedString) { - BlobSasPermission perms = BlobSasPermission.parse(expectedString); - - assertEquals(read, perms.hasReadPermission()); - assertEquals(write, perms.hasWritePermission()); - assertEquals(delete, perms.hasDeletePermission()); - assertEquals(create, perms.hasCreatePermission()); - assertEquals(add, perms.hasAddPermission()); - assertEquals(deleteVersion, perms.hasDeleteVersionPermission()); - assertEquals(tags, perms.hasTagsPermission()); - assertEquals(list, perms.hasListPermission()); - assertEquals(move, perms.hasMovePermission()); - assertEquals(execute, perms.hasExecutePermission()); - assertEquals(setImmutabilityPolicy, perms.hasImmutabilityPolicyPermission()); - } - - private static Stream blobSASPermissionsParseSupplier() { - return Stream.of(Arguments.of(true, false, false, false, false, false, false, false, false, false, false, "r"), - Arguments.of(false, true, false, false, false, false, false, false, false, false, false, "w"), - Arguments.of(false, false, true, false, false, false, false, false, false, false, false, "d"), - Arguments.of(false, false, false, true, false, false, false, false, false, false, false, "c"), - Arguments.of(false, false, false, false, true, false, false, false, false, false, false, "a"), - Arguments.of(false, false, false, false, false, true, false, false, false, false, false, "x"), - Arguments.of(false, false, false, false, false, false, true, false, false, false, false, "t"), - Arguments.of(false, false, false, false, false, false, false, true, false, false, false, "l"), - Arguments.of(false, false, false, false, false, false, false, false, true, false, false, "m"), - Arguments.of(false, false, false, false, false, false, false, false, false, true, false, "e"), - Arguments.of(false, false, false, false, false, false, false, false, false, false, true, "i"), - Arguments.of(true, true, true, true, true, true, true, true, true, true, true, "racwdxltmei"), - Arguments.of(true, true, true, true, true, true, true, true, true, true, true, "dtcxiewlrma")); - } - - @Test - public void blobSASPermissionsParseIA() { - assertThrows(IllegalArgumentException.class, () -> BlobSasPermission.parse("rwaq")); - } - - @Test - public void blobSasPermissionNull() { - assertThrows(NullPointerException.class, () -> BlobSasPermission.parse(null)); - } - - @ParameterizedTest - @MethodSource("blobSASPermissionsToStringSupplier") - public void containerSASPermissionsToString(boolean read, boolean write, boolean delete, boolean create, - boolean add, boolean deleteVersion, boolean tags, boolean list, boolean move, boolean execute, - boolean setImmutabilityPolicy, String expectedString) { - BlobContainerSasPermission perms = new BlobContainerSasPermission().setReadPermission(read) - .setWritePermission(write) - .setDeletePermission(delete) - .setCreatePermission(create) - .setAddPermission(add) - .setListPermission(list) - .setDeleteVersionPermission(deleteVersion) - .setTagsPermission(tags) - .setMovePermission(move) - .setExecutePermission(execute) - .setImmutabilityPolicyPermission(setImmutabilityPolicy); - - assertEquals(perms.toString(), expectedString); - } - - @ParameterizedTest - @MethodSource("blobSASPermissionsParseSupplier") - public void containerSASPermissionsParse(boolean read, boolean write, boolean delete, boolean create, boolean add, - boolean deleteVersion, boolean tags, boolean list, boolean move, boolean execute, boolean setImmutabilityPolicy, - String expectedString) { - BlobContainerSasPermission perms = BlobContainerSasPermission.parse(expectedString); - - assertEquals(read, perms.hasReadPermission()); - assertEquals(write, perms.hasWritePermission()); - assertEquals(delete, perms.hasDeletePermission()); - assertEquals(create, perms.hasCreatePermission()); - assertEquals(add, perms.hasAddPermission()); - assertEquals(deleteVersion, perms.hasDeleteVersionPermission()); - assertEquals(tags, perms.hasTagsPermission()); - assertEquals(list, perms.hasListPermission()); - assertEquals(move, perms.hasMovePermission()); - assertEquals(execute, perms.hasExecutePermission()); - assertEquals(setImmutabilityPolicy, perms.hasImmutabilityPolicyPermission()); - } - - @Test - public void containerSASPermissionsParseIA() { - assertThrows(IllegalArgumentException.class, () -> BlobContainerSasPermission.parse("rwaq")); - } - - @Test - public void containerSASPermissionsNull() { - assertThrows(NullPointerException.class, () -> BlobContainerSasPermission.parse(null)); - } - - @Test - public void blobSasImplUtilNull() { - OffsetDateTime e = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - BlobSasPermission p = new BlobSasPermission().setReadPermission(true); - BlobServiceSasSignatureValues v = new BlobServiceSasSignatureValues(e, p); - BlobSasImplUtil implUtil = new BlobSasImplUtil(v, "containerName", "blobName", null, null, null); - - NullPointerException ex - = assertThrows(NullPointerException.class, () -> implUtil.generateSas(null, Context.NONE)); - assertTrue(ex.getMessage().contains("storageSharedKeyCredential")); - - ex = assertThrows(NullPointerException.class, - () -> implUtil.generateUserDelegationSas(null, "accountName", Context.NONE)); - assertTrue(ex.getMessage().contains("delegationKey")); - - ex = assertThrows(NullPointerException.class, - () -> implUtil.generateUserDelegationSas(new UserDelegationKey(), null, Context.NONE)); - - assertTrue(ex.getMessage().contains("accountName")); - } - - @SuppressWarnings("deprecation") - @Test - public void ensureStateIllegalArgument() { - BlobServiceSasSignatureValues sasSignatureValues = new BlobServiceSasSignatureValues(); - BlobSasImplUtil implUtil = new BlobSasImplUtil(sasSignatureValues, null); - assertThrows(IllegalStateException.class, - () -> implUtil.generateSas(ENVIRONMENT.getPrimaryAccount().getCredential(), Context.NONE)); - } - - @ParameterizedTest - @MethodSource("ensureStateResourceAndPermissionSupplier") - public void ensureStateResourceAndPermission(String container, String blob, String snapshot, String versionId, - BlobContainerSasPermission blobContainerSasPermission, BlobSasPermission blobSasPermission, String resource, - String permissionString) { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - BlobServiceSasSignatureValues values = blobContainerSasPermission != null - ? new BlobServiceSasSignatureValues(expiryTime, blobContainerSasPermission) - : new BlobServiceSasSignatureValues(expiryTime, blobSasPermission); - - BlobSasImplUtil implUtil = new BlobSasImplUtil(values, container, blob, snapshot, versionId, null); - implUtil.ensureState(); - assertEquals(resource, implUtil.getResource()); - assertEquals(permissionString, implUtil.getPermissions()); - } - - private static Stream ensureStateResourceAndPermissionSupplier() { - return Stream.of( - Arguments.of("container", null, null, null, - new BlobContainerSasPermission().setReadPermission(true).setListPermission(true), null, "c", "rl"), - Arguments.of("container", "blob", null, null, null, new BlobSasPermission().setReadPermission(true), "b", - "r"), - Arguments.of("container", "blob", "snapshot", null, null, new BlobSasPermission().setReadPermission(true), - "bs", "r"), - Arguments.of("container", "blob", null, "version", null, new BlobSasPermission().setReadPermission(true), - "bv", "r")); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceVersionTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceVersionTests.java deleted file mode 100644 index 50531cf4378b..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceVersionTests.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.DevopsPipeline; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledIf; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class BlobServiceVersionTests { - @DisabledIf("doNotRun") - @Test - public void getLatestPointsToLatest() { - BlobServiceVersion[] values = BlobServiceVersion.values(); - assertEquals(values[values.length - 1], BlobServiceVersion.getLatest()); - } - - @DisabledIf("doNotRun") - @Test - public void sasVersionShouldMatchLastWhenWeRelease() { - assertEquals(Constants.SAS_SERVICE_VERSION, BlobServiceVersion.getLatest().getVersion()); - } - - @SuppressWarnings("deprecation") - @DisabledIf("doNotRun") - @Test - public void headerVersionShouldMatchLastWhenWeRelease() { - assertEquals(Constants.HeaderConstants.TARGET_STORAGE_VERSION, BlobServiceVersion.getLatest().getVersion()); - } - - static boolean doNotRun() { - return DevopsPipeline.getInstance().map(it -> !it.releasesToMavenCentral()).orElse(true); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobTestBase.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobTestBase.java deleted file mode 100644 index ac02cb353957..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobTestBase.java +++ /dev/null @@ -1,848 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.credential.TokenRequestContext; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.rest.Response; -import com.azure.core.test.TestMode; -import com.azure.core.test.TestProxyTestBase; -import com.azure.core.test.models.CustomMatcher; -import com.azure.core.test.models.TestProxySanitizer; -import com.azure.core.test.models.TestProxySanitizerType; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.models.BlobContainerItem; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.ListBlobContainersOptions; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.options.BlobBreakLeaseOptions; -import com.azure.storage.blob.specialized.BlobAsyncClientBase; -import com.azure.storage.blob.specialized.BlobClientBase; -import com.azure.storage.blob.specialized.BlobLeaseAsyncClient; -import com.azure.storage.blob.specialized.BlobLeaseClient; -import com.azure.storage.blob.specialized.BlobLeaseClientBuilder; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.test.shared.StorageCommonTestUtils; -import com.azure.storage.common.test.shared.TestAccount; -import com.azure.storage.common.test.shared.TestDataFactory; -import com.azure.storage.common.test.shared.TestEnvironment; -import com.azure.storage.common.test.shared.policy.PerCallVersionPolicy; -import org.junit.jupiter.params.provider.Arguments; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; - -/** - * Base class for Azure Storage Blob tests. - */ -public class BlobTestBase extends TestProxyTestBase { - public static final TestEnvironment ENVIRONMENT = TestEnvironment.getInstance(); - protected static final TestDataFactory DATA = TestDataFactory.getInstance(); - protected static final ClientLogger LOGGER = new ClientLogger(BlobTestBase.class); - - Integer entityNo = 0; // Used to generate stable container names for recording tests requiring multiple containers. - - // both sync and async clients point to same container - protected BlobContainerClient cc; - protected BlobContainerClient ccPremium; - protected BlobContainerAsyncClient ccAsync; - - /* - The values below are used to create data-driven tests for access conditions. - */ - protected static final OffsetDateTime OLD_DATE = OffsetDateTime.now().minusDays(1); - - protected static final OffsetDateTime NEW_DATE = OffsetDateTime.now().plusDays(1); - - protected static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); - protected static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); - protected static final HttpHeaderName LAST_MODIFIED = HttpHeaderName.fromString("last-modified"); - protected static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - protected static final HttpHeaderName X_MS_VERSION_ID = HttpHeaderName.fromString("x-ms-version-id"); - protected static final HttpHeaderName X_MS_CONTENT_CRC64 = HttpHeaderName.fromString("x-ms-content-crc64"); - protected static final HttpHeaderName X_MS_REQUEST_SERVER_ENCRYPTED - = HttpHeaderName.fromString("x-ms-request-server-encrypted"); - protected static final HttpHeaderName X_MS_SERVER_ENCRYPTED = HttpHeaderName.fromString("x-ms-server-encrypted"); - protected static final HttpHeaderName X_MS_ENCRYPTION_KEY_SHA256 - = HttpHeaderName.fromString("x-ms-encryption-key-sha256"); - protected static final HttpHeaderName X_MS_BLOB_CONTENT_LENGTH - = HttpHeaderName.fromString("x-ms-blob-content-length"); - - protected static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); - - protected static final HttpHeaderName X_MS_ENCRYPTION_SCOPE = HttpHeaderName.fromString("x-ms-encryption-scope"); - protected static final HttpHeaderName X_MS_BLOB_SEALED = HttpHeaderName.fromString("x-ms-blob-sealed"); - - /* - Note that this value is only used to check if we are depending on the received etag. This value will not actually - be used. - */ - protected static final String RECEIVED_ETAG = "received"; - - protected static final String GARBAGE_ETAG = "garbage"; - - /* - Note that this value is only used to check if we are depending on the received etag. This value will not actually - be used. - */ - protected static final String RECEIVED_LEASE_ID = "received"; - - protected static final String GARBAGE_LEASE_ID = CoreUtils.randomUuid().toString(); - - protected BlobServiceClient primaryBlobServiceClient; - protected BlobServiceAsyncClient primaryBlobServiceAsyncClient; - protected BlobServiceClient alternateBlobServiceClient; - protected BlobServiceAsyncClient alternateBlobServiceAsyncClient; - - protected BlobServiceClient premiumBlobServiceClient; - protected BlobServiceAsyncClient premiumBlobServiceAsyncClient; - protected BlobServiceClient versionedBlobServiceClient; - protected BlobServiceAsyncClient versionedBlobServiceAsyncClient; - protected BlobServiceClient softDeleteServiceClient; - protected BlobServiceAsyncClient softDeleteServiceAsyncClient; - - protected String containerName; - - protected String prefix; - - @Override - public void beforeTest() { - super.beforeTest(); - prefix = StorageCommonTestUtils.getCrc32(testContextManager.getTestPlaybackRecordingName()); - - if (getTestMode() != TestMode.LIVE) { - interceptorManager - .addSanitizers(Arrays.asList(new TestProxySanitizer("sig=(.*)", "REDACTED", TestProxySanitizerType.URL), - new TestProxySanitizer("x-ms-encryption-key", ".+", "REDACTED", TestProxySanitizerType.HEADER), - new TestProxySanitizer("x-ms-copy-source", "((?<=http://|https://)([^/?]+)|sig=(.*))", "REDACTED", - TestProxySanitizerType.HEADER), - new TestProxySanitizer("x-ms-copy-source-authorization", ".+", "REDACTED", - TestProxySanitizerType.HEADER), - new TestProxySanitizer("x-ms-rename-source", "((?<=http://|https://)([^/?]+)|sig=(.*))", "REDACTED", - TestProxySanitizerType.HEADER))); - } - - // Ignore changes to the order of query parameters and wholly ignore the 'sv' (service version) query parameter - // in SAS tokens. - interceptorManager.addMatchers(Collections.singletonList(new CustomMatcher().setComparingBodies(false) - .setHeadersKeyOnlyMatch(Arrays.asList("x-ms-lease-id", "x-ms-proposed-lease-id", "If-Modified-Since", - "If-Unmodified-Since", "x-ms-expiry-time", "x-ms-source-if-modified-since", - "x-ms-source-if-unmodified-since", "x-ms-source-lease-id", "x-ms-encryption-key-sha256")) - .setQueryOrderingIgnored(true) - .setIgnoredQueryParameters(Collections.singletonList("sv")))); - - primaryBlobServiceClient = getServiceClient(ENVIRONMENT.getPrimaryAccount()); - primaryBlobServiceAsyncClient = getServiceAsyncClient(ENVIRONMENT.getPrimaryAccount()); - alternateBlobServiceClient = getServiceClient(ENVIRONMENT.getSecondaryAccount()); - alternateBlobServiceAsyncClient = getServiceAsyncClient(ENVIRONMENT.getSecondaryAccount()); - premiumBlobServiceClient = getServiceClient(ENVIRONMENT.getPremiumAccount()); - premiumBlobServiceAsyncClient = getServiceAsyncClient(ENVIRONMENT.getPremiumAccount()); - versionedBlobServiceClient = getServiceClient(ENVIRONMENT.getVersionedAccount()); - versionedBlobServiceAsyncClient = getServiceAsyncClient(ENVIRONMENT.getVersionedAccount()); - softDeleteServiceClient = getServiceClient(ENVIRONMENT.getSoftDeleteAccount()); - softDeleteServiceAsyncClient = getServiceAsyncClient(ENVIRONMENT.getSoftDeleteAccount()); - - containerName = generateContainerName(); - cc = primaryBlobServiceClient.getBlobContainerClient(containerName); - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName); - cc.createIfNotExists(); - ccAsync.createIfNotExists().block(); - } - - /** - * Clean up the test queues and messages for the account. - */ - @Override - protected void afterTest() { - super.afterTest(); - if (getTestMode() == TestMode.PLAYBACK) { - return; - } - - BlobServiceClient cleanupClient - = new BlobServiceClientBuilder().httpClient(StorageCommonTestUtils.getHttpClient(interceptorManager)) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .buildClient(); - - ListBlobContainersOptions options = new ListBlobContainersOptions().setPrefix(prefix); - for (BlobContainerItem container : cleanupClient.listBlobContainers(options, null)) { - BlobContainerClient containerClient = cleanupClient.getBlobContainerClient(container.getName()); - - if (container.getProperties().getLeaseState() == LeaseStateType.LEASED) { - createLeaseClient(containerClient).breakLeaseWithResponse( - new BlobBreakLeaseOptions().setBreakPeriod(Duration.ofSeconds(0)), null, null); - } - containerClient.deleteIfExists(); - } - } - - protected static Mono collectBytesInBuffer(Flux content) { - return FluxUtil.collectBytesInByteBufferStream(content).map(ByteBuffer::wrap); - } - - protected String getAuthToken() { - if (ENVIRONMENT.getTestMode() == TestMode.PLAYBACK) { - // we just need some string to satisfy SDK for playback mode. Recording framework handles this fine. - return "recordingBearerToken"; - } - return StorageCommonTestUtils.getTokenCredential(interceptorManager) - .getTokenSync( - new TokenRequestContext().setScopes(Collections.singletonList("https://storage.azure.com/.default"))) - .getToken(); - } - - protected String generateContainerName() { - return generateResourceName(entityNo++); - } - - protected String generateBlobName() { - return generateResourceName(entityNo++); - } - - protected String generateResourceName(int entityNo) { - return testResourceNamer.randomName(prefix + entityNo, 63); - } - - protected String getBlockID() { - return Base64.getEncoder().encodeToString(testResourceNamer.randomUuid().getBytes(StandardCharsets.UTF_8)); - } - - /** - * This will retrieve the etag to be used in testing match conditions. The result will typically be assigned to - * the ifMatch condition when testing success and the ifNoneMatch condition when testing failure. - * - * @param bc The URL to the blob to get the etag on. - * @param match - * The ETag value for this test. If {@code receivedEtag} is passed, that will signal that the test is expecting - * the blob's actual etag for this test, so it is retrieved. - * @return The appropriate etag value to run the current test. - */ - protected String setupBlobMatchCondition(BlobClientBase bc, String match) { - if (Objects.equals(match, RECEIVED_ETAG)) { - return bc.getProperties().getETag(); - } else { - return match; - } - } - - protected static List convertNulls(String... conditions) { - return Arrays.stream(conditions) - .map(condition -> "null".equals(condition) ? null : condition) - .collect(Collectors.toList()); - } - - protected static String convertNull(String condition) { - return "null".equals(condition) ? null : condition; - } - - protected Mono setupBlobMatchCondition(BlobAsyncClientBase bac, String match) { - if (Objects.equals(match, RECEIVED_ETAG)) { - return bac.getProperties().map(BlobProperties::getETag); - } else { - return Mono.justOrEmpty(match).defaultIfEmpty("null"); - } - } - - /** - * This helper method will acquire a lease on a blob to prepare for testing lease Id. We want to test - * against a valid lease in both the success and failure cases to guarantee that the results actually indicate - * proper setting of the header. If we pass null, though, we don't want to acquire a lease, as that will interfere - * with other AC tests. - * - * @param bc The blob on which to acquire a lease. - * @param leaseID The signalID. Values should only ever be {@code receivedLeaseID}, {@code garbageLeaseID}, - * or {@code null}. - * @return The actual lease Id of the blob if recievedLeaseID is passed, otherwise whatever was passed will be - * returned. - */ - protected String setupBlobLeaseCondition(BlobClientBase bc, String leaseID) { - String responseLeaseId = null; - if (Objects.equals(leaseID, RECEIVED_LEASE_ID) || Objects.equals(leaseID, GARBAGE_LEASE_ID)) { - responseLeaseId = createLeaseClient(bc).acquireLease(-1); - } - if (Objects.equals(leaseID, RECEIVED_LEASE_ID)) { - return responseLeaseId; - } else { - return leaseID; - } - } - - protected Mono setupBlobLeaseCondition(BlobAsyncClientBase bac, String leaseID) { - Mono responseLeaseId = null; - if (Objects.equals(leaseID, RECEIVED_LEASE_ID) || Objects.equals(leaseID, GARBAGE_LEASE_ID)) { - responseLeaseId = new BlobLeaseClientBuilder().blobAsyncClient(bac).buildAsyncClient().acquireLease(-1); - } - - if (responseLeaseId == null) { - return Mono.justOrEmpty(leaseID).defaultIfEmpty("null"); - } - - return responseLeaseId.map(returnedLeaseId -> Objects.equals(RECEIVED_LEASE_ID, leaseID) - ? returnedLeaseId - : (leaseID == null ? "null" : leaseID)); - } - - protected String setupContainerLeaseCondition(BlobContainerClient cu, String leaseID) { - if (Objects.equals(leaseID, RECEIVED_LEASE_ID)) { - return createLeaseClient(cu).acquireLease(-1); - } else { - return leaseID; - } - } - - protected Mono setupContainerLeaseConditionAsync(BlobContainerAsyncClient cu, String leaseID) { - if (Objects.equals(leaseID, RECEIVED_LEASE_ID)) { - return createLeaseAsyncClient(cu).acquireLease(-1); - } else { - return Mono.justOrEmpty(leaseID).defaultIfEmpty("null"); - } - } - - protected BlobServiceClient getOAuthServiceClient() { - BlobServiceClientBuilder builder - = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()); - - instrument(builder); - - return builder.credential(StorageCommonTestUtils.getTokenCredential(interceptorManager)).buildClient(); - } - - protected BlobServiceAsyncClient getOAuthServiceAsyncClient() { - BlobServiceClientBuilder builder - = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()); - - instrument(builder); - - return builder.credential(StorageCommonTestUtils.getTokenCredential(interceptorManager)).buildAsyncClient(); - } - - protected BlobServiceClient getServiceClient(String endpoint) { - return getServiceClient(null, endpoint, (HttpPipelinePolicy) null); - } - - protected BlobServiceClient getServiceClient(TestAccount account) { - return getServiceClient(account.getCredential(), account.getBlobEndpoint()); - } - - protected BlobServiceClient getServiceClient(StorageSharedKeyCredential credential, String endpoint) { - return getServiceClient(credential, endpoint, (HttpPipelinePolicy) null); - } - - protected BlobServiceClient getServiceClient(StorageSharedKeyCredential credential, String endpoint, - HttpPipelinePolicy... policies) { - return getServiceClientBuilder(credential, endpoint, policies).buildClient(); - } - - protected BlobServiceClient getServiceClient(String sasToken, String endpoint) { - return getServiceClientBuilder(null, endpoint, (HttpPipelinePolicy) null).sasToken(sasToken).buildClient(); - } - - protected BlobServiceAsyncClient getServiceAsyncClient(TestAccount account) { - return getServiceClientBuilder(account.getCredential(), account.getBlobEndpoint()).buildAsyncClient(); - } - - protected BlobServiceAsyncClient getServiceAsyncClient(String sasToken, String endpoint) { - return getServiceClientBuilder(null, endpoint, (HttpPipelinePolicy) null).sasToken(sasToken).buildAsyncClient(); - } - - protected BlobServiceAsyncClient getServiceAsyncClient(String endpoint) { - return getServiceAsyncClient(null, endpoint, (HttpPipelinePolicy) null); - } - - protected BlobServiceAsyncClient getServiceAsyncClient(StorageSharedKeyCredential credential, String endpoint, - HttpPipelinePolicy... policies) { - return getServiceClientBuilder(credential, endpoint, policies).buildAsyncClient(); - } - - protected BlobServiceClientBuilder getServiceClientBuilder(StorageSharedKeyCredential credential, String endpoint, - HttpPipelinePolicy... policies) { - BlobServiceClientBuilder builder = new BlobServiceClientBuilder().endpoint(endpoint); - - for (HttpPipelinePolicy policy : policies) { - if (policy != null) { - builder.addPolicy(policy); - } - } - - instrument(builder); - - if (credential != null) { - builder.credential(credential); - } - - return builder; - } - - protected BlobServiceClientBuilder getServiceClientBuilderWithTokenCredential(String endpoint, - HttpPipelinePolicy... policies) { - BlobServiceClientBuilder builder = new BlobServiceClientBuilder().endpoint(endpoint); - - for (HttpPipelinePolicy policy : policies) { - builder.addPolicy(policy); - } - - builder.credential(StorageCommonTestUtils.getTokenCredential(interceptorManager)); - - instrument(builder); - return builder; - } - - protected static BlobLeaseClient createLeaseClient(BlobClientBase blobClient) { - return createLeaseClient(blobClient, null); - } - - protected static BlobLeaseClient createLeaseClient(BlobClientBase blobClient, String leaseId) { - return new BlobLeaseClientBuilder().blobClient(blobClient).leaseId(leaseId).buildClient(); - } - - protected static BlobLeaseAsyncClient createLeaseAsyncClient(BlobAsyncClientBase blobAsyncClient) { - return createLeaseAsyncClient(blobAsyncClient, null); - } - - protected static BlobLeaseAsyncClient createLeaseAsyncClient(BlobAsyncClientBase blobAsyncClient, String leaseId) { - return new BlobLeaseClientBuilder().blobAsyncClient(blobAsyncClient).leaseId(leaseId).buildAsyncClient(); - } - - protected static BlobLeaseClient createLeaseClient(BlobContainerClient containerClient) { - return createLeaseClient(containerClient, null); - } - - protected static BlobLeaseClient createLeaseClient(BlobContainerClient containerClient, String leaseId) { - return new BlobLeaseClientBuilder().containerClient(containerClient).leaseId(leaseId).buildClient(); - } - - protected static BlobLeaseAsyncClient createLeaseAsyncClient(BlobContainerAsyncClient containerAsyncClient) { - return createLeaseAsyncClient(containerAsyncClient, null); - } - - protected static BlobLeaseAsyncClient createLeaseAsyncClient(BlobContainerAsyncClient containerAsyncClient, - String leaseId) { - return new BlobLeaseClientBuilder().containerAsyncClient(containerAsyncClient) - .leaseId(leaseId) - .buildAsyncClient(); - } - - /** - * Some tests require extra configuration for retries when writing. - *

- * It is possible that tests which upload a reasonable amount of data with tight resource limits may cause the - * service to silently close a connection without returning a response due to high read latency (the resource - * constraints cause a latency between sending the headers and writing the body often due to waiting for buffer pool - * buffers). Without configuring a retry timeout, the operation will hang indefinitely. This is always something - * that must be configured by the customer. - *

- * Typically this needs to be configured in retries so that we can retry the individual block writes rather than - * the overall operation. - *

- * According to the following link, writes can take up to 10 minutes per MB before the service times out. In this - * case, most of our instrumentation (e.g. CI pipelines) will timeout and fail anyway, so we don't want to wait that - * long. The value is going to be a best guess and should be played with to allow test passes to succeed - *

- * - * Timeouts - * - * @param perRequestDataSize The amount of data expected to go out in each request. Will be used to calculate a - * timeout value--about 20s/MB. Won't be less than 1 minute. - */ - protected BlobServiceAsyncClient getPrimaryServiceClientForWrites(long perRequestDataSize) { - int retryTimeout = Math.toIntExact((perRequestDataSize / (long) Constants.MB) * 20L); - retryTimeout = Math.max(60, retryTimeout); - return getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), - ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .retryOptions(new RequestRetryOptions(null, null, retryTimeout, null, null, null)) - .buildAsyncClient(); - } - - protected BlobContainerClient getContainerClient(String sasToken, String endpoint) { - return getContainerClientBuilder(endpoint).sasToken(sasToken).buildClient(); - } - - protected BlobContainerAsyncClient getContainerAsyncClient(String sasToken, String endpoint) { - return getContainerClientBuilder(endpoint).sasToken(sasToken).buildAsyncClient(); - } - - protected BlobContainerClientBuilder getContainerClientBuilder(String endpoint) { - BlobContainerClientBuilder builder = new BlobContainerClientBuilder().endpoint(endpoint); - instrument(builder); - return builder; - } - - protected BlobContainerClientBuilder getContainerClientBuilderWithTokenCredential(String endpoint, - HttpPipelinePolicy... policies) { - BlobContainerClientBuilder builder = new BlobContainerClientBuilder().endpoint(endpoint); - - for (HttpPipelinePolicy policy : policies) { - builder.addPolicy(policy); - } - - builder.credential(StorageCommonTestUtils.getTokenCredential(interceptorManager)); - - instrument(builder); - return builder; - } - - protected BlobAsyncClient getBlobAsyncClient(StorageSharedKeyCredential credential, String endpoint, - String blobName) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint).blobName(blobName); - - instrument(builder); - - return builder.credential(credential).buildAsyncClient(); - } - - protected BlobAsyncClient getBlobAsyncClient(String sasToken, String endpoint, String blobName, String snapshotId) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint).blobName(blobName).snapshot(snapshotId); - - instrument(builder); - - return builder.sasToken(sasToken).buildAsyncClient(); - } - - protected BlobClient getBlobClient(String sasToken, String endpoint, String blobName) { - return getBlobClient(sasToken, endpoint, blobName, null); - } - - protected BlobClient getBlobClient(String sasToken, String endpoint, String blobName, String snapshotId) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint).blobName(blobName).snapshot(snapshotId); - - instrument(builder); - - return builder.sasToken(sasToken).buildClient(); - } - - protected BlobClient getBlobClient(StorageSharedKeyCredential credential, String endpoint, - HttpPipelinePolicy... policies) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint); - - for (HttpPipelinePolicy policy : policies) { - builder.addPolicy(policy); - } - - instrument(builder); - - return builder.credential(credential).buildClient(); - } - - protected BlobClientBuilder getBlobClientBuilderWithTokenCredential(String endpoint, - HttpPipelinePolicy... policies) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint); - - for (HttpPipelinePolicy policy : policies) { - builder.addPolicy(policy); - } - - builder.credential(StorageCommonTestUtils.getTokenCredential(interceptorManager)); - - instrument(builder); - return builder; - } - - protected BlobAsyncClient getBlobAsyncClient(StorageSharedKeyCredential credential, String endpoint, - HttpPipelinePolicy... policies) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint); - - for (HttpPipelinePolicy policy : policies) { - builder.addPolicy(policy); - } - instrument(builder); - return builder.credential(credential).buildAsyncClient(); - } - - protected BlobClient getBlobClient(StorageSharedKeyCredential credential, String endpoint, String blobName) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint).blobName(blobName); - - instrument(builder); - - return builder.credential(credential).buildClient(); - } - - protected BlobClient getBlobClient(String endpoint, String sasToken) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint); - instrument(builder); - - if (!CoreUtils.isNullOrEmpty(sasToken)) { - builder.sasToken(sasToken); - } - return builder.buildClient(); - } - - protected BlobAsyncClient getBlobAsyncClient(String endpoint, String sasToken) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint); - instrument(builder); - - if (!CoreUtils.isNullOrEmpty(sasToken)) { - builder.sasToken(sasToken); - } - return builder.buildAsyncClient(); - } - - protected BlobClientBuilder getBlobClientBuilder(String endpoint) { - BlobClientBuilder builder = new BlobClientBuilder().endpoint(endpoint); - - builder.connectionString(ENVIRONMENT.getPrimaryAccount().getConnectionString()); - return instrument(builder); - } - - protected SpecializedBlobClientBuilder getSpecializedBuilder(StorageSharedKeyCredential credential, String endpoint, - HttpPipelinePolicy... policies) { - SpecializedBlobClientBuilder builder = new SpecializedBlobClientBuilder().endpoint(endpoint); - - for (HttpPipelinePolicy policy : policies) { - builder.addPolicy(policy); - } - - builder.credential(credential); - return instrument(builder); - } - - protected SpecializedBlobClientBuilder getSpecializedBuilder(String endpoint) { - SpecializedBlobClientBuilder builder = new SpecializedBlobClientBuilder().endpoint(endpoint); - - builder.connectionString(ENVIRONMENT.getPrimaryAccount().getConnectionString()); - return instrument(builder); - } - - protected SpecializedBlobClientBuilder getSpecializedBuilderWithTokenCredential(String endpoint, - HttpPipelinePolicy... policies) { - SpecializedBlobClientBuilder builder = new SpecializedBlobClientBuilder().endpoint(endpoint); - - for (HttpPipelinePolicy policy : policies) { - builder.addPolicy(policy); - } - - builder.credential(StorageCommonTestUtils.getTokenCredential(interceptorManager)); - - instrument(builder); - return builder; - } - - protected HttpResponse getStubDownloadResponse(HttpResponse response, int code, Flux body, - HttpHeaders headers) { - return new HttpResponse(response.getRequest()) { - - @Override - public int getStatusCode() { - return code; - } - - @Override - public String getHeaderValue(String s) { - return headers.getValue(s); - } - - @Override - public HttpHeaders getHeaders() { - return headers; - } - - @Override - public Flux getBody() { - return body; - } - - @Override - public Mono getBodyAsByteArray() { - return Mono.just(new byte[0]); - } - - @Override - public Mono getBodyAsString() { - return Mono.just(""); - } - - @Override - public Mono getBodyAsString(Charset charset) { - return Mono.just(""); - } - }; - } - - /** - * Validates the presence of headers that are present on a large number of responses. These headers are generally - * random and can really only be checked as not null. - * @param headers The object (may be headers object or response object) that has properties which expose these common headers. - * @return Whether the header values are appropriate. - */ - protected static boolean validateBasicHeaders(HttpHeaders headers) { - return headers.getValue(HttpHeaderName.ETAG) != null - // Quotes should be scrubbed from etag header values - && !headers.getValue(HttpHeaderName.ETAG).contains("\"") - && headers.getValue(LAST_MODIFIED) != null - && headers.getValue(X_MS_REQUEST_ID) != null - && headers.getValue(X_MS_VERSION) != null - && headers.getValue(HttpHeaderName.DATE) != null; - } - - protected static boolean validateBlobProperties(Response response, String cacheControl, - String contentDisposition, String contentEncoding, String contentLanguage, byte[] contentMD5, - String contentType) { - return Objects.equals(response.getValue().getCacheControl(), cacheControl) - && Objects.equals(response.getValue().getContentDisposition(), contentDisposition) - && Objects.equals(response.getValue().getContentEncoding(), contentEncoding) - && Objects.equals(response.getValue().getContentLanguage(), contentLanguage) - && Arrays.equals(response.getValue().getContentMd5(), contentMD5) - && Objects.equals(response.getValue().getContentType(), contentType); - } - - /** - * Insecurely and quickly generates a random AES256 key for the purpose of unit tests. No one should ever make a - * real key this way. - */ - protected byte[] getRandomKey() { - return StorageCommonTestUtils.getRandomByteArray(32, testResourceNamer); // 256-bit key - } - - protected void liveTestScenarioWithRetry(Runnable runnable) { - if (!interceptorManager.isLiveMode()) { - runnable.run(); - return; - } - - int retry = 0; - while (retry < 5) { - try { - runnable.run(); - break; - } catch (Exception ex) { - retry++; - sleepIfRunningAgainstService(5000); - } - } - } - - protected HttpPipelinePolicy getPerCallVersionPolicy() { - return new PerCallVersionPolicy("2017-11-09"); - } - - // add this to BlobTestHelper class - protected static void assertExceptionStatusCodeAndMessage(Throwable throwable, int expectedStatusCode, - BlobErrorCode errMessage) { - BlobStorageException exception = assertInstanceOf(BlobStorageException.class, throwable); - assertEquals(expectedStatusCode, exception.getStatusCode()); - assertEquals(errMessage, exception.getErrorCode()); - } - - // add to TestHelper class - protected static Response assertResponseStatusCode(Response response, int expectedStatusCode) { - assertEquals(expectedStatusCode, response.getStatusCode()); - return response; - } - - protected static void assertAsyncResponseStatusCode(Mono> response, int expectedStatusCode) { - StepVerifier.create(response) - .assertNext(r -> assertEquals(expectedStatusCode, r.getStatusCode())) - .verifyComplete(); - } - - protected static Stream allConditionsSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null), Arguments.of(null, NEW_DATE, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null), - Arguments.of(null, null, null, null, null, "\"foo\" = 'bar'")); - } - - protected static Stream allConditionsFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null, null), - Arguments.of(null, OLD_DATE, null, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null, null), - Arguments.of(null, null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID, null), - Arguments.of(null, null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - protected static Stream fileACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null), Arguments.of(null, OLD_DATE, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null), Arguments.of(null, null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID)); - } - - protected HttpClient getHttpClient() { - return StorageCommonTestUtils.getHttpClient(interceptorManager); - } - - public static HttpClient getHttpClient(Supplier playbackClientSupplier) { - return StorageCommonTestUtils.getHttpClient(playbackClientSupplier); - } - - protected , E extends Enum> T instrument(T builder) { - return StorageCommonTestUtils.instrument(builder, BlobServiceClientBuilder.getDefaultHttpLogOptions(), - interceptorManager); - } - - protected byte[] convertInputStreamToByteArray(InputStream inputStream) { - return StorageCommonTestUtils.convertInputStreamToByteArray(inputStream); - } - - protected boolean compareFiles(File file1, File file2, long offset, long count) throws IOException { - return StorageCommonTestUtils.compareFiles(file1, file2, offset, count); - } - - protected byte[] getRandomByteArray(int size) { - return StorageCommonTestUtils.getRandomByteArray(size, testResourceNamer); - } - - public ByteBuffer getRandomData(int size) { - return StorageCommonTestUtils.getRandomData(size, testResourceNamer); - } - - protected File getRandomFile(int size) throws IOException { - return StorageCommonTestUtils.getRandomFile(size, testResourceNamer); - } - - /*https://learn.microsoft.com/en-us/rest/api/storageservices/define-stored-access-policy#creating-or-modifying-a-stored-access-policy - Second note, it can take up to 30 seconds to set/create an access policy and this was causing flakeyness in the live test pipeline - */ - protected void setAccessPolicySleep(BlobContainerClient cc, PublicAccessType access, - List identifiers) { - cc.setAccessPolicy(access, identifiers); - sleepIfRunningAgainstService(30 * 1000); - } - - protected Mono setAccessPolicySleepAsync(BlobContainerAsyncClient cc, PublicAccessType access, - List identifiers) { - Mono setPolicyMono = cc.setAccessPolicy(access, identifiers); - if (!interceptorManager.isPlaybackMode()) { - setPolicyMono = setPolicyMono.then(Mono.delay(Duration.ofSeconds(30))); - } - - return setPolicyMono; - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTests.java deleted file mode 100644 index af6c8fb26c0d..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTests.java +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.test.http.MockHttpResponse; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.implementation.util.BlobUserAgentModificationPolicy; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BlobUserAgentPropertiesTests { - - @Test - public void userAgentPropertiesNotNull() { - Map properties = CoreUtils.getProperties("azure-storage-blob.properties"); - assertEquals(properties.get("name"), "azure-storage-blob"); - assertTrue(properties.get("version").matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*")); - } - - @ParameterizedTest - @MethodSource("userAgentModificationPolicyTestSupplier") - public void userAgentModificationPolicyTest(String userAgentBefore, String name, String version, - String userAgentAfter) { - BlobUserAgentModificationPolicy uaPolicy = new BlobUserAgentModificationPolicy(name, version); - UAStringTestClient client = new UAStringTestClient(userAgentAfter); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(client).policies(uaPolicy).build(); - - StepVerifier - .create(pipeline.send(new HttpRequest(HttpMethod.GET, "https://account.blob.core.windows.net/") - .setHeader(HttpHeaderName.USER_AGENT, userAgentBefore))) - .assertNext(it -> assertEquals(it.getStatusCode(), 200)) - .verifyComplete(); - } - - private static Stream userAgentModificationPolicyTestSupplier() { - return Stream.of(Arguments.of("azsdk-java-azure-storage-blob/12.11.0-beta.2 (11.0.6; Windows 10; 10.0)", - "azure-storage-blob-batch", "12.8.0-beta.2", - "azsdk-java-azure-storage-blob/12.11.0-beta.2 azsdk-java-azure-storage-blob-batch/12.8.0-beta.2 (11.0.6; Windows 10; 10.0)"), // Tests both beta - Arguments.of("azsdk-java-azure-storage-blob/12.11.0 (11.0.6; Windows 10; 10.0)", "azure-storage-blob-batch", - "12.8.0-beta.2", - "azsdk-java-azure-storage-blob/12.11.0 azsdk-java-azure-storage-blob-batch/12.8.0-beta.2 (11.0.6; Windows 10; 10.0)"), // Tests blob GA and batch beta - Arguments.of("azsdk-java-azure-storage-blob/12.11.0-beta.2 (11.0.6; Windows 10; 10.0)", - "azure-storage-blob-batch", "12.8.0", - "azsdk-java-azure-storage-blob/12.11.0-beta.2 azsdk-java-azure-storage-blob-batch/12.8.0 (11.0.6; Windows 10; 10.0)"), // Tests blob beta and batch GA - Arguments.of("azsdk-java-azure-storage-blob/12.11.0 (11.0.6; Windows 10; 10.0)", "azure-storage-blob-batch", - "12.8.0", - "azsdk-java-azure-storage-blob/12.11.0 azsdk-java-azure-storage-blob-batch/12.8.0 (11.0.6; Windows 10; 10.0)"), // Tests both GA, user agent with appended OS and JVM info - Arguments.of("azsdk-java-azure-storage-blob/12.11.0 (11.0.6; Windows 10; 10.0)", - "azure-storage-blob-changefeed", "12.0.0", - "azsdk-java-azure-storage-blob/12.11.0 azsdk-java-azure-storage-blob-changefeed/12.0.0 (11.0.6; Windows 10; 10.0)"), // Tests for changefeed - Arguments.of("azsdk-java-azure-storage-blob/12.11.0 (11.0.6; Windows 10; 10.0)", "azure-storage-blob-nio", - "12.0.0", - "azsdk-java-azure-storage-blob/12.11.0 azsdk-java-azure-storage-blob-nio/12.0.0 (11.0.6; Windows 10; 10.0)"), // Tests for nio - Arguments.of("azsdk-java-azure-storage-blob/12.11.0 (11.0.6; Windows 10; 10.0)", - "azure-storage-file-datalake", "12.4.0", - "azsdk-java-azure-storage-blob/12.11.0 azsdk-java-azure-storage-file-datalake/12.4.0 (11.0.6; Windows 10; 10.0)"), // Tests for datalake - Arguments.of("azsdk-java-azure-storage-blob/12.11.0 (11.0.6; Windows 10; 10.0)", - "azure-storage-blob-cryptography", "12.11.0", - "azsdk-java-azure-storage-blob/12.11.0 azsdk-java-azure-storage-blob-cryptography/12.11.0 (11.0.6; Windows 10; 10.0)"), // Tests for cryptography - Arguments.of("prependappid azsdk-java-azure-storage-blob/12.11.0", "azure-storage-blob-batch", "12.8.0", - "prependappid azsdk-java-azure-storage-blob/12.11.0 azsdk-java-azure-storage-blob-batch/12.8.0"), // User agent with prepended custom id - Arguments.of("prependappid azsdk-java-azure-storage-blob/12.11.0 (11.0.6; Windows 10; 10.0)", - "azure-storage-blob-batch", "12.8.0", - "prependappid azsdk-java-azure-storage-blob/12.11.0 azsdk-java-azure-storage-blob-batch/12.8.0 (11.0.6; Windows 10; 10.0)"), // User agent with prepended custom id and appended OS JVM info - Arguments.of("azsdk-java-azure-storage-blob/12.11.0", "azure-storage-blob-batch", "12.8.0", - "azsdk-java-azure-storage-blob/12.11.0 azsdk-java-azure-storage-blob-batch/12.8.0"), // User agent - Arguments.of("azsdk-java-azure-storage-file-share/12.11.0 (11.0.6; Windows 10; 10.0)", - "azure-storage-blob-cryptography", "12.11.0", - "azsdk-java-azure-storage-file-share/12.11.0 (11.0.6; Windows 10; 10.0)"), // Tests for a header that should not be modified - Arguments.of("custom UA header", "azure-storage-blob-cryptography", "12.11.0", "custom UA header"), // Tests for a custom header that should not be modified - Arguments.of("customUAheader", "azure-storage-blob-cryptography", "12.11.0", "customUAheader") // Tests for a custom header that should not be modified - ); - } - - private static final class UAStringTestClient implements HttpClient { - - private final String expectedUA; - - UAStringTestClient(String expectedUA) { - this.expectedUA = expectedUA; - } - - @Override - public Mono send(HttpRequest request) { - if (CoreUtils.isNullOrEmpty(request.getHeaders().getValue(HttpHeaderName.USER_AGENT))) { - throw new RuntimeException("Failed to set 'User-Agent' header."); - } - assert request.getHeaders().getValue(HttpHeaderName.USER_AGENT).equals(expectedUA); - return Mono.just(new MockHttpResponse(request, 200)); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlockBlobInputOutputStreamTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlockBlobInputOutputStreamTests.java deleted file mode 100644 index 7c8a9ec298e0..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlockBlobInputOutputStreamTests.java +++ /dev/null @@ -1,456 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.test.utils.TestUtils; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.ConsistentReadControl; -import com.azure.storage.blob.options.BlobInputStreamOptions; -import com.azure.storage.blob.specialized.BlobInputStream; -import com.azure.storage.blob.specialized.BlobOutputStream; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BlockBlobInputOutputStreamTests extends BlobTestBase { - private BlockBlobClient bc; - - @BeforeEach - public void setup() { - bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - } - - @ParameterizedTest - @MethodSource("blobInputStreamReadToLargeBufferSupplier") - public void blobInputStreamReadToLargeBuffer(int dataSize, int retVal) throws IOException { - byte[] data = getRandomByteArray(dataSize); - bc.upload(new ByteArrayInputStream(data), data.length, true); - BlobInputStream is = bc.openInputStream(); - byte[] outArr = new byte[10 * 1024 * 1024]; - byte[] emptyData = new byte[outArr.length - dataSize]; - int count = is.read(outArr); - - TestUtils.assertArraysEqual(data, 0, outArr, 0, dataSize); - TestUtils.assertArraysEqual(emptyData, 0, outArr, dataSize, emptyData.length); - assertEquals(count, retVal); - } - - private static Stream blobInputStreamReadToLargeBufferSupplier() { - return Stream.of(Arguments.of(0, -1), Arguments.of(6 * 1024 * 1024, 6 * 1024 * 1024) // Test for GitHub issue #13811 - ); - } - - // Only run this test in live mode as BlobOutputStream dynamically assigns blocks - @LiveOnly - @Test - public void uploadDownload() throws IOException { - int length = 6 * Constants.MB; - byte[] randomBytes = getRandomByteArray(length); - - BlobOutputStream outStream = bc.getBlobOutputStream(true); - outStream.write(randomBytes, Constants.MB, 5 * Constants.MB); - outStream.close(); - - BlobInputStream inputStream = bc.openInputStream(); - - BlobProperties propertiesAfter = inputStream.getProperties(); - assertEquals(propertiesAfter.getBlobType(), BlobType.BLOCK_BLOB); - assertEquals(propertiesAfter.getBlobSize(), 5 * Constants.MB); - TestUtils.assertArraysEqual(randomBytes, Constants.MB, convertInputStreamToByteArray(inputStream), 0, - 5 * Constants.MB); - } - - // Only run this test in live mode as BlobOutputStream dynamically assigns blocks - @LiveOnly - @ParameterizedTest - @MethodSource("uploadDownloadBlockSizeSupplier") - public void uploadDownloadBlockSize(Integer blockSize, int numChunks, int[] sizes) throws IOException { - int length = 6 * Constants.MB; - byte[] randomBytes = getRandomByteArray(length); - - BlobOutputStream outStream = bc.getBlobOutputStream(true); - outStream.write(randomBytes, 0, 6 * Constants.MB); - outStream.close(); - - BlobInputStream inputStream = bc.openInputStream(new BlobInputStreamOptions().setBlockSize(blockSize)); - int b; - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try { - for (int i = 0; i < numChunks; i++) { - b = inputStream.read(); - assertTrue(b != -1); - outputStream.write(b); - // Make sure the internal buffer is the expected chunk size. - assertEquals(inputStream.available(), sizes[i] - 1); - // Read the rest of the chunk - for (int j = 0; j < sizes[i] - 1; j++) { - b = inputStream.read(); - assertTrue(b != -1); - outputStream.write(b); - } - } - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - assertEquals(inputStream.read(), -1); // Make sure we are at the end of the stream. - BlobProperties propertiesAfter = inputStream.getProperties(); - assertEquals(propertiesAfter.getBlobType(), BlobType.BLOCK_BLOB); - assertEquals(propertiesAfter.getBlobSize(), 6 * Constants.MB); - byte[] randomBytes2 = outputStream.toByteArray(); - TestUtils.assertArraysEqual(randomBytes2, randomBytes); - } - - private static Stream uploadDownloadBlockSizeSupplier() { - return Stream.of(Arguments.of(null, 2, new int[] { 4 * Constants.MB, 2 * Constants.MB }), // Default - Arguments.of(5 * Constants.MB, 2, new int[] { 5 * Constants.MB, Constants.MB }), // Greater than default - Arguments.of(3 * Constants.MB, 2, new int[] { 3 * Constants.MB, 3 * Constants.MB }) // Smaller than default - ); - } - - // Only run this test in live mode as BlobOutputStream dynamically assigns blocks - @LiveOnly - @ParameterizedTest - @MethodSource("blobRangeSupplier") - public void blobRange(Integer start, Long count) throws IOException { - int length = 6 * Constants.MB; - byte[] randomBytes = getRandomByteArray(length); - - BlobOutputStream outStream = bc.getBlobOutputStream(true); - outStream.write(randomBytes, 0, 6 * Constants.MB); - outStream.close(); - - long finalCount = count == null ? length - start : count; - byte[] resultBytes = new byte[(int) finalCount]; - BlobInputStream inputStream = bc.openInputStream( - new BlobInputStreamOptions().setRange(new BlobRange(start, count)).setBlockSize(4 * Constants.MB)); - inputStream.read(resultBytes); // read the whole range - - assertEquals(inputStream.read(), -1); - TestUtils.assertArraysEqual(randomBytes, start, resultBytes, 0, (int) finalCount); - } - - private static Stream blobRangeSupplier() { - return Stream.of(Arguments.of(0, null), // full blob - Arguments.of(0, 100L), // Small range - Arguments.of(0, 4L * Constants.MB), // block size - Arguments.of(0, 5L * Constants.MB), // Requires multiple chunks - Arguments.of(0, (Constants.KB) + 1L), // Range not a multiple of 1024 - Arguments.of(0, (Constants.KB) - 1L), // "" - Arguments.of(5, 100L), // small offset - Arguments.of(5, null), // full blob after an offset - Arguments.of(Constants.MB, 2L * Constants.MB), // larger offset inside first chunk - Arguments.of(Constants.KB, 4L * Constants.MB), // offset with range spanning chunks - Arguments.of(5 * Constants.MB, (long) Constants.KB), // Range entirely in second chunk - Arguments.of(5 * Constants.MB, (Constants.KB) + 1L), // Range not multiple of 1024 - Arguments.of(5 * Constants.MB, (Constants.KB) - 1L), // "" - Arguments.of(5 * Constants.MB, null) // rest of blob after first chunk - ); - } - - // Only run this test in live mode as BlobOutputStream dynamically assigns blocks - @LiveOnly - @Test - public void getPropertiesBefore() throws IOException { - int length = 6 * Constants.MB; - byte[] randomBytes = getRandomByteArray(length); - - BlobOutputStream outStream = bc.getBlobOutputStream(true); - outStream.write(randomBytes, Constants.MB, 5 * Constants.MB); - outStream.close(); - - BlobInputStream inputStream = bc.openInputStream(); - BlobProperties propertiesBefore = inputStream.getProperties(); - assertEquals(propertiesBefore.getBlobType(), BlobType.BLOCK_BLOB); - assertEquals(propertiesBefore.getBlobSize(), 5 * Constants.MB); - TestUtils.assertArraysEqual(randomBytes, Constants.MB, convertInputStreamToByteArray(inputStream), 0, - 5 * Constants.MB); - } - - @Test - public void inputStreamETagLockDefault() throws IOException { - int length = 6 * Constants.MB; - byte[] randomBytes = getRandomByteArray(length); - bc.upload(new ByteArrayInputStream(randomBytes), length, true); - - // Create the input stream and read from it. - // Note: Setting block size to 1 is inefficient but helps demonstrate the purpose of this test. - BlobInputStream inputStream = bc.openInputStream(new BlobInputStreamOptions().setBlockSize(1)); - inputStream.read(); - - // Modify the blob again. - bc.upload(new ByteArrayInputStream(randomBytes), length, true); - - // when: "Reading after eTag has been changed" - assertThrows(IOException.class, inputStream::read); - } - - @Test - public void inputStreamConsistentReadControlNone() throws IOException { - int length = 6 * Constants.MB; - byte[] randomBytes = getRandomByteArray(length); - bc.upload(new ByteArrayInputStream(randomBytes), length, true); - - // Create the input stream and read from it. - // Note: Setting block size to 1 is inefficient but helps demonstrate the purpose of this test. - BlobInputStream inputStream = bc.openInputStream( - new BlobInputStreamOptions().setBlockSize(1).setConsistentReadControl(ConsistentReadControl.NONE)); - inputStream.read(); - - // Modify the blob again. - bc.upload(new ByteArrayInputStream(randomBytes), length, true); - - // then: "Exception should not be thrown even though blob was modified" - assertDoesNotThrow(() -> inputStream.read()); - } - - @Test - public void inputStreamConsistentReadControlETagClientChoosesETag() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - - // No eTag specified - client will lock on latest one. - BlobInputStream inputStream = blobClient - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(ConsistentReadControl.ETAG)); - - TestUtils.assertArraysEqual(randomBytes, convertInputStreamToByteArray(inputStream)); - } - - @Test - public void inputStreamConsistentReadControlETagUserProvidesETag() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - BlobProperties properties = blobClient.getProperties(); - - BlobInputStream inputStream = blobClient - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(ConsistentReadControl.ETAG) - // User provides eTag to use - .setRequestConditions(new BlobRequestConditions().setIfMatch(properties.getETag()))); - - TestUtils.assertArraysEqual(randomBytes, convertInputStreamToByteArray(inputStream)); - } - - @Test - public void inputStreamConsistentReadControlETagUserProvidesVersionAndETag() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - BlobProperties properties = blobClient.getProperties(); - - // User provides version client - BlobInputStream inputStream = blobClient.getVersionClient(properties.getVersionId()) - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(ConsistentReadControl.ETAG) - // User provides eTag to use - .setRequestConditions(new BlobRequestConditions().setIfMatch(properties.getETag()))); - - TestUtils.assertArraysEqual(randomBytes, convertInputStreamToByteArray(inputStream)); - } - - @Test - public void inputStreamConsistentReadControlNullVersion() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - bc.upload(new ByteArrayInputStream(randomBytes), length, true); - - // Version ID set but not a versioned account - assertThrows(UnsupportedOperationException.class, () -> bc - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(ConsistentReadControl.VERSION_ID))); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void inputStreamConsistentReadControlETagUserProvidesVersionClientChoosesETag() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - BlobProperties properties = blobClient.getProperties(); - - // User provides version client - BlobInputStream inputStream = blobClient.getVersionClient(properties.getVersionId()) - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(ConsistentReadControl.ETAG)); - // When a versioned client is used it should still succeed if the blob has been modified - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - - TestUtils.assertArraysEqual(randomBytes, convertInputStreamToByteArray(inputStream)); - } - - // Error case - @Test - public void inputStreamConsistentReadControlETagUserProvidesOldETag() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - BlobProperties properties = blobClient.getProperties(); - - BlobInputStream inputStream = blobClient.openInputStream(new BlobInputStreamOptions().setBlockSize(1) - .setConsistentReadControl(ConsistentReadControl.ETAG) - // Set the block size to be small enough to not retrieve the whole blob on initial download - .setBlockSize(500) - .setRequestConditions(new BlobRequestConditions().setIfMatch(properties.getETag()))); - - // Since eTag is the only form of consistentReadControl and the blob is modified, we will throw. - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - - // BlobStorageException = ConditionNotMet - assertThrows(IOException.class, () -> inputStream.read(new byte[600])); // Read enough to exceed the initial download - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void inputStreamConsistentReadControlVersionClientChoosesVersion() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - - // No version specified - client will lock on it. - BlobInputStream inputStream = blobClient - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(ConsistentReadControl.VERSION_ID)); - - // When a versioned client is used it should still succeed if the blob has been modified - blobClient.upload(new ByteArrayInputStream(getRandomByteArray(length)), length, true); - - TestUtils.assertArraysEqual(randomBytes, convertInputStreamToByteArray(inputStream)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void inputStreamConsistentReadControlVersionUserProvidesVersion() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - BlobProperties properties = blobClient.getProperties(); - - blobClient.upload(new ByteArrayInputStream(getRandomByteArray(length)), length, true); - - // User provides version client - BlobInputStream inputStream = blobClient.getVersionClient(properties.getVersionId()) - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(ConsistentReadControl.VERSION_ID)); - - // When a versioned client is used it should still succeed if the blob has been modified - blobClient.upload(new ByteArrayInputStream(getRandomByteArray(length)), length, true); - - TestUtils.assertArraysEqual(randomBytes, convertInputStreamToByteArray(inputStream)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void inputStreamConsistentReadControlVersionUserProvidesVersionAndETag() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - BlobProperties properties = blobClient.getProperties(); - - // User provides version client - BlobInputStream inputStream = blobClient.getVersionClient(properties.getVersionId()) - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(ConsistentReadControl.VERSION_ID) - // User provides eTag to use - .setRequestConditions(new BlobRequestConditions().setIfMatch(properties.getETag()))); - - // When a versioned client is used it should still succeed if the blob has been modified - blobClient.upload(new ByteArrayInputStream(getRandomByteArray(length)), length, true); - - TestUtils.assertArraysEqual(randomBytes, convertInputStreamToByteArray(inputStream)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void inputStreamConsistentReadControlVersionUserProvidesETagClientChoosesVersion() { - int length = Constants.KB; - byte[] randomBytes = getRandomByteArray(length); - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - BlobProperties properties = blobClient.getProperties(); - - // No version specified - client will lock on it. - BlobInputStream inputStream = blobClient - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(ConsistentReadControl.VERSION_ID) - // User provides eTag to use - .setRequestConditions(new BlobRequestConditions().setIfMatch(properties.getETag()))); - - // When a versioned client is used it should still succeed if the blob has been modified - blobClient.upload(new ByteArrayInputStream(randomBytes), length, true); - - TestUtils.assertArraysEqual(randomBytes, convertInputStreamToByteArray(inputStream)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("inputStreamConsistentReadControlValidStatesSupplier") - public void inputStreamConsistentReadControlValidStates(boolean useETag, boolean useVersionId, - ConsistentReadControl consistentReadControl) { - BlobContainerClient blobContainerClient - = versionedBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - blobClient.upload(new ByteArrayInputStream(new byte[0]), 0, true); - BlobProperties properties = blobClient.getProperties(); - BlobRequestConditions requestConditions - = useETag ? new BlobRequestConditions().setIfMatch(properties.getETag()) : null; - - if (useVersionId) { - assertDoesNotThrow(() -> blobClient.getVersionClient(properties.getVersionId()) - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(consistentReadControl) - .setRequestConditions(requestConditions))); - } else { - assertDoesNotThrow(() -> blobClient - .openInputStream(new BlobInputStreamOptions().setConsistentReadControl(consistentReadControl) - .setRequestConditions(requestConditions))); - } - } - - private static Stream inputStreamConsistentReadControlValidStatesSupplier() { - return Stream.of(Arguments.of(true, false, ConsistentReadControl.NONE), - Arguments.of(false, true, ConsistentReadControl.NONE), - Arguments.of(true, false, ConsistentReadControl.VERSION_ID), - Arguments.of(false, true, ConsistentReadControl.ETAG), - Arguments.of(true, true, ConsistentReadControl.VERSION_ID), - Arguments.of(true, true, ConsistentReadControl.ETAG)); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BuilderHelperTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BuilderHelperTests.java deleted file mode 100644 index fcda9579f5c8..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BuilderHelperTests.java +++ /dev/null @@ -1,658 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.credential.AzureSasCredential; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.FixedDelayOptions; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.test.http.MockHttpResponse; -import com.azure.core.test.http.NoOpHttpClient; -import com.azure.core.test.utils.MockTokenCredential; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.core.util.Header; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.util.BuilderHelper; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.RetryPolicyType; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.io.IOException; -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BuilderHelperTests { - private static final StorageSharedKeyCredential CREDENTIALS - = new StorageSharedKeyCredential("accountName", "accountKey"); - private static final String ENDPOINT = "https://account.blob.core.windows.net/"; - private static final RequestRetryOptions REQUEST_RETRY_OPTIONS - = new RequestRetryOptions(RetryPolicyType.FIXED, 2, 2, 1000L, 4000L, null); - private static final RetryOptions CORE_RETRY_OPTIONS - = new RetryOptions(new FixedDelayOptions(1, Duration.ofSeconds(2))); - - private static HttpRequest request(String url) { - return new HttpRequest(HttpMethod.HEAD, url).setBody(Flux.empty()) - .setHeader(HttpHeaderName.CONTENT_LENGTH, "0"); - } - - /** - * Tests that a new date will be applied to every retry when using the default pipeline builder. - */ - @Test - public void freshDateAppliedOnRetry() { - HttpPipeline pipeline - = BuilderHelper.buildPipeline(CREDENTIALS, null, null, null, ENDPOINT, REQUEST_RETRY_OPTIONS, null, - BuilderHelper.getDefaultHttpLogOptions(), new ClientOptions(), new FreshDateTestClient(), - new ArrayList<>(), new ArrayList<>(), null, null, new ClientLogger(BuilderHelperTests.class)); - - StepVerifier.create(pipeline.send(request(ENDPOINT))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that a new date will be applied to every retry when using the serviceClientBuilder's default pipeline. - */ - @Test - public void serviceClientFreshDateOnRetry() { - BlobServiceClient serviceClient = new BlobServiceClientBuilder().endpoint(ENDPOINT) - .credential(CREDENTIALS) - .httpClient(new FreshDateTestClient()) - .retryOptions(REQUEST_RETRY_OPTIONS) - .buildClient(); - - StepVerifier.create(serviceClient.getHttpPipeline().send(request(serviceClient.getAccountUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that a new date will be applied to every retry when using the serviceClientBuilder's default pipeline. - */ - @Test - public void containerClientFreshDateOnRetry() { - BlobContainerClient containerClient = new BlobContainerClientBuilder().endpoint(ENDPOINT) - .containerName("container") - .credential(CREDENTIALS) - .httpClient(new FreshDateTestClient()) - .retryOptions(REQUEST_RETRY_OPTIONS) - .buildClient(); - - StepVerifier.create(containerClient.getHttpPipeline().send(request(containerClient.getBlobContainerUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that a new date will be applied to every retry when using the blobClientBuilder's default pipeline. - */ - @Test - public void blobClientFreshDateOnRetry() { - BlobClient blobClient = new BlobClientBuilder().endpoint(ENDPOINT) - .containerName("container") - .blobName("blob") - .credential(CREDENTIALS) - .httpClient(new FreshDateTestClient()) - .retryOptions(REQUEST_RETRY_OPTIONS) - .buildClient(); - - StepVerifier.create(blobClient.getHttpPipeline().send(request(blobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that a new date will be applied to every retry when using the specializedBlobClientBuilder's default - * pipeline. - */ - @Test - public void specializedBlobClientFreshDateOnRetry() { - SpecializedBlobClientBuilder specializedBlobClientBuilder - = new SpecializedBlobClientBuilder().endpoint(ENDPOINT) - .containerName("container") - .blobName("blob") - .credential(CREDENTIALS) - .retryOptions(REQUEST_RETRY_OPTIONS) - .httpClient(new FreshDateTestClient()); - - AppendBlobClient appendBlobClient = specializedBlobClientBuilder.buildAppendBlobClient(); - - StepVerifier.create(appendBlobClient.getHttpPipeline().send(request(appendBlobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - - BlockBlobClient blockBlobClient = specializedBlobClientBuilder.buildBlockBlobClient(); - - StepVerifier.create(blockBlobClient.getHttpPipeline().send(request(blockBlobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - - PageBlobClient pageBlobClient = specializedBlobClientBuilder.buildPageBlobClient(); - - StepVerifier.create(pageBlobClient.getHttpPipeline().send(request(pageBlobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that a user application id will be honored in the UA string when using the default pipeline builder. - */ - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("customApplicationIdInUAStringSupplier") - public void customApplicationIdInUAString(String logOptionsUA, String clientOptionsUA, String expectedUA) { - HttpPipeline pipeline = BuilderHelper.buildPipeline(CREDENTIALS, null, null, null, ENDPOINT, - new RequestRetryOptions(), null, new HttpLogOptions().setApplicationId(logOptionsUA), - new ClientOptions().setApplicationId(clientOptionsUA), new ApplicationIdUAStringTestClient(expectedUA), - new ArrayList<>(), new ArrayList<>(), null, null, new ClientLogger(BuilderHelperTests.class)); - - StepVerifier.create(pipeline.send(request(ENDPOINT))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - private static Stream customApplicationIdInUAStringSupplier() { - return Stream.of(Arguments.of("log-options-id", null, "log-options-id"), - Arguments.of(null, "client-options-id", "client-options-id"), - // Client options preferred over log options - Arguments.of("log-options-id", "client-options-id", "client-options-id")); - } - - /** - * Tests that a user application id will be honored in the UA string when using the serviceClientBuilder's - * default pipeline. - */ - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("customApplicationIdInUAStringSupplier") - public void serviceClientCustomApplicationIdInUAString(String logOptionsUA, String clientOptionsUA, - String expectedUA) { - BlobServiceClient serviceClient = new BlobServiceClientBuilder().endpoint(ENDPOINT) - .credential(CREDENTIALS) - .httpLogOptions(new HttpLogOptions().setApplicationId(logOptionsUA)) - .clientOptions(new ClientOptions().setApplicationId(clientOptionsUA)) - .httpClient(new ApplicationIdUAStringTestClient(expectedUA)) - .buildClient(); - - StepVerifier.create(serviceClient.getHttpPipeline().send(request(serviceClient.getAccountUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that a user application id will be honored in the UA string when using the serviceClientBuilder - * default pipeline. - */ - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("customApplicationIdInUAStringSupplier") - public void containerClientcustomApplicationIdInUAString(String logOptionsUA, String clientOptionsUA, - String expectedUA) { - BlobContainerClient containerClient = new BlobContainerClientBuilder().endpoint(ENDPOINT) - .containerName("container") - .credential(CREDENTIALS) - .httpLogOptions(new HttpLogOptions().setApplicationId(logOptionsUA)) - .clientOptions(new ClientOptions().setApplicationId(clientOptionsUA)) - .httpClient(new ApplicationIdUAStringTestClient(expectedUA)) - .buildClient(); - - StepVerifier.create(containerClient.getHttpPipeline().send(request(containerClient.getBlobContainerUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that a user application id will be honored in the UA string when using the blobClientBuilder default pipeline. - */ - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("customApplicationIdInUAStringSupplier") - public void blobClientcustomApplicationIdInUAString(String logOptionsUA, String clientOptionsUA, - String expectedUA) { - BlobClient blobClient = new BlobClientBuilder().endpoint(ENDPOINT) - .containerName("container") - .blobName("blob") - .credential(CREDENTIALS) - .httpLogOptions(new HttpLogOptions().setApplicationId(logOptionsUA)) - .clientOptions(new ClientOptions().setApplicationId(clientOptionsUA)) - .httpClient(new ApplicationIdUAStringTestClient(expectedUA)) - .buildClient(); - - StepVerifier.create(blobClient.getHttpPipeline().send(request(blobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that a user application id will be honored in the UA string when using the specializedBlobClientBuilder - * default pipeline. - */ - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("customApplicationIdInUAStringSupplier") - public void specializedBlobClientCustomApplicationIdInUAString(String logOptionsUA, String clientOptionsUA, - String expectedUA) { - SpecializedBlobClientBuilder specializedBlobClientBuilder - = new SpecializedBlobClientBuilder().endpoint(ENDPOINT) - .containerName("container") - .blobName("blob") - .credential(CREDENTIALS) - .httpLogOptions(new HttpLogOptions().setApplicationId(logOptionsUA)) - .clientOptions(new ClientOptions().setApplicationId(clientOptionsUA)) - .httpClient(new ApplicationIdUAStringTestClient(expectedUA)); - - AppendBlobClient appendBlobClient = specializedBlobClientBuilder.buildAppendBlobClient(); - - StepVerifier.create(appendBlobClient.getHttpPipeline().send(request(appendBlobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - - BlockBlobClient blockBlobClient = specializedBlobClientBuilder.buildBlockBlobClient(); - - StepVerifier.create(blockBlobClient.getHttpPipeline().send(request(blockBlobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - - PageBlobClient pageBlobClient = specializedBlobClientBuilder.buildPageBlobClient(); - - StepVerifier.create(pageBlobClient.getHttpPipeline().send(request(pageBlobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that a custom headers will be honored when using the default pipeline builder. - */ - @Test - public void customHeadersClientOptions() { - List

headers = new ArrayList<>(); - headers.add(new Header("custom", "header")); - headers.add(new Header("Authorization", "notthis")); - headers.add(new Header("User-Agent", "overwritten")); - - HttpPipeline pipeline = BuilderHelper.buildPipeline(CREDENTIALS, null, null, null, ENDPOINT, - new RequestRetryOptions(), null, BuilderHelper.getDefaultHttpLogOptions(), - new ClientOptions().setHeaders(headers), new ClientOptionsHeadersTestClient(headers), new ArrayList<>(), - new ArrayList<>(), null, null, new ClientLogger(BuilderHelperTests.class)); - - StepVerifier.create(pipeline.send(request(ENDPOINT))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that custom headers will be honored when using the serviceClienBuilder's default pipeline. - */ - @Test - public void serviceClientcustomHeadersClientoptions() { - List
headers = new ArrayList<>(); - headers.add(new Header("custom", "header")); - headers.add(new Header("Authorization", "notthis")); - headers.add(new Header("User-Agent", "overwritten")); - - BlobServiceClient serviceClient = new BlobServiceClientBuilder().endpoint(ENDPOINT) - .credential(CREDENTIALS) - .clientOptions(new ClientOptions().setHeaders(headers)) - .httpClient(new ClientOptionsHeadersTestClient(headers)) - .buildClient(); - - StepVerifier.create(serviceClient.getHttpPipeline().send(request(serviceClient.getAccountUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that custom headers will be honored when using the serviceClientBuilder's default pipeline. - */ - @Test - public void containerClientCustomHeadersClientOptions() { - List
headers = new ArrayList<>(); - headers.add(new Header("custom", "header")); - headers.add(new Header("Authorization", "notthis")); - headers.add(new Header("User-Agent", "overwritten")); - - BlobContainerClient containerClient = new BlobContainerClientBuilder().endpoint(ENDPOINT) - .containerName("container") - .credential(CREDENTIALS) - .clientOptions(new ClientOptions().setHeaders(headers)) - .httpClient(new ClientOptionsHeadersTestClient(headers)) - .buildClient(); - - StepVerifier.create(containerClient.getHttpPipeline().send(request(containerClient.getBlobContainerUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that custom headers will be honored when using the blobClientBuilder's default pipeline. - */ - @Test - public void blobClientCustomHeadersClientoptions() { - List
headers = new ArrayList<>(); - headers.add(new Header("custom", "header")); - headers.add(new Header("Authorization", "notthis")); - headers.add(new Header("User-Agent", "overwritten")); - - BlobClient blobClient = new BlobClientBuilder().endpoint(ENDPOINT) - .containerName("container") - .blobName("blob") - .credential(CREDENTIALS) - .clientOptions(new ClientOptions().setHeaders(headers)) - .httpClient(new ClientOptionsHeadersTestClient(headers)) - .buildClient(); - - StepVerifier.create(blobClient.getHttpPipeline().send(request(blobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - /** - * Tests that custom headers will be honored when using the specializedBlobClientBuilder's default - * pipeline. - */ - @Test - public void specializedBlobClientCustomHeadersClientOptions() { - List
headers = new ArrayList<>(); - headers.add(new Header("custom", "header")); - headers.add(new Header("Authorization", "notthis")); - headers.add(new Header("User-Agent", "overwritten")); - - SpecializedBlobClientBuilder specializedBlobClientBuilder - = new SpecializedBlobClientBuilder().endpoint(ENDPOINT) - .containerName("container") - .blobName("blob") - .credential(CREDENTIALS) - .clientOptions(new ClientOptions().setHeaders(headers)) - .httpClient(new ClientOptionsHeadersTestClient(headers)); - - AppendBlobClient appendBlobClient = specializedBlobClientBuilder.buildAppendBlobClient(); - - StepVerifier.create(appendBlobClient.getHttpPipeline().send(request(appendBlobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - - BlockBlobClient blockBlobClient = specializedBlobClientBuilder.buildBlockBlobClient(); - - StepVerifier.create(blockBlobClient.getHttpPipeline().send(request(blockBlobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - - PageBlobClient pageBlobClient = specializedBlobClientBuilder.buildPageBlobClient(); - - StepVerifier.create(pageBlobClient.getHttpPipeline().send(request(pageBlobClient.getBlobUrl()))) - .assertNext(it -> assertEquals(200, it.getStatusCode())) - .verifyComplete(); - } - - @Test - public void doesNotThrowOnAmbiguousCredentialsWithoutAzureSasCredential() { - assertDoesNotThrow(() -> new BlobClientBuilder().endpoint(ENDPOINT) - .blobName("foo") - .credential(new StorageSharedKeyCredential("foo", "bar")) - .credential(new MockTokenCredential()) - .sasToken("foo") - .httpClient(new NoOpHttpClient()) - .buildClient()); - - assertDoesNotThrow(() -> new SpecializedBlobClientBuilder().endpoint(ENDPOINT) - .blobName("foo") - .credential(new StorageSharedKeyCredential("foo", "bar")) - .credential(new MockTokenCredential()) - .sasToken("foo") - .httpClient(new NoOpHttpClient()) - .buildBlockBlobClient()); - - assertDoesNotThrow(() -> new BlobContainerClientBuilder().endpoint(ENDPOINT) - .credential(new StorageSharedKeyCredential("foo", "bar")) - .credential(new MockTokenCredential()) - .sasToken("foo") - .httpClient(new NoOpHttpClient()) - .buildClient()); - - assertDoesNotThrow(() -> new BlobServiceClientBuilder().endpoint(ENDPOINT) - .credential(new StorageSharedKeyCredential("foo", "bar")) - .credential(new MockTokenCredential()) - .sasToken("foo") - .httpClient(new NoOpHttpClient()) - .buildClient()); - } - - @Test - public void throwsOnAmbiguousCredentialsWithAzureSasCredential() { - assertThrows(IllegalStateException.class, - () -> new BlobClientBuilder().endpoint(ENDPOINT) - .blobName("foo") - .credential(new StorageSharedKeyCredential("foo", "bar")) - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobClientBuilder().endpoint(ENDPOINT) - .blobName("foo") - .credential(new MockTokenCredential()) - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobClientBuilder().endpoint(ENDPOINT) - .blobName("foo") - .sasToken("foo") - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobClientBuilder().endpoint(ENDPOINT + "?sig=foo") - .blobName("foo") - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new SpecializedBlobClientBuilder().endpoint(ENDPOINT) - .blobName("foo") - .credential(new StorageSharedKeyCredential("foo", "bar")) - .credential(new AzureSasCredential("foo")) - .buildBlockBlobClient()); - - assertThrows(IllegalStateException.class, - () -> new SpecializedBlobClientBuilder().endpoint(ENDPOINT) - .blobName("foo") - .credential(new MockTokenCredential()) - .credential(new AzureSasCredential("foo")) - .buildBlockBlobClient()); - - assertThrows(IllegalStateException.class, - () -> new SpecializedBlobClientBuilder().endpoint(ENDPOINT) - .blobName("foo") - .sasToken("foo") - .credential(new AzureSasCredential("foo")) - .buildBlockBlobClient()); - - assertThrows(IllegalStateException.class, - () -> new SpecializedBlobClientBuilder().endpoint(ENDPOINT + "?sig=foo") - .blobName("foo") - .credential(new AzureSasCredential("foo")) - .buildBlockBlobClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobContainerClientBuilder().endpoint(ENDPOINT) - .credential(new StorageSharedKeyCredential("foo", "bar")) - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobContainerClientBuilder().endpoint(ENDPOINT) - .credential(new MockTokenCredential()) - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobContainerClientBuilder().endpoint(ENDPOINT) - .sasToken("foo") - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobContainerClientBuilder().endpoint(ENDPOINT + "?sig=foo") - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobServiceClientBuilder().endpoint(ENDPOINT) - .credential(new StorageSharedKeyCredential("foo", "bar")) - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobServiceClientBuilder().endpoint(ENDPOINT) - .credential(new MockTokenCredential()) - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobServiceClientBuilder().endpoint(ENDPOINT) - .sasToken("foo") - .credential(new AzureSasCredential("foo")) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobServiceClientBuilder().endpoint(ENDPOINT + "?sig=foo") - .credential(new AzureSasCredential("foo")) - .buildClient()); - } - - @Test - public void onlyOneRetryOptionsCanBeApplied() { - assertThrows(IllegalStateException.class, - () -> new BlobServiceClientBuilder().endpoint(ENDPOINT) - .credential(CREDENTIALS) - .retryOptions(REQUEST_RETRY_OPTIONS) - .retryOptions(CORE_RETRY_OPTIONS) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobContainerClientBuilder().endpoint(ENDPOINT) - .credential(CREDENTIALS) - .containerName("foo") - .retryOptions(REQUEST_RETRY_OPTIONS) - .retryOptions(CORE_RETRY_OPTIONS) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new BlobClientBuilder().endpoint(ENDPOINT) - .credential(CREDENTIALS) - .containerName("foo") - .blobName("foo") - .retryOptions(REQUEST_RETRY_OPTIONS) - .retryOptions(CORE_RETRY_OPTIONS) - .buildClient()); - - assertThrows(IllegalStateException.class, - () -> new SpecializedBlobClientBuilder().endpoint(ENDPOINT) - .credential(CREDENTIALS) - .containerName("foo") - .blobName("foo") - .retryOptions(REQUEST_RETRY_OPTIONS) - .retryOptions(CORE_RETRY_OPTIONS) - .buildBlockBlobClient()); - } - - private static final class FreshDateTestClient implements HttpClient { - private DateTimeRfc1123 firstDate; - - @Override - public Mono send(HttpRequest request) { - if (firstDate == null) { - firstDate = convertToDateObject(request.getHeaders().getValue(HttpHeaderName.DATE)); - return Mono.error(new IOException("IOException!")); - } - - assertNotEquals(firstDate, convertToDateObject(request.getHeaders().getValue(HttpHeaderName.DATE))); - return Mono.just(new MockHttpResponse(request, 200)); - } - - private static DateTimeRfc1123 convertToDateObject(String dateHeader) { - if (CoreUtils.isNullOrEmpty(dateHeader)) { - throw new RuntimeException("Failed to set 'Date' header."); - } - - return new DateTimeRfc1123(dateHeader); - } - } - - private static final class ApplicationIdUAStringTestClient implements HttpClient { - - private final String expectedUA; - - ApplicationIdUAStringTestClient(String expectedUA) { - this.expectedUA = expectedUA; - } - - @Override - public Mono send(HttpRequest request) { - if (CoreUtils.isNullOrEmpty(request.getHeaders().getValue(HttpHeaderName.USER_AGENT))) { - throw new RuntimeException("Failed to set 'User-Agent' header."); - } - assertTrue(request.getHeaders().getValue(HttpHeaderName.USER_AGENT).startsWith(expectedUA)); - return Mono.just(new MockHttpResponse(request, 200)); - } - } - - private static final class ClientOptionsHeadersTestClient implements HttpClient { - - private final Iterable
headers; - - ClientOptionsHeadersTestClient(Iterable
headers) { - this.headers = headers; - } - - @SuppressWarnings("deprecation") - @Override - public Mono send(HttpRequest request) { - headers.forEach(header -> { - if (CoreUtils.isNullOrEmpty(request.getHeaders().getValue(header.getName()))) { - throw new RuntimeException("Failed to set custom header " + header.getName()); - } - // This is meant to not match. - if (Objects.equals(header.getName(), "Authorization")) { - if (Objects.equals(request.getHeaders().getValue(header.getName()), header.getValue())) { - throw new RuntimeException("Custom header " + header.getName() + " did not match expectation."); - } - } else { - if (!Objects.equals(request.getHeaders().getValue(header.getName()), header.getValue())) { - throw new RuntimeException("Custom header " + header.getName() + " did not match expectation."); - } - } - }); - return Mono.just(new MockHttpResponse(request, 200)); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKAsyncTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKAsyncTests.java deleted file mode 100644 index 829cfb143e9b..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKAsyncTests.java +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.rest.Response; -import com.azure.core.test.annotation.LiveOnly; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobAsyncClient; -import com.azure.storage.blob.specialized.BlobAsyncClientBase; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.blob.specialized.PageBlobAsyncClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@LiveOnly -public class CPKAsyncTests extends BlobTestBase { - // LiveOnly because "x-ms-encryption-key-sha256 cannot be stored in recordings" - private CustomerProvidedKey key; - private BlobContainerAsyncClient cpkContainer; - private BlockBlobAsyncClient cpkBlockBlob; - private PageBlobAsyncClient cpkPageBlob; - private AppendBlobAsyncClient cpkAppendBlob; - private BlobAsyncClientBase cpkExistingBlob; - - @BeforeEach - public void setup() { - key = new CustomerProvidedKey(getRandomKey()); - BlobContainerClientBuilder builder - = instrument(new BlobContainerClientBuilder().endpoint(ccAsync.getBlobContainerUrl()) - .customerProvidedKey(key) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential())); - - cpkContainer = builder.buildAsyncClient(); - cpkBlockBlob = cpkContainer.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - cpkPageBlob = cpkContainer.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - cpkAppendBlob = cpkContainer.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - BlockBlobAsyncClient existingBlobSetup - = cpkContainer.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - existingBlobSetup.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()).block(); - cpkExistingBlob = existingBlobSetup; - } - - @Test - public void putBlobWithCPK() { - StepVerifier - .create(cpkBlockBlob.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null, null, - null, null)) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), r.getValue().getEncryptionKeySha256()); - }) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - @Test - public void getBlobWithCPK() { - StepVerifier.create(cpkBlockBlob.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(cpkBlockBlob.downloadWithResponse(null, null, null, false)) - .flatMap(r -> { - assertResponseStatusCode(r, 200); - return FluxUtil.collectBytesInByteBufferStream(r.getValue()); - })).assertNext(r -> TestUtils.assertArraysEqual(r, DATA.getDefaultBytes())).verifyComplete(); - } - - @Test - public void putBlockWithCPK() { - StepVerifier - .create(cpkBlockBlob.stageBlockWithResponse(getBlockID(), DATA.getDefaultFlux(), DATA.getDefaultDataSize(), - null, null)) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(Boolean.parseBoolean(r.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - }) - .verifyComplete(); - } - - @Test - public void putBlockFromURLWithCPK() { - String blobName = generateBlobName(); - BlockBlobAsyncClient sourceBlob = ccAsync.getBlobAsyncClient(blobName).getBlockBlobAsyncClient(); - String sas = ccAsync.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - StepVerifier - .create( - sourceBlob.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(cpkBlockBlob.stageBlockFromUrlWithResponse(getBlockID(), sourceBlob.getBlobUrl() + "?" + sas, - null, null, null, null))) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(Boolean.parseBoolean(r.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - }) - .verifyComplete(); - } - - @Test - public void putBlockListWithCPK() { - List blockIDList = Arrays.asList(getBlockID(), getBlockID()); - - Mono> response = Flux.fromIterable(blockIDList) - .flatMap(r -> cpkBlockBlob.stageBlock(r, DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .then(cpkBlockBlob.commitBlockListWithResponse(blockIDList, null, null, null, null)); - - StepVerifier.create(response).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), r.getValue().getEncryptionKeySha256()); - }).verifyComplete(); - } - - @Test - public void putPageWithCPK() { - StepVerifier - .create(cpkPageBlob.create(PageBlobClient.PAGE_BYTES) - .then(cpkPageBlob.uploadPagesWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, null))) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), r.getValue().getEncryptionKeySha256()); - }) - .verifyComplete(); - } - - @Test - public void putPageFromURLWithCPK() { - String blobName = generateBlobName(); - PageBlobAsyncClient sourceBlob = ccAsync.getBlobAsyncClient(blobName).getPageBlobAsyncClient(); - - String sas = ccAsync.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - Mono> response = sourceBlob.create(PageBlobClient.PAGE_BYTES) - .then(sourceBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, null)) - .then(cpkPageBlob.create(PageBlobClient.PAGE_BYTES)) - .then(cpkPageBlob.uploadPagesFromUrlWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), sourceBlob.getBlobUrl() + "?" + sas, - null, null, null, null)); - - StepVerifier.create(response).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), r.getValue().getEncryptionKeySha256()); - }).verifyComplete(); - } - - @Test - public void putMultiplePagesWithCPK() { - StepVerifier - .create(cpkPageBlob.create(PageBlobClient.PAGE_BYTES * 2) - .then(cpkPageBlob.uploadPagesWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES * 2))), null, null))) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), r.getValue().getEncryptionKeySha256()); - }) - .verifyComplete(); - } - - @Test - public void appendBlockWithCPK() { - StepVerifier.create(cpkAppendBlob.create() - .then(cpkAppendBlob.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null))) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), r.getValue().getEncryptionKeySha256()); - }) - .verifyComplete(); - } - - @Test - public void appendBlockFromURLWithCPK() { - String blobName = generateBlobName(); - BlockBlobAsyncClient sourceBlob = ccAsync.getBlobAsyncClient(blobName).getBlockBlobAsyncClient(); - String sas = ccAsync.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - Mono> response = cpkAppendBlob.create() - .then(sourceBlob.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .then(cpkAppendBlob.appendBlockFromUrlWithResponse(sourceBlob.getBlobUrl() + "?" + sas, null, null, null, - null)); - - StepVerifier.create(response).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), r.getValue().getEncryptionKeySha256()); - }).verifyComplete(); - } - - @Test - public void setBlobMetadataWithCPK() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - - StepVerifier.create(cpkExistingBlob.setMetadataWithResponse(metadata, null)).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertTrue(Boolean.parseBoolean(r.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - assertEquals(key.getKeySha256(), r.getHeaders().getValue(X_MS_ENCRYPTION_KEY_SHA256)); - }).verifyComplete(); - } - - @Test - public void getBlobPropertiesAndMetadataWithCPK() { - StepVerifier.create(cpkExistingBlob.getPropertiesWithResponse(null)).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertTrue(Boolean.parseBoolean(r.getHeaders().getValue(X_MS_SERVER_ENCRYPTED))); - assertEquals(key.getKeySha256(), r.getHeaders().getValue(X_MS_ENCRYPTION_KEY_SHA256)); - }).verifyComplete(); - } - - @Test - public void snapshotBlobWithCPK() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - assertAsyncResponseStatusCode(cpkExistingBlob.createSnapshotWithResponse(metadata, null), 201); - } - - @Test - public void getCustomerProvidedKeyClient() { - CustomerProvidedKey newCpk = new CustomerProvidedKey(getRandomKey()); - - // when: "AppendBlob" - AppendBlobAsyncClient newCpkAppendBlob = cpkAppendBlob.getCustomerProvidedKeyAsyncClient(newCpk); - - assertInstanceOf(AppendBlobAsyncClient.class, newCpkAppendBlob); - assertNotEquals(newCpkAppendBlob.getCustomerProvidedKey(), cpkAppendBlob.getCustomerProvidedKey()); - - // when: "BlockBlob" - BlockBlobAsyncClient newCpkBlockBlob = cpkBlockBlob.getCustomerProvidedKeyAsyncClient(newCpk); - - assertInstanceOf(BlockBlobAsyncClient.class, newCpkBlockBlob); - assertNotEquals(newCpkBlockBlob.getCustomerProvidedKey(), cpkBlockBlob.getCustomerProvidedKey()); - - // when: "PageBlob" - PageBlobAsyncClient newCpkPageBlob = cpkPageBlob.getCustomerProvidedKeyAsyncClient(newCpk); - - assertInstanceOf(PageBlobAsyncClient.class, newCpkPageBlob); - assertNotEquals(newCpkPageBlob.getCustomerProvidedKey(), cpkPageBlob.getCustomerProvidedKey()); - - // when: "BlobClientBase" - BlobAsyncClientBase newCpkBlobClientBase = cpkExistingBlob.getCustomerProvidedKeyAsyncClient(newCpk); - - assertInstanceOf(BlobAsyncClientBase.class, newCpkBlobClientBase); - assertNotEquals(newCpkBlobClientBase.getCustomerProvidedKey(), cpkExistingBlob.getCustomerProvidedKey()); - - // when: "BlobClient" - BlobAsyncClient cpkBlobClient = cpkContainer.getBlobAsyncClient(generateBlobName()); // Inherits container's CPK - BlobAsyncClient newCpkBlobClient = cpkBlobClient.getCustomerProvidedKeyAsyncClient(newCpk); - - assertInstanceOf(BlobAsyncClient.class, newCpkBlobClient); - assertNotEquals(newCpkBlobClient.getCustomerProvidedKey(), cpkBlobClient.getCustomerProvidedKey()); - } - - @Test - public void existsWithoutCPK() { - BlobAsyncClientBase clientWithoutCpk = cpkExistingBlob.getCustomerProvidedKeyAsyncClient(null); - StepVerifier.create(clientWithoutCpk.exists()).expectNext(true).verifyComplete(); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNAsyncTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNAsyncTests.java deleted file mode 100644 index b27f9215b80c..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNAsyncTests.java +++ /dev/null @@ -1,398 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.rest.Response; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.BlobContainerEncryptionScope; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobAsyncClient; -import com.azure.storage.blob.specialized.BlobAsyncClientBase; -import com.azure.storage.blob.specialized.BlobBaseTestHelper; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.blob.specialized.PageBlobAsyncClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class CPKNAsyncTests extends BlobTestBase { - - private final String scope1 = "testscope1"; - private final String scope2 = "testscope2"; - private String es; - private BlobContainerEncryptionScope ces; - private BlobContainerClientBuilder builder; - - private BlobContainerAsyncClient cpknContainer; - private BlockBlobAsyncClient cpknBlockBlob; - private PageBlobAsyncClient cpknPageBlob; - private AppendBlobAsyncClient cpknAppendBlob; - - @BeforeEach - public void setup() { - es = scope1; - ces = new BlobContainerEncryptionScope().setDefaultEncryptionScope(scope2) - .setEncryptionScopeOverridePrevented(true); - - builder = getContainerClientBuilder(ccAsync.getBlobContainerUrl()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()); - - cpknContainer = builder.encryptionScope(es).buildAsyncClient(); - - cpknBlockBlob = cpknContainer.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - cpknPageBlob = cpknContainer.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - cpknAppendBlob = cpknContainer.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - } - - @Test - public void containerCreate() { - BlobContainerAsyncClient cpknCesContainer = builder.blobContainerEncryptionScope(ces) - .encryptionScope(null) - .containerName(generateContainerName()) - .buildAsyncClient(); - - assertAsyncResponseStatusCode(cpknCesContainer.createWithResponse(null, null), 201); - } - - @Test - public void containerDenyEncryptionScopeOverride() { - BlobContainerAsyncClient cpknCesContainer - = builder.blobContainerEncryptionScope(ces).containerName(generateContainerName()).buildAsyncClient(); - - cpknAppendBlob = builder.encryptionScope(es) - .containerName(cpknCesContainer.getBlobContainerName()) - .buildAsyncClient() - .getBlobAsyncClient(generateBlobName()) - .getAppendBlobAsyncClient(); - - StepVerifier.create(cpknCesContainer.create().then(cpknAppendBlob.create())) - .verifyError(BlobStorageException.class); - } - - @Test - public void containerListBlobsFlat() { - BlobContainerAsyncClient cpkncesContainer = builder.blobContainerEncryptionScope(ces) - .encryptionScope(null) - .containerName(generateContainerName()) - .buildAsyncClient(); - AppendBlobAsyncClient cpknAppendBlob - = cpkncesContainer.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - StepVerifier - .create(cpkncesContainer.create().then(cpknAppendBlob.create()).thenMany(cpkncesContainer.listBlobs())) - .assertNext(r -> assertEquals(scope2, r.getProperties().getEncryptionScope())) - .verifyComplete(); - } - - @Test - public void containerListBlobsHierarchical() { - BlobContainerAsyncClient cpkncesContainer = builder.blobContainerEncryptionScope(ces) - .encryptionScope(null) - .containerName(generateContainerName()) - .buildAsyncClient(); - AppendBlobAsyncClient cpknAppendBlob - = cpkncesContainer.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - StepVerifier.create( - cpkncesContainer.create().then(cpknAppendBlob.create()).thenMany(cpkncesContainer.listBlobsByHierarchy(""))) - .assertNext(r -> assertEquals(scope2, r.getProperties().getEncryptionScope())) - .verifyComplete(); - } - - @Test - public void appendBlobCreate() { - StepVerifier.create(cpknAppendBlob.createWithResponse(null, null, null)).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(scope1, r.getValue().getEncryptionScope()); - }).verifyComplete(); - } - - @Test - public void appendBlobAppendBlock() { - StepVerifier.create(cpknAppendBlob.create() - .then(cpknAppendBlob.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null))) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(scope1, r.getValue().getEncryptionScope()); - }) - .verifyComplete(); - } - - @Test - public void appendBlobAppendBlockFromURL() { - String blobName = generateBlobName(); - BlockBlobAsyncClient sourceBlob = ccAsync.getBlobAsyncClient(blobName).getBlockBlobAsyncClient(); - String sas = ccAsync.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - Mono> response = cpknAppendBlob.create() - .then(sourceBlob.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .then(cpknAppendBlob.appendBlockFromUrlWithResponse(sourceBlob.getBlobUrl() + "?" + sas, null, null, null, - null)); - - StepVerifier.create(response).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(scope1, r.getValue().getEncryptionScope()); - }).verifyComplete(); - } - - @Test - public void pageBlobCreate() { - StepVerifier.create(cpknPageBlob.createWithResponse(1024, null, null, null, null)).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(scope1, r.getValue().getEncryptionScope()); - }).verifyComplete(); - } - - @Test - public void pageBlobPutPage() { - StepVerifier - .create(cpknPageBlob.create(PageBlobClient.PAGE_BYTES) - .then(cpknPageBlob.uploadPagesWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, null))) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(scope1, r.getValue().getEncryptionScope()); - }) - .verifyComplete(); - } - - @Test - public void pageBlobPutPageFromURL() { - String blobName = generateBlobName(); - PageBlobAsyncClient sourceBlob = ccAsync.getBlobAsyncClient(blobName).getPageBlobAsyncClient(); - String sas = ccAsync.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - Mono> response = sourceBlob.create(PageBlobClient.PAGE_BYTES) - .then(sourceBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, null)) - .then(cpknPageBlob.create(PageBlobClient.PAGE_BYTES)) - .then(cpknPageBlob.uploadPagesFromUrlWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), sourceBlob.getBlobUrl() + "?" + sas, - null, null, null, null)); - - StepVerifier.create(response).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(r.getValue().isServerEncrypted()); - assertEquals(scope1, r.getValue().getEncryptionScope()); - }).verifyComplete(); - } - - @Test - public void pageBlobPutMultiplePages() { - StepVerifier - .create(cpknPageBlob.create(PageBlobClient.PAGE_BYTES * 2) - .then(cpknPageBlob.uploadPagesWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES * 2))), null, null))) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - Assertions.assertTrue(r.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, r.getValue().getEncryptionScope()); - }) - .verifyComplete(); - } - - @Test - public void pageBlobClearPage() { - Mono> response - = cpknPageBlob.create(PageBlobClient.PAGE_BYTES * 2) - .then(cpknPageBlob.uploadPagesWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, null)) - .then(cpknPageBlob - .clearPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), null)); - - assertAsyncResponseStatusCode(response, 201); - } - - @Test - public void pageBlobResize() { - Mono> response = cpknPageBlob.create(PageBlobClient.PAGE_BYTES * 2) - .then(cpknPageBlob.resizeWithResponse(PageBlobClient.PAGE_BYTES * 2, null)); - - assertAsyncResponseStatusCode(response, 200); - } - - @Test - public void blockBlobUpload() { - StepVerifier - .create(cpknBlockBlob.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null, null, - null, null)) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - Assertions.assertTrue(r.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, r.getValue().getEncryptionScope()); - }) - .verifyComplete(); - } - - @Test - public void blockBlobStageBlock() { - StepVerifier - .create( - cpknBlockBlob.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(cpknBlockBlob.stageBlockWithResponse(getBlockID(), DATA.getDefaultFlux(), - DATA.getDefaultDataSize(), null, null))) - .assertNext(r -> { - HttpHeaders headers = r.getHeaders(); - - assertResponseStatusCode(r, 201); - Assertions.assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - Assertions.assertEquals(scope1, headers.getValue(X_MS_ENCRYPTION_SCOPE)); - }) - .verifyComplete(); - } - - @Test - public void blockBlobCommitBlockList() { - String blockID = getBlockID(); - List ids = Collections.singletonList(blockID); - - StepVerifier.create(cpknBlockBlob.stageBlock(blockID, DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(cpknBlockBlob.commitBlockListWithResponse(ids, null, null, null, null))).assertNext(r -> { - assertResponseStatusCode(r, 201); - Assertions.assertTrue(r.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, r.getValue().getEncryptionScope()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @Test - public void asyncCopyEncryptionScope() { - BlobAsyncClient blobSource = ccAsync.getBlobAsyncClient(generateBlobName()); - String sas = blobSource.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono response = blobSource.upload(DATA.getDefaultBinaryData()) - .then( - cpknBlockBlob.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(blobSource.getBlobUrl() + "?" + sas))) - .then(cpknBlockBlob.getProperties()); - - StepVerifier.create(response).assertNext(r -> assertEquals(scope1, r.getEncryptionScope())).verifyComplete(); - } - - @Test - public void serviceClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new BlobServiceClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .buildAsyncClient()); - } - - @Test - public void containerClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new BlobContainerClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .buildAsyncClient()); - } - - @Test - public void blobClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new BlobClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .endpoint(ccAsync.getBlobContainerUrl()) - .blobName(generateBlobName()) - .buildAsyncClient()); - } - - @Test - public void appendBlobClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new SpecializedBlobClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .endpoint(ccAsync.getBlobContainerUrl()) - .blobName(generateBlobName()) - .buildAppendBlobAsyncClient()); - } - - @Test - public void blockBlobClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new SpecializedBlobClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .endpoint(ccAsync.getBlobContainerUrl()) - .blobName(generateBlobName()) - .buildBlockBlobAsyncClient()); - } - - @Test - public void pageBlobClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new SpecializedBlobClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .endpoint(ccAsync.getBlobContainerUrl()) - .blobName(generateBlobName()) - .buildPageBlobAsyncClient()); - } - - @Test - public void getEncryptionScopeClient() { - String newEncryptionScope = "newtestscope"; - - // when: "AppendBlob" - AppendBlobAsyncClient newCpknAppendBlob = cpknAppendBlob.getEncryptionScopeAsyncClient(newEncryptionScope); - assertInstanceOf(AppendBlobAsyncClient.class, newCpknAppendBlob); - assertNotEquals(BlobBaseTestHelper.getEncryptionScope(cpknAppendBlob), - BlobBaseTestHelper.getEncryptionScope(newCpknAppendBlob)); - - // when: "BlockBlob" - BlockBlobAsyncClient newCpknBlockBlob = cpknBlockBlob.getEncryptionScopeAsyncClient(newEncryptionScope); - assertInstanceOf(BlockBlobAsyncClient.class, newCpknBlockBlob); - assertNotEquals(BlobBaseTestHelper.getEncryptionScope(cpknBlockBlob), - BlobBaseTestHelper.getEncryptionScope(newCpknBlockBlob)); - - // when: "PageBlob" - PageBlobAsyncClient newCpknPageBlob = cpknPageBlob.getEncryptionScopeAsyncClient(newEncryptionScope); - assertInstanceOf(PageBlobAsyncClient.class, newCpknPageBlob); - assertNotEquals(BlobBaseTestHelper.getEncryptionScope(cpknPageBlob), - BlobBaseTestHelper.getEncryptionScope(newCpknPageBlob)); - - // when: "BlobClient" - BlobAsyncClient cpkBlobClient = cpknContainer.getBlobAsyncClient(generateBlobName()); // Inherits container's CPK - BlobAsyncClient newCpknBlobClient = cpkBlobClient.getEncryptionScopeAsyncClient(newEncryptionScope); - assertInstanceOf(BlobAsyncClient.class, newCpknBlobClient); - assertNotEquals(BlobBaseTestHelper.getEncryptionScope(cpkBlobClient), - BlobBaseTestHelper.getEncryptionScope(newCpknBlobClient)); - - // when: "BlobClientBase" - BlobAsyncClientBase newCpknBlobClientBase - = ((BlobAsyncClientBase) cpkBlobClient).getEncryptionScopeAsyncClient(newEncryptionScope); - assertInstanceOf(BlobAsyncClientBase.class, newCpknBlobClientBase); - assertNotEquals(BlobBaseTestHelper.getEncryptionScope(cpkBlobClient), - BlobBaseTestHelper.getEncryptionScope(newCpknBlobClientBase)); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTests.java deleted file mode 100644 index 0ef86cea8f0c..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTests.java +++ /dev/null @@ -1,381 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.rest.Response; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.BlobContainerEncryptionScope; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlobClientBase; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.io.ByteArrayInputStream; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -public class CPKNTests extends BlobTestBase { - - private final String scope1 = "testscope1"; - private final String scope2 = "testscope2"; - private String es; - private BlobContainerEncryptionScope ces; - private BlobContainerClientBuilder builder; - - private BlobContainerClient cpknContainer; - private BlockBlobClient cpknBlockBlob; - private PageBlobClient cpknPageBlob; - private AppendBlobClient cpknAppendBlob; - - @BeforeEach - public void setup() { - es = scope1; - ces = new BlobContainerEncryptionScope().setDefaultEncryptionScope(scope2) - .setEncryptionScopeOverridePrevented(true); - - builder = getContainerClientBuilder(cc.getBlobContainerUrl()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()); - - cpknContainer = builder.encryptionScope(es).buildClient(); - - cpknBlockBlob = cpknContainer.getBlobClient(generateBlobName()).getBlockBlobClient(); - cpknPageBlob = cpknContainer.getBlobClient(generateBlobName()).getPageBlobClient(); - cpknAppendBlob = cpknContainer.getBlobClient(generateBlobName()).getAppendBlobClient(); - } - - @Test - public void getEncryptionScope() { - Assertions.assertEquals(es, cpknContainer.getEncryptionScope()); - } - - @Test - public void containerCreate() { - BlobContainerClient cpknCesContainer = builder.blobContainerEncryptionScope(ces) - .encryptionScope(null) - .containerName(generateContainerName()) - .buildClient(); - Response response = cpknCesContainer.createWithResponse(null, null, null, null); - assertResponseStatusCode(response, 201); - } - - @Test - public void containerDenyEncryptionScopeOverride() { - BlobContainerClient cpknCesContainer - = builder.blobContainerEncryptionScope(ces).containerName(generateContainerName()).buildClient(); - cpknCesContainer.create(); - - cpknAppendBlob = builder.encryptionScope(es) - .containerName(cpknCesContainer.getBlobContainerName()) - .buildClient() - .getBlobClient(generateBlobName()) - .getAppendBlobClient(); - - Assertions.assertThrows(BlobStorageException.class, () -> cpknAppendBlob.create()); - } - - @Test - public void containerListBlobsFlat() { - BlobContainerClient cpkncesContainer = builder.blobContainerEncryptionScope(ces) - .encryptionScope(null) - .containerName(generateContainerName()) - .buildClient(); - cpkncesContainer.create(); - AppendBlobClient cpknAppendBlob = cpkncesContainer.getBlobClient(generateBlobName()).getAppendBlobClient(); - cpknAppendBlob.create(); - - Iterator items = cpkncesContainer.listBlobs().iterator(); - - BlobItem blob = items.next(); - Assertions.assertFalse(items.hasNext()); - Assertions.assertEquals(scope2, blob.getProperties().getEncryptionScope()); - } - - @Test - public void containerListBlobsHierarchical() { - BlobContainerClient cpkncesContainer = builder.blobContainerEncryptionScope(ces) - .encryptionScope(null) - .containerName(generateContainerName()) - .buildClient(); - cpkncesContainer.create(); - AppendBlobClient cpknAppendBlob = cpkncesContainer.getBlobClient(generateBlobName()).getAppendBlobClient(); - cpknAppendBlob.create(); - - Iterator items = cpkncesContainer.listBlobsByHierarchy("").iterator(); - - BlobItem blob = items.next(); - Assertions.assertFalse(items.hasNext()); - Assertions.assertEquals(scope2, blob.getProperties().getEncryptionScope()); - } - - @Test - public void appendBlobCreate() { - Response response = cpknAppendBlob.createWithResponse(null, null, null, null, null); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(response.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, response.getValue().getEncryptionScope()); - } - - @Test - public void appendBlobAppendBlock() { - cpknAppendBlob.create(); - - Response response = cpknAppendBlob.appendBlockWithResponse(DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(response.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, response.getValue().getEncryptionScope()); - } - - @Test - public void appendBlobAppendBlockFromURL() { - cpknAppendBlob.create(); - String blobName = generateBlobName(); - BlockBlobClient sourceBlob = cc.getBlobClient(blobName).getBlockBlobClient(); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - String sas = cc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - Response response = cpknAppendBlob - .appendBlockFromUrlWithResponse(sourceBlob.getBlobUrl() + "?" + sas, null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(response.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, response.getValue().getEncryptionScope()); - } - - @Test - public void pageBlobCreate() { - Response response = cpknPageBlob.createWithResponse(1024, null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(response.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, response.getValue().getEncryptionScope()); - } - - @Test - public void pageBlobPutPage() { - cpknPageBlob.create(PageBlobClient.PAGE_BYTES); - - Response response - = cpknPageBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, null, null, null); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(response.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, response.getValue().getEncryptionScope()); - } - - @Test - public void pageBlobPutPageFromURL() { - String blobName = generateBlobName(); - PageBlobClient sourceBlob = cc.getBlobClient(blobName).getPageBlobClient(); - sourceBlob.create(PageBlobClient.PAGE_BYTES); - sourceBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, null, null, null); - - cpknPageBlob.create(PageBlobClient.PAGE_BYTES); - String sas = cc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - Response response = cpknPageBlob.uploadPagesFromUrlWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), sourceBlob.getBlobUrl() + "?" + sas, - null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(response.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, response.getValue().getEncryptionScope()); - } - - @Test - public void pageBlobPutMultiplePages() { - cpknPageBlob.create(PageBlobClient.PAGE_BYTES * 2); - - Response response = cpknPageBlob.uploadPagesWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES * 2)), null, null, null, null); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(response.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, response.getValue().getEncryptionScope()); - } - - @Test - public void pageBlobClearPage() { - cpknPageBlob.create(PageBlobClient.PAGE_BYTES * 2); - cpknPageBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, null, null, null); - - Response response = cpknPageBlob.clearPagesWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), null, null, null); - - assertResponseStatusCode(response, 201); - } - - @Test - public void pageBlobResize() { - cpknPageBlob.create(PageBlobClient.PAGE_BYTES * 2); - Response response - = cpknPageBlob.resizeWithResponse(PageBlobClient.PAGE_BYTES * 2, null, null, null); - - assertResponseStatusCode(response, 200); - } - - @Test - public void blockBlobUpload() { - Response response = cpknBlockBlob.uploadWithResponse(DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(response.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, response.getValue().getEncryptionScope()); - } - - @Test - public void blockBlobStageBlock() { - cpknBlockBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - Response response = cpknBlockBlob.stageBlockWithResponse(getBlockID(), DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null); - HttpHeaders headers = response.getHeaders(); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - Assertions.assertEquals(scope1, headers.getValue(X_MS_ENCRYPTION_SCOPE)); - } - - @Test - public void blockBlobCommitBlockList() { - String blockID = getBlockID(); - cpknBlockBlob.stageBlock(blockID, DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - List ids = Collections.singletonList(blockID); - - Response response - = cpknBlockBlob.commitBlockListWithResponse(ids, null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - Assertions.assertTrue(response.getValue().isServerEncrypted()); - Assertions.assertEquals(scope1, response.getValue().getEncryptionScope()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @Test - public void syncCopyEncryptionScope() { - BlobClient blobSource = cc.getBlobClient(generateBlobName()); - blobSource.upload(DATA.getDefaultBinaryData()); - - String sas = blobSource.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - cpknBlockBlob.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(blobSource.getBlobUrl() + "?" + sas), null, - null); - - Assertions.assertEquals(scope1, cpknBlockBlob.getProperties().getEncryptionScope()); - } - - @Test - public void serviceClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new BlobServiceClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .buildClient()); - } - - @Test - public void containerClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new BlobContainerClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .buildClient()); - } - - @Test - public void blobClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new BlobClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .endpoint(cc.getBlobContainerUrl()) - .blobName(generateBlobName()) - .buildClient()); - } - - @Test - public void appendBlobClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new SpecializedBlobClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .endpoint(cc.getBlobContainerUrl()) - .blobName(generateBlobName()) - .buildAppendBlobClient()); - } - - @Test - public void blockBlobClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new SpecializedBlobClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .endpoint(cc.getBlobContainerUrl()) - .blobName(generateBlobName()) - .buildBlockBlobClient()); - } - - @Test - public void pageBlobClientBuilderCheck() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> new SpecializedBlobClientBuilder().encryptionScope(es) - .customerProvidedKey(new CustomerProvidedKey(getRandomKey())) - .endpoint(cc.getBlobContainerUrl()) - .blobName(generateBlobName()) - .buildPageBlobClient()); - } - - @Test - public void getEncryptionScopeClient() { - String newEncryptionScope = "newtestscope"; - - // when: "AppendBlob" - AppendBlobClient newCpknAppendBlob = cpknAppendBlob.getEncryptionScopeClient(newEncryptionScope); - Assertions.assertInstanceOf(AppendBlobClient.class, newCpknAppendBlob); - Assertions.assertNotEquals(cpknAppendBlob.getEncryptionScope(), newCpknAppendBlob.getEncryptionScope()); - - // when: "BlockBlob" - BlockBlobClient newCpknBlockBlob = cpknBlockBlob.getEncryptionScopeClient(newEncryptionScope); - Assertions.assertInstanceOf(BlockBlobClient.class, newCpknBlockBlob); - Assertions.assertNotEquals(cpknBlockBlob.getEncryptionScope(), newCpknBlockBlob.getEncryptionScope()); - - // when: "PageBlob" - PageBlobClient newCpknPageBlob = cpknPageBlob.getEncryptionScopeClient(newEncryptionScope); - Assertions.assertInstanceOf(PageBlobClient.class, newCpknPageBlob); - Assertions.assertNotEquals(cpknPageBlob.getEncryptionScope(), newCpknPageBlob.getEncryptionScope()); - - // when: "BlobClient" - BlobClient cpkBlobClient = cpknContainer.getBlobClient(generateBlobName()); // Inherits container's CPK - BlobClient newCpknBlobClient = cpkBlobClient.getEncryptionScopeClient(newEncryptionScope); - Assertions.assertInstanceOf(BlobClient.class, newCpknBlobClient); - Assertions.assertNotEquals(cpkBlobClient.getEncryptionScope(), newCpknBlobClient.getEncryptionScope()); - - // when: "BlobClientBase" - BlobClientBase newCpknBlobClientBase - = ((BlobClientBase) cpkBlobClient).getEncryptionScopeClient(newEncryptionScope); - Assertions.assertInstanceOf(BlobClientBase.class, newCpknBlobClientBase); - Assertions.assertNotEquals(cpkBlobClient.getEncryptionScope(), newCpknBlobClientBase.getEncryptionScope()); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTests.java deleted file mode 100644 index 49369449b5a4..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTests.java +++ /dev/null @@ -1,289 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.rest.Response; -import com.azure.core.test.annotation.LiveOnly; -import com.azure.core.test.utils.TestUtils; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.BlobDownloadResponse; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlobClientBase; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@LiveOnly -public class CPKTests extends BlobTestBase { - // LiveOnly because "x-ms-encryption-key-sha256 cannot be stored in recordings" - private CustomerProvidedKey key; - private BlobContainerClient cpkContainer; - private BlockBlobClient cpkBlockBlob; - private PageBlobClient cpkPageBlob; - private AppendBlobClient cpkAppendBlob; - private BlobClientBase cpkExistingBlob; - - @BeforeEach - public void setup() { - key = new CustomerProvidedKey(getRandomKey()); - BlobContainerClientBuilder builder - = instrument(new BlobContainerClientBuilder().endpoint(cc.getBlobContainerUrl()) - .customerProvidedKey(key) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential())); - - cpkContainer = builder.buildClient(); - - cpkBlockBlob = cpkContainer.getBlobClient(generateBlobName()).getBlockBlobClient(); - cpkPageBlob = cpkContainer.getBlobClient(generateBlobName()).getPageBlobClient(); - cpkAppendBlob = cpkContainer.getBlobClient(generateBlobName()).getAppendBlobClient(); - - BlockBlobClient existingBlobSetup = cpkContainer.getBlobClient(generateBlobName()).getBlockBlobClient(); - existingBlobSetup.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - cpkExistingBlob = existingBlobSetup; - - } - - @Test - public void getCPK() { - assertEquals(key.getKey(), cpkContainer.getCustomerProvidedKey().getEncryptionKey()); - } - - @Test - public void putBlobWithCPK() { - Response response = cpkBlockBlob.uploadWithResponse(DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null, null, null, null); - assertResponseStatusCode(response, 201); - assertTrue(response.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), response.getValue().getEncryptionKeySha256()); - } - - @SuppressWarnings("deprecation") - @Test - public void getBlobWithCPK() { - cpkBlockBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - ByteArrayOutputStream dataStream = new ByteArrayOutputStream(); - - BlobDownloadResponse response - = cpkBlockBlob.downloadWithResponse(dataStream, null, null, null, false, null, null); - - assertResponseStatusCode(response, 200); - TestUtils.assertArraysEqual(dataStream.toByteArray(), DATA.getDefaultBytes()); - } - - @Test - public void putBlockWithCPK() { - Response response = cpkBlockBlob.stageBlockWithResponse(getBlockID(), DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(Boolean.parseBoolean(response.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - } - - @Test - public void putBlockFromURLWithCPK() { - String blobName = generateBlobName(); - BlockBlobClient sourceBlob = cc.getBlobClient(blobName).getBlockBlobClient(); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - String sas = cc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - Response response = cpkBlockBlob.stageBlockFromUrlWithResponse(getBlockID(), - sourceBlob.getBlobUrl() + "?" + sas, null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(Boolean.parseBoolean(response.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - } - - @Test - public void putBlockListWithCPK() { - List blockIDList = Arrays.asList(getBlockID(), getBlockID()); - for (String blockId : blockIDList) { - cpkBlockBlob.stageBlock(blockId, DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - } - - Response response - = cpkBlockBlob.commitBlockListWithResponse(blockIDList, null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(response.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), response.getValue().getEncryptionKeySha256()); - } - - @Test - public void putPageWithCPK() { - cpkPageBlob.create(PageBlobClient.PAGE_BYTES); - - Response response - = cpkPageBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(response.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), response.getValue().getEncryptionKeySha256()); - } - - @Test - public void putPageFromURLWithCPK() { - String blobName = generateBlobName(); - PageBlobClient sourceBlob = cc.getBlobClient(blobName).getPageBlobClient(); - sourceBlob.create(PageBlobClient.PAGE_BYTES); - sourceBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, null, null, null); - - cpkPageBlob.create(PageBlobClient.PAGE_BYTES); - String sas = cc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - Response response = cpkPageBlob.uploadPagesFromUrlWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), sourceBlob.getBlobUrl() + "?" + sas, - null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(response.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), response.getValue().getEncryptionKeySha256()); - } - - @Test - public void putMultiplePagesWithCPK() { - cpkPageBlob.create(PageBlobClient.PAGE_BYTES * 2); - - Response response - = cpkPageBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES * 2)), null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(response.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), response.getValue().getEncryptionKeySha256()); - } - - @Test - public void appendBlockWithCPK() { - cpkAppendBlob.create(); - - Response response = cpkAppendBlob.appendBlockWithResponse(DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(response.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), response.getValue().getEncryptionKeySha256()); - } - - @Test - public void appendBlockFromURLWithCPK() { - cpkAppendBlob.create(); - String blobName = generateBlobName(); - BlockBlobClient sourceBlob = cc.getBlobClient(blobName).getBlockBlobClient(); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - String sas = cc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusHours(1), - new BlobSasPermission().setReadPermission(true))); - - Response response = cpkAppendBlob - .appendBlockFromUrlWithResponse(sourceBlob.getBlobUrl() + "?" + sas, null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(response.getValue().isServerEncrypted()); - assertEquals(key.getKeySha256(), response.getValue().getEncryptionKeySha256()); - } - - @Test - public void setBlobMetadataWithCPK() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - - Response response = cpkExistingBlob.setMetadataWithResponse(metadata, null, null, null); - - assertResponseStatusCode(response, 200); - assertTrue(Boolean.parseBoolean(response.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - assertEquals(key.getKeySha256(), response.getHeaders().getValue(X_MS_ENCRYPTION_KEY_SHA256)); - } - - @Test - public void getBlobPropertiesAndMetadataWithCPK() { - Response response = cpkExistingBlob.getPropertiesWithResponse(null, null, null); - - assertResponseStatusCode(response, 200); - assertTrue(Boolean.parseBoolean(response.getHeaders().getValue(X_MS_SERVER_ENCRYPTED))); - assertEquals(key.getKeySha256(), response.getHeaders().getValue(X_MS_ENCRYPTION_KEY_SHA256)); - } - - // @Test - // public void setBlobTierWithCPK() { - // Response response = cpkExistingBlob.setAccessTierWithResponse(AccessTier.COOL, null, null, null, null); - // - // assertResponseStatusCode(response, 200); - // assertTrue(Boolean.parseBoolean(response.getHeaders().getValue(X_MS_SERVER_ENCRYPTED))); - // assertEquals(key.getKeySha256(), response.getHeaders().getValue(X_MS_ENCRYPTION_KEY_SHA256)); - // } - - @Test - public void snapshotBlobWithCPK() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - Response response = cpkExistingBlob.createSnapshotWithResponse(metadata, null, null, null); - assertResponseStatusCode(response, 201); - } - - @Test - public void getCustomerProvidedKeyClient() { - CustomerProvidedKey newCpk = new CustomerProvidedKey(getRandomKey()); - - // when: "AppendBlob" - AppendBlobClient newCpkAppendBlob = cpkAppendBlob.getCustomerProvidedKeyClient(newCpk); - - assertInstanceOf(AppendBlobClient.class, newCpkAppendBlob); - assertNotEquals(newCpkAppendBlob.getCustomerProvidedKey(), cpkAppendBlob.getCustomerProvidedKey()); - - // when: "BlockBlob" - BlockBlobClient newCpkBlockBlob = cpkBlockBlob.getCustomerProvidedKeyClient(newCpk); - - assertInstanceOf(BlockBlobClient.class, newCpkBlockBlob); - assertNotEquals(newCpkBlockBlob.getCustomerProvidedKey(), cpkBlockBlob.getCustomerProvidedKey()); - - // when: "PageBlob" - PageBlobClient newCpkPageBlob = cpkPageBlob.getCustomerProvidedKeyClient(newCpk); - - assertInstanceOf(PageBlobClient.class, newCpkPageBlob); - assertNotEquals(newCpkPageBlob.getCustomerProvidedKey(), cpkPageBlob.getCustomerProvidedKey()); - - // when: "BlobClientBase" - BlobClientBase newCpkBlobClientBase = cpkExistingBlob.getCustomerProvidedKeyClient(newCpk); - - assertInstanceOf(BlobClientBase.class, newCpkBlobClientBase); - assertNotEquals(newCpkBlobClientBase.getCustomerProvidedKey(), cpkExistingBlob.getCustomerProvidedKey()); - - // when: "BlobClient" - BlobClient cpkBlobClient = cpkContainer.getBlobClient(generateBlobName()); // Inherits container's CPK - BlobClient newCpkBlobClient = cpkBlobClient.getCustomerProvidedKeyClient(newCpk); - - assertInstanceOf(BlobClient.class, newCpkBlobClient); - assertNotEquals(newCpkBlobClient.getCustomerProvidedKey(), cpkBlobClient.getCustomerProvidedKey()); - } - - @Test - public void existsWithoutCPK() { - BlobClientBase clientWithoutCpk = cpkExistingBlob.getCustomerProvidedKeyClient(null); - assertTrue(clientWithoutCpk.exists()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerApiTests.java deleted file mode 100644 index 7fef867889d3..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerApiTests.java +++ /dev/null @@ -1,2092 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.Response; -import com.azure.core.test.utils.MockTokenCredential; -import com.azure.core.util.Context; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.BlobAccessPolicy; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobContainerProperties; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobListDetails; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobSignedIdentifier; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlobType; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.LeaseStatusType; -import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.blob.models.ObjectReplicationPolicy; -import com.azure.storage.blob.models.ObjectReplicationStatus; -import com.azure.storage.blob.models.PublicAccessType; -import com.azure.storage.blob.models.RehydratePriority; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.TaggedBlobItem; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.BlobSetAccessTierOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.TestHttpClientType; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.PlaybackOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; - -import java.io.ByteArrayInputStream; -import java.net.URL; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ContainerApiTests extends BlobTestBase { - private String tagKey; - private String tagValue; - - @BeforeEach - public void setup() { - tagKey = testResourceNamer.randomName(prefix, 20); - tagValue = testResourceNamer.randomName(prefix, 20); - } - - @Test - public void blobNameNull() { - assertThrows(NullPointerException.class, () -> cc.getBlobClient(null)); - } - - @Test - public void createAllNull() { - // Overwrite the existing cc, which has already been created - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - - Response response = cc.createWithResponse(null, null, null, null); - assertResponseStatusCode(response, 201); - validateBasicHeaders(response.getHeaders()); - } - - @Test - public void createMin() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - assertTrue(cc.exists()); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createMetadata(String key1, String value1, String key2, String value2) { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - cc.createWithResponse(metadata, null, null, null); - Response response = cc.getPropertiesWithResponse(null, null, null); - - if (ENVIRONMENT.getHttpClientType() == TestHttpClientType.JDK_HTTP) { - // JDK HttpClient returns headers with names lowercased. - Map lowercasedMetadata = metadata.entrySet() - .stream() - .collect(Collectors.toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue)); - assertEquals(lowercasedMetadata, response.getValue().getMetadata()); - } else { - assertEquals(metadata, response.getValue().getMetadata()); - } - } - - private static Stream createMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of("testFoo", "testBar", "testFizz", "testBuzz")); - } - - @ParameterizedTest - @MethodSource("publicAccessSupplier") - @PlaybackOnly - public void createPublicAccess(PublicAccessType publicAccess) { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - cc.createWithResponse(null, publicAccess, null, null); - PublicAccessType access = cc.getProperties().getBlobPublicAccess(); - assertEquals(access, publicAccess); - } - - private static Stream publicAccessSupplier() { - return Stream.of(Arguments.of(PublicAccessType.BLOB), Arguments.of(PublicAccessType.CONTAINER), - Arguments.of((PublicAccessType) null)); - } - - @Test - public void createError() { - BlobStorageException e = assertThrows(BlobStorageException.class, () -> cc.create()); - assertExceptionStatusCodeAndMessage(e, 409, BlobErrorCode.CONTAINER_ALREADY_EXISTS); - assertTrue(e.getServiceMessage().contains("The specified container already exists.")); - } - - @Test - public void createBlobVersionClient() { - String name = generateBlobName(); - BlockBlobClient bc = cc.getBlobClient(name).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), 7); - BlobClient vc = cc.getBlobVersionClient(name, null); - - assertTrue(vc.exists()); - } - - @Test - public void createIfNotExistsAllNull() { - // Overwrite the existing cc, which has already been created - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - - Response response = cc.createIfNotExistsWithResponse(null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(validateBasicHeaders(response.getHeaders())); - } - - @Test - public void createIfNotExistsMin() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainerIfNotExists(generateContainerName()); - - assertTrue(cc.exists()); - } - - @Test - public void createIfNotExistsMinContainer() { - BlobContainerClient cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - boolean result = cc.createIfNotExists(); - assertTrue(result); - } - - @Test - public void createIfNotExistsWithResponse() { - Response response - = primaryBlobServiceClient.createBlobContainerIfNotExistsWithResponse(generateContainerName(), null, null); - - assertResponseStatusCode(response, 201); - } - - @Test - public void createIfNotExistsBlobServiceThatAlreadyExists() { - String containerName = generateContainerName(); - Response response - = primaryBlobServiceClient.createBlobContainerIfNotExistsWithResponse(containerName, null, null); - Response secondResponse - = primaryBlobServiceClient.createBlobContainerIfNotExistsWithResponse(containerName, null, null); - - assertResponseStatusCode(response, 201); - assertResponseStatusCode(secondResponse, 409); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createIfNotExistsMetadataIfNotExists(String key1, String value1, String key2, String value2) { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata); - - Response result = cc.createIfNotExistsWithResponse(options, null, null); - Response response = cc.getPropertiesWithResponse(null, null, null); - - if (ENVIRONMENT.getHttpClientType() == TestHttpClientType.JDK_HTTP) { - // JDK HttpClient returns headers with names lowercased. - Map lowercasedMetadata = metadata.entrySet() - .stream() - .collect(Collectors.toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue)); - assertEquals(lowercasedMetadata, response.getValue().getMetadata()); - } else { - assertEquals(metadata, response.getValue().getMetadata()); - } - assertTrue(result.getValue()); - } - - @ParameterizedTest - @MethodSource("publicAccessSupplier") - @PlaybackOnly - public void createIfNotExistsPublicAccess(PublicAccessType publicAccess) { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - Response result = cc.createIfNotExistsWithResponse( - new BlobContainerCreateOptions().setPublicAccessType(publicAccess), null, null); - PublicAccessType access = cc.getProperties().getBlobPublicAccess(); - assertEquals(access, publicAccess); - assertTrue(result.getValue()); - } - - @Test - public void createIfNotExistsOnContainerThatAlreadyExists() { - assertFalse(cc.createIfNotExists()); - } - - @Test - public void createIfNotExistsOnAContainerThatAlreadyExistsWithResponse() { - BlobContainerClient cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - Response initialResponse = cc.createIfNotExistsWithResponse(null, null, null); - - Response secondResponse = cc.createIfNotExistsWithResponse(null, null, null); - - assertResponseStatusCode(initialResponse, 201); - assertTrue(initialResponse.getValue()); - assertResponseStatusCode(secondResponse, 409); - assertFalse(secondResponse.getValue()); - } - - @Test - public void getPropertiesNull() { - Response response = cc.getPropertiesWithResponse(null, null, null); - - assertTrue(validateBasicHeaders(response.getHeaders())); - assertNull(response.getValue().getBlobPublicAccess()); - assertFalse(response.getValue().hasImmutabilityPolicy()); - assertFalse(response.getValue().hasLegalHold()); - assertNull(response.getValue().getLeaseDuration()); - assertEquals(response.getValue().getLeaseState(), LeaseStateType.AVAILABLE); - assertEquals(response.getValue().getLeaseStatus(), LeaseStatusType.UNLOCKED); - assertEquals(0, response.getValue().getMetadata().size()); - assertFalse(response.getValue().isEncryptionScopeOverridePrevented()); - assertNotNull(response.getValue().getDefaultEncryptionScope()); - } - - @Test - public void getPropertiesMin() { - assertNotNull(cc.getProperties()); - } - - @Test - public void getPropertiesLease() { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - - assertResponseStatusCode(cc.getPropertiesWithResponse(leaseID, null, null), 200); - } - - @Test - public void getPropertiesLeaseFail() { - assertThrows(BlobStorageException.class, () -> cc.getPropertiesWithResponse("garbage", null, null)); - } - - @Test - public void getPropertiesError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> cc.getProperties()); - } - - @Test - public void setMetadata() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - Map metadata = new HashMap<>(); - metadata.put("key", "value"); - cc.createWithResponse(metadata, null, null, null); - - Response response = cc.setMetadataWithResponse(null, null, null, null); - - assertResponseStatusCode(response, 200); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertEquals(cc.getPropertiesWithResponse(null, null, null).getValue().getMetadata().size(), 0); - } - - @Test - public void setMetadataMin() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - - cc.setMetadata(metadata); - - assertEquals(cc.getPropertiesWithResponse(null, null, null).getValue().getMetadata(), metadata); - } - - @ParameterizedTest - @MethodSource("setMetadataMetadataSupplier") - public void setMetadataMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - assertResponseStatusCode(cc.setMetadataWithResponse(metadata, null, null, null), 200); - assertEquals(cc.getPropertiesWithResponse(null, null, null).getValue().getMetadata(), metadata); - } - - private static Stream setMetadataMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @ParameterizedTest - @MethodSource("setMetadataACSupplier") - public void setMetadataAC(OffsetDateTime modified, String leaseID) { - leaseID = setupContainerLeaseCondition(cc, leaseID); - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID).setIfModifiedSince(modified); - - assertResponseStatusCode(cc.setMetadataWithResponse(null, cac, null, null), 200); - } - - private static Stream setMetadataACSupplier() { - return Stream.of(Arguments.of(null, null), Arguments.of(OLD_DATE, null), Arguments.of(null, RECEIVED_LEASE_ID)); - } - - @ParameterizedTest - @MethodSource("setMetadataACFailSupplier") - public void setMetadataACFail(OffsetDateTime modified, String leaseID) { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID).setIfModifiedSince(modified); - - assertThrows(BlobStorageException.class, () -> cc.setMetadataWithResponse(null, cac, null, null)); - } - - private static Stream setMetadataACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null), Arguments.of(null, GARBAGE_LEASE_ID)); - } - - @ParameterizedTest - @MethodSource("setMetadataACIllegalSupplier") - public void setMetadataACIllegal(OffsetDateTime unmodified, String match, String noneMatch) { - BlobRequestConditions mac - = new BlobRequestConditions().setIfUnmodifiedSince(unmodified).setIfMatch(match).setIfNoneMatch(noneMatch); - - assertThrows(UnsupportedOperationException.class, () -> cc.setMetadataWithResponse(null, mac, null, null)); - } - - private static Stream setMetadataACIllegalSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null), Arguments.of(null, RECEIVED_ETAG, null), - Arguments.of(null, null, GARBAGE_ETAG)); - } - - @Test - public void setMetadataError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> cc.setMetadata(null)); - } - - @ParameterizedTest - @MethodSource("publicAccessSupplier") - @PlaybackOnly - public void setAccessPolicy(PublicAccessType publicAccess) { - Response response = cc.setAccessPolicyWithResponse(publicAccess, null, null, null, null); - - assertTrue(validateBasicHeaders(response.getHeaders())); - assertEquals(cc.getProperties().getBlobPublicAccess(), publicAccess); - } - - @Test - public void setAccessPolicyIds() { - BlobSignedIdentifier identifier = new BlobSignedIdentifier().setId("0000") - .setAccessPolicy(new BlobAccessPolicy().setStartsOn(testResourceNamer.now()) - .setExpiresOn(testResourceNamer.now().plusDays(1)) - .setPermissions("r")); - BlobSignedIdentifier identifier2 = new BlobSignedIdentifier().setId("0001") - .setAccessPolicy(new BlobAccessPolicy().setStartsOn(testResourceNamer.now()) - .setExpiresOn(testResourceNamer.now().plusDays(2)) - .setPermissions("w")); - List ids = Arrays.asList(identifier, identifier2); - - Response response = cc.setAccessPolicyWithResponse(null, ids, null, null, null); - - List receivedIdentifiers - = cc.getAccessPolicyWithResponse(null, null, null).getValue().getIdentifiers(); - - assertResponseStatusCode(response, 200); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertEquals(receivedIdentifiers.get(0).getAccessPolicy().getExpiresOn(), - identifier.getAccessPolicy().getExpiresOn()); - assertEquals(receivedIdentifiers.get(0).getAccessPolicy().getStartsOn(), - identifier.getAccessPolicy().getStartsOn()); - assertEquals(receivedIdentifiers.get(0).getAccessPolicy().getPermissions(), - identifier.getAccessPolicy().getPermissions()); - assertEquals(receivedIdentifiers.get(1).getAccessPolicy().getExpiresOn(), - identifier2.getAccessPolicy().getExpiresOn()); - assertEquals(receivedIdentifiers.get(1).getAccessPolicy().getStartsOn(), - identifier2.getAccessPolicy().getStartsOn()); - assertEquals(receivedIdentifiers.get(1).getAccessPolicy().getPermissions(), - identifier2.getAccessPolicy().getPermissions()); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACSupplier") - public void setAccessPolicyAC(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - leaseID = setupContainerLeaseCondition(cc, leaseID); - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - assertResponseStatusCode(cc.setAccessPolicyWithResponse(null, null, cac, null, null), 200); - } - - private static Stream setAccessPolicyACSupplier() { - return Stream.of(Arguments.of(null, null, null), Arguments.of(OLD_DATE, null, null), - Arguments.of(null, NEW_DATE, null), Arguments.of(null, null, RECEIVED_LEASE_ID)); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACFailSupplier") - public void setAccessPolicyACFail(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - assertThrows(BlobStorageException.class, () -> cc.setAccessPolicyWithResponse(null, null, cac, null, null)); - } - - private static Stream setAccessPolicyACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null), Arguments.of(null, OLD_DATE, null), - Arguments.of(null, null, GARBAGE_LEASE_ID)); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACIllegalSupplier") - public void setAccessPolicyACIllegal(String match, String noneMatch) { - BlobRequestConditions mac = new BlobRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - assertThrows(UnsupportedOperationException.class, - () -> cc.setAccessPolicyWithResponse(null, null, mac, null, null)); - } - - private static Stream setAccessPolicyACIllegalSupplier() { - return Stream.of(Arguments.of(RECEIVED_ETAG, null), Arguments.of(null, GARBAGE_ETAG)); - } - - @Test - public void getAccessPolicyLease() { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - assertResponseStatusCode(cc.getAccessPolicyWithResponse(leaseID, null, null), 200); - } - - @Test - public void getAccessPolicyLeaseFail() { - assertThrows(BlobStorageException.class, () -> cc.getAccessPolicyWithResponse(GARBAGE_LEASE_ID, null, null)); - } - - @Test - public void getAccessPolicyError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> cc.getAccessPolicy()); - } - - @Test - public void delete() { - Response response = cc.deleteWithResponse(null, null, null); - assertResponseStatusCode(response, 202); - - assertNotNull(response.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(response.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(response.getHeaders().getValue(HttpHeaderName.DATE)); - } - - @Test - public void deleteMin() { - cc.delete(); - assertFalse(cc.exists()); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACSupplier") - public void deleteAC(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - leaseID = setupContainerLeaseCondition(cc, leaseID); - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - assertResponseStatusCode(cc.deleteWithResponse(cac, null, null), 202); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACFailSupplier") - public void deleteACFail(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - assertThrows(BlobStorageException.class, () -> cc.deleteWithResponse(cac, null, null)); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACIllegalSupplier") - public void deleteACIllegal(String match, String noneMatch) { - BlobRequestConditions mac = new BlobRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - assertThrows(UnsupportedOperationException.class, () -> cc.deleteWithResponse(mac, null, null)); - } - - @Test - public void deleteError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> cc.delete()); - } - - @Test - public void deleteIfExists() { - Response response = cc.deleteIfExistsWithResponse(null, null, null); - - assertTrue(response.getValue()); - assertResponseStatusCode(response, 202); - assertNotNull(response.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(response.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(response.getHeaders().getValue(HttpHeaderName.DATE)); - } - - @Test - public void deleteIfExistsMin() { - boolean result = cc.deleteIfExists(); - - assertTrue(result); - assertFalse(cc.exists()); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACSupplier") - public void deleteIfExistsAC(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - leaseID = setupContainerLeaseCondition(cc, leaseID); - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - assertResponseStatusCode(cc.deleteIfExistsWithResponse(cac, null, null), 202); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACFailSupplier") - public void deleteIfExistsACFail(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - assertThrows(BlobStorageException.class, () -> cc.deleteIfExistsWithResponse(cac, null, null)); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACIllegalSupplier") - public void deleteIfExistsACIllegal(String match, String noneMatch) { - BlobRequestConditions mac = new BlobRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - assertThrows(UnsupportedOperationException.class, () -> cc.deleteIfExistsWithResponse(mac, null, null)); - } - - @Test - public void deleteIfExistsOnAContainerThatDoesNotExist() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - - Response response = cc.deleteIfExistsWithResponse(new BlobRequestConditions(), null, null); - - assertFalse(response.getValue()); - assertResponseStatusCode(response, 404); - } - - // We can't guarantee that the requests will always happen before the container is garbage collected - @PlaybackOnly - @Test - public void deleteIfExistsContainerThatWasAlreadyDeleted() { - boolean result = cc.deleteIfExists(); - boolean result2 = cc.deleteIfExists(); - - assertTrue(result); - // Confirming the behavior of the api when the container is in the deleting state. - // After deletehas been called once but before it has been garbage collected - assertTrue(result2); - assertFalse(cc.exists()); - } - - @Test - public void listBlockBlobsFlat() { - String name = generateBlobName(); - BlockBlobClient bu = cc.getBlobClient(name).getBlockBlobClient(); - bu.upload(DATA.getDefaultInputStream(), 7); - - Iterator blobs = cc.listBlobs(new ListBlobsOptions().setPrefix(prefix), null).iterator(); - - BlobItem blob = blobs.next(); - assertFalse(blobs.hasNext()); - assertEquals(name, blob.getName()); - assertEquals(BlobType.BLOCK_BLOB, blob.getProperties().getBlobType()); - assertNull(blob.getProperties().getCopyCompletionTime()); - assertNull(blob.getProperties().getCopyStatusDescription()); - assertNull(blob.getProperties().getCopyId()); - assertNull(blob.getProperties().getCopyProgress()); - assertNull(blob.getProperties().getCopySource()); - assertNull(blob.getProperties().getCopyStatus()); - assertNull(blob.getProperties().isIncrementalCopy()); - assertNull(blob.getProperties().getDestinationSnapshot()); - assertNull(blob.getProperties().getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, blob.getProperties().getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, blob.getProperties().getLeaseStatus()); - assertNotNull(blob.getProperties().getContentLength()); - assertNotNull(blob.getProperties().getContentType()); - assertNotNull(blob.getProperties().getContentMd5()); - assertNull(blob.getProperties().getContentEncoding()); - assertNull(blob.getProperties().getContentDisposition()); - assertNull(blob.getProperties().getContentLanguage()); - assertNull(blob.getProperties().getCacheControl()); - assertNull(blob.getProperties().getBlobSequenceNumber()); - assertTrue(blob.getProperties().isServerEncrypted()); - assertTrue(blob.getProperties().isAccessTierInferred()); - assertEquals(AccessTier.HOT, blob.getProperties().getAccessTier()); - assertNull(blob.getProperties().getArchiveStatus()); - assertNotNull(blob.getProperties().getCreationTime()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listAppendBlobsFlat() { - String name = generateBlobName(); - AppendBlobClient bu = cc.getBlobClient(name).getAppendBlobClient(); - bu.create(); - bu.seal(); - - Iterator blobs = cc.listBlobs(new ListBlobsOptions().setPrefix(prefix), null).iterator(); - - BlobItem blob = blobs.next(); - assertFalse(blobs.hasNext()); - assertEquals(name, blob.getName()); - assertEquals(BlobType.APPEND_BLOB, blob.getProperties().getBlobType()); - assertNull(blob.getProperties().getCopyCompletionTime()); - assertNull(blob.getProperties().getCopyStatusDescription()); - assertNull(blob.getProperties().getCopyId()); - assertNull(blob.getProperties().getCopyProgress()); - assertNull(blob.getProperties().getCopySource()); - assertNull(blob.getProperties().getCopyStatus()); - assertNull(blob.getProperties().isIncrementalCopy()); - assertNull(blob.getProperties().getDestinationSnapshot()); - assertNull(blob.getProperties().getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, blob.getProperties().getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, blob.getProperties().getLeaseStatus()); - assertNotNull(blob.getProperties().getContentLength()); - assertNotNull(blob.getProperties().getContentType()); - assertNull(blob.getProperties().getContentMd5()); - assertNull(blob.getProperties().getContentEncoding()); - assertNull(blob.getProperties().getContentDisposition()); - assertNull(blob.getProperties().getContentLanguage()); - assertNull(blob.getProperties().getCacheControl()); - assertNull(blob.getProperties().getBlobSequenceNumber()); - assertTrue(blob.getProperties().isServerEncrypted()); - assertNull(blob.getProperties().isAccessTierInferred()); - assertNull(blob.getProperties().getAccessTier()); - assertNull(blob.getProperties().getArchiveStatus()); - assertNotNull(blob.getProperties().getCreationTime()); - assertTrue(blob.getProperties().isSealed()); - } - - @Test - public void listPageBlobsFlat() { - ccPremium = premiumBlobServiceClient.getBlobContainerClient(containerName); - ccPremium.createIfNotExists(); - String name = generateBlobName(); - PageBlobClient bu = ccPremium.getBlobClient(name).getPageBlobClient(); - bu.create(512); - - Iterator blobs = ccPremium.listBlobs(new ListBlobsOptions().setPrefix(prefix), null).iterator(); - BlobItem blob = blobs.next(); - assertFalse(blobs.hasNext()); - assertEquals(name, blob.getName()); - assertEquals(BlobType.PAGE_BLOB, blob.getProperties().getBlobType()); - assertNull(blob.getProperties().getCopyCompletionTime()); - assertNull(blob.getProperties().getCopyStatusDescription()); - assertNull(blob.getProperties().getCopyId()); - assertNull(blob.getProperties().getCopyProgress()); - assertNull(blob.getProperties().getCopySource()); - assertNull(blob.getProperties().getCopyStatus()); - assertNull(blob.getProperties().isIncrementalCopy()); - assertNull(blob.getProperties().getDestinationSnapshot()); - assertNull(blob.getProperties().getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, blob.getProperties().getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, blob.getProperties().getLeaseStatus()); - assertNotNull(blob.getProperties().getContentLength()); - assertNotNull(blob.getProperties().getContentType()); - assertNull(blob.getProperties().getContentMd5()); - assertNull(blob.getProperties().getContentEncoding()); - assertNull(blob.getProperties().getContentDisposition()); - assertNull(blob.getProperties().getContentLanguage()); - assertNull(blob.getProperties().getCacheControl()); - assertEquals(0, blob.getProperties().getBlobSequenceNumber()); - assertTrue(blob.getProperties().isServerEncrypted()); - assertTrue(blob.getProperties().isAccessTierInferred()); - assertEquals(AccessTier.P10, blob.getProperties().getAccessTier()); - assertNull(blob.getProperties().getArchiveStatus()); - assertNotNull(blob.getProperties().getCreationTime()); - - // cleanup: - ccPremium.delete(); - } - - @Test - public void listBlobsFlatMin() { - assertDoesNotThrow(() -> cc.listBlobs().iterator().hasNext()); - } - - private String setupListBlobsTest(String normalName, String copyName, String metadataName, String tagsName, - String uncommittedName) { - PageBlobClient normal = cc.getBlobClient(normalName).getPageBlobClient(); - normal.create(512); - - PageBlobClient copyBlob = cc.getBlobClient(copyName).getPageBlobClient(); - setPlaybackSyncPollerPollInterval(copyBlob.beginCopy(normal.getBlobUrl(), null)).waitForCompletion(); - - PageBlobClient metadataBlob = cc.getBlobClient(metadataName).getPageBlobClient(); - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - metadataBlob.createWithResponse(512, null, null, metadata, null, null, null); - - PageBlobClient tagsBlob = cc.getBlobClient(tagsName).getPageBlobClient(); - Map tags = new HashMap<>(); - tags.put(tagKey, tagValue); - tagsBlob.createWithResponse(new PageBlobCreateOptions(512).setTags(tags), null, null); - - BlockBlobClient uncommittedBlob = cc.getBlobClient(uncommittedName).getBlockBlobClient(); - uncommittedBlob.stageBlock(getBlockID(), DATA.getDefaultInputStream(), DATA.getDefaultData().remaining()); - - return normal.createSnapshot().getSnapshotId(); - } - - @Test - public void listBlobsFlatOptionsCopy() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveCopy(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - List blobs = cc.listBlobs(options, null).stream().collect(Collectors.toList()); - - assertEquals(normalName, blobs.get(0).getName()); - assertEquals(copyName, blobs.get(1).getName()); - assertNotNull(blobs.get(1).getProperties().getCopyId()); - // Comparing the urls isn't reliable because the service may use https. - assertTrue(blobs.get(1).getProperties().getCopySource().contains(normalName)); - // We waited for the copy to complete. - assertEquals(CopyStatusType.SUCCESS, blobs.get(1).getProperties().getCopyStatus()); - assertNotNull(blobs.get(1).getProperties().getCopyProgress()); - assertNotNull(blobs.get(1).getProperties().getCopyCompletionTime()); - assertEquals(4, blobs.size()); // Normal, copy, metadata, tags - } - - @Test - public void listBlobsFlatOptionsMetadata() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveMetadata(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - List blobs = cc.listBlobs(options, null).stream().collect(Collectors.toList()); - - assertEquals(normalName, blobs.get(0).getName()); - assertEquals(copyName, blobs.get(1).getName()); - assertNull(blobs.get(1).getProperties().getCopyCompletionTime()); - assertEquals(metadataName, blobs.get(2).getName()); - assertEquals("bar", blobs.get(2).getMetadata().get("foo")); - assertEquals(4, blobs.size()); // Normal, copy, metadata, tags - } - - @PlaybackOnly - @Test - public void listBlobsFlatOptionsLastAccessTime() { - BlockBlobClient b = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - b.upload(DATA.getDefaultInputStream(), DATA.getDefaultData().remaining()); - BlobItem blob = cc.listBlobs().iterator().next(); - - assertNotNull(blob.getProperties().getLastAccessedTime()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listBlobsFlatOptionsTags() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveTags(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - List blobs = cc.listBlobs(options, null).stream().collect(Collectors.toList()); - - assertEquals(normalName, blobs.get(0).getName()); - assertEquals(copyName, blobs.get(1).getName()); - assertNull(blobs.get(1).getProperties().getCopyCompletionTime()); - assertEquals(metadataName, blobs.get(2).getName()); - assertNull(blobs.get(2).getMetadata()); - assertEquals(tagValue, blobs.get(3).getTags().get(tagKey)); - assertEquals(1, blobs.get(3).getProperties().getTagCount()); - assertEquals(4, blobs.size()); // Normal, copy, metadata, tags - } - - @Test - public void listBlobsFlatOptionsSnapshots() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveSnapshots(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - String snapshotTime = setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - List blobs = cc.listBlobs(options, null).stream().collect(Collectors.toList()); - - assertEquals(normalName, blobs.get(0).getName()); - assertEquals(snapshotTime, blobs.get(0).getSnapshot()); - assertEquals(normalName, blobs.get(1).getName()); - assertEquals(5, blobs.size()); // Normal, snapshot, copy, metadata, tags - } - - @Test - public void listBlobsFlatOptionsUncommitted() { - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveUncommittedBlobs(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - List blobs = cc.listBlobs(options, null).stream().collect(Collectors.toList()); - - assertEquals(normalName, blobs.get(0).getName()); - assertEquals(uncommittedName, blobs.get(4).getName()); - assertEquals(5, blobs.size()); // Normal, copy, metadata, tags, uncommitted - } - - @Test - public void listBlobsFlatOptionsPrefix() { - ListBlobsOptions options = new ListBlobsOptions().setPrefix("a"); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - Iterator blobs = cc.listBlobs(options, null).iterator(); - - assertEquals(normalName, blobs.next().getName()); - assertFalse(blobs.hasNext()); // Normal - } - - @Test - public void listBlobsFlatOptionsMaxResults() { - int pageSize = 2; - ListBlobsOptions options = new ListBlobsOptions().setDetails( - new BlobListDetails().setRetrieveCopy(true).setRetrieveSnapshots(true).setRetrieveUncommittedBlobs(true)) - .setMaxResultsPerPage(pageSize); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - // expect: "Get first page of blob listings (sync and async)" - assertEquals(pageSize, cc.listBlobs(options, null).iterableByPage().iterator().next().getValue().size()); - } - - @Test - public void listBlobsFlatOptionsMaxResultsByPage() { - int pageSize = 2; - ListBlobsOptions options = new ListBlobsOptions().setDetails( - new BlobListDetails().setRetrieveCopy(true).setRetrieveSnapshots(true).setRetrieveUncommittedBlobs(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - // expect: "Get first page of blob listings (sync and async)" - for (PagedResponse page : cc.listBlobs(options, null).iterableByPage(pageSize)) { - assertTrue(page.getValue().size() <= pageSize); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void listBlobsFlatOptionsDeletedWithVersions() { - BlobContainerClient versionedCC = versionedBlobServiceClient.getBlobContainerClient(containerName); - versionedCC.createIfNotExists(); - String blobName = generateBlobName(); - AppendBlobClient blob = versionedCC.getBlobClient(blobName).getAppendBlobClient(); - blob.create(); - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - blob.setMetadata(metadata); - blob.delete(); - ListBlobsOptions options = new ListBlobsOptions().setPrefix(blobName) - .setDetails(new BlobListDetails().setRetrieveDeletedBlobsWithVersions(true)); - - Iterator blobs = versionedCC.listBlobs(options, null).iterator(); - - BlobItem b = blobs.next(); - assertFalse(blobs.hasNext()); - assertEquals(blobName, b.getName()); - assertTrue(b.hasVersionsOnly()); - - // cleanup: - versionedCC.delete(); - } - - @Test - public void listBlobsPrefixWithComma() { - String prefix = generateBlobName() + ", " + generateBlobName(); - BlockBlobClient b = cc.getBlobClient(prefix).getBlockBlobClient(); - b.upload(DATA.getDefaultInputStream(), DATA.getDefaultData().remaining()); - - ListBlobsOptions options = new ListBlobsOptions().setPrefix(prefix); - BlobItem blob = cc.listBlobs(options, null).iterator().next(); - assertEquals(prefix, blob.getName()); - } - - @Test - public void listBlobsFlatOptionsFail() { - assertThrows(IllegalArgumentException.class, () -> new ListBlobsOptions().setMaxResultsPerPage(0)); - } - - @Test - public void listBlobsFlatMarker() { - int numBlobs = 10; - int pageSize = 6; - for (int i = 0; i < numBlobs; i++) { - PageBlobClient bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - bc.create(512); - } - - // when: "listBlobs with sync client" - PagedIterable pagedIterable - = cc.listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageSize), null); - PagedResponse pagedSyncResponse1 = pagedIterable.iterableByPage().iterator().next(); - PagedResponse pagedSyncResponse2 - = pagedIterable.iterableByPage(pagedSyncResponse1.getContinuationToken()).iterator().next(); - - assertEquals(pageSize, pagedSyncResponse1.getValue().size()); - assertEquals(numBlobs - pageSize, pagedSyncResponse2.getValue().size()); - assertNull(pagedSyncResponse2.getContinuationToken()); - } - - @Test - public void listBlobsFlatMarkerOverload() { - int numBlobs = 10; - int pageSize = 6; - for (int i = 0; i < numBlobs; i++) { - PageBlobClient bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - bc.create(512); - } - - // when: "listBlobs with sync client" - PagedIterable pagedIterable - = cc.listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageSize), null); - PagedResponse pagedSyncResponse1 = pagedIterable.iterableByPage().iterator().next(); - - pagedIterable = cc.listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageSize), - pagedSyncResponse1.getContinuationToken(), null); - PagedResponse pagedSyncResponse2 = pagedIterable.iterableByPage().iterator().next(); - - assertEquals(pageSize, pagedSyncResponse1.getValue().size()); - assertEquals(numBlobs - pageSize, pagedSyncResponse2.getValue().size()); - assertNull(pagedSyncResponse2.getContinuationToken()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("listBlobsFlatRehydratePrioritySupplier") - public void listBlobsFlatRehydratePriority(RehydratePriority rehydratePriority) { - String name = generateBlobName(); - BlockBlobClient bc = cc.getBlobClient(name).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), 7); - - if (rehydratePriority != null) { - bc.setAccessTier(AccessTier.ARCHIVE); - bc.setAccessTierWithResponse(new BlobSetAccessTierOptions(AccessTier.HOT).setPriority(rehydratePriority), - null, null); - } - BlobItem item = cc.listBlobs().iterator().next(); - assertEquals(rehydratePriority, item.getProperties().getRehydratePriority()); - } - - private static Stream listBlobsFlatRehydratePrioritySupplier() { - return Stream.of(Arguments.of((RehydratePriority) null), Arguments.of(RehydratePriority.STANDARD), - Arguments.of(RehydratePriority.HIGH)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-02-12") - @Test - public void listBlobsFlatInvalidXml() { - String blobName = "dir1/dir2/file\uFFFE.blob"; - cc.getBlobClient(blobName).getAppendBlobClient().create(); - - BlobItem blobItem = cc.listBlobs().iterator().next(); - assertEquals(blobName, blobItem.getName()); - } - - @Test - public void listBlobsFlatError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> cc.listBlobs().iterator().hasNext()); - } - - @Test - public void listBlobsFlatWithTimeoutStillBackedByPagedStream() { - int numBlobs = 5; - int pageResults = 3; - - for (int i = 0; i < numBlobs; i++) { - BlockBlobClient blob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - blob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - } - - // when: "Consume results by page, then still have paging functionality" - assertDoesNotThrow( - () -> cc.listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageResults), Duration.ofSeconds(10)) - .streamByPage() - .count()); - } - - @Test - public void listBlobsHierWithTimeoutStillBackedByPagedStream() { - int numBlobs = 5; - int pageResults = 3; - - for (int i = 0; i < numBlobs; i++) { - BlockBlobClient blob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - blob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - } - - // when: "Consume results by page, then still have paging functionality" - assertDoesNotThrow(() -> cc - .listBlobsByHierarchy("/", new ListBlobsOptions().setMaxResultsPerPage(pageResults), Duration.ofSeconds(10)) - .streamByPage() - .count()); - } - - /* - This test requires two accounts that are configured in a very specific way. It is not feasible to setup that - relationship programmatically, so we have recorded a successful interaction and only test recordings. - */ - - //@EnabledIf("com.azure.storage.blob.BlobTestBase#isPlaybackMode") - @Disabled("Need to re-record once account is setup properly.") - @Test - public void listBlobsFlatORS() { - BlobContainerClient sourceContainer = primaryBlobServiceClient.getBlobContainerClient("test1"); - BlobContainerClient destContainer = alternateBlobServiceClient.getBlobContainerClient("test2"); - - List sourceBlobs = sourceContainer.listBlobs().stream().collect(Collectors.toList()); - List destBlobs = destContainer.listBlobs().stream().collect(Collectors.toList()); - - int i = 0; - for (BlobItem blob : sourceBlobs) { - if (i == 1) { - assertNull(blob.getObjectReplicationSourcePolicies()); - } else { - assertTrue(validateOR(blob.getObjectReplicationSourcePolicies())); - } - i++; - } - - /* Service specifies no ors metadata on the dest blobs. */ - for (BlobItem blob : destBlobs) { - assertNull(blob.getObjectReplicationSourcePolicies()); - } - } - - private boolean validateOR(List policies) { - return policies.stream() - .filter(policy -> "fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80".equals(policy.getPolicyId())) - .findFirst() - .get() - .getRules() - .stream() - .filter(rule -> "105f9aad-f39b-4064-8e47-ccd7937295ca".equals(rule.getRuleId())) - .findFirst() - .get() - .getStatus() == ObjectReplicationStatus.COMPLETE; - } - - @Test - public void listBlobsHierarchy() { - String name = generateBlobName(); - PageBlobClient bu = cc.getBlobClient(name).getPageBlobClient(); - bu.create(512); - - Iterator blobs = cc.listBlobsByHierarchy(null).iterator(); - assertEquals(name, blobs.next().getName()); - assertFalse(blobs.hasNext()); - } - - @Test - public void listBlobsHierarchyMin() { - assertDoesNotThrow(() -> cc.listBlobsByHierarchy("/").iterator().hasNext()); - } - - @Test - public void listBlobsHierOptionsCopy() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveCopy(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - List blobs = cc.listBlobsByHierarchy("", options, null).stream().collect(Collectors.toList()); - - assertEquals(normalName, blobs.get(0).getName()); - assertEquals(copyName, blobs.get(1).getName()); - assertNotNull(blobs.get(1).getProperties().getCopyId()); - // Comparing the urls isn't reliable because the service may use https. - assertTrue(blobs.get(1).getProperties().getCopySource().contains(normalName)); - assertEquals(CopyStatusType.SUCCESS, blobs.get(1).getProperties().getCopyStatus()); // We waited for the copy to complete. - assertNotNull(blobs.get(1).getProperties().getCopyProgress()); - assertNotNull(blobs.get(1).getProperties().getCopyCompletionTime()); - assertEquals(4, blobs.size()); // Normal, copy, metadata, tags - } - - @Test - public void listBlobsHierOptionsMetadata() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveMetadata(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - List blobs = cc.listBlobsByHierarchy("", options, null).stream().collect(Collectors.toList()); - - assertEquals(normalName, blobs.get(0).getName()); - assertEquals(copyName, blobs.get(1).getName()); - assertNull(blobs.get(1).getProperties().getCopyCompletionTime()); - assertEquals(metadataName, blobs.get(2).getName()); - assertEquals("bar", blobs.get(2).getMetadata().get("foo")); - assertEquals(4, blobs.size()); // Normal, copy, metadata, tags - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listBlobsHierOptionsTags() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveTags(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - List blobs = cc.listBlobsByHierarchy("", options, null).stream().collect(Collectors.toList()); - - assertEquals(normalName, blobs.get(0).getName()); - assertEquals(copyName, blobs.get(1).getName()); - assertNull(blobs.get(1).getProperties().getCopyCompletionTime()); - assertEquals(metadataName, blobs.get(2).getName()); - assertNull(blobs.get(2).getMetadata()); - assertEquals(tagValue, blobs.get(3).getTags().get(tagKey)); - assertEquals(1, blobs.get(3).getProperties().getTagCount()); - assertEquals(4, blobs.size()); // Normal, copy, metadata, tags - } - - @Test - public void listBlobsHierOptionsUncommitted() { - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveUncommittedBlobs(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - List blobs = cc.listBlobsByHierarchy("", options, null).stream().collect(Collectors.toList()); - - assertEquals(normalName, blobs.get(0).getName()); - assertEquals(uncommittedName, blobs.get(4).getName()); - assertEquals(5, blobs.size()); // Normal, copy, metadata, tags, uncommitted - } - - @Test - public void listBlobsHierOptionsprefix() { - ListBlobsOptions options = new ListBlobsOptions().setPrefix("a"); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - Iterator blobs = cc.listBlobsByHierarchy("", options, null).iterator(); - - assertEquals(normalName, blobs.next().getName()); - assertFalse(blobs.hasNext()); // Normal - } - - @Test - public void listBlobsHierOptionsMaxResultsByPage() { - ListBlobsOptions options = new ListBlobsOptions() - .setDetails(new BlobListDetails().setRetrieveCopy(true).setRetrieveUncommittedBlobs(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName); - - PagedIterable pagedIterable = cc.listBlobsByHierarchy("", options, null); - - Iterable> iterableByPage = pagedIterable.iterableByPage(1); - for (PagedResponse page : iterableByPage) { - assertEquals(1, page.getValue().size()); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void listBlobsHierOptionsDeletedWithVersions() { - BlobContainerClient versionedCC = versionedBlobServiceClient.getBlobContainerClient(containerName); - versionedCC.createIfNotExists(); - String blobName = generateBlobName(); - AppendBlobClient blob = versionedCC.getBlobClient(blobName).getAppendBlobClient(); - blob.create(); - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - blob.setMetadata(metadata); - blob.delete(); - ListBlobsOptions options = new ListBlobsOptions().setPrefix(blobName) - .setDetails(new BlobListDetails().setRetrieveDeletedBlobsWithVersions(true)); - - Iterator blobs = versionedCC.listBlobsByHierarchy("", options, null).iterator(); - - BlobItem b = blobs.next(); - assertFalse(blobs.hasNext()); - assertEquals(blobName, b.getName()); - assertTrue(b.hasVersionsOnly()); - - // cleanup: - versionedCC.delete(); - } - - @ParameterizedTest - @MethodSource("listBlobsHierOptionsFailSupplier") - public void listBlobsHierOptionsFail(boolean snapshots, int maxResults, Class exceptionType) { - assertThrows(exceptionType, () -> { - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveSnapshots(snapshots)) - .setMaxResultsPerPage(maxResults); - cc.listBlobsByHierarchy(null, options, null).iterator().hasNext(); - }); - } - - private static Stream listBlobsHierOptionsFailSupplier() { - return Stream.of(Arguments.of(true, 5, UnsupportedOperationException.class), - Arguments.of(false, 0, IllegalArgumentException.class)); - } - - @Test - public void listBlobsHierDelim() { - List blobNames = Arrays.asList("a", "b/a", "c", "d/a", "e", "f", "g/a"); - for (String blobName : blobNames) { - AppendBlobClient bu = cc.getBlobClient(blobName).getAppendBlobClient(); - bu.create(); - } - - Set foundBlobs = new HashSet<>(); - Set foundPrefixes = new HashSet<>(); - cc.listBlobsByHierarchy(null).stream().collect(Collectors.toList()).forEach(blobItem -> { - if (blobItem.isPrefix()) { - foundPrefixes.add(blobItem.getName()); - } else { - foundBlobs.add(blobItem.getName()); - } - }); - - List expectedBlobs = Arrays.asList("a", "c", "e", "f"); - List expectedPrefixes = Arrays.asList("b/", "d/", "g/"); - - for (String blobName : expectedBlobs) { - assertTrue(foundBlobs.contains(blobName)); - } - - for (String prefix : expectedPrefixes) { - assertTrue(foundPrefixes.contains(prefix)); - } - } - - @Test - public void listBlobsHierMarker() { - int numBlobs = 10; - int pageSize = 6; - for (int i = 0; i < numBlobs; i++) { - PageBlobClient bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - bc.create(512); - } - - PagedIterable blobs - = cc.listBlobsByHierarchy("/", new ListBlobsOptions().setMaxResultsPerPage(pageSize), null); - - PagedResponse firstPage = blobs.iterableByPage().iterator().next(); - - assertEquals(pageSize, firstPage.getValue().size()); - assertNotNull(firstPage.getContinuationToken()); - - PagedResponse secondPage = blobs.iterableByPage(firstPage.getContinuationToken()).iterator().next(); - - assertEquals(secondPage.getValue().size(), numBlobs - pageSize); - assertNull(secondPage.getContinuationToken()); - } - - /* - This test requires two accounts that are configured in a very specific way. It is not feasible to setup that - relationship programmatically, so we have recorded a successful interaction and only test recordings. - */ - - @PlaybackOnly - @Test - public void listBlobsHierORS() { - BlobContainerClient sourceContainer = primaryBlobServiceClient.getBlobContainerClient("test1"); - BlobContainerClient destContainer = alternateBlobServiceClient.getBlobContainerClient("test2"); - - List sourceBlobs = sourceContainer.listBlobsByHierarchy("/").stream().collect(Collectors.toList()); - List destBlobs = destContainer.listBlobsByHierarchy("/").stream().collect(Collectors.toList()); - - int i = 0; - for (BlobItem blob : sourceBlobs) { - if (i == 1) { - assertNull(blob.getObjectReplicationSourcePolicies()); - } else { - assertTrue(validateOR(blob.getObjectReplicationSourcePolicies())); - } - i++; - } - - /* Service specifies no ors metadata on the dest blobs. */ - for (BlobItem blob : destBlobs) { - assertNull(blob.getObjectReplicationSourcePolicies()); - } - } - - @Test - public void listBlobsFlatSimple() { - // setup: "Create 10 page blobs in the container" - int numBlobs = 10; - int pageSize = 3; - for (int i = 0; i < numBlobs; i++) { - PageBlobClient bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - bc.create(512); - } - - // expect: "listing operation will fetch all 10 blobs, despite page size being smaller than 10" - assertEquals(numBlobs, - cc.listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageSize), null).stream().count()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("listBlobsFlatRehydratePrioritySupplier") - public void listBlobsHierRehydratePriority(RehydratePriority rehydratePriority) { - String name = generateBlobName(); - BlockBlobClient bc = cc.getBlobClient(name).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), 7); - - if (rehydratePriority != null) { - bc.setAccessTier(AccessTier.ARCHIVE); - bc.setAccessTierWithResponse(new BlobSetAccessTierOptions(AccessTier.HOT).setPriority(rehydratePriority), - null, null); - } - - BlobItem item = cc.listBlobsByHierarchy(null).iterator().next(); - assertEquals(rehydratePriority, item.getProperties().getRehydratePriority()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listAppendBlobsHier() { - String name = generateBlobName(); - AppendBlobClient bu = cc.getBlobClient(name).getAppendBlobClient(); - bu.create(); - bu.seal(); - - Iterator blobs - = cc.listBlobsByHierarchy(null, new ListBlobsOptions().setPrefix(prefix), null).iterator(); - - BlobItem blob = blobs.next(); - assertFalse(blobs.hasNext()); - assertEquals(name, blob.getName()); - assertEquals(BlobType.APPEND_BLOB, blob.getProperties().getBlobType()); - assertNull(blob.getProperties().getCopyCompletionTime()); - assertNull(blob.getProperties().getCopyStatusDescription()); - assertNull(blob.getProperties().getCopyId()); - assertNull(blob.getProperties().getCopyProgress()); - assertNull(blob.getProperties().getCopySource()); - assertNull(blob.getProperties().getCopyStatus()); - assertNull(blob.getProperties().isIncrementalCopy()); - assertNull(blob.getProperties().getDestinationSnapshot()); - assertNull(blob.getProperties().getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, blob.getProperties().getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, blob.getProperties().getLeaseStatus()); - assertNotNull(blob.getProperties().getContentLength()); - assertNotNull(blob.getProperties().getContentType()); - assertNull(blob.getProperties().getContentMd5()); - assertNull(blob.getProperties().getContentEncoding()); - assertNull(blob.getProperties().getContentDisposition()); - assertNull(blob.getProperties().getContentLanguage()); - assertNull(blob.getProperties().getCacheControl()); - assertNull(blob.getProperties().getBlobSequenceNumber()); - assertTrue(blob.getProperties().isServerEncrypted()); - assertNull(blob.getProperties().isAccessTierInferred()); - assertNull(blob.getProperties().getAccessTier()); - assertNull(blob.getProperties().getArchiveStatus()); - assertNotNull(blob.getProperties().getCreationTime()); - assertTrue(blob.getProperties().isSealed()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-02-12") - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void listBlobsHierInvalidXml(boolean delimiter) { - String blobName = "dir1/dir2/file\uFFFE.blob"; - cc.getBlobClient(blobName).getAppendBlobClient().create(); - - BlobItem blobItem; - if (!delimiter) { - blobItem = cc.listBlobsByHierarchy("", null, null).iterator().next(); - } else { - blobItem = cc.listBlobsByHierarchy(".b", null, null).iterator().next(); - } - - assertEquals(blobItem.getName(), (delimiter ? "dir1/dir2/file\uFFFE.b" : blobName)); - assertEquals(delimiter, blobItem.isPrefix()); - } - - @Test - public void listBlobsHierError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> cc.listBlobsByHierarchy(".").iterator().hasNext()); - } - - private void setupContainerForListing(BlobContainerClient containerClient) { - List blobNames - = Arrays.asList("foo", "bar", "baz", "foo/foo", "foo/bar", "baz/foo", "baz/foo/bar", "baz/bar/foo"); - byte[] data = getRandomByteArray(Constants.KB); - - for (String blob : blobNames) { - BlockBlobClient blockBlobClient = containerClient.getBlobClient(blob).getBlockBlobClient(); - blockBlobClient.upload(new ByteArrayInputStream(data), Constants.KB); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void listBlobsHierSegmentWithVersionPrefixAndDelimiter() { - BlobContainerClient versionedCC = versionedBlobServiceClient.getBlobContainerClient(containerName); - versionedCC.createIfNotExists(); - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveVersions(true)).setPrefix("baz"); - - setupContainerForListing(versionedCC); - - Set foundBlobs = new HashSet<>(); - Set foundPrefixes = new HashSet<>(); - - versionedCC.listBlobsByHierarchy("/", options, null).stream().collect(Collectors.toList()).forEach(blobItem -> { - if (blobItem.isPrefix()) { - foundPrefixes.add(blobItem); - } else { - foundBlobs.add(blobItem); - } - }); - - assertEquals(1, foundBlobs.size()); - assertEquals(1, foundPrefixes.size()); - BlobItem first = foundBlobs.iterator().next(); - assertEquals("baz", first.getName()); - assertNotNull(first.getVersionId()); - assertEquals("baz/", foundPrefixes.iterator().next().getName()); - - // cleanup: - versionedCC.delete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsMin() { - assertDoesNotThrow(() -> cc.findBlobsByTags("\"key\"='value'").iterator().hasNext()); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsQuery() { - BlobClient blobClient = cc.getBlobClient(generateBlobName()); - blobClient - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(Collections.singletonMap("key", "value")), null, null); - blobClient = cc.getBlobClient(generateBlobName()); - blobClient - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(Collections.singletonMap("bar", "foo")), null, null); - blobClient = cc.getBlobClient(generateBlobName()); - blobClient.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - sleepIfRunningAgainstService(10 * 1000); // To allow tags to index - - String query = "\"bar\"='foo'"; - PagedIterable results = cc.findBlobsByTags(String.format(query, cc.getBlobContainerName())); - - assertEquals(1, results.stream().count()); - TaggedBlobItem tags = results.iterator().next(); - Map blobTags = tags.getTags(); - assertEquals(1, blobTags.size()); - assertEquals("foo", blobTags.get("bar")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsMarker() { - Map tags = Collections.singletonMap(tagKey, tagValue); - for (int i = 0; i < 10; i++) { - cc.getBlobClient(generateBlobName()) - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()).setTags(tags), null, - null); - } - - sleepIfRunningAgainstService(10 * 1000); // To allow tags to index - - PagedResponse firstPage = cc.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(5), null, - Context.NONE).iterableByPage().iterator().next(); - String marker = firstPage.getContinuationToken(); - String firstBlobName = firstPage.getValue().iterator().next().getName(); - - PagedResponse secondPage = cc.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(5), null, - Context.NONE).iterableByPage(marker).iterator().next(); - - // Assert that the second segment is indeed after the first alphabetically - assertTrue(firstBlobName.compareTo(secondPage.getValue().iterator().next().getName()) < 0); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsMaxResults() { - int numBlobs = 7; - int pageResults = 3; - Map tags = Collections.singletonMap(tagKey, tagValue); - - for (int i = 0; i < numBlobs; i++) { - cc.getBlobClient(generateBlobName()) - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()).setTags(tags), null, - null); - } - - for (PagedResponse page : cc - .findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(pageResults), - null, Context.NONE) - .iterableByPage()) { - assertTrue(page.getValue().size() <= pageResults); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsMaxResultsByPage() { - int numBlobs = 7; - int pageResults = 3; - Map tags = Collections.singletonMap(tagKey, tagValue); - - for (int i = 0; i < numBlobs; i++) { - cc.getBlobClient(generateBlobName()) - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()).setTags(tags), null, - null); - } - - for (PagedResponse page : cc - .findBlobsByTags(new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)), null, Context.NONE) - .iterableByPage(pageResults)) { - assertTrue(page.getValue().size() <= pageResults); - } - } - - @Test - public void findBlobsError() { - assertThrows(BlobStorageException.class, () -> cc.findBlobsByTags("garbageTag").streamByPage().count()); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsWithTimeoutStillBackedByPagedStream() { - int numBlobs = 5; - int pageResults = 3; - Map tags = Collections.singletonMap(tagKey, tagValue); - - for (int i = 0; i < numBlobs; i++) { - cc.getBlobClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags), - null, null); - } - - // when: "Consume results by page, still have paging functionality" - assertDoesNotThrow(() -> cc.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(pageResults), - Duration.ofSeconds(10), Context.NONE).streamByPage().count()); - } - - @ParameterizedTest - @ValueSource(strings = { "中文", "az[]", "hello world", "hello/world", "hello&world", "!*'();:@&=+/$,/?#[]" }) - public void createURLSpecialChars(String name) { - // This test checks that we encode special characters in blob names correctly. - AppendBlobClient bu2 = cc.getBlobClient(name).getAppendBlobClient(); - PageBlobClient bu3 = cc.getBlobClient(name + "2").getPageBlobClient(); - BlockBlobClient bu4 = cc.getBlobClient(name + "3").getBlockBlobClient(); - BlockBlobClient bu5 = cc.getBlobClient(name).getBlockBlobClient(); - - assertResponseStatusCode(bu2.createWithResponse(null, null, null, null, null), 201); - assertResponseStatusCode(bu5.getPropertiesWithResponse(null, null, null), 200); - assertResponseStatusCode(bu3.createWithResponse(512, null, null, null, null, null, null), 201); - assertResponseStatusCode(bu4.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, - null, null, null, null, null, null), 201); - - Iterator blobs = cc.listBlobs().iterator(); - - assertEquals(name, blobs.next().getName()); - assertEquals(name + "2", blobs.next().getName()); - assertEquals(name + "3", blobs.next().getName()); - } - - @ParameterizedTest - @ValueSource( - strings = { - "%E4%B8%AD%E6%96%87", - "az%5B%5D", - "hello%20world", - "hello%2Fworld", - "hello%26world", - "%21%2A%27%28%29%3B%3A%40%26%3D%2B%24%2C%2F%3F%23%5B%5D" }) - public void createURLSpecialCharsEncoded(String name) { - // This test checks that we handle blob names with encoded special characters correctly. - AppendBlobClient bu2 = cc.getBlobClient(name).getAppendBlobClient(); - PageBlobClient bu3 = cc.getBlobClient(name + "2").getPageBlobClient(); - BlockBlobClient bu4 = cc.getBlobClient(name + "3").getBlockBlobClient(); - BlockBlobClient bu5 = cc.getBlobClient(name).getBlockBlobClient(); - - assertResponseStatusCode(bu2.createWithResponse(null, null, null, null, null), 201); - assertResponseStatusCode(bu5.getPropertiesWithResponse(null, null, null), 200); - assertResponseStatusCode(bu3.createWithResponse(512, null, null, null, null, null, null), 201); - assertResponseStatusCode(bu4.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, - null, null, null, null, null, null), 201); - - Iterator blobs = cc.listBlobs().iterator(); - - assertEquals(name, blobs.next().getName()); - assertEquals(name + "2", blobs.next().getName()); - assertEquals(name + "3", blobs.next().getName()); - } - - @ParameterizedTest - @ValueSource( - strings = { - "%E4%B8%AD%E6%96%87", - "az%5B%5D", - "hello%20world", - "hello%2Fworld", - "hello%26world", - "%21%2A%27%28%29%3B%3A%40%26%3D%2B%24%2C%2F%3F%23%5B%5D" }) - public void createURLSpecialCharsDecoded(String name) { - // This test checks that we handle blob names with encoded special characters correctly. - String decodedName = Utility.urlDecode(name); - AppendBlobClient bu2 = cc.getBlobClient(decodedName).getAppendBlobClient(); - PageBlobClient bu3 = cc.getBlobClient(decodedName + "2").getPageBlobClient(); - BlockBlobClient bu4 = cc.getBlobClient(decodedName + "3").getBlockBlobClient(); - BlockBlobClient bu5 = cc.getBlobClient(decodedName).getBlockBlobClient(); - - assertResponseStatusCode(bu2.createWithResponse(null, null, null, null, null), 201); - assertResponseStatusCode(bu5.getPropertiesWithResponse(null, null, null), 200); - assertResponseStatusCode(bu3.createWithResponse(512, null, null, null, null, null, null), 201); - assertResponseStatusCode(bu4.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, - null, null, null, null, null, null), 201); - - Iterator blobs = cc.listBlobs().iterator(); - - assertEquals(decodedName, blobs.next().getName()); - assertEquals(decodedName + "2", blobs.next().getName()); - assertEquals(decodedName + "3", blobs.next().getName()); - } - - @Test - public void rootExplicit() { - cc = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.ROOT_CONTAINER_NAME); - // create root container if not exist. - if (!cc.exists()) { - cc.create(); - } - AppendBlobClient bu = cc.getBlobClient("rootblob").getAppendBlobClient(); - assertResponseStatusCode(bu.createWithResponse(null, null, null, null, null), 201); - } - - @Test - public void rootExplicitInEndpoint() { - cc = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.ROOT_CONTAINER_NAME); - // create root container if not exist. - if (!cc.exists()) { - cc.create(); - } - AppendBlobClient bu = cc.getBlobClient("rootblob").getAppendBlobClient(); - - Response createResponse = bu.createWithResponse(null, null, null, null, null); - Response propsResponse = bu.getPropertiesWithResponse(null, null, null); - - assertResponseStatusCode(createResponse, 201); - assertResponseStatusCode(propsResponse, 200); - assertEquals(BlobType.APPEND_BLOB, propsResponse.getValue().getBlobType()); - } - - @Test - public void blobClientBuilderRootImplicit() { - cc = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.ROOT_CONTAINER_NAME); - // createroot container if not exist. - if (!cc.exists()) { - cc.create(); - } - - AppendBlobClient bc - = instrument(new BlobClientBuilder().credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .blobName("rootblob")).buildClient().getAppendBlobClient(); - - Response createResponse = bc.createWithResponse(null, null, null, null, null); - - Response propsResponse = bc.getPropertiesWithResponse(null, null, null); - - assertResponseStatusCode(createResponse, 201); - assertResponseStatusCode(propsResponse, 200); - assertEquals(BlobType.APPEND_BLOB, propsResponse.getValue().getBlobType()); - } - - @Test - public void containerClientBuilderRootImplicit() { - cc = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.ROOT_CONTAINER_NAME); - // create root container if not exist. - if (!cc.exists()) { - cc.create(); - } - - cc = instrument(new BlobContainerClientBuilder().credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .containerName(null)).buildClient(); - - assertNotNull(cc.getProperties()); - assertEquals(BlobContainerAsyncClient.ROOT_CONTAINER_NAME, cc.getBlobContainerName()); - - AppendBlobClient bc = cc.getBlobClient("rootblob").getAppendBlobClient(); - bc.create(true); - - assertTrue(bc.exists()); - } - - @Test - public void serviceClientImplicitRoot() { - assertEquals(primaryBlobServiceClient.getBlobContainerClient(null).getBlobContainerName(), - BlobContainerAsyncClient.ROOT_CONTAINER_NAME); - assertEquals(primaryBlobServiceClient.getBlobContainerClient("").getBlobContainerName(), - BlobContainerAsyncClient.ROOT_CONTAINER_NAME); - } - - @Test - public void webContainer() { - cc = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.STATIC_WEBSITE_CONTAINER_NAME); - // createroot container if not exist. - try { - cc.create(); - } catch (BlobStorageException se) { - if (se.getErrorCode() != BlobErrorCode.CONTAINER_ALREADY_EXISTS) { - throw se; - } - } - - BlobContainerClient webContainer - = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.STATIC_WEBSITE_CONTAINER_NAME); - - // Validate some basic operation. - assertDoesNotThrow(() -> webContainer.setAccessPolicy(null, null)); - } - - @Test - public void getAccountInfo() { - Response response = primaryBlobServiceClient.getAccountInfoWithResponse(null, null); - assertNotNull(response.getHeaders().getValue(HttpHeaderName.DATE)); - assertNotNull(response.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(response.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(response.getValue().getAccountKind()); - assertNotNull(response.getValue().getSkuName()); - } - - @Test - public void getAccountInfoMin() { - assertResponseStatusCode(primaryBlobServiceClient.getAccountInfoWithResponse(null, null), 200); - } - - @Test - public void getAccountInfoBase() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - StorageAccountInfo info = cc.getAccountInfo(null); - - assertNotNull(info.getAccountKind()); - assertNotNull(info.getSkuName()); - assertFalse(info.isHierarchicalNamespaceEnabled()); - } - - @Test - public void getAccountInfoBaseFail() { - BlobServiceClient serviceClient - = instrument(new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(new MockTokenCredential())).buildClient(); - - BlobContainerClient containerClient = serviceClient.getBlobContainerClient(generateContainerName()); - - BlobStorageException e = assertThrows(BlobStorageException.class, () -> containerClient.getAccountInfo(null)); - assertEquals(BlobErrorCode.INVALID_AUTHENTICATION_INFO, e.getErrorCode()); - - } - - @Test - public void getContainerName() { - String containerName = generateContainerName(); - BlobContainerClient newcc = primaryBlobServiceClient.getBlobContainerClient(containerName); - assertEquals(containerName, newcc.getBlobContainerName()); - } - - @Test - public void builderCpkValidation() { - URL endpoint = BlobUrlParts.parse(cc.getBlobContainerUrl()).setScheme("http").toUrl(); - BlobContainerClientBuilder builder = new BlobContainerClientBuilder() - .customerProvidedKey(new CustomerProvidedKey(Base64.getEncoder().encodeToString(getRandomByteArray(256)))) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildClient); - } - - @Test - public void builderBearerTokenValidation() { - URL endpoint = BlobUrlParts.parse(cc.getBlobContainerUrl()).setScheme("http").toUrl(); - BlobContainerClientBuilder builder - = new BlobContainerClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildClient); - } - - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - @Test - public void perCallPolicy() { - BlobContainerClient containerClient = getContainerClientBuilder(cc.getBlobContainerUrl()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .addPolicy(getPerCallVersionPolicy()) - .buildClient(); - - Response response = containerClient.getPropertiesWithResponse(null, null, null); - assertEquals("2017-11-09", response.getHeaders().getValue(X_MS_VERSION)); - } - - @Test - public void defaultAudience() { - BlobContainerClient aadContainer - = getContainerClientBuilderWithTokenCredential(cc.getBlobContainerUrl()).audience(null).buildClient(); - - assertTrue(aadContainer.exists()); - } - - @Test - public void storageAccountAudience() { - BlobContainerClient aadContainer = getContainerClientBuilderWithTokenCredential(cc.getBlobContainerUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(cc.getAccountName())) - .buildClient(); - - assertTrue(aadContainer.exists()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - BlobContainerClient aadContainer = getContainerClientBuilderWithTokenCredential(cc.getBlobContainerUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildClient(); - - assertNotNull(aadContainer.getProperties()); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", cc.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - BlobContainerClient aadContainer - = getContainerClientBuilderWithTokenCredential(cc.getBlobContainerUrl()).audience(audience).buildClient(); - - assertTrue(aadContainer.exists()); - } - - // TODO: Reintroduce these tests once service starts supporting it. - - // public void Rename() { - // setup: - // def newName = generateContainerName() - // - // when: - // def renamedContainer = cc.rename(newName) - // - // then: - // renamedContainer.getPropertiesWithResponse(null, null, null).getStatusCode() == 200 - // - // cleanup: - // renamedContainer.delete() - // } - - // public void Rename sas() { - // setup: - // def newName = generateContainerName() - // def service = new AccountSasService() - // .setBlobAccess(true) - // def resourceType = new AccountSasResourceType() - // .setContainer(true) - // .setService(true) - // .setObject(true) - // def expiryTime = testResourceNamer.now().plusDays(1) - // def permissions = new AccountSasPermission() - // .setReadPermission(true) - // .setWritePermission(true) - // .setCreatePermission(true) - // .setDeletePermission(true) - // - // def sasValues = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType) - // def sas = primaryBlobServiceClient.generateAccountSas(sasValues) - // def sasClient = getContainerClient(sas, cc.getBlobContainerUrl()) - // - // when: - // def renamedContainer = sasClient.rename(newName) - // - // then: - // renamedContainer.getPropertiesWithResponse(null, null, null).getStatusCode() == 200 - // - // cleanup: - // renamedContainer.delete() - // } - - // @ParameterizedTest - // public void Rename AC() { - // setup: - // leaseID = setupContainerLeaseCondition(cc, leaseID) - // BlobRequestConditions cac = new BlobRequestConditions() - // .setLeaseId(leaseID) - // - // expect: - // cc.renameWithResponse(new BlobContainerRenameOptions(generateContainerName()).setRequestConditions(cac), - // null, null).getStatusCode() == 200 - // - // where: - // leaseID || _ - // null || _ - // receivedLeaseID || _ - // } - - // @ParameterizedTest - // public void Rename AC fail() { - // setup: - // BlobRequestConditions cac = new BlobRequestConditions() - // .setLeaseId(leaseID) - // - // when: - // cc.renameWithResponse(new BlobContainerRenameOptions(generateContainerName()).setRequestConditions(cac), - // null, null) - // - // then: - // assertThrows(BlobStorageException.class, () -> - // - // where: - // leaseID || _ - // garbageLeaseID || _ - // } - - // @ParameterizedTest - // public void Rename AC illegal() { - // setup: - // def ac = new BlobRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch).setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified).setTagsConditions(tags) - // - // when: - // cc.renameWithResponse(new BlobContainerRenameOptions(generateContainerName()).setRequestConditions(ac), - // null, null) - // - // then: - // assertThrows(UnsupportedOperationException.class, () -> - // - // where: - // modified | unmodified | match | noneMatch | tags - // oldDate | null | null | null | null - // null | newDate | null | null | null - // null | null | receivedEtag | null | null - // null | null | null | garbageEtag | null - // null | null | null | null | "tags" - // } - - // public void Rename error() { - // setup: - // cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()) - // def newName = generateContainerName() - // - // when: - // cc.rename(newName) - // - // then: - // assertThrows(BlobStorageException.class, () -> - // } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAsyncApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAsyncApiTests.java deleted file mode 100644 index a6000405d00f..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAsyncApiTests.java +++ /dev/null @@ -1,2101 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.rest.PagedFlux; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.Response; -import com.azure.core.test.TestMode; -import com.azure.core.test.utils.MockTokenCredential; -import com.azure.core.util.Context; -import com.azure.core.util.polling.PollerFlux; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.models.*; -import com.azure.storage.blob.options.BlobContainerCreateOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.BlobSetAccessTierOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.specialized.AppendBlobAsyncClient; -import com.azure.storage.blob.specialized.BlobAsyncClientBase; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.blob.specialized.PageBlobAsyncClient; -import com.azure.storage.common.test.shared.TestHttpClientType; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.PlaybackOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.function.Tuple2; - -import java.net.URL; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ContainerAsyncApiTests extends BlobTestBase { - private String tagKey; - private String tagValue; - - @BeforeEach - public void setup() { - tagKey = testResourceNamer.randomName(prefix, 20); - tagValue = testResourceNamer.randomName(prefix, 20); - } - - @Test - public void blobNameNull() { - assertThrows(NullPointerException.class, () -> cc.getBlobClient(null)); - } - - @Test - public void createAllNull() { - // Overwrite the existing cc, which has already been created - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - - StepVerifier.create(ccAsync.createWithResponse(null, null)).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(validateBasicHeaders(r.getHeaders())); - }).verifyComplete(); - } - - @Test - public void createMin() { - StepVerifier.create(primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()) - .flatMap(BlobContainerAsyncClient::exists)).expectNext(true).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createMetadata(String key1, String value1, String key2, String value2) { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - StepVerifier.create(ccAsync.createWithResponse(metadata, null).then(ccAsync.getPropertiesWithResponse(null))) - .assertNext(r -> { - if (ENVIRONMENT.getHttpClientType() == TestHttpClientType.JDK_HTTP) { - // JDK HttpClient returns headers with names lowercased. - Map lowercasedMetadata = metadata.entrySet() - .stream() - .collect(Collectors.toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue)); - assertEquals(lowercasedMetadata, r.getValue().getMetadata()); - } else { - assertEquals(metadata, r.getValue().getMetadata()); - } - }) - .verifyComplete(); - } - - private static Stream createMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of("testFoo", "testBar", "testFizz", "testBuzz")); - } - - @ParameterizedTest - @MethodSource("publicAccessSupplier") - @PlaybackOnly - public void createPublicAccess(PublicAccessType publicAccess) { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(ccAsync.createWithResponse(null, publicAccess).then(ccAsync.getProperties())) - .assertNext(r -> assertEquals(r.getBlobPublicAccess(), publicAccess)) - .verifyComplete(); - } - - private static Stream publicAccessSupplier() { - return Stream.of(Arguments.of(PublicAccessType.BLOB), Arguments.of(PublicAccessType.CONTAINER), - Arguments.of((PublicAccessType) null)); - } - - @Test - public void createError() { - StepVerifier.create(ccAsync.create()).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertExceptionStatusCodeAndMessage(e, 409, BlobErrorCode.CONTAINER_ALREADY_EXISTS); - assertTrue(e.getServiceMessage().contains("The specified container already exists.")); - }); - } - - @Test - public void createIfNotExistsAllNull() { - // Overwrite the existing cc, which has already been created - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - - StepVerifier.create(ccAsync.createIfNotExistsWithResponse(null)).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(validateBasicHeaders(r.getHeaders())); - }).verifyComplete(); - } - - @Test - public void createIfNotExistsMin() { - StepVerifier.create(primaryBlobServiceAsyncClient.createBlobContainerIfNotExists(generateContainerName()) - .flatMap(BlobContainerAsyncClient::exists)).expectNext(true).verifyComplete(); - } - - @Test - public void createIfNotExistsMinContainer() { - BlobContainerAsyncClient cc - = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - - StepVerifier.create(cc.createIfNotExists()).expectNext(true).verifyComplete(); - } - - @Test - public void createIfNotExistsWithResponse() { - assertAsyncResponseStatusCode( - primaryBlobServiceAsyncClient.createBlobContainerIfNotExistsWithResponse(generateContainerName(), null), - 201); - } - - @Test - public void createIfNotExistsBlobServiceThatAlreadyExists() { - String containerName = generateContainerName(); - - assertAsyncResponseStatusCode( - primaryBlobServiceAsyncClient.createBlobContainerIfNotExistsWithResponse(containerName, null), 201); - assertAsyncResponseStatusCode( - primaryBlobServiceAsyncClient.createBlobContainerIfNotExistsWithResponse(containerName, null), 409); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createIfNotExistsMetadataIfNotExists(String key1, String value1, String key2, String value2) { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata); - - StepVerifier.create(ccAsync.createIfNotExistsWithResponse(options)) - .assertNext(r -> assertTrue(r.getValue())) - .verifyComplete(); - - StepVerifier.create(ccAsync.getPropertiesWithResponse(null)).assertNext(r -> { - if (ENVIRONMENT.getHttpClientType() == TestHttpClientType.JDK_HTTP) { - // JDK HttpClient returns headers with names lowercased. - Map lowercasedMetadata = metadata.entrySet() - .stream() - .collect(Collectors.toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue)); - assertEquals(lowercasedMetadata, r.getValue().getMetadata()); - } else { - assertEquals(metadata, r.getValue().getMetadata()); - } - }).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("publicAccessSupplier") - @PlaybackOnly - public void createIfNotExistsPublicAccess(PublicAccessType publicAccess) { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - - StepVerifier - .create(ccAsync - .createIfNotExistsWithResponse(new BlobContainerCreateOptions().setPublicAccessType(publicAccess))) - .assertNext(r -> assertTrue(r.getValue())) - .verifyComplete(); - - StepVerifier.create(ccAsync.getProperties()) - .assertNext(r -> assertEquals(r.getBlobPublicAccess(), publicAccess)) - .verifyComplete(); - } - - @Test - public void createIfNotExistsOnContainerThatAlreadyExists() { - StepVerifier.create(ccAsync.createIfNotExists()).expectNext(false).verifyComplete(); - } - - @Test - public void createIfNotExistsOnAContainerThatAlreadyExistsWithResponse() { - BlobContainerAsyncClient cc - = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - - StepVerifier.create(cc.createIfNotExistsWithResponse(null)).assertNext(r -> { - assertEquals(r.getStatusCode(), 201); - assertTrue(r.getValue()); - }).verifyComplete(); - - StepVerifier.create(cc.createIfNotExistsWithResponse(null)).assertNext(r -> { - assertEquals(r.getStatusCode(), 409); - assertFalse(r.getValue()); - }).verifyComplete(); - } - - @Test - public void getPropertiesNull() { - StepVerifier.create(ccAsync.getPropertiesWithResponse(null)).assertNext(r -> { - assertTrue(validateBasicHeaders(r.getHeaders())); - assertNull(r.getValue().getBlobPublicAccess()); - assertFalse(r.getValue().hasImmutabilityPolicy()); - assertFalse(r.getValue().hasLegalHold()); - assertNull(r.getValue().getLeaseDuration()); - assertEquals(r.getValue().getLeaseState(), LeaseStateType.AVAILABLE); - assertEquals(r.getValue().getLeaseStatus(), LeaseStatusType.UNLOCKED); - assertEquals(0, r.getValue().getMetadata().size()); - assertFalse(r.getValue().isEncryptionScopeOverridePrevented()); - assertNotNull(r.getValue().getDefaultEncryptionScope()); - }).verifyComplete(); - } - - @Test - public void getPropertiesMin() { - StepVerifier.create(ccAsync.getProperties()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - @Test - public void getPropertiesLease() { - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> ccAsync.getPropertiesWithResponse(r)); - - assertAsyncResponseStatusCode(response, 200); - } - - @Test - public void getPropertiesLeaseFail() { - StepVerifier.create(ccAsync.getPropertiesWithResponse("garbage")).verifyError(BlobStorageException.class); - } - - @Test - public void getPropertiesError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(ccAsync.getProperties()).verifyError(BlobStorageException.class); - } - - @Test - public void setMetadata() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - Map metadata = new HashMap<>(); - metadata.put("key", "value"); - - StepVerifier - .create(ccAsync.createWithResponse(metadata, null).then(ccAsync.setMetadataWithResponse(null, null))) - .assertNext(r -> { - assertEquals(r.getStatusCode(), 200); - assertTrue(validateBasicHeaders(r.getHeaders())); - }) - .verifyComplete(); - - StepVerifier.create(ccAsync.getPropertiesWithResponse(null)) - .assertNext(r -> assertEquals(r.getValue().getMetadata().size(), 0)) - .verifyComplete(); - } - - @Test - public void setMetadataMin() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - - StepVerifier.create(ccAsync.setMetadata(metadata).then(ccAsync.getPropertiesWithResponse(null))) - .assertNext(r -> assertEquals(r.getValue().getMetadata(), metadata)) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("setMetadataMetadataSupplier") - public void setMetadataMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - assertAsyncResponseStatusCode(ccAsync.setMetadataWithResponse(metadata, null), 200); - - StepVerifier.create(ccAsync.getPropertiesWithResponse(null)) - .assertNext(r -> assertEquals(r.getValue().getMetadata(), metadata)) - .verifyComplete(); - } - - private static Stream setMetadataMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @ParameterizedTest - @MethodSource("setMetadataACSupplier") - public void setMetadataAC(OffsetDateTime modified, String leaseID) { - Mono> response = setupContainerLeaseConditionAsync(ccAsync, leaseID).flatMap(condition -> { - BlobRequestConditions cac - = new BlobRequestConditions().setLeaseId(convertNull(condition)).setIfModifiedSince(modified); - - return ccAsync.setMetadataWithResponse(null, cac); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - private static Stream setMetadataACSupplier() { - return Stream.of(Arguments.of(null, null), Arguments.of(OLD_DATE, null), Arguments.of(null, RECEIVED_LEASE_ID)); - } - - @ParameterizedTest - @MethodSource("setMetadataACFailSupplier") - public void setMetadataACFail(OffsetDateTime modified, String leaseID) { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID).setIfModifiedSince(modified); - - StepVerifier.create(ccAsync.setMetadataWithResponse(null, cac)).verifyError(BlobStorageException.class); - } - - private static Stream setMetadataACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null), Arguments.of(null, GARBAGE_LEASE_ID)); - } - - @ParameterizedTest - @MethodSource("setMetadataACIllegalSupplier") - public void setMetadataACIllegal(OffsetDateTime unmodified, String match, String noneMatch) { - BlobRequestConditions mac - = new BlobRequestConditions().setIfUnmodifiedSince(unmodified).setIfMatch(match).setIfNoneMatch(noneMatch); - - StepVerifier.create(ccAsync.setMetadataWithResponse(null, mac)) - .verifyError(UnsupportedOperationException.class); - } - - private static Stream setMetadataACIllegalSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null), Arguments.of(null, RECEIVED_ETAG, null), - Arguments.of(null, null, GARBAGE_ETAG)); - } - - @Test - public void setMetadataError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(ccAsync.setMetadata(null)).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("publicAccessSupplier") - @PlaybackOnly - public void setAccessPolicy(PublicAccessType publicAccess) { - StepVerifier.create(ccAsync.setAccessPolicyWithResponse(publicAccess, null, null)) - .assertNext(r -> assertTrue(validateBasicHeaders(r.getHeaders()))) - .verifyComplete(); - - StepVerifier.create(ccAsync.getProperties()) - .assertNext(r -> assertEquals(r.getBlobPublicAccess(), publicAccess)) - .verifyComplete(); - } - - @Test - public void setAccessPolicyIds() { - BlobSignedIdentifier identifier = new BlobSignedIdentifier().setId("0000") - .setAccessPolicy(new BlobAccessPolicy().setStartsOn(testResourceNamer.now()) - .setExpiresOn(testResourceNamer.now().plusDays(1)) - .setPermissions("r")); - BlobSignedIdentifier identifier2 = new BlobSignedIdentifier().setId("0001") - .setAccessPolicy(new BlobAccessPolicy().setStartsOn(testResourceNamer.now()) - .setExpiresOn(testResourceNamer.now().plusDays(2)) - .setPermissions("w")); - List ids = Arrays.asList(identifier, identifier2); - - StepVerifier.create(ccAsync.setAccessPolicyWithResponse(null, ids, null)).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertTrue(validateBasicHeaders(r.getHeaders())); - }).verifyComplete(); - - StepVerifier.create(ccAsync.getAccessPolicyWithResponse(null)).assertNext(r -> { - List receivedIdentifiers = r.getValue().getIdentifiers(); - assertEquals(receivedIdentifiers.get(0).getAccessPolicy().getExpiresOn(), - identifier.getAccessPolicy().getExpiresOn()); - assertEquals(receivedIdentifiers.get(0).getAccessPolicy().getStartsOn(), - identifier.getAccessPolicy().getStartsOn()); - assertEquals(receivedIdentifiers.get(0).getAccessPolicy().getPermissions(), - identifier.getAccessPolicy().getPermissions()); - assertEquals(receivedIdentifiers.get(1).getAccessPolicy().getExpiresOn(), - identifier2.getAccessPolicy().getExpiresOn()); - assertEquals(receivedIdentifiers.get(1).getAccessPolicy().getStartsOn(), - identifier2.getAccessPolicy().getStartsOn()); - assertEquals(receivedIdentifiers.get(1).getAccessPolicy().getPermissions(), - identifier2.getAccessPolicy().getPermissions()); - }).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACSupplier") - public void setAccessPolicyAC(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - Mono> response = setupContainerLeaseConditionAsync(ccAsync, leaseID).flatMap(condition -> { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(convertNull(condition)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - return ccAsync.setAccessPolicyWithResponse(null, null, cac); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - private static Stream setAccessPolicyACSupplier() { - return Stream.of(Arguments.of(null, null, null), Arguments.of(OLD_DATE, null, null), - Arguments.of(null, NEW_DATE, null), Arguments.of(null, null, RECEIVED_LEASE_ID)); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACFailSupplier") - public void setAccessPolicyACFail(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - StepVerifier.create(ccAsync.setAccessPolicyWithResponse(null, null, cac)) - .verifyError(BlobStorageException.class); - } - - private static Stream setAccessPolicyACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null), Arguments.of(null, OLD_DATE, null), - Arguments.of(null, null, GARBAGE_LEASE_ID)); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACIllegalSupplier") - public void setAccessPolicyACIllegal(String match, String noneMatch) { - BlobRequestConditions mac = new BlobRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - StepVerifier.create(ccAsync.setAccessPolicyWithResponse(null, null, mac)) - .verifyError(UnsupportedOperationException.class); - } - - private static Stream setAccessPolicyACIllegalSupplier() { - return Stream.of(Arguments.of(RECEIVED_ETAG, null), Arguments.of(null, GARBAGE_ETAG)); - } - - @Test - public void getAccessPolicyLease() { - Mono> response - = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> ccAsync.getAccessPolicyWithResponse(r)); - - assertAsyncResponseStatusCode(response, 200); - } - - @Test - public void getAccessPolicyLeaseFail() { - StepVerifier.create(ccAsync.getAccessPolicyWithResponse(GARBAGE_LEASE_ID)) - .verifyError(BlobStorageException.class); - } - - @Test - public void getAccessPolicyError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(ccAsync.getAccessPolicy()).verifyError(BlobStorageException.class); - } - - @Test - public void delete() { - StepVerifier.create(ccAsync.deleteWithResponse(null)).assertNext(r -> { - assertResponseStatusCode(r, 202); - assertNotNull(r.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(r.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(r.getHeaders().getValue(HttpHeaderName.DATE)); - }).verifyComplete(); - } - - @Test - public void deleteMin() { - StepVerifier.create(ccAsync.delete().then(ccAsync.exists())).expectNext(false).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACSupplier") - public void deleteAC(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - Mono> response = setupContainerLeaseConditionAsync(ccAsync, leaseID).flatMap(condition -> { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(convertNull(condition)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - return ccAsync.deleteWithResponse(cac); - }); - - assertAsyncResponseStatusCode(response, 202); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACFailSupplier") - public void deleteACFail(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - StepVerifier.create(ccAsync.deleteWithResponse(cac)).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACIllegalSupplier") - public void deleteACIllegal(String match, String noneMatch) { - BlobRequestConditions mac = new BlobRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - StepVerifier.create(ccAsync.deleteWithResponse(mac)).verifyError(UnsupportedOperationException.class); - } - - @Test - public void deleteError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(ccAsync.delete()).verifyError(BlobStorageException.class); - } - - @Test - public void deleteIfExists() { - StepVerifier.create(ccAsync.deleteIfExistsWithResponse(null)).assertNext(r -> { - assertTrue(r.getValue()); - assertResponseStatusCode(r, 202); - assertNotNull(r.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(r.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(r.getHeaders().getValue(HttpHeaderName.DATE)); - }).verifyComplete(); - } - - @Test - public void deleteIfExistsMin() { - StepVerifier.create(ccAsync.deleteIfExists()).expectNext(true).verifyComplete(); - - StepVerifier.create(ccAsync.exists()).expectNext(false).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACSupplier") - public void deleteIfExistsAC(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - Mono> response = setupContainerLeaseConditionAsync(ccAsync, leaseID).flatMap(condition -> { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(convertNull(condition)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - return ccAsync.deleteIfExistsWithResponse(cac); - }); - - assertAsyncResponseStatusCode(response, 202); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACFailSupplier") - public void deleteIfExistsACFail(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) { - BlobRequestConditions cac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - - StepVerifier.create(ccAsync.deleteIfExistsWithResponse(cac)).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("setAccessPolicyACIllegalSupplier") - public void deleteIfExistsACIllegal(String match, String noneMatch) { - BlobRequestConditions mac = new BlobRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - StepVerifier.create(ccAsync.deleteIfExistsWithResponse(mac)).verifyError(UnsupportedOperationException.class); - } - - @Test - public void deleteIfExistsOnAContainerThatDoesNotExist() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - - StepVerifier.create(ccAsync.deleteIfExistsWithResponse(new BlobRequestConditions())).assertNext(r -> { - assertFalse(r.getValue()); - assertResponseStatusCode(r, 404); - }).verifyComplete(); - } - - // We can't guarantee that the requests will always happen before the container is garbage collected - @PlaybackOnly - @Test - public void deleteIfExistsContainerThatWasAlreadyDeleted() { - StepVerifier.create(ccAsync.deleteIfExists()).expectNext(true).verifyComplete(); - - // Confirming the behavior of the api when the container is in the deleting state. - // After deletehas been called once but before it has been garbage collected - StepVerifier.create(ccAsync.deleteIfExists()).expectNext(true).verifyComplete(); - - StepVerifier.create(ccAsync.exists()).expectNext(false).verifyComplete(); - } - - @Test - public void listBlockBlobsFlat() { - String name = generateBlobName(); - BlockBlobAsyncClient bu = ccAsync.getBlobAsyncClient(name).getBlockBlobAsyncClient(); - - StepVerifier - .create(bu.upload(DATA.getDefaultFlux(), 7) - .thenMany(ccAsync.listBlobs(new ListBlobsOptions().setPrefix(prefix)))) - .assertNext(r -> { - assertEquals(name, r.getName()); - assertEquals(BlobType.BLOCK_BLOB, r.getProperties().getBlobType()); - assertNull(r.getProperties().getCopyCompletionTime()); - assertNull(r.getProperties().getCopyStatusDescription()); - assertNull(r.getProperties().getCopyId()); - assertNull(r.getProperties().getCopyProgress()); - assertNull(r.getProperties().getCopySource()); - assertNull(r.getProperties().getCopyStatus()); - assertNull(r.getProperties().isIncrementalCopy()); - assertNull(r.getProperties().getDestinationSnapshot()); - assertNull(r.getProperties().getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, r.getProperties().getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, r.getProperties().getLeaseStatus()); - assertNotNull(r.getProperties().getContentLength()); - assertNotNull(r.getProperties().getContentType()); - assertNotNull(r.getProperties().getContentMd5()); - assertNull(r.getProperties().getContentEncoding()); - assertNull(r.getProperties().getContentDisposition()); - assertNull(r.getProperties().getContentLanguage()); - assertNull(r.getProperties().getCacheControl()); - assertNull(r.getProperties().getBlobSequenceNumber()); - assertTrue(r.getProperties().isServerEncrypted()); - assertTrue(r.getProperties().isAccessTierInferred()); - assertEquals(AccessTier.HOT, r.getProperties().getAccessTier()); - assertNull(r.getProperties().getArchiveStatus()); - assertNotNull(r.getProperties().getCreationTime()); - }) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listAppendBlobsFlat() { - String name = generateBlobName(); - AppendBlobAsyncClient bu = ccAsync.getBlobAsyncClient(name).getAppendBlobAsyncClient(); - - StepVerifier - .create(bu.create().then(bu.seal()).thenMany(ccAsync.listBlobs(new ListBlobsOptions().setPrefix(prefix)))) - .assertNext(r -> { - assertEquals(name, r.getName()); - assertEquals(BlobType.APPEND_BLOB, r.getProperties().getBlobType()); - assertNull(r.getProperties().getCopyCompletionTime()); - assertNull(r.getProperties().getCopyStatusDescription()); - assertNull(r.getProperties().getCopyId()); - assertNull(r.getProperties().getCopyProgress()); - assertNull(r.getProperties().getCopySource()); - assertNull(r.getProperties().getCopyStatus()); - assertNull(r.getProperties().isIncrementalCopy()); - assertNull(r.getProperties().getDestinationSnapshot()); - assertNull(r.getProperties().getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, r.getProperties().getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, r.getProperties().getLeaseStatus()); - assertNotNull(r.getProperties().getContentLength()); - assertNotNull(r.getProperties().getContentType()); - assertNull(r.getProperties().getContentMd5()); - assertNull(r.getProperties().getContentEncoding()); - assertNull(r.getProperties().getContentDisposition()); - assertNull(r.getProperties().getContentLanguage()); - assertNull(r.getProperties().getCacheControl()); - assertNull(r.getProperties().getBlobSequenceNumber()); - assertTrue(r.getProperties().isServerEncrypted()); - assertNull(r.getProperties().isAccessTierInferred()); - assertNull(r.getProperties().getAccessTier()); - assertNull(r.getProperties().getArchiveStatus()); - assertNotNull(r.getProperties().getCreationTime()); - assertTrue(r.getProperties().isSealed()); - }) - .verifyComplete(); - } - - @Test - public void listPageBlobsFlat() { - String containerName = generateContainerName(); - ccAsync = premiumBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName); - String name = generateBlobName(); - PageBlobAsyncClient bu = ccAsync.getBlobAsyncClient(name).getPageBlobAsyncClient(); - - Flux response = ccAsync.createIfNotExists() - .then(bu.create(512)) - .thenMany(ccAsync.listBlobs(new ListBlobsOptions().setPrefix(prefix), null)); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(name, r.getName()); - assertEquals(BlobType.PAGE_BLOB, r.getProperties().getBlobType()); - assertNull(r.getProperties().getCopyCompletionTime()); - assertNull(r.getProperties().getCopyStatusDescription()); - assertNull(r.getProperties().getCopyId()); - assertNull(r.getProperties().getCopyProgress()); - assertNull(r.getProperties().getCopySource()); - assertNull(r.getProperties().getCopyStatus()); - assertNull(r.getProperties().isIncrementalCopy()); - assertNull(r.getProperties().getDestinationSnapshot()); - assertNull(r.getProperties().getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, r.getProperties().getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, r.getProperties().getLeaseStatus()); - assertNotNull(r.getProperties().getContentLength()); - assertNotNull(r.getProperties().getContentType()); - assertNull(r.getProperties().getContentMd5()); - assertNull(r.getProperties().getContentEncoding()); - assertNull(r.getProperties().getContentDisposition()); - assertNull(r.getProperties().getContentLanguage()); - assertNull(r.getProperties().getCacheControl()); - assertEquals(0, r.getProperties().getBlobSequenceNumber()); - assertTrue(r.getProperties().isServerEncrypted()); - assertTrue(r.getProperties().isAccessTierInferred()); - assertEquals(AccessTier.P10, r.getProperties().getAccessTier()); - assertNull(r.getProperties().getArchiveStatus()); - assertNotNull(r.getProperties().getCreationTime()); - }).verifyComplete(); - - //cleanup - premiumBlobServiceAsyncClient.deleteBlobContainer(containerName).block(); - } - - @Test - public void listBlobsFlatMin() { - StepVerifier.create(ccAsync.listBlobs()).verifyComplete(); - } - - private Mono setupListBlobsTest(String normalName, String copyName, String metadataName, - String tagsName, String uncommittedName) { - PageBlobAsyncClient normal = ccAsync.getBlobAsyncClient(normalName).getPageBlobAsyncClient(); - - PageBlobAsyncClient copyBlob = ccAsync.getBlobAsyncClient(copyName).getPageBlobAsyncClient(); - PollerFlux poller - = setPlaybackPollerFluxPollInterval(copyBlob.beginCopy(normal.getBlobUrl(), null)); - - PageBlobAsyncClient metadataBlob = ccAsync.getBlobAsyncClient(metadataName).getPageBlobAsyncClient(); - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - - PageBlobAsyncClient tagsBlob = ccAsync.getBlobAsyncClient(tagsName).getPageBlobAsyncClient(); - Map tags = new HashMap<>(); - tags.put(tagKey, tagValue); - - BlockBlobAsyncClient uncommittedBlob = ccAsync.getBlobAsyncClient(uncommittedName).getBlockBlobAsyncClient(); - - return normal.create(512) - .then(poller.last()) - .then(metadataBlob.createWithResponse(512, null, null, metadata, null)) - .then(tagsBlob.createWithResponse(new PageBlobCreateOptions(512).setTags(tags))) - .then(uncommittedBlob.stageBlock(getBlockID(), DATA.getDefaultFlux(), DATA.getDefaultData().remaining())) - .then(normal.createSnapshot()); - } - - @Test - public void listBlobsFlatOptionsCopy() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveCopy(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobs(options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .assertNext(r -> { - assertEquals(copyName, r.getName()); - assertNotNull(r.getProperties().getCopyId()); - // Comparing the urls isn't reliable because the service may use https. - assertTrue(r.getProperties().getCopySource().contains(normalName)); - // We waited for the copy to complete. - assertEquals(CopyStatusType.SUCCESS, r.getProperties().getCopyStatus()); - assertNotNull(r.getProperties().getCopyProgress()); - assertNotNull(r.getProperties().getCopyCompletionTime()); - }) - .expectNextCount(2) // metadata, tags - .verifyComplete(); - } - - @Test - public void listBlobsFlatOptionsMetadata() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveMetadata(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobs(options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .assertNext(r -> { - assertEquals(copyName, r.getName()); - assertNull(r.getProperties().getCopyCompletionTime()); - }) - .assertNext(r -> { - assertEquals(metadataName, r.getName()); - assertEquals("bar", r.getMetadata().get("foo")); - }) - .expectNextCount(1) // tags - .verifyComplete(); - } - - @PlaybackOnly - @Test - public void listBlobsFlatOptionsLastAccessTime() { - BlockBlobAsyncClient b = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - StepVerifier - .create(b.upload(DATA.getDefaultFlux(), DATA.getDefaultData().remaining()).thenMany(ccAsync.listBlobs())) - .assertNext(r -> assertNotNull(r.getProperties().getLastAccessedTime())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listBlobsFlatOptionsTags() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveTags(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobs(options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .assertNext(r -> { - assertEquals(copyName, r.getName()); - assertNull(r.getProperties().getCopyCompletionTime()); - }) - .assertNext(r -> { - assertEquals(metadataName, r.getName()); - assertNull(r.getMetadata()); - }) - .assertNext(r -> { - assertEquals(tagValue, r.getTags().get(tagKey)); - assertEquals(1, r.getProperties().getTagCount()); - }) - .verifyComplete(); - } - - @Test - public void listBlobsFlatOptionsSnapshots() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveSnapshots(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - Mono>> response - = setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName).flatMap( - snapshot -> Mono.zip(Mono.just(snapshot.getSnapshotId()), ccAsync.listBlobs(options).collectList())); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(r.getT1(), r.getT2().get(0).getSnapshot()); - assertEquals(normalName, r.getT2().get(0).getName()); - assertEquals(normalName, r.getT2().get(1).getName()); - assertEquals(copyName, r.getT2().get(2).getName()); - assertEquals(metadataName, r.getT2().get(3).getName()); - assertEquals(tagsName, r.getT2().get(4).getName()); - }).verifyComplete(); - } - - @Test - public void listBlobsFlatOptionsUncommitted() { - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveUncommittedBlobs(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobs(options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .expectNextCount(3) - .assertNext(r -> assertEquals(uncommittedName, r.getName())) - .verifyComplete(); - } - - @Test - public void listBlobsFlatOptionsPrefix() { - ListBlobsOptions options = new ListBlobsOptions().setPrefix("a"); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobs(options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - @Test - public void listBlobsFlatOptionsMaxResults() { - int pageSize = 2; - ListBlobsOptions options = new ListBlobsOptions().setDetails( - new BlobListDetails().setRetrieveCopy(true).setRetrieveSnapshots(true).setRetrieveUncommittedBlobs(true)) - .setMaxResultsPerPage(pageSize); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - // expect: "Get first page of blob listings" - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobs(options).byPage().limitRequest(1))) - .assertNext(it -> assertEquals(pageSize, it.getValue().size())) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - @Test - public void listBlobsFlatOptionsMaxResultsByPage() { - int pageSize = 2; - ListBlobsOptions options = new ListBlobsOptions().setDetails( - new BlobListDetails().setRetrieveCopy(true).setRetrieveSnapshots(true).setRetrieveUncommittedBlobs(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - // expect: "Get first page of blob listings - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobs(options).byPage(pageSize).limitRequest(1))) - .assertNext(it -> assertEquals(pageSize, it.getValue().size())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void listBlobsFlatOptionsDeletedWithVersions() { - String containerName = generateContainerName(); - BlobContainerAsyncClient versionedCC - = versionedBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName); - String blobName = generateBlobName(); - AppendBlobAsyncClient blob = versionedCC.getBlobAsyncClient(blobName).getAppendBlobAsyncClient(); - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - ListBlobsOptions options = new ListBlobsOptions().setPrefix(blobName) - .setDetails(new BlobListDetails().setRetrieveDeletedBlobsWithVersions(true)); - - Flux response = versionedCC.createIfNotExists() - .then(blob.create()) - .then(blob.setMetadata(metadata)) - .then(blob.delete()) - .thenMany(versionedCC.listBlobs(options)); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(blobName, r.getName()); - assertTrue(r.hasVersionsOnly()); - }).verifyComplete(); - - //cleanup - versionedBlobServiceAsyncClient.deleteBlobContainer(containerName).block(); - } - - @Test - public void listBlobsPrefixWithComma() { - String prefix = generateBlobName() + ", " + generateBlobName(); - BlockBlobAsyncClient b = ccAsync.getBlobAsyncClient(prefix).getBlockBlobAsyncClient(); - - ListBlobsOptions options = new ListBlobsOptions().setPrefix(prefix); - StepVerifier - .create( - b.upload(DATA.getDefaultFlux(), DATA.getDefaultData().remaining()).thenMany(ccAsync.listBlobs(options))) - .assertNext(r -> assertEquals(prefix, r.getName())) - .verifyComplete(); - } - - @Test - public void listBlobsFlatMarker() { - int numBlobs = 10; - int pageSize = 6; - - Mono> createBlob = Flux.range(0, numBlobs).flatMap(i -> { - PageBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - return bc.create(512); - }).collectList(); - - PagedFlux pagedFlux = ccAsync.listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageSize)); - - Flux> response - = createBlob.thenMany(pagedFlux.byPage().take(1).flatMap(pagedResponse1 -> { - assertNotNull(pagedResponse1); - assertEquals(pageSize, pagedResponse1.getValue().size()); - return pagedFlux.byPage(pagedResponse1.getContinuationToken()).take(1); - })); - - StepVerifier.create(response).assertNext(pagedResponse2 -> { - assertNotNull(pagedResponse2); - assertEquals(numBlobs - pageSize, pagedResponse2.getValue().size()); - assertNull(pagedResponse2.getContinuationToken()); - }).verifyComplete(); - } - - @Test - public void listBlobsFlatMarkerOverload() { - int numBlobs = 10; - int pageSize = 6; - - Mono> createBlob = Flux.range(0, numBlobs).flatMap(i -> { - PageBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - return bc.create(512); - }).collectList(); - - PagedFlux pagedFlux = ccAsync.listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageSize)); - Flux> response - = createBlob.thenMany(pagedFlux.byPage().take(1).flatMap(pagedResponse1 -> { - assertNotNull(pagedResponse1); - assertEquals(pageSize, pagedResponse1.getValue().size()); - return ccAsync - .listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageSize), - pagedResponse1.getContinuationToken()) - .byPage() - .take(1); - })); - - StepVerifier.create(response).assertNext(pagedResponse2 -> { - assertNotNull(pagedResponse2); - assertEquals(numBlobs - pageSize, pagedResponse2.getValue().size()); - assertNull(pagedResponse2.getContinuationToken()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("listBlobsFlatRehydratePrioritySupplier") - public void listBlobsFlatRehydratePriority(RehydratePriority rehydratePriority) { - String name = generateBlobName(); - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(name).getBlockBlobAsyncClient(); - - Mono> rehydrate = Mono.empty(); - - if (rehydratePriority != null) { - rehydrate = bc.setAccessTier(AccessTier.ARCHIVE) - .then(bc.setAccessTierWithResponse( - new BlobSetAccessTierOptions(AccessTier.HOT).setPriority(rehydratePriority))); - } - - Flux response - = bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()).then(rehydrate).thenMany(ccAsync.listBlobs()); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(rehydratePriority, r.getProperties().getRehydratePriority())) - .verifyComplete(); - } - - private static Stream listBlobsFlatRehydratePrioritySupplier() { - return Stream.of(Arguments.of((RehydratePriority) null), Arguments.of(RehydratePriority.STANDARD), - Arguments.of(RehydratePriority.HIGH)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-02-12") - @Test - public void listBlobsFlatInvalidXml() { - String blobName = "dir1/dir2/file\uFFFE.blob"; - - StepVerifier - .create( - ccAsync.getBlobAsyncClient(blobName).getAppendBlobAsyncClient().create().thenMany(ccAsync.listBlobs())) - .assertNext(r -> assertEquals(blobName, r.getName())) - .verifyComplete(); - } - - @Test - public void listBlobsFlatError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(ccAsync.listBlobs()).verifyError(BlobStorageException.class); - } - - @Test - public void listBlobsFlatWithTimeoutStillBackedByPagedFlux() { - int numBlobs = 5; - int pageResults = 3; - - Mono> createBlob = Flux.range(0, numBlobs).flatMap(i -> { - BlockBlobAsyncClient blob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return blob.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()); - }).collectList(); - - // when: "Consume results by page, then still have paging functionality" - StepVerifier - .create(createBlob - .thenMany(ccAsync.listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageResults)).byPage())) - .expectNextCount(2) - .verifyComplete(); - } - - @Test - public void listBlobsHierWithTimeoutStillBackedByPagedFlux() { - int numBlobs = 5; - int pageResults = 3; - - Mono> createBlob = Flux.range(0, numBlobs).flatMap(i -> { - BlockBlobAsyncClient blob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - return blob.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()); - }).collectList(); - - // when: "Consume results by page, then still have paging functionality" - StepVerifier - .create(createBlob.thenMany( - ccAsync.listBlobsByHierarchy("/", new ListBlobsOptions().setMaxResultsPerPage(pageResults)).byPage())) - .expectNextCount(2) - .verifyComplete(); - } - - /* - This test requires two accounts that are configured in a very specific way. It is not feasible to setup that - relationship programmatically, so we have recorded a successful interaction and only test recordings. - */ - //@PlaybackOnly - @Disabled("Need to re-record once account is setup properly.") - @Test - public void listBlobsFlatORS() { - BlobContainerAsyncClient sourceContainer = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient("test1"); - BlobContainerAsyncClient destContainer = alternateBlobServiceAsyncClient.getBlobContainerAsyncClient("test2"); - - Mono> sourceBlobs = sourceContainer.listBlobs().collect(Collectors.toList()); - Mono> destBlobs = destContainer.listBlobs().collect(Collectors.toList()); - - StepVerifier.create(sourceBlobs).assertNext(r -> { - int i = 0; - for (BlobItem blob : r) { - if (i == 1) { - assertNull(blob.getObjectReplicationSourcePolicies()); - } else { - assertTrue(validateOR(blob.getObjectReplicationSourcePolicies())); - } - i++; - } - }).verifyComplete(); - - StepVerifier.create(destBlobs).assertNext(r -> { - /* Service specifies no ors metadata on the dest blobs. */ - for (BlobItem blob : r) { - assertNull(blob.getObjectReplicationSourcePolicies()); - } - }).verifyComplete(); - } - - private boolean validateOR(List policies) { - return policies.stream() - .filter(policy -> "fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80".equals(policy.getPolicyId())) - .findFirst() - .get() - .getRules() - .stream() - .filter(rule -> "105f9aad-f39b-4064-8e47-ccd7937295ca".equals(rule.getRuleId())) - .findFirst() - .get() - .getStatus() == ObjectReplicationStatus.COMPLETE; - } - - @Test - public void listBlobsHierarchy() { - String name = generateBlobName(); - PageBlobAsyncClient bu = ccAsync.getBlobAsyncClient(name).getPageBlobAsyncClient(); - - StepVerifier.create(bu.create(512).thenMany(ccAsync.listBlobsByHierarchy(null))) - .assertNext(r -> assertEquals(name, r.getName())) - .verifyComplete(); - } - - @Test - public void listBlobsHierarchyMin() { - StepVerifier.create(ccAsync.listBlobsByHierarchy("/")).verifyComplete(); - } - - @Test - public void listBlobsHierOptionsCopy() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveCopy(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobsByHierarchy("", options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .assertNext(r -> { - assertEquals(copyName, r.getName()); - assertNotNull(r.getProperties().getCopyId()); - // Comparing the urls isn't reliable because the service may use https. - assertTrue(r.getProperties().getCopySource().contains(normalName)); - assertEquals(CopyStatusType.SUCCESS, r.getProperties().getCopyStatus()); // We waited for the copy to complete. - assertNotNull(r.getProperties().getCopyProgress()); - assertNotNull(r.getProperties().getCopyCompletionTime()); - }) - .expectNextCount(2) //metadata, tags - .verifyComplete(); - } - - @Test - public void listBlobsHierOptionsMetadata() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveMetadata(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobsByHierarchy("", options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .assertNext(r -> { - assertEquals(copyName, r.getName()); - assertNull(r.getProperties().getCopyCompletionTime()); - }) - .assertNext(r -> { - assertEquals(metadataName, r.getName()); - assertEquals("bar", r.getMetadata().get("foo")); - }) - .expectNextCount(1) - .verifyComplete(); //tags - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listBlobsHierOptionsTags() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveTags(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobsByHierarchy("", options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .assertNext(r -> { - assertEquals(copyName, r.getName()); - assertNull(r.getProperties().getCopyCompletionTime()); - }) - .assertNext(r -> { - assertEquals(metadataName, r.getName()); - assertNull(r.getMetadata()); - }) - .assertNext(r -> { - assertEquals(tagValue, r.getTags().get(tagKey)); - assertEquals(1, r.getProperties().getTagCount()); - }) - .verifyComplete(); - } - - @Test - public void listBlobsHierOptionsUncommitted() { - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveUncommittedBlobs(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobsByHierarchy("", options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .expectNextCount(3) - .assertNext(r -> assertEquals(uncommittedName, r.getName())) - .verifyComplete(); - } - - @Test - public void listBlobsHierOptionsprefix() { - ListBlobsOptions options = new ListBlobsOptions().setPrefix("a"); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobsByHierarchy("", options))) - .assertNext(r -> assertEquals(normalName, r.getName())) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - @Test - public void listBlobsHierOptionsmaxResults() { - ListBlobsOptions options = new ListBlobsOptions() - .setDetails(new BlobListDetails().setRetrieveCopy(true).setRetrieveUncommittedBlobs(true)) - .setMaxResultsPerPage(1); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier - .create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobsByHierarchy("", options).byPage().limitRequest(1))) - .assertNext(it -> assertEquals(1, it.getValue().size())) - .verifyComplete(); - } - - @Test - public void listBlobsHierOptionsMaxResultsByPage() { - ListBlobsOptions options = new ListBlobsOptions() - .setDetails(new BlobListDetails().setRetrieveCopy(true).setRetrieveUncommittedBlobs(true)); - String normalName = "a" + generateBlobName(); - String copyName = "c" + generateBlobName(); - String metadataName = "m" + generateBlobName(); - String tagsName = "t" + generateBlobName(); - String uncommittedName = "u" + generateBlobName(); - - StepVerifier.create(setupListBlobsTest(normalName, copyName, metadataName, tagsName, uncommittedName) - .thenMany(ccAsync.listBlobsByHierarchy("", options).byPage(1))).thenConsumeWhile(r -> { - assertEquals(1, r.getValue().size()); - return true; - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void listBlobsHierOptionsDeletedWithVersions() { - String containerName = generateContainerName(); - BlobContainerAsyncClient versionedCC - = versionedBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName); - String blobName = generateBlobName(); - AppendBlobAsyncClient blob = versionedCC.getBlobAsyncClient(blobName).getAppendBlobAsyncClient(); - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - ListBlobsOptions options = new ListBlobsOptions().setPrefix(blobName) - .setDetails(new BlobListDetails().setRetrieveDeletedBlobsWithVersions(true)); - - Flux response = versionedCC.createIfNotExists() - .then(blob.create()) - .then(blob.setMetadata(metadata)) - .then(blob.delete()) - .thenMany(versionedCC.listBlobsByHierarchy("", options)); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(blobName, r.getName()); - assertTrue(r.hasVersionsOnly()); - }).verifyComplete(); - - //cleanup - versionedBlobServiceAsyncClient.deleteBlobContainer(containerName).block(); - } - - @Test - public void listBlobsHierOptionsFail() { - ListBlobsOptions options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveSnapshots(true)) - .setMaxResultsPerPage(5); - - StepVerifier.create(ccAsync.listBlobsByHierarchy(null, options)) - .verifyError(UnsupportedOperationException.class); - } - - @Test - public void listBlobsHierDelim() { - List blobNames = Arrays.asList("a", "b/a", "c", "d/a", "e", "f", "g/a"); - List expectedBlobs = Arrays.asList("a", "c", "e", "f"); - List expectedPrefixes = Arrays.asList("b/", "d/", "g/"); - - Flux createBlob = Flux.fromIterable(blobNames).flatMap(it -> { - AppendBlobAsyncClient bu = ccAsync.getBlobAsyncClient(it).getAppendBlobAsyncClient(); - return bu.create(); - }); - - StepVerifier.create(createBlob.then(ccAsync.listBlobsByHierarchy(null).collect(Collectors.toList()))) - .assertNext(r -> { - Set foundBlobs = new HashSet<>(); - Set foundPrefixes = new HashSet<>(); - r.forEach(blobItem -> { - if (blobItem.isPrefix()) { - foundPrefixes.add(blobItem.getName()); - } else { - foundBlobs.add(blobItem.getName()); - } - }); - - for (String blobName : expectedBlobs) { - assertTrue(foundBlobs.contains(blobName)); - } - - for (String prefix : expectedPrefixes) { - assertTrue(foundPrefixes.contains(prefix)); - } - }) - .verifyComplete(); - } - - @Test - public void listBlobsHierMarker() { - int numBlobs = 10; - int pageSize = 6; - - Mono> createBlob = Flux.range(0, numBlobs).flatMap(i -> { - PageBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - return bc.create(512); - }).collectList(); - - StepVerifier - .create(createBlob.thenMany( - ccAsync.listBlobsByHierarchy("/", new ListBlobsOptions().setMaxResultsPerPage(pageSize)).byPage())) - .assertNext(r -> { - assertEquals(pageSize, r.getValue().size()); - assertNotNull(r.getContinuationToken()); - }) - .assertNext(r -> { - assertEquals(r.getValue().size(), numBlobs - pageSize); - assertNull(r.getContinuationToken()); - }) - .verifyComplete(); - } - - /* - This test requires two accounts that are configured in a very specific way. It is not feasible to setup that - relationship programmatically, so we have recorded a successful interaction and only test recordings. - */ - @PlaybackOnly - @Test - public void listBlobsHierORS() { - BlobContainerAsyncClient sourceContainer = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient("test1"); - BlobContainerAsyncClient destContainer = alternateBlobServiceAsyncClient.getBlobContainerAsyncClient("test2"); - - Mono> sourceBlobs = sourceContainer.listBlobsByHierarchy("/").collect(Collectors.toList()); - Mono> destBlobs = destContainer.listBlobsByHierarchy("/").collect(Collectors.toList()); - - StepVerifier.create(sourceBlobs).assertNext(r -> { - int i = 0; - for (BlobItem blob : r) { - if (i == 1) { - assertNull(blob.getObjectReplicationSourcePolicies()); - } else { - assertTrue(validateOR(blob.getObjectReplicationSourcePolicies())); - } - i++; - } - }).verifyComplete(); - - StepVerifier.create(destBlobs).assertNext(r -> { - /* Service specifies no ors metadata on the dest blobs. */ - for (BlobItem blob : r) { - assertNull(blob.getObjectReplicationSourcePolicies()); - } - }).verifyComplete(); - - } - - @Test - public void listBlobsFlatSimple() { - // setup: "Create 10 page blobs in the container" - int numBlobs = 10; - int pageSize = 3; - - Mono> createBlob = Flux.range(0, numBlobs).flatMap(i -> { - PageBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - return bc.create(512); - }).collectList(); - - // expect: "listing operation will fetch all 10 blobs, despite page size being smaller than 10" - StepVerifier - .create(createBlob.thenMany(ccAsync.listBlobs(new ListBlobsOptions().setMaxResultsPerPage(pageSize)))) - .expectNextCount(numBlobs) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("listBlobsFlatRehydratePrioritySupplier") - public void listBlobsHierRehydratePriority(RehydratePriority rehydratePriority) { - String name = generateBlobName(); - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(name).getBlockBlobAsyncClient(); - - Mono> rehydrate = Mono.empty(); - - if (rehydratePriority != null) { - rehydrate = bc.setAccessTier(AccessTier.ARCHIVE) - .then(bc.setAccessTierWithResponse( - new BlobSetAccessTierOptions(AccessTier.HOT).setPriority(rehydratePriority))); - } - - Flux response = bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(rehydrate) - .thenMany(ccAsync.listBlobsByHierarchy(null)); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(rehydratePriority, r.getProperties().getRehydratePriority())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listAppendBlobsHier() { - String name = generateBlobName(); - AppendBlobAsyncClient bu = ccAsync.getBlobAsyncClient(name).getAppendBlobAsyncClient(); - - Flux response = bu.create() - .then(bu.seal()) - .thenMany(ccAsync.listBlobsByHierarchy(null, new ListBlobsOptions().setPrefix(prefix))); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(name, r.getName()); - assertEquals(BlobType.APPEND_BLOB, r.getProperties().getBlobType()); - assertNull(r.getProperties().getCopyCompletionTime()); - assertNull(r.getProperties().getCopyStatusDescription()); - assertNull(r.getProperties().getCopyId()); - assertNull(r.getProperties().getCopyProgress()); - assertNull(r.getProperties().getCopySource()); - assertNull(r.getProperties().getCopyStatus()); - assertNull(r.getProperties().isIncrementalCopy()); - assertNull(r.getProperties().getDestinationSnapshot()); - assertNull(r.getProperties().getLeaseDuration()); - assertEquals(LeaseStateType.AVAILABLE, r.getProperties().getLeaseState()); - assertEquals(LeaseStatusType.UNLOCKED, r.getProperties().getLeaseStatus()); - assertNotNull(r.getProperties().getContentLength()); - assertNotNull(r.getProperties().getContentType()); - assertNull(r.getProperties().getContentMd5()); - assertNull(r.getProperties().getContentEncoding()); - assertNull(r.getProperties().getContentDisposition()); - assertNull(r.getProperties().getContentLanguage()); - assertNull(r.getProperties().getCacheControl()); - assertNull(r.getProperties().getBlobSequenceNumber()); - assertTrue(r.getProperties().isServerEncrypted()); - assertNull(r.getProperties().isAccessTierInferred()); - assertNull(r.getProperties().getAccessTier()); - assertNull(r.getProperties().getArchiveStatus()); - assertNotNull(r.getProperties().getCreationTime()); - assertTrue(r.getProperties().isSealed()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-02-12") - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void listBlobsHierInvalidXml(boolean delimiter) { - String blobName = "dir1/dir2/file\uFFFE.blob"; - - if (!delimiter) { - StepVerifier.create(ccAsync.getBlobAsyncClient(blobName) - .getAppendBlobAsyncClient() - .create() - .thenMany(ccAsync.listBlobsByHierarchy("", null))).assertNext(r -> { - assertEquals(r.getName(), blobName); - assertEquals(false, r.isPrefix()); - }).verifyComplete(); - } else { - StepVerifier.create(ccAsync.getBlobAsyncClient(blobName) - .getAppendBlobAsyncClient() - .create() - .thenMany(ccAsync.listBlobsByHierarchy(".b", null))).assertNext(r -> { - assertEquals(r.getName(), "dir1/dir2/file\uFFFE.b"); - assertEquals(true, r.isPrefix()); - }).verifyComplete(); - } - } - - @Test - public void listBlobsHierError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(ccAsync.listBlobsByHierarchy(".")).verifyError(BlobStorageException.class); - } - - private Flux setupContainerForListing(BlobContainerAsyncClient containerClient) { - List blobNames - = Arrays.asList("foo", "bar", "baz", "foo/foo", "foo/bar", "baz/foo", "baz/foo/bar", "baz/bar/foo"); - - return Flux.fromIterable(blobNames).flatMap(it -> { - BlockBlobAsyncClient blockBlobClient = containerClient.getBlobAsyncClient(it).getBlockBlobAsyncClient(); - return blockBlobClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void listBlobsHierSegmentWithVersionPrefixAndDelimiter() { - String containerName = generateContainerName(); - BlobContainerAsyncClient versionedCC - = versionedBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName); - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveVersions(true)).setPrefix("baz"); - - Mono> response = versionedCC.createIfNotExists() - .thenMany(setupContainerForListing(versionedCC)) - .then(versionedCC.listBlobsByHierarchy("/", options).collect(Collectors.toList())); - - StepVerifier.create(response).assertNext(r -> { - Set foundBlobs = new HashSet<>(); - Set foundPrefixes = new HashSet<>(); - r.forEach(blobItem -> { - if (blobItem.isPrefix()) { - foundPrefixes.add(blobItem); - } else { - foundBlobs.add(blobItem); - } - }); - assertEquals(1, foundBlobs.size()); - assertEquals(1, foundPrefixes.size()); - BlobItem first = foundBlobs.iterator().next(); - assertEquals("baz", first.getName()); - assertNotNull(first.getVersionId()); - assertEquals("baz/", foundPrefixes.iterator().next().getName()); - }).verifyComplete(); - - //cleanup - versionedBlobServiceAsyncClient.deleteBlobContainer(containerName).block(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsMin() { - StepVerifier.create(ccAsync.findBlobsByTags("\"key\"='value'")).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsQuery() { - BlobAsyncClient blobClient = ccAsync.getBlobAsyncClient(generateBlobName()); - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 10000L; - String query = "\"bar\"='foo'"; - - Flux response - = blobClient - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(Collections.singletonMap("key", "value"))) - .flatMap(r -> { - BlobAsyncClient blobClient2 = ccAsync.getBlobAsyncClient(generateBlobName()); - return blobClient2.uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(Collections.singletonMap("bar", "foo"))); - }) - .flatMap(r -> { - BlobAsyncClient blobClient3 = ccAsync.getBlobAsyncClient(generateBlobName()); - return blobClient3.upload(DATA.getDefaultFlux(), null); - }) - .then(Mono.delay(Duration.ofMillis(delay))) - .thenMany(ccAsync.findBlobsByTags(String.format(query, ccAsync.getBlobContainerName()))); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(1, r.getTags().size()); - assertEquals("foo", r.getTags().get("bar")); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsMarker() { - Map tags = Collections.singletonMap(tagKey, tagValue); - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 10000L; - - Mono uploadBlob = Flux.range(0, 10) - .flatMap(i -> ccAsync.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()).setTags(tags))) - .collectList() - .then(Mono.delay(Duration.ofMillis(delay))); - - Flux>> response - = uploadBlob - .thenMany( - ccAsync.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(5), - null, Context.NONE).byPage().take(1)) - .flatMap(firstPage -> { - String marker = firstPage.getContinuationToken(); - String firstBlobName = firstPage.getValue().iterator().next().getName(); - return Flux.zip(Flux.just(firstBlobName), ccAsync.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(5), - null, Context.NONE).byPage(marker).takeLast(1)); - }); - - StepVerifier.create(response) - .assertNext(secondPage -> assertTrue( - secondPage.getT1().compareTo(secondPage.getT2().getValue().iterator().next().getName()) < 0)) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsMaxResults() { - int numBlobs = 7; - int pageResults = 3; - Map tags = Collections.singletonMap(tagKey, tagValue); - - Mono>> uploadBlob = Flux.range(0, numBlobs) - .flatMap(i -> ccAsync.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()).setTags(tags))) - .collectList(); - - StepVerifier.create(uploadBlob.thenMany(ccAsync.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(pageResults), - null, Context.NONE).byPage())).thenConsumeWhile(r -> { - assertTrue(r.getValue().size() <= pageResults); - return true; - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsMaxResultsByPage() { - int numBlobs = 7; - int pageResults = 3; - Map tags = Collections.singletonMap(tagKey, tagValue); - - Mono>> uploadBlob = Flux.range(0, numBlobs) - .flatMap(i -> ccAsync.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()).setTags(tags))) - .collectList(); - - StepVerifier.create(uploadBlob - .thenMany(ccAsync.findBlobsByTags(new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue))) - .byPage(pageResults))) - .thenConsumeWhile(r -> { - assertTrue(r.getValue().size() <= pageResults); - return true; - }) - .verifyComplete(); - } - - @Test - public void findBlobsError() { - StepVerifier.create(ccAsync.findBlobsByTags("garbageTag").byPage()).verifyError(BlobStorageException.class); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void findBlobsWithTimeoutStillBackedByPagedFlux() { - int numBlobs = 5; - int pageResults = 3; - Map tags = Collections.singletonMap(tagKey, tagValue); - - Mono>> uploadBlob = Flux.range(0, numBlobs) - .flatMap(i -> ccAsync.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags))) - .collectList(); - - // when: "Consume results by page, still have paging functionality" - StepVerifier - .create( - uploadBlob - .thenMany( - ccAsync - .findBlobsByTags(new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)) - .setMaxResultsPerPage(pageResults), Duration.ofSeconds(10), Context.NONE) - .byPage() - .count())) - .expectNextCount(1) - .verifyComplete(); - } - - @ParameterizedTest - @ValueSource(strings = { "中文", "az[]", "hello world", "hello/world", "hello&world", "!*'();:@&=+/$,/?#[]" }) - public void createURLSpecialChars(String name) { - // This test checks that we encode special characters in blob names correctly. - AppendBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(name).getAppendBlobAsyncClient(); - PageBlobAsyncClient bu3 = ccAsync.getBlobAsyncClient(name + "2").getPageBlobAsyncClient(); - BlockBlobAsyncClient bu4 = ccAsync.getBlobAsyncClient(name + "3").getBlockBlobAsyncClient(); - BlockBlobAsyncClient bu5 = ccAsync.getBlobAsyncClient(name).getBlockBlobAsyncClient(); - - assertAsyncResponseStatusCode(bu2.createWithResponse(null, null, null), 201); - assertAsyncResponseStatusCode(bu5.getPropertiesWithResponse(null), 200); - assertAsyncResponseStatusCode(bu3.createWithResponse(512, null, null, null, null), 201); - assertAsyncResponseStatusCode( - bu4.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null, null, null, null), - 201); - - StepVerifier.create(ccAsync.listBlobs()) - .assertNext(r -> assertEquals(name, r.getName())) - .assertNext(r -> assertEquals(name + "2", r.getName())) - .assertNext(r -> assertEquals(name + "3", r.getName())) - .verifyComplete(); - } - - @ParameterizedTest - @ValueSource( - strings = { - "%E4%B8%AD%E6%96%87", - "az%5B%5D", - "hello%20world", - "hello%2Fworld", - "hello%26world", - "%21%2A%27%28%29%3B%3A%40%26%3D%2B%24%2C%2F%3F%23%5B%5D" }) - public void createURLSpecialCharsEncoded(String name) { - // This test checks that we handle blob names with encoded special characters correctly. - AppendBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(name).getAppendBlobAsyncClient(); - PageBlobAsyncClient bu3 = ccAsync.getBlobAsyncClient(name + "2").getPageBlobAsyncClient(); - BlockBlobAsyncClient bu4 = ccAsync.getBlobAsyncClient(name + "3").getBlockBlobAsyncClient(); - BlockBlobAsyncClient bu5 = ccAsync.getBlobAsyncClient(name).getBlockBlobAsyncClient(); - - assertAsyncResponseStatusCode(bu2.createWithResponse(null, null, null), 201); - assertAsyncResponseStatusCode(bu5.getPropertiesWithResponse(null), 200); - assertAsyncResponseStatusCode(bu3.createWithResponse(512, null, null, null, null), 201); - assertAsyncResponseStatusCode( - bu4.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null, null, null, null), - 201); - - StepVerifier.create(ccAsync.listBlobs()) - .assertNext(r -> assertEquals(name, r.getName())) - .assertNext(r -> assertEquals(name + "2", r.getName())) - .assertNext(r -> assertEquals(name + "3", r.getName())) - .verifyComplete(); - } - - @Test - public void rootExplicit() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(BlobContainerClient.ROOT_CONTAINER_NAME); - // create root container if not exist. - Mono create = ccAsync.exists().flatMap(r -> { - if (!r) { - return ccAsync.create(); - } - return Mono.empty(); - }); - - AppendBlobAsyncClient bu = ccAsync.getBlobAsyncClient("rootblob").getAppendBlobAsyncClient(); - assertAsyncResponseStatusCode(create.then(bu.createWithResponse(null, null, null)), 201); - } - - @Test - public void rootExplicitInEndpoint() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(BlobContainerClient.ROOT_CONTAINER_NAME); - // create root container if not exist. - Mono create = ccAsync.exists().flatMap(r -> { - if (!r) { - return ccAsync.create(); - } - return Mono.empty(); - }); - - AppendBlobAsyncClient bu = ccAsync.getBlobAsyncClient("rootblob").getAppendBlobAsyncClient(); - assertAsyncResponseStatusCode(create.then(bu.createWithResponse(null, null, null)), 201); - StepVerifier.create(bu.getPropertiesWithResponse(null)).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(BlobType.APPEND_BLOB, r.getValue().getBlobType()); - }).verifyComplete(); - } - - @Test - public void blobClientBuilderRootImplicit() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(BlobContainerClient.ROOT_CONTAINER_NAME); - // createroot container if not exist. - Mono create = ccAsync.exists().flatMap(r -> { - if (!r) { - return ccAsync.create(); - } - return Mono.empty(); - }); - - AppendBlobAsyncClient bc - = instrument(new BlobClientBuilder().credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .blobName("rootblob")).buildAsyncClient().getAppendBlobAsyncClient(); - - assertAsyncResponseStatusCode(create.then(bc.createWithResponse(null, null, null)), 201); - - StepVerifier.create(bc.getPropertiesWithResponse(null)).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(BlobType.APPEND_BLOB, r.getValue().getBlobType()); - }).verifyComplete(); - } - - @Test - public void containerClientBuilderRootImplicit() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(BlobContainerClient.ROOT_CONTAINER_NAME); - // create root container if not exist. - Mono create = ccAsync.exists().flatMap(r -> { - if (!r) { - return ccAsync.create(); - } - return Mono.empty(); - }); - - ccAsync - = instrument(new BlobContainerClientBuilder().credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .containerName(null)).buildAsyncClient(); - - StepVerifier.create(create.then(ccAsync.getProperties())) - .assertNext(Assertions::assertNotNull) - .verifyComplete(); - - assertEquals(BlobContainerAsyncClient.ROOT_CONTAINER_NAME, ccAsync.getBlobContainerName()); - - AppendBlobAsyncClient bc = ccAsync.getBlobAsyncClient("rootblob").getAppendBlobAsyncClient(); - - StepVerifier.create(bc.create(true).then(bc.exists())).expectNext(true).verifyComplete(); - } - - @Test - public void serviceClientImplicitRoot() { - assertEquals(primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(null).getBlobContainerName(), - BlobContainerAsyncClient.ROOT_CONTAINER_NAME); - assertEquals(primaryBlobServiceAsyncClient.getBlobContainerAsyncClient("").getBlobContainerName(), - BlobContainerAsyncClient.ROOT_CONTAINER_NAME); - } - - @Test - public void webContainer() { - ccAsync = primaryBlobServiceAsyncClient - .getBlobContainerAsyncClient(BlobContainerClient.STATIC_WEBSITE_CONTAINER_NAME); - // create root container if not exist. - Mono create = ccAsync.exists().flatMap(r -> { - if (!r) { - return ccAsync.create(); - } - return Mono.empty(); - }); - - BlobContainerAsyncClient webContainer = primaryBlobServiceAsyncClient - .getBlobContainerAsyncClient(BlobContainerClient.STATIC_WEBSITE_CONTAINER_NAME); - - // Validate some basic operation. - StepVerifier.create(create.then(webContainer.setAccessPolicy(null, null))).verifyComplete(); - } - - @Test - public void getAccountInfo() { - StepVerifier.create(premiumBlobServiceAsyncClient.getAccountInfoWithResponse()).assertNext(r -> { - assertNotNull(r.getHeaders().getValue(HttpHeaderName.DATE)); - assertNotNull(r.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(r.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(r.getValue().getAccountKind()); - assertNotNull(r.getValue().getSkuName()); - }).verifyComplete(); - } - - @Test - public void getAccountInfoMin() { - assertAsyncResponseStatusCode(primaryBlobServiceAsyncClient.getAccountInfoWithResponse(), 200); - } - - @Test - public void getAccountInfoBase() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - - StepVerifier.create(ccAsync.getAccountInfo()).assertNext(r -> { - assertNotNull(r.getAccountKind()); - assertNotNull(r.getSkuName()); - assertFalse(r.isHierarchicalNamespaceEnabled()); - }).verifyComplete(); - } - - @Test - public void getAccountInfoBaseFail() { - BlobServiceAsyncClient serviceClient - = instrument(new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(new MockTokenCredential())).buildAsyncClient(); - - BlobContainerAsyncClient containerClient = serviceClient.getBlobContainerAsyncClient(generateContainerName()); - - StepVerifier.create(containerClient.getAccountInfo()).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.INVALID_AUTHENTICATION_INFO, e.getErrorCode()); - }); - } - - @Test - public void getContainerName() { - String containerName = generateContainerName(); - BlobContainerAsyncClient newcc = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName); - assertEquals(containerName, newcc.getBlobContainerName()); - } - - @Test - public void builderCpkValidation() { - URL endpoint = BlobUrlParts.parse(ccAsync.getBlobContainerUrl()).setScheme("http").toUrl(); - BlobContainerClientBuilder builder = new BlobContainerClientBuilder() - .customerProvidedKey(new CustomerProvidedKey(Base64.getEncoder().encodeToString(getRandomByteArray(256)))) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildAsyncClient); - } - - @Test - public void builderBearerTokenValidation() { - URL endpoint = BlobUrlParts.parse(ccAsync.getBlobContainerUrl()).setScheme("http").toUrl(); - BlobContainerClientBuilder builder - = new BlobContainerClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildAsyncClient); - } - - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - @Test - public void perCallPolicy() { - BlobContainerAsyncClient containerClient = getContainerClientBuilder(ccAsync.getBlobContainerUrl()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .addPolicy(getPerCallVersionPolicy()) - .buildAsyncClient(); - - StepVerifier.create(containerClient.getPropertiesWithResponse(null)) - .assertNext(r -> assertEquals("2017-11-09", r.getHeaders().getValue(X_MS_VERSION))) - .verifyComplete(); - } - - @Test - public void defaultAudience() { - BlobContainerAsyncClient aadContainer - = getContainerClientBuilderWithTokenCredential(ccAsync.getBlobContainerUrl()).audience(null) - .buildAsyncClient(); - - StepVerifier.create(aadContainer.exists()).expectNext(true); - } - - @Test - public void storageAccountAudience() { - BlobContainerAsyncClient aadContainer - = getContainerClientBuilderWithTokenCredential(ccAsync.getBlobContainerUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(ccAsync.getAccountName())) - .buildAsyncClient(); - - StepVerifier.create(aadContainer.exists()).expectNext(true); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - BlobContainerAsyncClient aadContainer - = getContainerClientBuilderWithTokenCredential(ccAsync.getBlobContainerUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildAsyncClient(); - - StepVerifier.create(aadContainer.exists()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", ccAsync.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - BlobContainerAsyncClient aadContainer - = getContainerClientBuilderWithTokenCredential(ccAsync.getBlobContainerUrl()).audience(audience) - .buildAsyncClient(); - - StepVerifier.create(aadContainer.exists()).expectNext(true); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/FakeCredentialInTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/FakeCredentialInTests.java deleted file mode 100644 index c3f88efffdc4..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/FakeCredentialInTests.java +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -/** - * Fake credential shared in Tests - */ -public class FakeCredentialInTests { - /** - * Fake Storage SAS signature value used in test - */ - public static final String FAKE_SIGNATURE_PLACEHOLDER = "sD3fPKLnFKZUjnSV4qA%2FXoJOqsmDfNfxWcZ7kPtLc0I%3D"; -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningAsyncTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningAsyncTests.java deleted file mode 100644 index bac330eb9d0f..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningAsyncTests.java +++ /dev/null @@ -1,821 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.credential.TokenCredential; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; -import com.azure.core.test.TestMode; -import com.azure.core.test.utils.MockTokenCredential; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.polling.PollerFlux; -import com.azure.identity.AzureCliCredentialBuilder; -import com.azure.identity.AzureDeveloperCliCredentialBuilder; -import com.azure.identity.AzurePipelinesCredentialBuilder; -import com.azure.identity.AzurePowerShellCredentialBuilder; -import com.azure.identity.ChainedTokenCredentialBuilder; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.identity.EnvironmentCredentialBuilder; -import com.azure.json.JsonProviders; -import com.azure.json.JsonWriter; -import com.azure.storage.blob.models.BlobContainerProperties; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobItemProperties; -import com.azure.storage.blob.models.BlobListDetails; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.ListBlobContainersOptions; -import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.AppendBlobCreateOptions; -import com.azure.storage.blob.options.BlobBeginCopyOptions; -import com.azure.storage.blob.options.BlobBreakLeaseOptions; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobAsyncClient; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.blob.specialized.PageBlobAsyncClient; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.UUID; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ImmutableStorageWithVersioningAsyncTests extends BlobTestBase { - private static String vlwContainerName; - private static final String ACCOUNT_NAME = ENVIRONMENT.getVersionedAccount().getName(); - private static final String RESOURCE_GROUP_NAME = ENVIRONMENT.getResourceGroupName(); - private static final String SUBSCRIPTION_ID = ENVIRONMENT.getSubscriptionId(); - private static final String API_VERSION = "2021-04-01"; - private static final TokenCredential CREDENTIAL = getTokenCredential(ENVIRONMENT.getTestMode()); - private static final BearerTokenAuthenticationPolicy CREDENTIAL_POLICY - = new BearerTokenAuthenticationPolicy(CREDENTIAL, "https://management.azure.com/.default"); - private BlobContainerAsyncClient vlwContainer; - private BlobAsyncClient vlwBlob; - - @BeforeAll - public static void setupSpec() throws IOException { - if (ENVIRONMENT.getTestMode() != TestMode.PLAYBACK) { - vlwContainerName = UUID.randomUUID().toString(); - - String url = String.format( - "https://management.azure.com/subscriptions/%s/resourceGroups/%s/providers/" - + "Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s?api-version=%s", - SUBSCRIPTION_ID, RESOURCE_GROUP_NAME, ACCOUNT_NAME, vlwContainerName, API_VERSION); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(CREDENTIAL_POLICY).build(); - - ImmutableStorageWithVersioningTests.ImmutableStorageWithVersioning immutableStorageWithVersioning - = new ImmutableStorageWithVersioningTests.ImmutableStorageWithVersioning(); - immutableStorageWithVersioning.setEnabled(true); - ImmutableStorageWithVersioningTests.Properties properties - = new ImmutableStorageWithVersioningTests.Properties(); - properties.setImmutableStorageWithVersioning(immutableStorageWithVersioning); - ImmutableStorageWithVersioningTests.Body body = new ImmutableStorageWithVersioningTests.Body(); - body.setId(String.format( - "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/" - + "%s/blobServices/default/containers/%s", - SUBSCRIPTION_ID, RESOURCE_GROUP_NAME, ACCOUNT_NAME, vlwContainerName)); - body.setName(vlwContainerName); - body.setType("Microsoft.Storage/storageAccounts/blobServices/containers"); - body.setProperties(properties); - - ByteArrayOutputStream json = new ByteArrayOutputStream(); - try (JsonWriter jsonWriter = JsonProviders.createWriter(json)) { - body.toJson(jsonWriter); - } - - HttpResponse response = httpPipeline.send(new HttpRequest(HttpMethod.PUT, new URL(url), new HttpHeaders(), - Flux.just(ByteBuffer.wrap(json.toByteArray())))).block(); - assertNotNull(response); - if (response.getStatusCode() != 201) { - LOGGER.warning(response.getBodyAsString().block()); - } - assertEquals(201, response.getStatusCode()); - } - } - - @BeforeEach - public void setup() { - vlwContainer = versionedBlobServiceAsyncClient - .getBlobContainerAsyncClient(testResourceNamer.recordValueFromConfig(vlwContainerName)); - vlwBlob = vlwContainer.getBlobAsyncClient(generateBlobName()); - vlwBlob.upload(Flux.just(ByteBuffer.wrap(new byte[0])), null).block(); - } - - @AfterAll - public static void cleanupSpec() throws MalformedURLException { - if (ENVIRONMENT.getTestMode() != TestMode.PLAYBACK) { - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(CREDENTIAL_POLICY).build(); - BlobServiceClient cleanupClient - = new BlobServiceClientBuilder().credential(ENVIRONMENT.getVersionedAccount().getCredential()) - .endpoint(ENVIRONMENT.getVersionedAccount().getBlobEndpoint()) - .buildClient(); - - BlobContainerClient containerClient = cleanupClient.getBlobContainerClient(vlwContainerName); - BlobContainerProperties containerProperties = containerClient.getProperties(); - - if (containerProperties.getLeaseState() == LeaseStateType.LEASED) { - createLeaseClient(containerClient).breakLeaseWithResponse( - new BlobBreakLeaseOptions().setBreakPeriod(Duration.ofSeconds(0)), null, null); - } - if (containerProperties.isImmutableStorageWithVersioningEnabled()) { - ListBlobsOptions options = new ListBlobsOptions() - .setDetails(new BlobListDetails().setRetrieveImmutabilityPolicy(true).setRetrieveLegalHold(true)); - for (BlobItem blob : containerClient.listBlobs(options, null)) { - BlobClient blobClient = containerClient.getBlobClient(blob.getName()); - BlobItemProperties blobProperties = blob.getProperties(); - if (Objects.equals(true, blobProperties.hasLegalHold())) { - blobClient.setLegalHold(false); - } - if (blobProperties.getImmutabilityPolicy().getPolicyMode() != null) { - blobClient.deleteImmutabilityPolicy(); - } - blobClient.delete(); - } - } - - String url = String.format( - "https://management.azure.com/subscriptions/%s/resourceGroups/%s/providers/" - + "Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s?api-version=%s", - SUBSCRIPTION_ID, RESOURCE_GROUP_NAME, ACCOUNT_NAME, vlwContainerName, API_VERSION); - HttpResponse response - = httpPipeline.send(new HttpRequest(HttpMethod.DELETE, new URL(url), new HttpHeaders(), Flux.empty())) - .block(); - assertNotNull(response); - if (response.getStatusCode() != 200) { - LOGGER.warning(response.getBodyAsString().block()); - } - assertEquals(200, response.getStatusCode()); - } - } - - public static TokenCredential getTokenCredential(TestMode testMode) { - if (testMode == TestMode.RECORD) { - return new DefaultAzureCredentialBuilder().build(); - } else if (testMode == TestMode.LIVE) { - Configuration config = Configuration.getGlobalConfiguration(); - - ChainedTokenCredentialBuilder builder - = new ChainedTokenCredentialBuilder().addLast(new EnvironmentCredentialBuilder().build()) - .addLast(new AzureCliCredentialBuilder().build()) - .addLast(new AzureDeveloperCliCredentialBuilder().build()); - - String serviceConnectionId = config.get("AZURESUBSCRIPTION_SERVICE_CONNECTION_ID"); - String clientId = config.get("AZURESUBSCRIPTION_CLIENT_ID"); - String tenantId = config.get("AZURESUBSCRIPTION_TENANT_ID"); - String systemAccessToken = config.get("SYSTEM_ACCESSTOKEN"); - - if (!CoreUtils.isNullOrEmpty(serviceConnectionId) - && !CoreUtils.isNullOrEmpty(clientId) - && !CoreUtils.isNullOrEmpty(tenantId) - && !CoreUtils.isNullOrEmpty(systemAccessToken)) { - - builder.addLast(new AzurePipelinesCredentialBuilder().systemAccessToken(systemAccessToken) - .clientId(clientId) - .tenantId(tenantId) - .serviceConnectionId(serviceConnectionId) - .build()); - } - - builder.addLast(new AzurePowerShellCredentialBuilder().build()); - - return builder.build(); - } else { //playback or not set - return new MockTokenCredential(); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyMin() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - - StepVerifier.create(vlwBlob.setImmutabilityPolicy(immutabilityPolicy)).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, r.getPolicyMode()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicy() { - BlobImmutabilityPolicyMode policyMode = BlobImmutabilityPolicyMode.UNLOCKED; - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(policyMode); - - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - - // when: "set immutability policy" - StepVerifier.create(vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, null)).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getValue().getExpiryTime()); - assertEquals(policyMode, r.getValue().getPolicyMode()); - }).verifyComplete(); - - // when: "get properties" - StepVerifier.create(vlwBlob.getProperties()).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getImmutabilityPolicy().getExpiryTime()); - assertEquals(policyMode, r.getImmutabilityPolicy().getPolicyMode()); - }).verifyComplete(); - - // when: "list blob" - ListBlobsOptions options = new ListBlobsOptions().setPrefix(vlwBlob.getBlobName()) - .setDetails(new BlobListDetails().setRetrieveImmutabilityPolicy(true).setRetrieveLegalHold(true)); - StepVerifier.create(vlwContainer.listBlobs(options, null)).assertNext(r -> { - assertEquals(vlwBlob.getBlobName(), r.getName()); - assertEquals(expectedImmutabilityPolicyExpiry, r.getProperties().getImmutabilityPolicy().getExpiryTime()); - assertEquals(policyMode, r.getProperties().getImmutabilityPolicy().getPolicyMode()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyAC() { - List unmodifiedDates = Arrays.asList(null, NEW_DATE); - - for (OffsetDateTime unmodified : unmodifiedDates) { - BlobRequestConditions bac = new BlobRequestConditions().setIfUnmodifiedSince(unmodified); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy().setExpiryTime(expiryTime) - .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - assertAsyncResponseStatusCode(vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, bac), 200); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyACFail() { - BlobRequestConditions bac = new BlobRequestConditions().setIfUnmodifiedSince(OLD_DATE); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier.create(vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, bac)) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.CONDITION_NOT_MET, e.getErrorCode()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @ParameterizedTest - @MethodSource("setImmutabilityPolicyACIASupplier") - public void setImmutabilityPolicyACIA(String leaseId, String tags, String ifMatch, String ifNoneMatch, - OffsetDateTime ifModifiedSince, String wrongCondition) { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseId) - .setTagsConditions(tags) - .setIfMatch(ifMatch) - .setIfNoneMatch(ifNoneMatch) - .setIfModifiedSince(ifModifiedSince); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier.create(vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, bac)) - .verifyErrorSatisfies(r -> { - IllegalArgumentException e = assertInstanceOf(IllegalArgumentException.class, r); - assertEquals( - String.format("%s does not support the %s request condition(s) for parameter 'requestConditions'.", - "setImmutabilityPolicy(WithResponse)", wrongCondition), - e.getMessage()); - }); - } - - private static Stream setImmutabilityPolicyACIASupplier() { - return Stream.of(Arguments.of("leaseId", null, null, null, null, "LeaseId"), - Arguments.of(null, "tagsConditions", null, null, null, "TagsConditions"), - Arguments.of(null, null, "ifMatch", null, null, "IfMatch"), - Arguments.of(null, null, null, "ifNoneMatch", null, "IfNoneMatch"), - Arguments.of(null, null, null, null, OLD_DATE, "IfModifiedSince"), - Arguments.of("leaseId", "tagsConditions", "ifMatch", "ifNoneMatch", OLD_DATE, - "LeaseId, TagsConditions, " + "IfModifiedSince, IfMatch, IfNoneMatch")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyError() { - BlobAsyncClient blob = vlwContainer.getBlobAsyncClient(generateBlobName()); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier.create(blob.setImmutabilityPolicyWithResponse(immutabilityPolicy, null)) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.BLOB_NOT_FOUND, e.getErrorCode()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyIA() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.MUTABLE); - - StepVerifier.create(vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, null)) - .verifyErrorSatisfies(r -> { - IllegalArgumentException e = assertInstanceOf(IllegalArgumentException.class, r); - assertEquals("immutabilityPolicy.policyMode must be Locked or Unlocked", e.getMessage()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void deleteImmutabilityPolicyMin() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier.create(vlwBlob.setImmutabilityPolicy(immutabilityPolicy) - .then(vlwBlob.deleteImmutabilityPolicy()) - .then(vlwBlob.getProperties())).assertNext(r -> { - assertNull(r.getImmutabilityPolicy().getPolicyMode()); - assertNull(r.getImmutabilityPolicy().getExpiryTime()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void deleteImmutabilityPolicy() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier.create(vlwBlob.setImmutabilityPolicy(immutabilityPolicy) - .then(vlwBlob.deleteImmutabilityPolicyWithResponse()) - .then(vlwBlob.getProperties())).assertNext(r -> { - assertNull(r.getImmutabilityPolicy().getPolicyMode()); - assertNull(r.getImmutabilityPolicy().getExpiryTime()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void deleteImmutabilityPolicyError() { - BlobAsyncClient blobClient = vlwContainer.getBlobAsyncClient(generateBlobName()); - StepVerifier.create(blobClient.deleteImmutabilityPolicyWithResponse()).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.BLOB_NOT_FOUND, e.getErrorCode()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void setLegalHoldMin(boolean legalHold) { - StepVerifier.create(vlwBlob.setLegalHold(legalHold)) - .assertNext(r -> assertEquals(legalHold, r.hasLegalHold())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void setLegalHold(boolean legalHold) { - // when: "set legal hold" - StepVerifier.create(vlwBlob.setLegalHoldWithResponse(legalHold)) - .assertNext(r -> assertEquals(legalHold, r.getValue().hasLegalHold())) - .verifyComplete(); - - // when: "get properties" - StepVerifier.create(vlwBlob.getProperties()) - .assertNext(r -> assertEquals(legalHold, r.hasLegalHold())) - .verifyComplete(); - - // when: "list blob" - ListBlobsOptions options = new ListBlobsOptions().setPrefix(vlwBlob.getBlobName()) - .setDetails(new BlobListDetails().setRetrieveImmutabilityPolicy(true).setRetrieveLegalHold(true)); - StepVerifier.create(vlwContainer.listBlobs(options, null)).assertNext(r -> { - assertEquals(vlwBlob.getBlobName(), r.getName()); - assertEquals(legalHold, r.getProperties().hasLegalHold()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setLegalHoldError() { - BlobAsyncClient blob = vlwContainer.getBlobAsyncClient(generateBlobName()); - - StepVerifier.create(blob.setLegalHoldWithResponse(false)).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.BLOB_NOT_FOUND, e.getErrorCode()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void containerProperties() { - StepVerifier.create(vlwContainer.getProperties()) - .assertNext(r -> assertTrue(r.isImmutableStorageWithVersioningEnabled())) - .verifyComplete(); - - StepVerifier - .create(vlwContainer.getServiceAsyncClient() - .listBlobContainers(new ListBlobContainersOptions().setPrefix(vlwContainer.getBlobContainerName()))) - .assertNext(r -> assertTrue(r.getProperties().isImmutableStorageWithVersioningEnabled())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void appendBlobCreate() { - AppendBlobAsyncClient appendBlob - = vlwContainer.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier.create(appendBlob - .createWithResponse( - new AppendBlobCreateOptions().setImmutabilityPolicy(immutabilityPolicy).setLegalHold(true)) - .then(appendBlob.getProperties())).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, r.getImmutabilityPolicy().getPolicyMode()); - assertTrue(r.hasLegalHold()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void pageBlobCreate() { - PageBlobAsyncClient pageBlob = vlwContainer.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier.create(pageBlob - .createWithResponse( - new PageBlobCreateOptions(512).setImmutabilityPolicy(immutabilityPolicy).setLegalHold(true)) - .then(pageBlob.getProperties())).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, r.getImmutabilityPolicy().getPolicyMode()); - assertTrue(r.hasLegalHold()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void blockBlobCommitBlockList() { - BlockBlobAsyncClient blockBlob = vlwBlob.getBlockBlobAsyncClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier - .create( - blockBlob - .commitBlockListWithResponse( - new BlockBlobCommitBlockListOptions(new ArrayList<>()).setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true)) - .then(blockBlob.getProperties())) - .assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, r.getImmutabilityPolicy().getPolicyMode()); - assertTrue(r.hasLegalHold()); - }) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void blockBlobUpload() { - BlockBlobAsyncClient blockBlob = vlwBlob.getBlockBlobAsyncClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier - .create( - blockBlob - .uploadWithResponse( - new BlockBlobSimpleUploadOptions(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true)) - .then(blockBlob.getProperties())) - .assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, r.getImmutabilityPolicy().getPolicyMode()); - assertTrue(r.hasLegalHold()); - }) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @LiveOnly - @ParameterizedTest - @MethodSource("blobUploadSupplier") - public void blobUpload(Long blockSize) { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - StepVerifier.create(vlwBlob.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultFlux()) - .setParallelTransferOptions( - new ParallelTransferOptions().setBlockSizeLong(blockSize).setMaxSingleUploadSizeLong(blockSize)) - .setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true)).then(vlwBlob.getProperties())).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, r.getImmutabilityPolicy().getPolicyMode()); - assertTrue(r.hasLegalHold()); - }).verifyComplete(); - } - - private static Stream blobUploadSupplier() { - return Stream.of(Arguments.of(1L), Arguments.of((Long) null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void syncCopy() { - BlockBlobAsyncClient destination - = vlwContainer.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - String sas = vlwBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono response = destination.copyFromUrlWithResponse( - new BlobCopyFromUrlOptions(vlwBlob.getBlobUrl() + "?" + sas).setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true)) - .then(destination.getProperties()); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, r.getImmutabilityPolicy().getPolicyMode()); - assertTrue(r.hasLegalHold()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void copy() { - BlockBlobAsyncClient destination - = vlwContainer.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - PollerFlux poller = setPlaybackPollerFluxPollInterval(destination - .beginCopy(new BlobBeginCopyOptions(vlwBlob.getBlobUrl()).setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true))); - - Mono response = poller.then(destination.getProperties()); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, r.getImmutabilityPolicy().getPolicyMode()); - assertTrue(r.hasLegalHold()); - }).verifyComplete(); - } - - /* SAS tests */ - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void accountSas() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasPermission permissions = AccountSasPermission.parse("rwdxlacuptfi"); - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resource = new AccountSasResourceType().setObject(true).setContainer(true); - AccountSasSignatureValues sasValues = new AccountSasSignatureValues(expiryTime, permissions, service, resource); - expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - String sas = versionedBlobServiceAsyncClient.generateAccountSas(sasValues); - BlobAsyncClient client - = getBlobAsyncClient(sas, vlwContainer.getBlobContainerUrl(), vlwBlob.getBlobName(), null); - - StepVerifier.create(client.setImmutabilityPolicy(immutabilityPolicy)).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, r.getPolicyMode()); - }).verifyComplete(); - - StepVerifier.create(client.setLegalHold(false)).assertNext(r -> assertFalse(r.hasLegalHold())).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void containerSas() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobContainerSasPermission permissions = BlobContainerSasPermission.parse("racwdxltmei"); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - String sas = vlwContainer.generateSas(sasValues); - BlobAsyncClient client - = getBlobAsyncClient(sas, vlwContainer.getBlobContainerUrl(), vlwBlob.getBlobName(), null); - - StepVerifier.create(client.setImmutabilityPolicy(immutabilityPolicy)).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED.toString(), r.getPolicyMode().toString()); - }).verifyComplete(); - - StepVerifier.create(client.setLegalHold(false)).assertNext(r -> assertFalse(r.hasLegalHold())).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void blobSas() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobSasPermission permissions = BlobSasPermission.parse("racwdxtlmei"); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - String sas = vlwBlob.generateSas(sasValues); - BlobAsyncClient client - = getBlobAsyncClient(sas, vlwContainer.getBlobContainerUrl(), vlwBlob.getBlobName(), null); - - StepVerifier.create(client.setImmutabilityPolicy(immutabilityPolicy)).assertNext(r -> { - assertEquals(expectedImmutabilityPolicyExpiry, r.getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED.toString(), r.getPolicyMode().toString()); - }).verifyComplete(); - - StepVerifier.create(client.setLegalHold(false)).assertNext(r -> assertFalse(r.hasLegalHold())).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-06-12") - @Test - public void testVersionBlobImmutabilityExpiry() { - OffsetDateTime time1 = testResourceNamer.now().plusDays(3); - OffsetDateTime time2 = testResourceNamer.now().plusDays(4); - - Mono response = vlwBlob.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .flatMap(r1 -> vlwBlob.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .flatMap(r2 -> { - BlobAsyncClient oldBlob = vlwBlob.getVersionClient(r1.getVersionId()); - BlobAsyncClient newBlob = vlwBlob.getVersionClient(r2.getVersionId()); - - BlobImmutabilityPolicy policy1 = new BlobImmutabilityPolicy().setExpiryTime(time1); - BlobImmutabilityPolicy policy2 = new BlobImmutabilityPolicy().setExpiryTime(time2); - - return oldBlob.setImmutabilityPolicy(policy1) - .then(newBlob.setImmutabilityPolicy(policy2)) - .then(Mono.zip(oldBlob.getProperties(), newBlob.getProperties())) - .flatMap(propTuple -> { - assertEquals(policy1.getExpiryTime().truncatedTo(ChronoUnit.SECONDS), - propTuple.getT1().getImmutabilityPolicy().getExpiryTime()); - assertEquals(policy2.getExpiryTime().truncatedTo(ChronoUnit.SECONDS), - propTuple.getT2().getImmutabilityPolicy().getExpiryTime()); - //cleanup - return oldBlob.deleteImmutabilityPolicy().then(oldBlob.delete()); - }); - })); - - StepVerifier.create(response).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-06-12") - @Test - public void testImmutabilitySnapshot() { - OffsetDateTime time1 = testResourceNamer.now().plusDays(3); - OffsetDateTime time2 = testResourceNamer.now().plusDays(4); - - Mono response = vlwBlob.createSnapshot().flatMap(snapshotBlob -> { - BlobImmutabilityPolicy policy1 = new BlobImmutabilityPolicy().setExpiryTime(time1); - BlobImmutabilityPolicy policy2 = new BlobImmutabilityPolicy().setExpiryTime(time2); - - return vlwBlob.setImmutabilityPolicy(policy1) - .then(snapshotBlob.setImmutabilityPolicy(policy2)) - .then(Mono.zip(vlwBlob.getProperties(), snapshotBlob.getProperties())) - .flatMap(propTuple -> { - assertEquals(policy1.getExpiryTime().truncatedTo(ChronoUnit.SECONDS), - propTuple.getT1().getImmutabilityPolicy().getExpiryTime()); - assertEquals(policy2.getExpiryTime().truncatedTo(ChronoUnit.SECONDS), - propTuple.getT2().getImmutabilityPolicy().getExpiryTime()); - //cleanup - return snapshotBlob.deleteImmutabilityPolicy().then(snapshotBlob.delete()); - }); - }); - - StepVerifier.create(response).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-06-12") - @Test - public void testLegalHoldVersion() { - Mono response = vlwBlob.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .flatMap(r1 -> vlwBlob.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .flatMap(r2 -> { - BlobAsyncClient oldBlob = vlwBlob.getVersionClient(r1.getVersionId()); - BlobAsyncClient newBlob = vlwBlob.getVersionClient(r2.getVersionId()); - - return oldBlob.setLegalHold(true).flatMap(r -> { - assertTrue(r.hasLegalHold()); - return Mono.empty(); - }).then(oldBlob.getProperties()).flatMap(r -> { - assertTrue(r.hasLegalHold()); - return Mono.empty(); - }).then(newBlob.getProperties()).flatMap(r -> { - assertNull(r.hasLegalHold()); - return Mono.empty(); - }).then(oldBlob.setLegalHold(false)).then(oldBlob.delete()); - })); - - StepVerifier.create(response).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-06-12") - @Test - public void testLegalHoldSnapshot() { - Mono response = vlwBlob.createSnapshot().flatMap(snapshotBlob -> vlwBlob.setLegalHold(true).flatMap(r -> { - assertTrue(r.hasLegalHold()); - return snapshotBlob.getProperties().flatMap(props -> { - assertNull(props.hasLegalHold()); - //cleanup - return snapshotBlob.setLegalHold(false).then(snapshotBlob.delete()); - }); - })); - - StepVerifier.create(response).verifyComplete(); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTests.java deleted file mode 100644 index b572c1ee3167..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTests.java +++ /dev/null @@ -1,864 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.credential.TokenCredential; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; -import com.azure.core.http.rest.Response; -import com.azure.core.test.TestMode; -import com.azure.core.test.utils.MockTokenCredential; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.AzureCliCredentialBuilder; -import com.azure.identity.AzureDeveloperCliCredentialBuilder; -import com.azure.identity.AzurePipelinesCredentialBuilder; -import com.azure.identity.AzurePowerShellCredentialBuilder; -import com.azure.identity.ChainedTokenCredentialBuilder; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.identity.EnvironmentCredentialBuilder; -import com.azure.json.JsonProviders; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonWriter; -import com.azure.storage.blob.models.BlobContainerItem; -import com.azure.storage.blob.models.BlobContainerProperties; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobImmutabilityPolicy; -import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobItemProperties; -import com.azure.storage.blob.models.BlobLegalHoldResult; -import com.azure.storage.blob.models.BlobListDetails; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.models.ListBlobContainersOptions; -import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.AppendBlobCreateOptions; -import com.azure.storage.blob.options.BlobBeginCopyOptions; -import com.azure.storage.blob.options.BlobBreakLeaseOptions; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlobClientBase; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Flux; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ImmutableStorageWithVersioningTests extends BlobTestBase { - private static String vlwContainerName; - private static final String ACCOUNT_NAME = ENVIRONMENT.getVersionedAccount().getName(); - private static final String RESOURCE_GROUP_NAME = ENVIRONMENT.getResourceGroupName(); - private static final String SUBSCRIPTION_ID = ENVIRONMENT.getSubscriptionId(); - private static final String API_VERSION = "2021-04-01"; - private static final TokenCredential CREDENTIAL = getTokenCredential(ENVIRONMENT.getTestMode()); - private static final BearerTokenAuthenticationPolicy CREDENTIAL_POLICY - = new BearerTokenAuthenticationPolicy(CREDENTIAL, "https://management.azure.com/.default"); - private BlobContainerClient vlwContainer; - private BlobClient vlwBlob; - - @BeforeAll - public static void setupSpec() throws IOException { - if (ENVIRONMENT.getTestMode() != TestMode.PLAYBACK) { - vlwContainerName = CoreUtils.randomUuid().toString(); - - String url = String.format( - "https://management.azure.com/subscriptions/%s/resourceGroups/%s/providers/" - + "Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s?api-version=%s", - SUBSCRIPTION_ID, RESOURCE_GROUP_NAME, ACCOUNT_NAME, vlwContainerName, API_VERSION); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(CREDENTIAL_POLICY).build(); - - ImmutableStorageWithVersioning immutableStorageWithVersioning = new ImmutableStorageWithVersioning(); - immutableStorageWithVersioning.setEnabled(true); - Properties properties = new Properties(); - properties.setImmutableStorageWithVersioning(immutableStorageWithVersioning); - Body body = new Body(); - body.setId(String.format( - "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/" - + "%s/blobServices/default/containers/%s", - SUBSCRIPTION_ID, RESOURCE_GROUP_NAME, ACCOUNT_NAME, vlwContainerName)); - body.setName(vlwContainerName); - body.setType("Microsoft.Storage/storageAccounts/blobServices/containers"); - body.setProperties(properties); - - ByteArrayOutputStream json = new ByteArrayOutputStream(); - try (JsonWriter jsonWriter = JsonProviders.createWriter(json)) { - body.toJson(jsonWriter); - } - - HttpResponse response = httpPipeline.send(new HttpRequest(HttpMethod.PUT, new URL(url), new HttpHeaders(), - Flux.just(ByteBuffer.wrap(json.toByteArray())))).block(); - assertNotNull(response); - if (response.getStatusCode() != 201) { - LOGGER.warning(response.getBodyAsString().block()); - } - assertEquals(201, response.getStatusCode()); - } - } - - @BeforeEach - public void setup() { - vlwContainer = versionedBlobServiceClient - .getBlobContainerClient(testResourceNamer.recordValueFromConfig(vlwContainerName)); - vlwBlob = vlwContainer.getBlobClient(generateBlobName()); - vlwBlob.upload(new ByteArrayInputStream(new byte[0]), 0); - } - - public static final class Body implements JsonSerializable { - private String id; - private String name; - private String type; - private Properties properties; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } - - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject() - .writeStringField("id", this.id) - .writeStringField("name", this.name) - .writeStringField("type", this.type) - .writeJsonField("properties", this.properties); - - return jsonWriter.writeEndObject(); - } - } - - public static final class Properties implements JsonSerializable { - private ImmutableStorageWithVersioning immutableStorageWithVersioning; - - public void setImmutableStorageWithVersioning(ImmutableStorageWithVersioning immutableStorageWithVersioning) { - this.immutableStorageWithVersioning = immutableStorageWithVersioning; - } - - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject() - .writeJsonField("immutableStorageWithVersioning", this.immutableStorageWithVersioning); - - return jsonWriter.writeEndObject(); - } - } - - public static final class ImmutableStorageWithVersioning - implements JsonSerializable { - private boolean enabled; - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject().writeBooleanField("enabled", this.enabled); - - return jsonWriter.writeEndObject(); - } - } - - @AfterAll - public static void cleanupSpec() throws MalformedURLException { - if (ENVIRONMENT.getTestMode() != TestMode.PLAYBACK) { - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(CREDENTIAL_POLICY).build(); - BlobServiceClient cleanupClient - = new BlobServiceClientBuilder().credential(ENVIRONMENT.getVersionedAccount().getCredential()) - .endpoint(ENVIRONMENT.getVersionedAccount().getBlobEndpoint()) - .buildClient(); - - BlobContainerClient containerClient = cleanupClient.getBlobContainerClient(vlwContainerName); - BlobContainerProperties containerProperties = containerClient.getProperties(); - - if (containerProperties.getLeaseState() == LeaseStateType.LEASED) { - createLeaseClient(containerClient).breakLeaseWithResponse( - new BlobBreakLeaseOptions().setBreakPeriod(Duration.ofSeconds(0)), null, null); - } - if (containerProperties.isImmutableStorageWithVersioningEnabled()) { - ListBlobsOptions options = new ListBlobsOptions() - .setDetails(new BlobListDetails().setRetrieveImmutabilityPolicy(true).setRetrieveLegalHold(true)); - for (BlobItem blob : containerClient.listBlobs(options, null)) { - BlobClient blobClient = containerClient.getBlobClient(blob.getName()); - BlobItemProperties blobProperties = blob.getProperties(); - if (Objects.equals(true, blobProperties.hasLegalHold())) { - blobClient.setLegalHold(false); - } - if (blobProperties.getImmutabilityPolicy().getPolicyMode() != null) { - blobClient.deleteImmutabilityPolicy(); - } - blobClient.delete(); - } - } - - String url = String.format( - "https://management.azure.com/subscriptions/%s/resourceGroups/%s/providers/" - + "Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s?api-version=%s", - SUBSCRIPTION_ID, RESOURCE_GROUP_NAME, ACCOUNT_NAME, vlwContainerName, API_VERSION); - HttpResponse response - = httpPipeline.send(new HttpRequest(HttpMethod.DELETE, new URL(url), new HttpHeaders(), Flux.empty())) - .block(); - assertNotNull(response); - if (response.getStatusCode() != 200) { - LOGGER.warning(response.getBodyAsString().block()); - } - assertEquals(200, response.getStatusCode()); - } - } - - public static TokenCredential getTokenCredential(TestMode testMode) { - if (testMode == TestMode.RECORD) { - return new DefaultAzureCredentialBuilder().build(); - } else if (testMode == TestMode.LIVE) { - Configuration config = Configuration.getGlobalConfiguration(); - - ChainedTokenCredentialBuilder builder - = new ChainedTokenCredentialBuilder().addLast(new EnvironmentCredentialBuilder().build()) - .addLast(new AzureCliCredentialBuilder().build()) - .addLast(new AzureDeveloperCliCredentialBuilder().build()); - - String serviceConnectionId = config.get("AZURESUBSCRIPTION_SERVICE_CONNECTION_ID"); - String clientId = config.get("AZURESUBSCRIPTION_CLIENT_ID"); - String tenantId = config.get("AZURESUBSCRIPTION_TENANT_ID"); - String systemAccessToken = config.get("SYSTEM_ACCESSTOKEN"); - - if (!CoreUtils.isNullOrEmpty(serviceConnectionId) - && !CoreUtils.isNullOrEmpty(clientId) - && !CoreUtils.isNullOrEmpty(tenantId) - && !CoreUtils.isNullOrEmpty(systemAccessToken)) { - - builder.addLast(new AzurePipelinesCredentialBuilder().systemAccessToken(systemAccessToken) - .clientId(clientId) - .tenantId(tenantId) - .serviceConnectionId(serviceConnectionId) - .build()); - } - - builder.addLast(new AzurePowerShellCredentialBuilder().build()); - - return builder.build(); - } else { //playback or not set - return new MockTokenCredential(); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyMin() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - - BlobImmutabilityPolicy response = vlwBlob.setImmutabilityPolicy(immutabilityPolicy); - - assertEquals(expectedImmutabilityPolicyExpiry, response.getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, response.getPolicyMode()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicy() { - BlobImmutabilityPolicyMode policyMode = BlobImmutabilityPolicyMode.UNLOCKED; - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(policyMode); - - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - - // when: "set immutability policy" - BlobImmutabilityPolicy response - = vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, null, null, null).getValue(); - - assertEquals(expectedImmutabilityPolicyExpiry, response.getExpiryTime()); - assertEquals(policyMode, response.getPolicyMode()); - - // when: "get properties" - BlobProperties props = vlwBlob.getProperties(); - assertEquals(expectedImmutabilityPolicyExpiry, props.getImmutabilityPolicy().getExpiryTime()); - assertEquals(policyMode, props.getImmutabilityPolicy().getPolicyMode()); - - // when: "list blob" - ListBlobsOptions options = new ListBlobsOptions().setPrefix(vlwBlob.getBlobName()) - .setDetails(new BlobListDetails().setRetrieveImmutabilityPolicy(true).setRetrieveLegalHold(true)); - Iterator blobItemIterator = vlwContainer.listBlobs(options, null).iterator(); - - BlobItem blob = blobItemIterator.next(); - assertFalse(blobItemIterator.hasNext()); - assertEquals(vlwBlob.getBlobName(), blob.getName()); - assertEquals(expectedImmutabilityPolicyExpiry, blob.getProperties().getImmutabilityPolicy().getExpiryTime()); - assertEquals(policyMode, blob.getProperties().getImmutabilityPolicy().getPolicyMode()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyAC() { - List unmodifiedDates = Arrays.asList(null, NEW_DATE); - - for (OffsetDateTime unmodified : unmodifiedDates) { - BlobRequestConditions bac = new BlobRequestConditions().setIfUnmodifiedSince(unmodified); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy().setExpiryTime(expiryTime) - .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - Response response - = vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, bac, null, null); - assertResponseStatusCode(response, 200); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyACFail() { - BlobRequestConditions bac = new BlobRequestConditions().setIfUnmodifiedSince(OLD_DATE); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, bac, null, null)); - assertEquals(BlobErrorCode.CONDITION_NOT_MET, e.getErrorCode()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @ParameterizedTest - @MethodSource("setImmutabilityPolicyACIASupplier") - public void setImmutabilityPolicyACIA(String leaseId, String tags, String ifMatch, String ifNoneMatch, - OffsetDateTime ifModifiedSince, String wrongCondition) { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseId) - .setTagsConditions(tags) - .setIfMatch(ifMatch) - .setIfNoneMatch(ifNoneMatch) - .setIfModifiedSince(ifModifiedSince); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, - () -> vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, bac, null, null)); - assertEquals(String.format("%s does not support the %s request condition(s) for parameter 'requestConditions'.", - "setImmutabilityPolicy(WithResponse)", wrongCondition), e.getMessage()); - } - - private static Stream setImmutabilityPolicyACIASupplier() { - return Stream.of(Arguments.of("leaseId", null, null, null, null, "LeaseId"), - Arguments.of(null, "tagsConditions", null, null, null, "TagsConditions"), - Arguments.of(null, null, "ifMatch", null, null, "IfMatch"), - Arguments.of(null, null, null, "ifNoneMatch", null, "IfNoneMatch"), - Arguments.of(null, null, null, null, OLD_DATE, "IfModifiedSince"), - Arguments.of("leaseId", "tagsConditions", "ifMatch", "ifNoneMatch", OLD_DATE, - "LeaseId, TagsConditions, " + "IfModifiedSince, IfMatch, IfNoneMatch")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyError() { - BlobClient blob = vlwContainer.getBlobClient(generateBlobName()); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blob.setImmutabilityPolicyWithResponse(immutabilityPolicy, null, null, null)); - assertEquals(BlobErrorCode.BLOB_NOT_FOUND, e.getErrorCode()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setImmutabilityPolicyIA() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.MUTABLE); - - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, - () -> vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, null, null, null)); - assertEquals("immutabilityPolicy.policyMode must be Locked or Unlocked", e.getMessage()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void deleteImmutabilityPolicyMin() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - vlwBlob.setImmutabilityPolicy(immutabilityPolicy); - - vlwBlob.deleteImmutabilityPolicy(); - - BlobProperties properties = vlwBlob.getProperties(); - assertNull(properties.getImmutabilityPolicy().getPolicyMode()); - assertNull(properties.getImmutabilityPolicy().getExpiryTime()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void deleteImmutabilityPolicy() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - vlwBlob.setImmutabilityPolicy(immutabilityPolicy); - - vlwBlob.deleteImmutabilityPolicyWithResponse(null, null); - - BlobProperties properties = vlwBlob.getProperties(); - assertNull(properties.getImmutabilityPolicy().getPolicyMode()); - assertNull(properties.getImmutabilityPolicy().getExpiryTime()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void deleteImmutabilityPolicyError() { - BlobClient blobClient = vlwContainer.getBlobClient(generateBlobName()); - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blobClient.deleteImmutabilityPolicyWithResponse(null, null)); - assertEquals(BlobErrorCode.BLOB_NOT_FOUND, e.getErrorCode()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void setLegalHoldMin(boolean legalHold) { - BlobLegalHoldResult response = vlwBlob.setLegalHold(legalHold); - assertEquals(legalHold, response.hasLegalHold()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void setLegalHold(boolean legalHold) { - // when: "set legal hold" - Response response = vlwBlob.setLegalHoldWithResponse(legalHold, null, null); - assertEquals(legalHold, response.getValue().hasLegalHold()); - - // when: "get properties" - BlobProperties properties = vlwBlob.getProperties(); - assertEquals(legalHold, properties.hasLegalHold()); - - // when: "list blob" - ListBlobsOptions options = new ListBlobsOptions().setPrefix(vlwBlob.getBlobName()) - .setDetails(new BlobListDetails().setRetrieveImmutabilityPolicy(true).setRetrieveLegalHold(true)); - Iterator itr = vlwContainer.listBlobs(options, null).iterator(); - - BlobItem blob = itr.next(); - assertFalse(itr.hasNext()); - assertEquals(vlwBlob.getBlobName(), blob.getName()); - assertEquals(legalHold, blob.getProperties().hasLegalHold()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void setLegalHoldError() { - BlobClient blob = vlwContainer.getBlobClient(generateBlobName()); - - BlobStorageException e - = assertThrows(BlobStorageException.class, () -> blob.setLegalHoldWithResponse(false, null, null)); - assertEquals(BlobErrorCode.BLOB_NOT_FOUND, e.getErrorCode()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void containerProperties() { - BlobContainerProperties properties = vlwContainer.getProperties(); - - assertTrue(properties.isImmutableStorageWithVersioningEnabled()); - - Iterator itr = vlwContainer.getServiceClient() - .listBlobContainers(new ListBlobContainersOptions().setPrefix(vlwContainer.getBlobContainerName()), null) - .iterator(); - - BlobContainerItem container = itr.next(); - assertFalse(itr.hasNext()); - assertTrue(container.getProperties().isImmutableStorageWithVersioningEnabled()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void appendBlobCreate() { - AppendBlobClient appendBlob = vlwContainer.getBlobClient(generateBlobName()).getAppendBlobClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - appendBlob.createWithResponse( - new AppendBlobCreateOptions().setImmutabilityPolicy(immutabilityPolicy).setLegalHold(true), null, null); - - BlobProperties properties = appendBlob.getProperties(); - assertEquals(expectedImmutabilityPolicyExpiry, properties.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, properties.getImmutabilityPolicy().getPolicyMode()); - assertTrue(properties.hasLegalHold()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void pageBlobCreate() { - PageBlobClient pageBlob = vlwContainer.getBlobClient(generateBlobName()).getPageBlobClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - pageBlob.createWithResponse( - new PageBlobCreateOptions(512).setImmutabilityPolicy(immutabilityPolicy).setLegalHold(true), null, null); - - BlobProperties properties = pageBlob.getProperties(); - assertEquals(expectedImmutabilityPolicyExpiry, properties.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, properties.getImmutabilityPolicy().getPolicyMode()); - assertTrue(properties.hasLegalHold()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void blockBlobCommitBlockList() { - BlockBlobClient blockBlob = vlwBlob.getBlockBlobClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - blockBlob.commitBlockListWithResponse( - new BlockBlobCommitBlockListOptions(new ArrayList<>()).setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true), - null, null); - - BlobProperties properties = blockBlob.getProperties(); - assertEquals(expectedImmutabilityPolicyExpiry, properties.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, properties.getImmutabilityPolicy().getPolicyMode()); - assertTrue(properties.hasLegalHold()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void blockBlobUpload() { - BlockBlobClient blockBlob = vlwBlob.getBlockBlobClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - blockBlob.uploadWithResponse(new BlockBlobSimpleUploadOptions(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true), null, null); - - BlobProperties properties = blockBlob.getProperties(); - assertEquals(expectedImmutabilityPolicyExpiry, properties.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, properties.getImmutabilityPolicy().getPolicyMode()); - assertTrue(properties.hasLegalHold()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @LiveOnly - @ParameterizedTest - @MethodSource("blobUploadSupplier") - public void blobUpload(Long blockSize) { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - vlwBlob.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultFlux()) - .setParallelTransferOptions( - new ParallelTransferOptions().setBlockSizeLong(blockSize).setMaxSingleUploadSizeLong(blockSize)) - .setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true), null, null); - - BlobProperties response = vlwBlob.getProperties(); - assertEquals(expectedImmutabilityPolicyExpiry, response.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, response.getImmutabilityPolicy().getPolicyMode()); - assertTrue(response.hasLegalHold()); - } - - private static Stream blobUploadSupplier() { - return Stream.of(Arguments.of(1L), Arguments.of((Long) null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void syncCopy() { - BlockBlobClient destination = vlwContainer.getBlobClient(generateBlobName()).getBlockBlobClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - String sas = vlwBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - destination.copyFromUrlWithResponse( - new BlobCopyFromUrlOptions(vlwBlob.getBlobUrl() + "?" + sas).setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true), - null, null); - - BlobProperties response = destination.getProperties(); - assertEquals(expectedImmutabilityPolicyExpiry, response.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, response.getImmutabilityPolicy().getPolicyMode()); - assertTrue(response.hasLegalHold()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void copy() { - BlockBlobClient destination = vlwContainer.getBlobClient(generateBlobName()).getBlockBlobClient(); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - - SyncPoller poller = setPlaybackSyncPollerPollInterval(destination - .beginCopy(new BlobBeginCopyOptions(vlwBlob.getBlobUrl()).setImmutabilityPolicy(immutabilityPolicy) - .setLegalHold(true))); - poller.waitForCompletion(); - - BlobProperties response = destination.getProperties(); - assertEquals(expectedImmutabilityPolicyExpiry, response.getImmutabilityPolicy().getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, response.getImmutabilityPolicy().getPolicyMode()); - assertTrue(response.hasLegalHold()); - } - - /* SAS tests */ - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void accountSas() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasPermission permissions = AccountSasPermission.parse("rwdxlacuptfi"); - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resource = new AccountSasResourceType().setObject(true).setContainer(true); - AccountSasSignatureValues sasValues = new AccountSasSignatureValues(expiryTime, permissions, service, resource); - expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - String sas = versionedBlobServiceClient.generateAccountSas(sasValues); - BlobClient client = getBlobClient(sas, vlwContainer.getBlobContainerUrl(), vlwBlob.getBlobName()); - - BlobImmutabilityPolicy response = client.setImmutabilityPolicy(immutabilityPolicy); - assertEquals(expectedImmutabilityPolicyExpiry, response.getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED, response.getPolicyMode()); - - BlobLegalHoldResult legalHold = client.setLegalHold(false); - assertFalse(legalHold.hasLegalHold()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void containerSas() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobContainerSasPermission permissions = BlobContainerSasPermission.parse("racwdxltmei"); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - String sas = vlwContainer.generateSas(sasValues); - BlobClient client = getBlobClient(sas, vlwContainer.getBlobContainerUrl(), vlwBlob.getBlobName()); - - BlobImmutabilityPolicy response = client.setImmutabilityPolicy(immutabilityPolicy); - assertEquals(expectedImmutabilityPolicyExpiry, response.getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED.toString(), response.getPolicyMode().toString()); - - BlobLegalHoldResult legalHold = client.setLegalHold(false); - assertFalse(legalHold.hasLegalHold()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void blobSas() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobSasPermission permissions = BlobSasPermission.parse("racwdxtlmei"); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - expiryTime = testResourceNamer.now().plusDays(2); - // The service rounds Immutability Policy Expiry to the nearest second. - OffsetDateTime expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS); - BlobImmutabilityPolicy immutabilityPolicy - = new BlobImmutabilityPolicy().setExpiryTime(expiryTime).setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED); - String sas = vlwBlob.generateSas(sasValues); - BlobClient client = getBlobClient(sas, vlwContainer.getBlobContainerUrl(), vlwBlob.getBlobName()); - - BlobImmutabilityPolicy response = client.setImmutabilityPolicy(immutabilityPolicy); - - assertEquals(expectedImmutabilityPolicyExpiry, response.getExpiryTime()); - assertEquals(BlobImmutabilityPolicyMode.UNLOCKED.toString(), response.getPolicyMode().toString()); - - BlobLegalHoldResult legalHold = client.setLegalHold(false); - assertFalse(legalHold.hasLegalHold()); - } - - @Test - public void testVersionBlobImmutabilityExpiry() { - BlockBlobItem blobItemV1 - = vlwBlob.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - BlockBlobItem blobItemV2 - = vlwBlob.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - - BlobClient oldBlob = vlwBlob.getVersionClient(blobItemV1.getVersionId()); - BlobClient newBlob = vlwBlob.getVersionClient(blobItemV2.getVersionId()); - - OffsetDateTime time1 = testResourceNamer.now().plusDays(3); - OffsetDateTime time2 = testResourceNamer.now().plusDays(4); - - BlobImmutabilityPolicy policy1 = new BlobImmutabilityPolicy().setExpiryTime(time1); - BlobImmutabilityPolicy policy2 = new BlobImmutabilityPolicy().setExpiryTime(time2); - oldBlob.setImmutabilityPolicy(policy1); - newBlob.setImmutabilityPolicy(policy2); - - assertEquals(policy1.getExpiryTime().truncatedTo(ChronoUnit.SECONDS), - oldBlob.getProperties().getImmutabilityPolicy().getExpiryTime()); - assertEquals(policy2.getExpiryTime().truncatedTo(ChronoUnit.SECONDS), - newBlob.getProperties().getImmutabilityPolicy().getExpiryTime()); - - //cleanup - oldBlob.deleteImmutabilityPolicy(); - oldBlob.delete(); - } - - @Test - public void testImmutabilitySnapshot() { - BlobClientBase snapshotBlob = vlwBlob.createSnapshot(); - - OffsetDateTime time1 = testResourceNamer.now().plusDays(3); - OffsetDateTime time2 = testResourceNamer.now().plusDays(4); - BlobImmutabilityPolicy policy1 = new BlobImmutabilityPolicy().setExpiryTime(time1); - BlobImmutabilityPolicy policy2 = new BlobImmutabilityPolicy().setExpiryTime(time2); - - vlwBlob.setImmutabilityPolicy(policy1); - snapshotBlob.setImmutabilityPolicy(policy2); - - assertEquals(policy1.getExpiryTime().truncatedTo(ChronoUnit.SECONDS), - vlwBlob.getProperties().getImmutabilityPolicy().getExpiryTime()); - assertEquals(policy2.getExpiryTime().truncatedTo(ChronoUnit.SECONDS), - snapshotBlob.getProperties().getImmutabilityPolicy().getExpiryTime()); - - //cleanup - snapshotBlob.deleteImmutabilityPolicy(); - snapshotBlob.delete(); - } - - @Test - public void testLegalHoldVersion() { - BlockBlobItem blobItemV1 - = vlwBlob.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - BlockBlobItem blobItemV2 - = vlwBlob.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - - BlobClient oldBlob = vlwBlob.getVersionClient(blobItemV1.getVersionId()); - BlobClient newBlob = vlwBlob.getVersionClient(blobItemV2.getVersionId()); - - BlobLegalHoldResult result1 = oldBlob.setLegalHold(true); - assertTrue(result1.hasLegalHold()); - - assertTrue(oldBlob.getProperties().hasLegalHold()); - assertNull(newBlob.getProperties().hasLegalHold()); - - //cleanup - oldBlob.setLegalHold(false); - oldBlob.delete(); - } - - @Test - public void testLegalHoldSnapshot() { - BlobClientBase snapshotBlob = vlwBlob.createSnapshot(); - - BlobLegalHoldResult result1 = vlwBlob.setLegalHold(true); - assertTrue(result1.hasLegalHold()); - assertNull(snapshotBlob.getProperties().hasLegalHold()); - - //cleanup - snapshotBlob.setLegalHold(false); - snapshotBlob.delete(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/LargeBlobTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/LargeBlobTests.java deleted file mode 100644 index 37feec1a6b68..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/LargeBlobTests.java +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.util.Context; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlockList; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.ResourceLock; -import reactor.core.publisher.Flux; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.SequenceInputStream; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.util.Base64; -import java.util.Collections; -import java.util.Vector; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - -@ResourceLock("LargeBlobTests") -@LiveOnly -public class LargeBlobTests extends BlobTestBase { - - private static BlobServiceClient blobServiceClient; - private static BlobServiceAsyncClient blobServiceAsyncClient; - - private static final long LARGE_BLOCK_SIZE = 2500L * Constants.MB; // exceed integer limit - - private BlobClient blobClient; - private BlobAsyncClient blobAsyncClient; - - @BeforeAll - public static void setupSpec() { - BlobServiceClientBuilder blobServiceClientBuilder - = new BlobServiceClientBuilder().connectionString("UseDevelopmentStorage=true"); - blobServiceClient = blobServiceClientBuilder.buildClient(); - blobServiceAsyncClient = blobServiceClientBuilder.buildAsyncClient(); - } - - @BeforeEach - public void setup() { - String containerName = CoreUtils.randomUuid().toString(); - BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient(containerName); - BlobContainerAsyncClient blobContainerAsyncClient - = blobServiceAsyncClient.getBlobContainerAsyncClient(containerName); - blobContainerClient.create(); - String blobName = CoreUtils.randomUuid().toString(); - blobClient = blobContainerClient.getBlobClient(blobName); - blobAsyncClient = blobContainerAsyncClient.getBlobAsyncClient(blobName); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void stageRealLargeBlob() { - InputStream stream = createLargeInputStream(LARGE_BLOCK_SIZE); - String blockId - = Base64.getEncoder().encodeToString(CoreUtils.randomUuid().toString().getBytes(StandardCharsets.UTF_8)); - - blobClient.getBlockBlobClient().stageBlock(blockId, stream, LARGE_BLOCK_SIZE); - blobClient.getBlockBlobClient().commitBlockList(Collections.singletonList((blockId))); - BlockList blockList = blobClient.getBlockBlobClient().listBlocks(BlockListType.COMMITTED); - - assertEquals(1, blockList.getCommittedBlocks().size()); - assertEquals(LARGE_BLOCK_SIZE, blockList.getCommittedBlocks().get(0).getSizeLong()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void uploadRealLargeBlobInSingleUpload() { - long size = LARGE_BLOCK_SIZE; - InputStream stream = createLargeInputStream(size); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setMaxSingleUploadSizeLong(BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES_LONG); - - blobClient.uploadWithResponse(stream, size, parallelTransferOptions, null, null, null, null, null, - Context.NONE); - BlobProperties properties = blobClient.getProperties(); - assertEquals(size, properties.getBlobSize()); - assertNull(properties.getCommittedBlockCount()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void uploadRealLargeBlobInSingleUploadAsync() { - long size = LARGE_BLOCK_SIZE; - Flux flux = createLargeBuffer(size); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setMaxSingleUploadSizeLong(BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES_LONG); - - blobAsyncClient.upload(flux, parallelTransferOptions).block(); - BlobProperties properties = blobClient.getProperties(); - assertEquals(size, properties.getBlobSize()); - assertNull(properties.getCommittedBlockCount()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void uploadLargeInput() { - long tailSize = Constants.MB; - long length = LARGE_BLOCK_SIZE + tailSize; - Flux flux = createLargeBuffer(length); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong(LARGE_BLOCK_SIZE); - - blobAsyncClient.upload(flux, parallelTransferOptions).block(); - BlockList blockList = blobAsyncClient.getBlockBlobAsyncClient().listBlocks(BlockListType.COMMITTED).block(); - assertNotNull(blockList); - assertEquals(2, blockList.getCommittedBlocks().size()); - assertEquals(LARGE_BLOCK_SIZE, blockList.getCommittedBlocks().get(0).getSizeLong()); - assertEquals(tailSize, blockList.getCommittedBlocks().get(1).getSizeLong()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void uploadLargeInputSync() { - long tailSize = Constants.MB; - long length = LARGE_BLOCK_SIZE + tailSize; - InputStream stream = createLargeInputStream(length, Constants.MB); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong(LARGE_BLOCK_SIZE); - - blobClient.uploadWithResponse(stream, length, parallelTransferOptions, null, null, null, null, null, - Context.NONE); - BlockList blockList = blobClient.getBlockBlobClient().listBlocks(BlockListType.COMMITTED); - - assertEquals(2, blockList.getCommittedBlocks().size()); - assertEquals(LARGE_BLOCK_SIZE, blockList.getCommittedBlocks().get(0).getSizeLong()); - assertEquals(tailSize, blockList.getCommittedBlocks().get(1).getSizeLong()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void uploadLargeInputSyncNoLengthGiven() { - long tailSize = Constants.MB; - long length = LARGE_BLOCK_SIZE + tailSize; - InputStream stream = createLargeInputStream(length, Constants.MB); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong(LARGE_BLOCK_SIZE); - - blobClient.uploadWithResponse( - new BlobParallelUploadOptions(stream).setParallelTransferOptions(parallelTransferOptions), null, - Context.NONE); - BlockList blockList = blobClient.getBlockBlobClient().listBlocks(BlockListType.COMMITTED); - - assertEquals(2, blockList.getCommittedBlocks().size()); - assertEquals(LARGE_BLOCK_SIZE, blockList.getCommittedBlocks().get(0).getSizeLong()); - assertEquals(tailSize, blockList.getCommittedBlocks().get(1).getSizeLong()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void uploadLargeFile() throws IOException { - long tailSize = Constants.MB; - File file = getRandomLargeFile(LARGE_BLOCK_SIZE + tailSize); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong(LARGE_BLOCK_SIZE); - - blobClient.uploadFromFile(file.toPath().toString(), parallelTransferOptions, null, null, null, null, null); - BlockList blockList = blobClient.getBlockBlobClient().listBlocks(BlockListType.COMMITTED); - - assertEquals(2, blockList.getCommittedBlocks().size()); - assertEquals(LARGE_BLOCK_SIZE, blockList.getCommittedBlocks().get(0).getSizeLong()); - assertEquals(tailSize, blockList.getCommittedBlocks().get(1).getSizeLong()); - } - - private InputStream createLargeInputStream(long size) { - return createLargeInputStream(size, Constants.MB); - } - - private InputStream createLargeInputStream(long size, int chunkSize) { - long numberOfSubStreams = size / chunkSize; - Vector subStreams = new Vector<>(); - byte[] bytes = getRandomByteArray(chunkSize); - for (long i = 0; i < numberOfSubStreams; i++) { - subStreams.add(new ByteArrayInputStream(bytes)); - } - return new SequenceInputStream(subStreams.elements()) { - @Override - public void reset() { - // no-op - } - }; - } - - private Flux createLargeBuffer(long size) { - return createLargeBuffer(size, Constants.MB); - } - - private Flux createLargeBuffer(long size, int bufferSize) { - byte[] bytes = getRandomByteArray(bufferSize); - long numberOfSubBuffers = size / bufferSize; - int remainder = (int) (size - numberOfSubBuffers * bufferSize); - Flux result - = Flux.just(ByteBuffer.wrap(bytes)).map(ByteBuffer::duplicate).repeat(numberOfSubBuffers - 1); - if (remainder > 0) { - byte[] extraBytes = getRandomByteArray(remainder); - result = Flux.concat(result, Flux.just(ByteBuffer.wrap(extraBytes))); - } - return result; - } - - File getRandomLargeFile(long size) throws IOException { - File file = File.createTempFile(CoreUtils.randomUuid().toString(), ".txt"); - file.deleteOnExit(); - FileOutputStream fos = new FileOutputStream(file); - - if (size > Constants.MB) { - for (int i = 0; i < size / Constants.MB; i++) { - int dataSize = (int) Math.min(Constants.MB, size - (long) i * Constants.MB); - fos.write(getRandomByteArray(dataSize)); - } - } else { - fos.write(getRandomByteArray((int) size)); - } - - fos.close(); - return file; - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/OAuthCopySourceTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/OAuthCopySourceTests.java deleted file mode 100644 index 5c7ea3eea6ab..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/OAuthCopySourceTests.java +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpAuthorization; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.options.AppendBlobAppendBlockFromUrlOptions; -import com.azure.storage.blob.options.BlobUploadFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockFromUrlOptions; -import com.azure.storage.blob.options.PageBlobUploadPagesFromUrlOptions; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.PageBlobClient; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.Base64; -import java.util.Collections; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class OAuthCopySourceTests extends BlobTestBase { - private BlobClient defaultDataSourceBlobClient; - private BlobClient pageBlobDataSourceBlobClient; - - private AppendBlobClient appendBlobClient; - private BlockBlobClient blockBlobClient; - private PageBlobClient pageBlobClient; - - @BeforeEach - public void setup() { - defaultDataSourceBlobClient = cc.getBlobClient(generateBlobName()); - defaultDataSourceBlobClient.upload(DATA.getDefaultBinaryData()); - pageBlobDataSourceBlobClient = cc.getBlobClient(generateBlobName()); - pageBlobDataSourceBlobClient.upload(BinaryData.fromBytes(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - - appendBlobClient = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - appendBlobClient.create(); - - blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - pageBlobClient = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - pageBlobClient.create(PageBlobClient.PAGE_BYTES); - } - - // RBAC replication lag - @Test - public void appendBlobAppendBlockFromURLSourceOauth() { - liveTestScenarioWithRetry(() -> { - BlobClient sourceBlob = cc.getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultBinaryData()); - String oauthHeader = getAuthToken(); - appendBlobClient - .appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceBlob.getBlobUrl()) - .setSourceAuthorization(new HttpAuthorization("Bearer", oauthHeader)), null, Context.NONE); - TestUtils.assertArraysEqual(appendBlobClient.downloadContent().toBytes(), DATA.getDefaultBytes()); - }); - } - - @Test - public void appendBlobAppendBlockFromURLSourceOauthFail() { - BlobClient sourceBlob = cc.getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultBinaryData()); - String oauthHeader = "garbage"; - - assertThrows(BlobStorageException.class, - () -> appendBlobClient - .appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceBlob.getBlobUrl()) - .setSourceAuthorization(new HttpAuthorization("Bearer", oauthHeader)), null, Context.NONE)); - } - - // RBAC replication lag - @Test - public void blockBlobUploadFromURLSourceOauth() { - liveTestScenarioWithRetry(() -> { - String oauthHeader = getAuthToken(); - blockBlobClient - .uploadFromUrlWithResponse(new BlobUploadFromUrlOptions(defaultDataSourceBlobClient.getBlobUrl()) - .setSourceAuthorization(new HttpAuthorization("Bearer", oauthHeader)), null, Context.NONE); - TestUtils.assertArraysEqual(blockBlobClient.downloadContent().toBytes(), DATA.getDefaultBytes()); - }); - } - - @Test - public void blockBlobUploadFromURLSourceOauthFail() { - BlobClient sourceBlob = cc.getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultBinaryData()); - String oauthHeader = "garbage"; - - assertThrows(BlobStorageException.class, - () -> blockBlobClient.uploadFromUrlWithResponse(new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl()) - .setSourceAuthorization(new HttpAuthorization("Bearer", oauthHeader)), null, Context.NONE)); - } - - // RBAC replication lag - @Test - public void blockBlobStageBlockFromURLSourceOauth() { - liveTestScenarioWithRetry(() -> { - String oauthHeader = getAuthToken(); - String blockId = Base64.getEncoder().encodeToString("myBlockId".getBytes()); - blockBlobClient.stageBlockFromUrlWithResponse( - new BlockBlobStageBlockFromUrlOptions(blockId, defaultDataSourceBlobClient.getBlobUrl()) - .setSourceAuthorization(new HttpAuthorization("Bearer", oauthHeader)), - null, Context.NONE); - blockBlobClient.commitBlockList(Collections.singletonList(blockId), true); - TestUtils.assertArraysEqual(blockBlobClient.downloadContent().toBytes(), DATA.getDefaultBytes()); - }); - - } - - @Test - public void blockBlobStageBlockFromURLSourceOauthFail() { - BlobClient sourceBlob = cc.getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultBinaryData()); - String oauthHeader = "garbage"; - String blockId = Base64.getEncoder().encodeToString("myBlockId".getBytes()); - - assertThrows(BlobStorageException.class, - () -> blockBlobClient - .stageBlockFromUrlWithResponse(new BlockBlobStageBlockFromUrlOptions(blockId, sourceBlob.getBlobUrl()) - .setSourceAuthorization(new HttpAuthorization("Bearer", oauthHeader)), null, Context.NONE)); - - } - - // RBAC replication lag - @Test - public void uploadPagesFromURLSourceOauth() { - liveTestScenarioWithRetry(() -> { - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - String oauthHeader = getAuthToken(); - - pageBlobClient.uploadPagesFromUrlWithResponse( - new PageBlobUploadPagesFromUrlOptions(pageRange, pageBlobDataSourceBlobClient.getBlobUrl()) - .setSourceAuthorization(new HttpAuthorization("Bearer", oauthHeader)), - null, Context.NONE); - - TestUtils.assertArraysEqual(pageBlobClient.downloadContent().toBytes(), - pageBlobDataSourceBlobClient.downloadContent().toBytes()); - }); - } - - @Test - public void uploadPagesFromURLSourceOauthFail() { - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - String oauthHeader = "garbage"; - - assertThrows(BlobStorageException.class, - () -> pageBlobClient.uploadPagesFromUrlWithResponse( - new PageBlobUploadPagesFromUrlOptions(pageRange, pageBlobDataSourceBlobClient.getBlobUrl()) - .setSourceAuthorization(new HttpAuthorization("Bearer", oauthHeader)), - null, Context.NONE)); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ProgressReporterTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ProgressReporterTests.java deleted file mode 100644 index 1b22eec01904..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ProgressReporterTests.java +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import org.junit.jupiter.api.Test; -import reactor.core.Disposable; -import reactor.core.publisher.Flux; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.locks.ReentrantLock; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@SuppressWarnings("deprecation") -public class ProgressReporterTests extends BlobTestBase { - - @Test - public void reportProgressSequential() { - ByteBuffer buf1 = getRandomData(10); - ByteBuffer buf2 = getRandomData(15); - ByteBuffer buf3 = getRandomData(5); - - TestBlobProgressReceiver mockReceiver = new TestBlobProgressReceiver(); - - Flux data = Flux.just(buf1, buf2, buf3); - data = ProgressReporter.addProgressReporting(data, mockReceiver); - - data.subscribe(); - data.subscribe(); // Subscribing twice enforces invocation of rewind - - // The same benchmarks should be reported on each subscription (retry). We should never go over total data size. - assertEquals(2, mockReceiver.progresses.stream().filter(p -> p == 10).count()); - assertEquals(2, mockReceiver.progresses.stream().filter(p -> p == 25).count()); - assertEquals(2, mockReceiver.progresses.stream().filter(p -> p == 30).count()); - assertEquals(0, mockReceiver.progresses.stream().filter(p -> p > 30).count()); - } - - @LiveOnly - @Test - public void reportProgressSequentialNetworkTest() { - TestBlobProgressReceiver mockReceiver = new TestBlobProgressReceiver(); - - ByteBuffer buffer = getRandomData(1024 * 1024); - Flux data = ProgressReporter.addProgressReporting(Flux.just(buffer), mockReceiver); - - BlockBlobAsyncClient bu = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - cc.getBlobContainerUrl(), generateBlobName()).getBlockBlobAsyncClient(); - - bu.upload(data, buffer.remaining()).block(); - - /* - With the HTTP client, etc. involved, the best we can guarantee is that it's called once with the total. There - may or may not be any intermediary calls. This test mostly looks to validate that there is no interference - with actual network calls. - */ - assertEquals(1, mockReceiver.progresses.stream().filter(p -> p == 1024 * 1024).count()); - } - - @Test - public void reportProgressParallel() { - ByteBuffer buf1 = getRandomData(10); - ByteBuffer buf2 = getRandomData(15); - ByteBuffer buf3 = getRandomData(5); - - ReentrantLock lock = new ReentrantLock(); - AtomicLong totalProgress = new AtomicLong(0); - - TestBlobProgressReceiver mockReceiver = new TestBlobProgressReceiver(); - Flux data = Flux.just(buf1, buf2, buf3); - Flux data2 = Flux.just(buf3, buf2, buf1); - data = ProgressReporter.addParallelProgressReporting(data, mockReceiver, lock, totalProgress); - data2 = ProgressReporter.addParallelProgressReporting(data2, mockReceiver, lock, totalProgress); - - Disposable disposable1 = data.subscribe(); - Disposable disposable2 = data2.subscribe(); - Disposable disposable3 = data.subscribe(); - Disposable disposable4 = data2.subscribe(); - - // a dummy value to avoid compiler warning - int count = 0; - while (!(disposable1.isDisposed() - && disposable2.isDisposed() - && disposable3.isDisposed() - && disposable4.isDisposed())) { - // Busy-wait loop; be cautious about potential for high CPU usage - count++; - } - - /* - There should be at least one call reporting the total length of the data. There may be two if both data and - data2 complete before the second batch of subscriptions - */ - // Verify that reportProgress was called 1 to 3 times with argument 60 - long reported60Count = mockReceiver.progresses.stream().filter(p -> p == 60).count(); - assertTrue(reported60Count >= 1 && reported60Count <= 3); - - /* - There should be 12 calls total, but either one or two of them could be reporting the total length, so we - can only guarantee four calls with an unknown parameter. This test doesn't strictly mimic the network as - there would never be concurrent subscriptions to the same Flux as may be the case here, but it is good - enough. - */ - // Verify that reportProgress was called 10 to 12 times with any long argument - assertTrue(mockReceiver.progresses.size() >= 10 && mockReceiver.progresses.size() <= 12); - - /* - We should never report more progress than the 60 total (30 from each Flux--Resubscribing is a retry and - therefore rewinds). - */ - assertEquals(0, mockReceiver.progresses.stream().filter(p -> p > 60).count()); - } - - /** - * This test asserts that ProgressListener from core dispatches progress notification to old - * ProgressReceiver API to assure backwards compatibility. - */ - @Test - public void progressListenerDelegatesToProgressReceiverByDefault() { - TestBlobProgressReceiver blobReceiver = new TestBlobProgressReceiver(); - TestCommonProgressReceiver commonReceiver = new TestCommonProgressReceiver(); - - blobReceiver.handleProgress(1L); - blobReceiver.handleProgress(3L); - blobReceiver.handleProgress(5L); - - assertArrayEquals(new Long[] { 1L, 3L, 5L }, blobReceiver.progresses.toArray()); - - commonReceiver.handleProgress(1L); - commonReceiver.handleProgress(3L); - commonReceiver.handleProgress(5L); - - assertArrayEquals(new Long[] { 1L, 3L, 5L }, commonReceiver.progresses.toArray()); - } - - private static class TestBlobProgressReceiver implements ProgressReceiver { - - List progresses = new ArrayList<>(); - - @Override - public void reportProgress(long bytesTransferred) { - progresses.add(bytesTransferred); - } - } - - private static class TestCommonProgressReceiver implements com.azure.storage.common.ProgressReceiver { - - List progresses = new ArrayList<>(); - - @Override - public void reportProgress(long bytesTransferred) { - progresses.add(bytesTransferred); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/RequestRetryTestFactory.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/RequestRetryTestFactory.java deleted file mode 100644 index 2e57878df057..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/RequestRetryTestFactory.java +++ /dev/null @@ -1,612 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.UrlBuilder; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.logging.LogLevel; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.RequestRetryPolicy; -import reactor.core.Disposable; -import reactor.core.Exceptions; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.time.OffsetDateTime; -import java.time.temporal.ChronoUnit; -import java.util.concurrent.TimeoutException; - -import static java.lang.StrictMath.pow; - -class RequestRetryTestFactory { - private static final ClientLogger LOGGER = new ClientLogger(RequestRetryTestFactory.class); - - static final int RETRY_TEST_SCENARIO_RETRY_UNTIL_SUCCESS = 1; - - static final int RETRY_TEST_SCENARIO_RETRY_UNTIL_MAX_RETRIES = 2; - - static final int RETRY_TEST_SCENARIO_NON_RETRYABLE = 3; - - static final int RETRY_TEST_SCENARIO_NON_RETRYABLE_SECONDARY = 4; - - static final int RETRY_TEST_SCENARIO_NETWORK_ERROR = 5; - - static final int RETRY_TEST_SCENARIO_EXPONENTIAL_TIMING = 6; - - static final int RETRY_TEST_SCENARIO_FIXED_TIMING = 7; - - static final int RETRY_TEST_SCENARIO_TRY_TIMEOUT = 8; - - static final int RETRY_TEST_SCENARIO_NON_REPLAYABLE_FLOWABLE = 9; - - static final int RETRY_TEST_SCENARIO_WRAPPED_NETWORK_ERROR = 10; - - static final int RETRY_TEST_SCENARIO_WRAPPED_TIMEOUT_ERROR = 11; - - static final int RETRY_TEST_SCENARIO_RETRY_UNTIL_MAX_RETRIES_WITH_EXCEPTION = 12; - - // Cancelable - - static final String RETRY_TEST_PRIMARY_HOST = "PrimaryDC"; - - static final String RETRY_TEST_SECONDARY_HOST = "SecondaryDC"; - private static final String RETRY_TEST_HEADER = "TestHeader"; - private static final String RETRY_TEST_QUERY_PARAM = "TestQueryParam"; - - private final ByteBuffer retryTestDefaultData = ByteBuffer.wrap("Default data".getBytes()); - private final HttpResponse retryTestOkResponse = new RetryTestResponse(200); - - /* - We wrap the response in a StorageErrorException to mock the HttpClient. Any responses that the HttpClient receives - that is not an expected response is wrapped in a StorageErrorException. - */ - private final HttpResponse retryTestTemporaryErrorResponse = new RetryTestResponse(503); - - private final HttpResponse retryTestTimeoutErrorResponse = new RetryTestResponse(500); - - private final HttpResponse retryTestNonRetryableError = new RetryTestResponse(400); - - private final HttpResponse retryTestNotFoundResponse = new RetryTestResponse(404); - - private int retryTestScenario; - - private RequestRetryOptions options; - - /* - It is atypical and not recommended to have mutable state on the factory itself. However, the tests will need to - be able to validate the number of tries, and the tests will not have access to the policies, so we break our own - rule here. - */ - private int tryNumber; - - private OffsetDateTime time; - - RequestRetryTestFactory(int scenario, RequestRetryOptions options) { - this.retryTestScenario = scenario; - this.options = options; - } - - Mono send(URL url) { - return new HttpPipelineBuilder().policies(new RequestRetryPolicy(this.options)) - .httpClient(new RetryTestClient(this)) - .build() - .send(new HttpRequest(HttpMethod.GET, url).setBody(Flux.just(retryTestDefaultData))); - } - - HttpResponse sendSync(URL url) { - return new HttpPipelineBuilder().policies(new RequestRetryPolicy(this.options)) - .httpClient(new RetryTestClient(this)) - .build() - .sendSync(new HttpRequest(HttpMethod.GET, url).setBody(BinaryData.fromByteBuffer(retryTestDefaultData)), - Context.NONE); - } - - int getTryNumber() { - return this.tryNumber; - } - - // The retry factory only really cares about the status code. - private static final class RetryTestResponse extends HttpResponse { - int statusCode; - - RetryTestResponse(int statusCode) { - super(null); - this.statusCode = statusCode; - } - - @Override - public int getStatusCode() { - return this.statusCode; - } - - @Override - public String getHeaderValue(String headerName) { - return null; - } - - @Override - public HttpHeaders getHeaders() { - return null; - } - - @Override - public Flux getBody() { - return null; - } - - @Override - public Mono getBodyAsByteArray() { - return null; - } - - @Override - public Mono getBodyAsString() { - return null; - } - - @Override - public Mono getBodyAsString(Charset charset) { - return null; - } - } - - private final class RetryTestClient implements HttpClient { - private RequestRetryTestFactory factory; - - RetryTestClient(RequestRetryTestFactory parent) { - this.factory = parent; - } - - @Override - public Mono send(HttpRequest request) { - this.factory.tryNumber++; - if (this.factory.tryNumber > this.factory.options.getMaxTries()) { - throw new IllegalArgumentException("Try number has exceeded max tries"); - } - - // Validate the expected preconditions for each try: The correct host is used. - String expectedHost = RETRY_TEST_PRIMARY_HOST; - if (this.factory.tryNumber % 2 == 0) { - /* - Special cases: retry until success scenario fail's on the 4th try with a 404 on the secondary, so we - never expect it to check the secondary after that. All other tests should continue to check the - secondary. - Exponential timing only tests secondary backoff once but uses the rest of the retries to hit the max - delay. - */ - if (!((this.factory.retryTestScenario == RequestRetryTestFactory.RETRY_TEST_SCENARIO_RETRY_UNTIL_SUCCESS - && this.factory.tryNumber > 4) - || (this.factory.retryTestScenario == RequestRetryTestFactory.RETRY_TEST_SCENARIO_EXPONENTIAL_TIMING - && this.factory.tryNumber > 2))) { - expectedHost = RETRY_TEST_SECONDARY_HOST; - } - } - - if (!request.getUrl().getHost().equals(expectedHost)) { - throw new IllegalArgumentException("The host does not match the expected host"); - } - - /* - This policy will add test headers and query parameters. Ensure they are removed/reset for each retry. - The retry policy should be starting with a fresh copy of the request for every try. - */ - if (request.getHeaders().getValue(RETRY_TEST_HEADER) != null) { - throw new IllegalArgumentException("Headers not reset."); - } - if ((request.getUrl().getQuery() != null && request.getUrl().getQuery().contains(RETRY_TEST_QUERY_PARAM))) { - throw new IllegalArgumentException("Query params not reset."); - } - - // Subscribe and block until all information is read to prevent a blocking on another thread exception from Reactor. - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - Disposable disposable = request.getBody().subscribe(data -> { - try { - outputStream.write(data.array()); - } catch (IOException ex) { - throw Exceptions.propagate(ex); - } - }); - while (!disposable.isDisposed()) { - LOGGER.log(LogLevel.VERBOSE, - () -> "Waiting for Flux to finish to prevent blocking on another thread exception"); - } - if (retryTestDefaultData.compareTo(ByteBuffer.wrap(outputStream.toByteArray())) != 0) { - throw new IllegalArgumentException(("Body not reset.")); - } - - /* - Modify the request as policies downstream of the retry policy are likely to do. These must be reset on each - try. - */ - request.getHeaders().put(RETRY_TEST_HEADER, "testheader"); - UrlBuilder builder = UrlBuilder.parse(request.getUrl()); - builder.setQueryParameter(RETRY_TEST_QUERY_PARAM, "testquery"); - try { - request.setUrl(builder.toUrl()); - } catch (MalformedURLException e) { - throw new IllegalArgumentException("The URL has been mangled"); - } - - switch (this.factory.retryTestScenario) { - case RETRY_TEST_SCENARIO_RETRY_UNTIL_SUCCESS: - switch (this.factory.tryNumber) { - case 1: - /* - The timer is set with a timeout on the Mono used to make the request. If the Mono - doesn't return success fast enough, it will throw a TimeoutException. We can short circuit - the waiting by simply returning an error. We will validate the time parameter later. Here, - we just test that a timeout is retried. - */ - return Mono.error(new TimeoutException()); - - case 2: - return Mono.just(retryTestTemporaryErrorResponse); - - case 3: - return Mono.just(retryTestTimeoutErrorResponse); - - case 4: - /* - By returning 404 when we should be testing against the secondary, we exercise the logic - that should prevent further tries to secondary when the secondary evidently doesn't have the - data. - */ - return Mono.just(retryTestNotFoundResponse); - - case 5: - // Just to get to a sixth try where we ensure we should not be trying the secondary again. - return Mono.just(retryTestTemporaryErrorResponse); - - case 6: - return Mono.just(retryTestOkResponse); - - default: - throw new IllegalArgumentException("Continued trying after success."); - } - - case RETRY_TEST_SCENARIO_RETRY_UNTIL_MAX_RETRIES: - return Mono.just(retryTestTemporaryErrorResponse); - - case RETRY_TEST_SCENARIO_RETRY_UNTIL_MAX_RETRIES_WITH_EXCEPTION: - return Mono.error(new IOException("Exception number " + this.factory.tryNumber)); - - case RETRY_TEST_SCENARIO_NON_RETRYABLE: - if (this.factory.tryNumber == 1) { - return Mono.just(retryTestNonRetryableError); - } else { - throw new IllegalArgumentException("Continued trying after non retryable error."); - } - - case RETRY_TEST_SCENARIO_NON_RETRYABLE_SECONDARY: - switch (this.factory.tryNumber) { - case 1: - return Mono.just(retryTestTemporaryErrorResponse); - - case 2: - return Mono.just(retryTestNonRetryableError); - - default: - throw new IllegalArgumentException("Continued trying after non retryable error."); - } - - case RETRY_TEST_SCENARIO_NETWORK_ERROR: - switch (this.factory.tryNumber) { - case 1: - // fall through - case 2: - return Mono.error(new IOException()); - - case 3: - return Mono.just(retryTestOkResponse); - - default: - throw new IllegalArgumentException("Continued retrying after success."); - } - - case RETRY_TEST_SCENARIO_WRAPPED_NETWORK_ERROR: - switch (this.factory.tryNumber) { - case 1: - // fall through - case 2: - return Mono.error(Exceptions.propagate(new IOException())); - - case 3: - return Mono.just(retryTestOkResponse); - - default: - throw new IllegalArgumentException("Continued retrying after success."); - } - - case RETRY_TEST_SCENARIO_WRAPPED_TIMEOUT_ERROR: - switch (this.factory.tryNumber) { - case 1: - // fall through - case 2: - return Mono.error(Exceptions.propagate(new TimeoutException())); - - case 3: - return Mono.just(retryTestOkResponse); - - default: - throw new IllegalArgumentException("Continued retrying after success."); - } - - case RETRY_TEST_SCENARIO_TRY_TIMEOUT: - switch (this.factory.tryNumber) { - case 1: - case 2: - return Mono.just(retryTestOkResponse) - .delaySubscription(options.getTryTimeoutDuration().plusSeconds(1)); - - case 3: - return Mono.just(retryTestOkResponse) - .delaySubscription(options.getTryTimeoutDuration().minusSeconds(1)); - - default: - throw new IllegalArgumentException("Continued retrying after success"); - } - - case RETRY_TEST_SCENARIO_EXPONENTIAL_TIMING: - switch (this.factory.tryNumber) { - case 1: - this.factory.time = OffsetDateTime.now(); - return Mono.just(retryTestTemporaryErrorResponse); - - case 2: - /* - Calculation for secondary is always the same, so we don't need to keep testing it. Not - trying the secondary any more will also speed up the test. - */ - return testDelayBounds(1, false, Mono.just(retryTestNotFoundResponse)); - - case 3: - return testDelayBounds(2, true, Mono.just(retryTestTemporaryErrorResponse)); - - case 4: - return testDelayBounds(3, true, Mono.just(retryTestTemporaryErrorResponse)); - - case 5: - /* - With the current configuration in RetryTest, the maxRetryDelay should be reached upon the - fourth try to the primary. - */ - return testMaxDelayBounds(Mono.just(retryTestTemporaryErrorResponse)); - - case 6: - return testMaxDelayBounds(Mono.just(retryTestOkResponse)); - - default: - throw new IllegalArgumentException("Max retries exceeded/continued retrying after success"); - } - - case RETRY_TEST_SCENARIO_FIXED_TIMING: - switch (this.factory.tryNumber) { - case 1: - this.factory.time = OffsetDateTime.now(); - return Mono.just(retryTestTemporaryErrorResponse); - - case 2: - return testDelayBounds(1, false, Mono.just(retryTestTemporaryErrorResponse)); - - case 3: - return testDelayBounds(2, true, Mono.just(retryTestTemporaryErrorResponse)); - - case 4: - /* - Fixed backoff means it's always the same and we never hit the max, no need to keep testing. - */ - return Mono.just(retryTestOkResponse); - - default: - throw new IllegalArgumentException("Retries continued after success."); - } - - case RETRY_TEST_SCENARIO_NON_REPLAYABLE_FLOWABLE: - switch (this.factory.tryNumber) { - case 1: - return Mono.just(retryTestTemporaryErrorResponse); - - case 2: - return Mono.error(new UnexpectedLengthException("Unexpected length", 5, 6)); - - default: - throw new IllegalArgumentException("Retries continued on non retryable error."); - } - default: - throw new IllegalArgumentException("Invalid retry test scenario."); - } - } - - @Override - public HttpResponse sendSync(HttpRequest request, Context context) { - this.factory.tryNumber++; - if (this.factory.tryNumber > this.factory.options.getMaxTries()) { - throw new IllegalArgumentException("Try number has exceeded max tries"); - } - - // Validate the expected preconditions for each try: The correct host is used. - String expectedHost = RETRY_TEST_PRIMARY_HOST; - if (this.factory.tryNumber % 2 == 0) { - /* - Special cases: retry until success scenario fail's on the 4th try with a 404 on the secondary, so we - never expect it to check the secondary after that. All other tests should continue to check the - secondary. - Exponential timing only tests secondary backoff once but uses the rest of the retries to hit the max - delay. - */ - if (!((this.factory.retryTestScenario == RequestRetryTestFactory.RETRY_TEST_SCENARIO_RETRY_UNTIL_SUCCESS - && this.factory.tryNumber > 4) - || (this.factory.retryTestScenario == RequestRetryTestFactory.RETRY_TEST_SCENARIO_EXPONENTIAL_TIMING - && this.factory.tryNumber > 2))) { - expectedHost = RETRY_TEST_SECONDARY_HOST; - } - } - - if (!request.getUrl().getHost().equals(expectedHost)) { - throw new IllegalArgumentException("The host does not match the expected host"); - } - - /* - This policy will add test headers and query parameters. Ensure they are removed/reset for each retry. - The retry policy should be starting with a fresh copy of the request for every try. - */ - if (request.getHeaders().getValue(RETRY_TEST_HEADER) != null) { - throw new IllegalArgumentException("Headers not reset."); - } - if ((request.getUrl().getQuery() != null && request.getUrl().getQuery().contains(RETRY_TEST_QUERY_PARAM))) { - throw new IllegalArgumentException("Query params not reset."); - } - - // Subscribe and block until all information is read to prevent a blocking on another thread exception from Reactor. - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try { - outputStream.write(request.getBodyAsBinaryData().toBytes()); - } catch (IOException ex) { - throw Exceptions.propagate(ex); - } - - if (retryTestDefaultData.compareTo(ByteBuffer.wrap(outputStream.toByteArray())) != 0) { - throw new IllegalArgumentException(("Body not reset.")); - } - - /* - Modify the request as policies downstream of the retry policy are likely to do. These must be reset on each - try. - */ - request.getHeaders().put(RETRY_TEST_HEADER, "testheader"); - UrlBuilder builder = UrlBuilder.parse(request.getUrl()); - builder.setQueryParameter(RETRY_TEST_QUERY_PARAM, "testquery"); - try { - request.setUrl(builder.toUrl()); - } catch (MalformedURLException e) { - throw new IllegalArgumentException("The URL has been mangled"); - } - - switch (this.factory.retryTestScenario) { - case RETRY_TEST_SCENARIO_RETRY_UNTIL_SUCCESS: - switch (this.factory.tryNumber) { - case 1: - /* - The timer is set with a timeout on the Mono used to make the request. If the Mono - doesn't return success fast enough, it will throw a TimeoutException. We can short circuit - the waiting by simply returning an error. We will validate the time parameter later. Here, - we just test that a timeout is retried. - */ - throw Exceptions.propagate(new TimeoutException()); - - case 2: - return retryTestTemporaryErrorResponse; - - case 3: - return retryTestTimeoutErrorResponse; - - case 4: - /* - By returning 404 when we should be testing against the secondary, we exercise the logic - that should prevent further tries to secondary when the secondary evidently doesn't have the - data. - */ - return retryTestNotFoundResponse; - - case 5: - // Just to get to a sixth try where we ensure we should not be trying the secondary again. - return retryTestTemporaryErrorResponse; - - case 6: - return retryTestOkResponse; - - default: - throw new IllegalArgumentException("Continued trying after success."); - } - default: - throw new IllegalArgumentException("Invalid retry test scenario."); - } - } - - /* - Calculate the delay in seconds. Round up to ensure we include the maximum value and some offset for the code - executing between the original calculation in the retry policy and this check. - */ - private long calcPrimaryDelay(int tryNumber) { - switch (this.factory.retryTestScenario) { - case RETRY_TEST_SCENARIO_EXPONENTIAL_TIMING: - return (long) Math - .ceil(((pow(2L, tryNumber - 1) - 1L) * this.factory.options.getRetryDelay().toMillis()) / 1000); - - case RETRY_TEST_SCENARIO_FIXED_TIMING: - return (long) Math.ceil(this.factory.options.getRetryDelay().toMillis() / 1000); - - default: - throw new IllegalArgumentException("Invalid test scenario"); - } - } - - private OffsetDateTime calcUpperBound(OffsetDateTime start, int primaryTryNumber, boolean tryingPrimary) { - if (tryingPrimary) { - return start.plus(calcPrimaryDelay(primaryTryNumber) * 1000 + 1000, ChronoUnit.MILLIS); - } else { - return start.plus(1500, ChronoUnit.MILLIS); - } - } - - private OffsetDateTime calcLowerBound(OffsetDateTime start, int primaryTryNumber, boolean tryingPrimary) { - if (tryingPrimary) { - return start.plus(calcPrimaryDelay(primaryTryNumber) * 1000 - 1000, ChronoUnit.MILLIS); - } else { - return start.plus(500, ChronoUnit.MILLIS); - } - } - - private Mono testDelayBounds(int primaryTryNumber, boolean tryingPrimary, - Mono response) { - /* - We have to return a new Mono so that the calculation for time is performed at the correct time, i.e. when - the Mono is actually subscribed to. This mocks an HttpClient because the requests are made only when - the Mono is subscribed to, not when all the infrastructure around it is put in place, and we care about - the delay before the request itself. - */ - return Mono.defer(() -> Mono.fromCallable(() -> { - OffsetDateTime now = OffsetDateTime.now(); - if (now.isAfter(calcUpperBound(factory.time, primaryTryNumber, tryingPrimary)) - || now.isBefore(calcLowerBound(factory.time, primaryTryNumber, tryingPrimary))) { - throw new IllegalArgumentException("Delay was not within jitter bounds"); - } - - factory.time = now; - return response.block(); - })); - } - - private Mono testMaxDelayBounds(Mono response) { - return Mono.defer(() -> Mono.fromCallable(() -> { - OffsetDateTime now = OffsetDateTime.now(); - if (now.isAfter(factory.time - .plusSeconds((long) Math.ceil((factory.options.getMaxRetryDelay().toMillis() / 1000) + 1)))) { - throw new IllegalArgumentException("Max retry delay exceeded"); - } else if (now.isBefore(factory.time - .plusSeconds((long) Math.ceil((factory.options.getMaxRetryDelay().toMillis() / 1000) - 1)))) { - throw new IllegalArgumentException("Retry did not delay long enough"); - } - - factory.time = now; - return response.block(); - })); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/RetryTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/RetryTests.java deleted file mode 100644 index 44ef32fad304..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/RetryTests.java +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpResponse; -import com.azure.core.util.logging.LogLevel; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.RetryPolicyType; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class RetryTests extends BlobTestBase { - private static URL retryTestURL; - - static { - try { - retryTestURL = new URL("https://" + RequestRetryTestFactory.RETRY_TEST_PRIMARY_HOST); - } catch (MalformedURLException e) { - LOGGER.log(LogLevel.VERBOSE, () -> "Failed to create URL for retry tests.", e); - } - } - - private static final RequestRetryOptions REQUEST_RETRY_OPTIONS = new RequestRetryOptions( - RetryPolicyType.EXPONENTIAL, 6, 2, 1000L, 4000L, RequestRetryTestFactory.RETRY_TEST_SECONDARY_HOST); - - protected void retryScenario(Runnable runnable) { - int retry = 0; - while (retry < 3) { - try { - runnable.run(); - break; - } catch (Exception ex) { - retry++; - sleepIfRunningAgainstService(1000); - } - } - } - - @Test - public void retriesUntilSuccess() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_RETRY_UNTIL_SUCCESS, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 200); - assertEquals(6, retryTestFactory.getTryNumber()); - }).verifyComplete(); - }); - } - - @Test - public void syncRetriesUntilSuccessWithPrimaryAndSecondaryHostScenario() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_RETRY_UNTIL_SUCCESS, REQUEST_RETRY_OPTIONS); - - try (HttpResponse response = retryTestFactory.sendSync(retryTestURL)) { - assertEquals(response.getStatusCode(), 200); - assertEquals(retryTestFactory.getTryNumber(), 6); - } - }); - } - - @Test - public void retriesUntilMaxRetries() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_RETRY_UNTIL_MAX_RETRIES, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 503); - assertEquals(retryTestFactory.getTryNumber(), REQUEST_RETRY_OPTIONS.getMaxTries()); - }).verifyComplete(); - }); - } - - @Test - public void retriesUntilMaxRetriesWithException() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_RETRY_UNTIL_MAX_RETRIES_WITH_EXCEPTION, - REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).expectErrorSatisfies(it -> { - assertInstanceOf(IOException.class, it); - assertEquals(it.getMessage(), "Exception number " + REQUEST_RETRY_OPTIONS.getMaxTries()); - assertNotNull(it.getSuppressed()); - assertInstanceOf(IOException.class, it.getSuppressed()[0]); - assertEquals("Exception number 1", it.getSuppressed()[0].getMessage()); - assertInstanceOf(IOException.class, it.getSuppressed()[1]); - assertEquals("Exception number 2", it.getSuppressed()[1].getMessage()); - assertInstanceOf(IOException.class, it.getSuppressed()[2]); - assertEquals("Exception number 3", it.getSuppressed()[2].getMessage()); - assertInstanceOf(IOException.class, it.getSuppressed()[3]); - assertEquals("Exception number 4", it.getSuppressed()[3].getMessage()); - assertInstanceOf(IOException.class, it.getSuppressed()[4]); - assertEquals("Exception number 5", it.getSuppressed()[4].getMessage()); - }).verify(); - }); - } - - @Test - public void retriesNonRetryable() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_NON_RETRYABLE, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 400); - assertEquals(retryTestFactory.getTryNumber(), 1); - }).verifyComplete(); - }); - } - - @Test - public void retriesNonRetryableSecondary() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_NON_RETRYABLE_SECONDARY, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 400); - assertEquals(retryTestFactory.getTryNumber(), 2); - }).verifyComplete(); - }); - } - - @Test - public void retriesNetworkError() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_NETWORK_ERROR, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 200); - assertEquals(retryTestFactory.getTryNumber(), 3); - }).verifyComplete(); - }); - } - - @Test - public void retriesWrappedNetworkError() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_WRAPPED_NETWORK_ERROR, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 200); - assertEquals(retryTestFactory.getTryNumber(), 3); - }).verifyComplete(); - }); - } - - @Test - public void retriesWrappedTimeoutError() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_WRAPPED_TIMEOUT_ERROR, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 200); - assertEquals(retryTestFactory.getTryNumber(), 3); - }).verifyComplete(); - }); - } - - @Test - public void retriesTryTimeout() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_TRY_TIMEOUT, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 200); - assertEquals(retryTestFactory.getTryNumber(), 3); - }).verifyComplete(); - }); - } - - @Test - public void retriesExponentialDelay() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_TRY_TIMEOUT, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 200); - assertEquals(retryTestFactory.getTryNumber(), 3); - }).verifyComplete(); - }); - } - - @Test - public void retriesFixedDelay() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_FIXED_TIMING, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).assertNext(it -> { - assertEquals(it.getStatusCode(), 200); - assertEquals(retryTestFactory.getTryNumber(), 4); - }).verifyComplete(); - }); - } - - @Test - public void retriesNonReplyableFlux() { - retryScenario(() -> { - RequestRetryTestFactory retryTestFactory = new RequestRetryTestFactory( - RequestRetryTestFactory.RETRY_TEST_SCENARIO_NON_REPLAYABLE_FLOWABLE, REQUEST_RETRY_OPTIONS); - - Mono responseMono = Mono.defer(() -> retryTestFactory.send(retryTestURL)); - - StepVerifier.create(responseMono).verifyErrorMatches(it -> { - assertInstanceOf(IllegalStateException.class, it); - assertTrue(it.getMessage().startsWith("The request failed because")); - assertInstanceOf(UnexpectedLengthException.class, it.getCause()); - return true; - }); - }); - } - - @ParameterizedTest - @MethodSource("retriesOptionsInvalidSupplier") - public void retriesOptionsInvalid(Integer maxTries, Integer tryTimeout, Long retryDelayInMs, - Long maxRetryDelayInMs) { - retryScenario(() -> assertThrows(IllegalArgumentException.class, - () -> new RequestRetryOptions(null, maxTries, tryTimeout, retryDelayInMs, maxRetryDelayInMs, null))); - } - - private static Stream retriesOptionsInvalidSupplier() { - return Stream.of(Arguments.of(0, null, null, null), Arguments.of(null, 0, null, null), - Arguments.of(null, null, 0L, 1L), Arguments.of(null, null, 1L, 0L), Arguments.of(null, null, null, 1L), - Arguments.of(null, null, 1L, null), Arguments.of(null, null, 5L, 4L)); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasAsyncClientTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasAsyncClientTests.java deleted file mode 100644 index 27efbf8da6a6..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasAsyncClientTests.java +++ /dev/null @@ -1,1292 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.credential.AzureSasCredential; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; -import com.azure.storage.blob.models.BlobContainerProperties; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.TaggedBlobItem; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobAsyncClient; -import com.azure.storage.blob.specialized.BlockBlobAsyncClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.implementation.AccountSasImplUtil; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import com.azure.storage.common.sas.CommonSasQueryParameters; -import com.azure.storage.common.sas.SasIpRange; -import com.azure.storage.common.sas.SasProtocol; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.function.Tuple2; -import reactor.util.function.Tuples; - -import java.io.File; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class SasAsyncClientTests extends BlobTestBase { - - private BlockBlobAsyncClient sasClient; - private String blobName; - - @BeforeEach - public void setup() { - blobName = generateBlobName(); - sasClient = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), ccAsync.getBlobContainerUrl(), - blobName).getBlockBlobAsyncClient(); - sasClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()).block(); - } - - @Test - public void blobSasAllPermissionsSuccess() { - // FE will reject a permission string it doesn't recognize - BlobSasPermission allPermissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - - if (Constants.SAS_SERVICE_VERSION.compareTo("2019-12-12") >= 0) { - allPermissions.setMovePermission(true) - .setExecutePermission(true) - .setDeleteVersionPermission(true) - .setTagsPermission(true); - } - if (Constants.SAS_SERVICE_VERSION.compareTo("2020-02-10") >= 0) { - allPermissions.setPermanentDeletePermission(true); - } - - if (Constants.SAS_SERVICE_VERSION.compareTo("2020-06-12") >= 0) { - allPermissions.setImmutabilityPolicyPermission(true); - } - - BlobServiceSasSignatureValues sasValues = generateValues(allPermissions); - - String sas = sasClient.generateSas(sasValues); - - BlockBlobAsyncClient client - = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null).getBlockBlobAsyncClient(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(client.downloadStream())) - .assertNext(r -> assertArrayEquals(DATA.getDefaultBytes(), r)) - .verifyComplete(); - - StepVerifier.create(client.getProperties()) - .assertNext(r -> assertTrue(validateSasProperties(r))) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - @Test - public void blobSasReadPermissions() { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - if (Constants.SAS_SERVICE_VERSION.compareTo("2019-12-12") >= 0) { - permissions.setMovePermission(true).setExecutePermission(true); - } - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - String sas = sasClient.generateSas(sasValues); - - BlockBlobAsyncClient client - = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null).getBlockBlobAsyncClient(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(client.download())) - .assertNext(r -> assertArrayEquals(DATA.getDefaultBytes(), r)) - .verifyComplete(); - - StepVerifier.create(client.getProperties()) - .assertNext(r -> assertTrue(validateSasProperties(r))) - .verifyComplete(); - } - - @Test - public void canUseConnectionStringWithSasAndQuestionMark() { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - String sas = sasClient.generateSas(sasValues); - - String connectionString = String.format("BlobEndpoint=%s;SharedAccessSignature=%s;", - ENVIRONMENT.getPrimaryAccount().getBlobEndpoint(), "?" + sas); - - BlobAsyncClient client = instrument(new BlobClientBuilder()).connectionString(connectionString) - .containerName(sasClient.getContainerName()) - .blobName(sasClient.getBlobName()) - .buildAsyncClient(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(client.downloadStream())) - .assertNext(r -> assertArrayEquals(DATA.getDefaultBytes(), r)) - .verifyComplete(); - - StepVerifier.create(client.getProperties()) - .assertNext(r -> assertTrue(validateSasProperties(r))) - .verifyComplete(); - } - - // RBAC replication lag - @Test - public void blobSasUserDelegation() { - liveTestScenarioWithRetry(() -> { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - if (Constants.SAS_SERVICE_VERSION.compareTo("2019-12-12") >= 0) { - permissions.setMovePermission(true).setExecutePermission(true); - } - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - Mono> response = getUserDelegationInfo().flatMap(r -> { - String sas = sasClient.generateUserDelegationSas(sasValues, r); - BlockBlobAsyncClient client - = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null).getBlockBlobAsyncClient(); - return Mono.zip(FluxUtil.collectBytesInByteBufferStream(client.downloadStream()), - client.getProperties()); - }); - - StepVerifier.create(response).assertNext(r -> { - assertArrayEquals(DATA.getDefaultBytes(), r.getT1()); - assertTrue(validateSasProperties(r.getT2())); - }).verifyComplete(); - }); - } - - @SuppressWarnings("deprecation") - @Test - public void blobSasSnapshot() { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true); - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - Mono> snapshotIDAndSasTuple = sasClient.createSnapshot().map(r -> { - BlockBlobAsyncClient snapshotBlob - = new SpecializedBlobClientBuilder().blobAsyncClient(r).buildBlockBlobAsyncClient(); - String snapshotId = snapshotBlob.getSnapshotId(); - String sas = snapshotBlob.generateSas(sasValues); - return Tuples.of(snapshotId, sas); - }); - - Flux baseBlobWithSnapshotSasResponse = snapshotIDAndSasTuple.flatMapMany(tuple -> { - AppendBlobAsyncClient client - = getBlobAsyncClient(tuple.getT2(), ccAsync.getBlobContainerUrl(), blobName, null) - .getAppendBlobAsyncClient(); - return client.download(); - }); - - // snapshot-level SAS shouldn't be able to access base blob - StepVerifier.create(baseBlobWithSnapshotSasResponse).verifyError(BlobStorageException.class); - - Mono> blobSnapshotSasResponse = snapshotIDAndSasTuple.flatMap(tuple -> { - AppendBlobAsyncClient snapClient - = getBlobAsyncClient(tuple.getT2(), ccAsync.getBlobContainerUrl(), blobName, tuple.getT1()) - .getAppendBlobAsyncClient(); - return Mono.zip(FluxUtil.collectBytesInByteBufferStream(snapClient.downloadStream()), - snapClient.getProperties()); - }); - - StepVerifier.create(blobSnapshotSasResponse).assertNext(r -> { - assertArrayEquals(DATA.getDefaultBytes(), r.getT1()); - assertTrue(validateSasProperties(r.getT2())); - }).verifyComplete(); - } - - // RBAC replication lag - @SuppressWarnings("deprecation") - @Test - public void blobSasSnapshotUserDelegation() { - liveTestScenarioWithRetry(() -> { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true); - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - Mono> snapshotIDAndSasTuple = sasClient.createSnapshot().flatMap(r -> { - BlockBlobAsyncClient snapshotBlob - = new SpecializedBlobClientBuilder().blobAsyncClient(r).buildBlockBlobAsyncClient(); - String snapshotId = snapshotBlob.getSnapshotId(); - return Mono.zip(Mono.just(snapshotId), getUserDelegationInfo() - .flatMap(info -> Mono.just(snapshotBlob.generateUserDelegationSas(sasValues, info)))); - }); - - Flux baseBlobWithSnapshotSasResponse = snapshotIDAndSasTuple.flatMapMany(tuple -> { - BlockBlobAsyncClient client - = getBlobAsyncClient(tuple.getT2(), ccAsync.getBlobContainerUrl(), blobName, null) - .getBlockBlobAsyncClient(); - return client.download(); - }); - - // snapshot-level SAS shouldn't be able to access base blob - StepVerifier.create(baseBlobWithSnapshotSasResponse).verifyError(BlobStorageException.class); - - Mono> blobSnapshotSasResponse = snapshotIDAndSasTuple.flatMap(tuple -> { - BlockBlobAsyncClient snapClient - = getBlobAsyncClient(tuple.getT2(), ccAsync.getBlobContainerUrl(), blobName, tuple.getT1()) - .getBlockBlobAsyncClient(); - return Mono.zip(FluxUtil.collectBytesInByteBufferStream(snapClient.downloadStream()), - snapClient.getProperties()); - }); - - StepVerifier.create(blobSnapshotSasResponse).assertNext(r -> { - assertArrayEquals(DATA.getDefaultBytes(), r.getT1()); - assertTrue(validateSasProperties(r.getT2())); - }).verifyComplete(); - }); - } - - // RBAC replication lag - @Test - public void containerSasUserDelegation() { - liveTestScenarioWithRetry(() -> { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - - Flux response = getUserDelegationInfo().flatMapMany(r -> { - String sasWithPermissions = ccAsync.generateUserDelegationSas(sasValues, r); - BlobContainerAsyncClient client - = getContainerAsyncClient(sasWithPermissions, ccAsync.getBlobContainerUrl()); - return client.listBlobs(); - }); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void blobSasTags() { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setTagsPermission(true); - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - String sas = sasClient.generateSas(sasValues); - BlobAsyncClient client = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - Mono> response = client.setTags(tags).then(client.getTags()); - StepVerifier.create(response).assertNext(r -> assertEquals(tags, r)).verifyComplete(); - } - - @Test - public void blobSasTagsFail() { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true); - /* No tags permission */ - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - String sas = sasClient.generateSas(sasValues); - BlobAsyncClient client = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - StepVerifier.create(client.setTags(tags)).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void containerSasTags() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true) - .setDeleteVersionPermission(true) - .setTagsPermission(true); - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sas = ccAsync.generateSas(sasValues); - BlobAsyncClient client = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - Mono> response = client.setTags(tags).then(client.getTags()); - StepVerifier.create(response).assertNext(r -> assertEquals(tags, r)).verifyComplete(); - } - - @Test - public void containerSasTagsFail() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true); - /* No tags permission. */ - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sas = sasClient.generateSas(sasValues); - BlobAsyncClient client = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - StepVerifier.create(client.setTags(tags)).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void containerSasFilterBlobs() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true) - .setDeleteVersionPermission(true) - .setTagsPermission(true) - .setFilterPermission(true); - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sas = ccAsync.generateSas(sasValues); - BlobAsyncClient client = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - Flux response = client.setTags(tags).thenMany(ccAsync.findBlobsByTags("\"foo\"='bar'")); - StepVerifier.create(response).thenConsumeWhile(x -> true).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void containerSasFilterBlobsFail() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true) - .setDeleteVersionPermission(true); - // no filter or tags permission - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sas = ccAsync.generateSas(sasValues); - BlobAsyncClient client = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - StepVerifier.create(client.setTags(tags)).verifyError(BlobStorageException.class); - } - - // RBAC replication lag - @Test - public void blobUserDelegationSaoid() { - liveTestScenarioWithRetry(() -> { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true); - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - Mono response - = getOAuthServiceAsyncClient().getUserDelegationKey(null, expiryTime).flatMap(r -> { - String keyOid = testResourceNamer.recordValueFromConfig(r.getSignedObjectId()); - r.setSignedObjectId(keyOid); - - String keyTid = testResourceNamer.recordValueFromConfig(r.getSignedTenantId()); - r.setSignedTenantId(keyTid); - - String saoid = testResourceNamer.randomUuid(); - - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions) - .setPreauthorizedAgentObjectId(saoid); - String sasWithPermissions = sasClient.generateUserDelegationSas(sasValues, r); - - BlobAsyncClient client - = getBlobAsyncClient(sasWithPermissions, ccAsync.getBlobContainerUrl(), blobName, null); - - assertDoesNotThrow(() -> sasWithPermissions.contains("saoid=" + saoid)); - - return client.getProperties(); - }); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - }); - } - - // RBAC replication lag - @Test - public void containerUserDelegationCorrelationId() { - liveTestScenarioWithRetry(() -> { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setListPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - String cid = testResourceNamer.randomUuid(); - BlobServiceSasSignatureValues sasValues - = new BlobServiceSasSignatureValues(expiryTime, permissions).setCorrelationId(cid); - - Flux response - = getOAuthServiceAsyncClient().getUserDelegationKey(null, expiryTime).flatMapMany(r -> { - String keyOid = testResourceNamer.recordValueFromConfig(r.getSignedObjectId()); - r.setSignedObjectId(keyOid); - - String keyTid = testResourceNamer.recordValueFromConfig(r.getSignedTenantId()); - r.setSignedTenantId(keyTid); - - String sasWithPermissions = ccAsync.generateUserDelegationSas(sasValues, r); - assertDoesNotThrow(() -> sasWithPermissions.contains("scid=" + cid)); - - BlobContainerAsyncClient client - = getContainerAsyncClient(sasWithPermissions, ccAsync.getBlobContainerUrl()); - - return client.listBlobs(); - }); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-02-10") - @Test - public void containerUserDelegationCorrelationIdError() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setListPermission(true); - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - String cid = "invalidcid"; - BlobServiceSasSignatureValues sasValues - = new BlobServiceSasSignatureValues(expiryTime, permissions).setCorrelationId(cid); - - Flux response = getOAuthServiceAsyncClient().getUserDelegationKey(null, expiryTime).flatMapMany(r -> { - String keyOid = testResourceNamer.recordValueFromConfig(r.getSignedObjectId()); - r.setSignedObjectId(keyOid); - - String keyTid = testResourceNamer.recordValueFromConfig(r.getSignedTenantId()); - r.setSignedTenantId(keyTid); - - String sasWithPermissions = ccAsync.generateUserDelegationSas(sasValues, r); - - BlobContainerAsyncClient client - = getContainerAsyncClient(sasWithPermissions, ccAsync.getBlobContainerUrl()); - return client.listBlobs(); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void blobSasEncryptionScope(boolean userDelegation) { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true).setWritePermission(true); - - BlobContainerClientBuilder builder - = getContainerClientBuilder(ccAsync.getBlobContainerUrl()).encryptionScope("testscope1") - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()); - - BlockBlobAsyncClient sharedKeyClient - = builder.buildAsyncClient().getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - // Generate a sas token using a client that has an encryptionScope - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - Mono response = getUserDelegationInfo().flatMap(r -> { - String sas; - if (userDelegation) { - sas = sharedKeyClient.generateUserDelegationSas(sasValues, r); - } else { - sas = sharedKeyClient.generateSas(sasValues); - } - - // Generate a sasClient that does not have an encryptionScope - sasClient = builder.sasToken(sas) - .encryptionScope(null) - .buildAsyncClient() - .getBlobAsyncClient(sharedKeyClient.getBlobName()) - .getBlockBlobAsyncClient(); - - // Uploading using the encryption scope sas should force the use of the encryptionScope - return sasClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()).then(sasClient.getProperties()); - }); - - StepVerifier.create(response) - .assertNext(r -> assertEquals("testscope1", r.getEncryptionScope())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @Test - public void accountSasEncryptionScope() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true).setWritePermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), - ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()).encryptionScope("testscope1") - .buildClient() - .generateAccountSas(sasValues); - BlockBlobAsyncClient client - = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null).getBlockBlobAsyncClient(); - - // Uploading using the encryption scope sas should force the use of the encryptionScope - Mono response - = client.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true).then(client.getProperties()); - - StepVerifier.create(response) - .assertNext(r -> assertEquals("testscope1", r.getEncryptionScope())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void accountSasTagsAndFilterTags() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setDeleteVersionPermission(true) - .setListPermission(true) - .setUpdatePermission(true) - .setProcessMessages(true) - .setFilterTagsPermission(true) - .setAddPermission(true) - .setTagsPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - BlockBlobAsyncClient client - = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null).getBlockBlobAsyncClient(); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - StepVerifier.create(client.setTags(tags).then(client.getTags())) - .assertNext(r -> assertEquals(tags, r)) - .verifyComplete(); - - BlobServiceAsyncClient serviceClient - = getServiceAsyncClient(sas, primaryBlobServiceAsyncClient.getAccountUrl()); - - StepVerifier.create(serviceClient.findBlobsByTags("\"foo\"='bar'")) - .thenConsumeWhile(x -> true) - .verifyComplete(); - } - - @Test - public void accountSasTagsFail() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setDeleteVersionPermission(true) - .setListPermission(true) - .setUpdatePermission(true) - .setProcessMessages(true) - .setFilterTagsPermission(true) - .setAddPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceAsyncClient.generateAccountSas(sasValues); - BlockBlobAsyncClient client - = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null).getBlockBlobAsyncClient(); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - StepVerifier.create(client.setTags(tags)).verifyError(BlobStorageException.class); - } - - @Test - public void accountSasFilterTagsFail() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setDeleteVersionPermission(true) - .setListPermission(true) - .setUpdatePermission(true) - .setProcessMessages(true) - .setAddPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceAsyncClient.generateAccountSas(sasValues); - BlobServiceAsyncClient client = getServiceAsyncClient(sas, primaryBlobServiceAsyncClient.getAccountUrl()); - - StepVerifier.create(client.findBlobsByTags("\"foo\"='bar'")).verifyError(BlobStorageException.class); - } - - @Test - public void accountSasBlobRead() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceAsyncClient.generateAccountSas(sasValues); - BlockBlobAsyncClient client - = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null).getBlockBlobAsyncClient(); - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(client.downloadStream())) - .assertNext(r -> assertArrayEquals(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @Test - public void accountSasBlobDeleteFails() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceAsyncClient.generateAccountSas(sasValues); - BlockBlobAsyncClient client - = getBlobAsyncClient(sas, ccAsync.getBlobContainerUrl(), blobName, null).getBlockBlobAsyncClient(); - StepVerifier.create(client.delete()).verifyError(BlobStorageException.class); - } - - @Test - public void accountSasCreateContainerFails() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions - = new AccountSasPermission().setReadPermission(true).setCreatePermission(false); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceAsyncClient.generateAccountSas(sasValues); - BlobServiceAsyncClient sc = getServiceAsyncClient(sas, primaryBlobServiceAsyncClient.getAccountUrl()); - StepVerifier.create(sc.createBlobContainer(generateContainerName())).verifyError(BlobStorageException.class); - } - - @Test - public void accountSasCreateContainerSucceeds() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true).setCreatePermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceAsyncClient.generateAccountSas(sasValues); - BlobServiceAsyncClient sc = getServiceAsyncClient(sas, primaryBlobServiceAsyncClient.getAccountUrl()); - StepVerifier.create(sc.createBlobContainer(generateContainerName())).expectNextCount(1).verifyComplete(); - } - - @Test - public void accountSasOnEndpoint() throws IOException { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true).setCreatePermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceAsyncClient.generateAccountSas(sasValues); - - BlobServiceAsyncClient sc = getServiceAsyncClient(primaryBlobServiceAsyncClient.getAccountUrl() + "?" + sas); - BlobContainerAsyncClient cc - = getContainerClientBuilder(primaryBlobServiceAsyncClient.getAccountUrl() + "/" + containerName + "?" + sas) - .buildAsyncClient(); - Mono response - = sc.createBlobContainer(generateContainerName()).then(cc.getProperties()); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - - BlobAsyncClient bc = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - primaryBlobServiceAsyncClient.getAccountUrl() + "/" + containerName + "/" + blobName + "?" + sas); - File file = getRandomFile(256); - file.deleteOnExit(); - StepVerifier.create(bc.uploadFromFile(file.toPath().toString(), true)).verifyComplete(); - } - - @Test - public void canUseSasToAuthenticate() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceAsyncClient.generateAccountSas(sasValues); - - BlobAsyncClient client = instrument( - new BlobClientBuilder().endpoint(ccAsync.getBlobContainerUrl()).blobName(blobName).sasToken(sas)) - .buildAsyncClient(); - StepVerifier.create(client.getProperties()).expectNextCount(1).verifyComplete(); - - client = instrument(new BlobClientBuilder().endpoint(ccAsync.getBlobContainerUrl()) - .blobName(blobName) - .credential(new AzureSasCredential(sas))).buildAsyncClient(); - StepVerifier.create(client.getProperties()).expectNextCount(1).verifyComplete(); - - client - = instrument(new BlobClientBuilder().endpoint(ccAsync.getBlobContainerUrl() + "?" + sas).blobName(blobName)) - .buildAsyncClient(); - StepVerifier.create(client.getProperties()).expectNextCount(1).verifyComplete(); - - BlockBlobAsyncClient blockClient = instrument( - new SpecializedBlobClientBuilder().endpoint(ccAsync.getBlobContainerUrl()).blobName(blobName).sasToken(sas)) - .buildBlockBlobAsyncClient(); - StepVerifier.create(blockClient.getProperties()).expectNextCount(1).verifyComplete(); - - blockClient = instrument(new SpecializedBlobClientBuilder().endpoint(ccAsync.getBlobContainerUrl()) - .blobName(blobName) - .credential(new AzureSasCredential(sas))).buildBlockBlobAsyncClient(); - StepVerifier.create(blockClient.getProperties()).expectNextCount(1).verifyComplete(); - - blockClient = instrument( - new SpecializedBlobClientBuilder().endpoint(ccAsync.getBlobContainerUrl() + "?" + sas).blobName(blobName)) - .buildBlockBlobAsyncClient(); - StepVerifier.create(blockClient.getProperties()).expectNextCount(1).verifyComplete(); - - BlobContainerAsyncClient containerClient - = instrument(new BlobContainerClientBuilder().endpoint(ccAsync.getBlobContainerUrl()).sasToken(sas)) - .buildAsyncClient(); - StepVerifier.create(containerClient.getProperties()).expectNextCount(1).verifyComplete(); - - containerClient = instrument(new BlobContainerClientBuilder().endpoint(ccAsync.getBlobContainerUrl()) - .credential(new AzureSasCredential(sas))).buildAsyncClient(); - StepVerifier.create(containerClient.getProperties()).expectNextCount(1).verifyComplete(); - - containerClient - = instrument(new BlobContainerClientBuilder().endpoint(ccAsync.getBlobContainerUrl() + "?" + sas)) - .buildAsyncClient(); - StepVerifier.create(containerClient.getProperties()).expectNextCount(1).verifyComplete(); - - BlobServiceAsyncClient serviceClient - = instrument(new BlobServiceClientBuilder().endpoint(ccAsync.getBlobContainerUrl()).sasToken(sas)) - .buildAsyncClient(); - StepVerifier.create(serviceClient.getProperties()).expectNextCount(1).verifyComplete(); - - serviceClient = instrument(new BlobServiceClientBuilder().endpoint(ccAsync.getBlobContainerUrl()) - .credential(new AzureSasCredential(sas))).buildAsyncClient(); - StepVerifier.create(serviceClient.getProperties()).expectNextCount(1).verifyComplete(); - - serviceClient = instrument(new BlobServiceClientBuilder().endpoint(ccAsync.getBlobContainerUrl() + "?" + sas)) - .buildAsyncClient(); - StepVerifier.create(serviceClient.getProperties()).expectNextCount(1).verifyComplete(); - } - - private BlobServiceSasSignatureValues generateValues(BlobSasPermission permission) { - return new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), permission) - .setStartTime(testResourceNamer.now().minusDays(1)) - .setProtocol(SasProtocol.HTTPS_HTTP) - .setCacheControl("cache") - .setContentDisposition("disposition") - .setContentEncoding("encoding") - .setContentLanguage("language") - .setContentType("type"); - } - - private boolean validateSasProperties(BlobProperties properties) { - boolean ret; - ret = properties.getCacheControl().equals("cache"); - ret &= properties.getContentDisposition().equals("disposition"); - ret &= properties.getContentEncoding().equals("encoding"); - ret &= properties.getContentLanguage().equals("language"); - return ret; - } - - private Mono getUserDelegationInfo() { - return getOAuthServiceAsyncClient() - .getUserDelegationKey(testResourceNamer.now().minusDays(1), testResourceNamer.now().plusDays(1)) - .flatMap(r -> { - String keyOid = testResourceNamer.recordValueFromConfig(r.getSignedObjectId()); - r.setSignedObjectId(keyOid); - String keyTid = testResourceNamer.recordValueFromConfig(r.getSignedTenantId()); - r.setSignedTenantId(keyTid); - return Mono.just(r); - }); - } - - /* - This test will ensure that each field gets placed into the proper location within the string to sign and that null - values are handled correctly. We will validate the whole SAS with service calls as well as correct serialization of - individual parts later. - */ - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @MethodSource("blobSasImplUtilStringToSignSupplier") - public void blobSasImplUtilStringToSign(OffsetDateTime startTime, String identifier, SasIpRange ipRange, - SasProtocol protocol, String snapId, String cacheControl, String disposition, String encoding, String language, - String type, String versionId, String encryptionScope, String expectedStringToSign) { - OffsetDateTime e = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - BlobSasPermission p = new BlobSasPermission(); - p.setReadPermission(true); - BlobServiceSasSignatureValues v = new BlobServiceSasSignatureValues(e, p); - - String expected = String.format(expectedStringToSign, ENVIRONMENT.getPrimaryAccount().getName()); - - v.setStartTime(startTime); - - if (ipRange != null) { - SasIpRange ipR = new SasIpRange(); - ipR.setIpMin("ip"); - v.setSasIpRange(ipR); - } - - v.setIdentifier(identifier) - .setProtocol(protocol) - .setCacheControl(cacheControl) - .setContentDisposition(disposition) - .setContentEncoding(encoding) - .setContentLanguage(language) - .setContentType(type); - - BlobSasImplUtil implUtil - = new BlobSasImplUtil(v, "containerName", "blobName", snapId, versionId, encryptionScope); - - String sasToken = implUtil.generateSas(ENVIRONMENT.getPrimaryAccount().getCredential(), Context.NONE); - - CommonSasQueryParameters token - = BlobUrlParts.parse(ccAsync.getBlobContainerUrl() + "?" + sasToken).getCommonSasQueryParameters(); - - assertEquals(token.getSignature(), ENVIRONMENT.getPrimaryAccount().getCredential().computeHmac256(expected)); - } - - /* - We don't test the blob or containerName properties because canonicalized resource is always added as at least - /blob/accountName. We test canonicalization of resources later. Again, this is not to test a fully functional - sas but the construction of the string to sign. - Signed resource is tested elsewhere, as we work some minor magic in choosing which value to use. - */ - private static Stream blobSasImplUtilStringToSignSupplier() { - return Stream.of( - Arguments.of(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC), null, null, null, null, null, null, - null, null, null, null, null, - "r\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, "id", null, null, null, null, null, null, null, null, null, null, "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\nid\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, new SasIpRange(), null, null, null, null, null, null, null, null, null, "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\nip\n\n" + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, SasProtocol.HTTPS_ONLY, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n" + SasProtocol.HTTPS_ONLY + "\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, "snapId", null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nbs\nsnapId\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, "control", null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\ncontrol\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, "disposition", null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\ndisposition\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "encoding", null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\nencoding\n\n"), - Arguments.of(null, null, null, null, null, null, null, null, "language", null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\nlanguage\n"), - Arguments.of(null, null, null, null, null, null, null, null, null, "type", null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\ntype"), - Arguments.of(null, null, null, null, null, null, null, null, null, null, "versionId", null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nbv\nversionId\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, null, null, null, null, "encryptionScope", - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\nencryptionScope\n\n\n\n\n")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @MethodSource("blobSasImplUtilStringToSignUserDelegationKeySupplier") - public void blobSasImplUtilStringToSignUserDelegationKey(OffsetDateTime startTime, String keyOid, String keyTid, - OffsetDateTime keyStart, OffsetDateTime keyExpiry, String keyService, String keyVersion, String keyValue, - SasIpRange ipRange, SasProtocol protocol, String snapId, String cacheControl, String disposition, - String encoding, String language, String type, String versionId, String saoid, String cid, - String encryptionScope, String expectedStringToSign) { - OffsetDateTime e = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - BlobSasPermission p = new BlobSasPermission().setReadPermission(true); - BlobServiceSasSignatureValues v = new BlobServiceSasSignatureValues(e, p); - - String expected = String.format(expectedStringToSign, ENVIRONMENT.getPrimaryAccount().getName()); - - v.setStartTime(startTime); - - if (ipRange != null) { - SasIpRange ipR = new SasIpRange(); - ipR.setIpMin("ip"); - v.setSasIpRange(ipR); - } - - v.setProtocol(protocol) - .setCacheControl(cacheControl) - .setContentDisposition(disposition) - .setContentEncoding(encoding) - .setContentLanguage(language) - .setContentType(type) - .setPreauthorizedAgentObjectId(saoid) - .setCorrelationId(cid); - - UserDelegationKey key = new UserDelegationKey().setSignedObjectId(keyOid) - .setSignedTenantId(keyTid) - .setSignedStart(keyStart) - .setSignedExpiry(keyExpiry) - .setSignedService(keyService) - .setSignedVersion(keyVersion) - .setValue(keyValue); - - BlobSasImplUtil implUtil - = new BlobSasImplUtil(v, "containerName", "blobName", snapId, versionId, encryptionScope); - String sasToken - = implUtil.generateUserDelegationSas(key, ENVIRONMENT.getPrimaryAccount().getName(), Context.NONE); - CommonSasQueryParameters token - = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getCommonSasQueryParameters(); - - assertEquals(token.getSignature(), StorageImplUtils.computeHMac256(key.getValue(), expected)); - } - - /* - We test string to sign functionality directly related toUserDelegation sas specific parameters - */ - private static Stream blobSasImplUtilStringToSignUserDelegationKeySupplier() { - return Stream.of( - Arguments.of(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC), null, null, null, null, null, null, - "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, null, null, - null, null, null, - "r\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, "11111111-1111-1111-1111-111111111111", null, null, null, null, null, - "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, null, null, - null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n11111111-1111-1111-1111-111111111111\n\n\n\n\n\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, "22222222-2222-2222-2222-222222222222", null, null, null, null, - "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, null, null, - null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n22222222-2222-2222-2222-222222222222\n\n\n\n\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, OffsetDateTime.of(LocalDateTime.of(2018, 1, 1, 0, 0), ZoneOffset.UTC), null, - null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, - null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n2018-01-01T00:00:00Z\n\n\n\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, OffsetDateTime.of(LocalDateTime.of(2018, 1, 1, 0, 0), ZoneOffset.UTC), - null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, - null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n2018-01-01T00:00:00Z\n\n\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, "b", null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\nb\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, "2018-06-17", - "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, null, null, - null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n2018-06-17\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", - new SasIpRange(), null, null, null, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\nip\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - SasProtocol.HTTPS_ONLY, null, null, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n" + SasProtocol.HTTPS_ONLY + "\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, "snapId", null, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nbs\nsnapId\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, "control", null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\ncontrol\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, "disposition", null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\ndisposition\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, "encoding", null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\nencoding\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, "language", null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\nlanguage\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, "type", null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\ntype"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, "versionId", null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nbv\nversionId\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, null, "saoid", null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\nsaoid\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, null, null, "cid", null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\ncid\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, null, null, null, "encryptionScope", - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\nencryptionScope\n\n\n\n\n")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @MethodSource("blobSasImplUtilCanonicalizedResourceSupplier") - public void blobSasImplUtilCanonicalizedResource(String containerName, String blobName, String snapId, - OffsetDateTime expiryTime, String expectedResource, String expectedStringToSign) { - BlobServiceSasSignatureValues v = new BlobServiceSasSignatureValues(expiryTime, new BlobSasPermission()); - BlobSasImplUtil implUtil = new BlobSasImplUtil(v, containerName, blobName, snapId, null, null); - - expectedStringToSign = String.format(expectedStringToSign, - Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiryTime), ENVIRONMENT.getPrimaryAccount().getName()); - - String token = implUtil.generateSas(ENVIRONMENT.getPrimaryAccount().getCredential(), Context.NONE); - - CommonSasQueryParameters queryParams = new CommonSasQueryParameters(SasImplUtils.parseQueryString(token), true); - - assertEquals(queryParams.getSignature(), - ENVIRONMENT.getPrimaryAccount().getCredential().computeHmac256(expectedStringToSign)); - assertEquals(expectedResource, queryParams.getResource()); - } - - private static Stream blobSasImplUtilCanonicalizedResourceSupplier() { - return Stream.of( - Arguments.of("c", "b", "id", OffsetDateTime.now(), "bs", - "\n\n%s\n" + "/blob/%s/c/b\n\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nbs\nid\n\n\n\n\n\n"), - Arguments.of("c", "b", null, OffsetDateTime.now(), "b", - "\n\n%s\n" + "/blob/%s/c/b\n\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of("c", null, null, OffsetDateTime.now(), "c", - "\n\n%s\n" + "/blob/%s/c\n\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nc\n\n\n\n\n\n\n")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @MethodSource("accountSasImplUtilStringToSignSupplier") - public void accountSasImplUtilStringToSign(OffsetDateTime startTime, SasIpRange ipRange, SasProtocol protocol, - String encryptionScope, String expectedStringToSign) { - AccountSasPermission p = new AccountSasPermission().setReadPermission(true); - OffsetDateTime e = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - AccountSasService s = new AccountSasService().setBlobAccess(true); - AccountSasResourceType rt = new AccountSasResourceType().setObject(true); - AccountSasSignatureValues v = new AccountSasSignatureValues(e, p, s, rt).setStartTime(startTime); - if (ipRange != null) { - SasIpRange ipR = new SasIpRange(); - ipR.setIpMin("ip"); - v.setSasIpRange(ipR); - } - - v.setProtocol(protocol); - - AccountSasImplUtil implUtil = new AccountSasImplUtil(v, encryptionScope); - String sasToken = implUtil.generateSas(ENVIRONMENT.getPrimaryAccount().getCredential(), Context.NONE); - CommonSasQueryParameters token - = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getCommonSasQueryParameters(); - - assertEquals(token.getSignature(), - ENVIRONMENT.getPrimaryAccount() - .getCredential() - .computeHmac256(String.format(expectedStringToSign, ENVIRONMENT.getPrimaryAccount().getName()))); - } - - private static Stream accountSasImplUtilStringToSignSupplier() { - return Stream.of( - Arguments.of(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC), null, null, null, - "%s" + "\nr\nb\no\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n\n\n" + Constants.SAS_SERVICE_VERSION + "\n\n"), - Arguments.of(null, new SasIpRange(), null, null, - "%s" + "\nr\nb\no\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\nip\n\n" + Constants.SAS_SERVICE_VERSION + "\n\n"), - Arguments.of(null, null, SasProtocol.HTTPS_ONLY, null, - "%s" + "\nr\nb\no\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.SAS_SERVICE_VERSION + "\n\n"), - Arguments.of(null, null, null, "encryptionScope", - "%s" + "\nr\nb\no\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nencryptionScope\n")); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.java deleted file mode 100644 index 816d8e82af56..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.java +++ /dev/null @@ -1,1222 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.credential.AzureSasCredential; -import com.azure.core.util.Context; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.AppendBlobClient; -import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.implementation.AccountSasImplUtil; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.implementation.StorageImplUtils; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import com.azure.storage.common.sas.CommonSasQueryParameters; -import com.azure.storage.common.sas.SasIpRange; -import com.azure.storage.common.sas.SasProtocol; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class SasClientTests extends BlobTestBase { - private BlockBlobClient sasClient; - private String blobName; - - @BeforeEach - public void setup() { - blobName = generateBlobName(); - sasClient = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), cc.getBlobContainerUrl(), blobName) - .getBlockBlobClient(); - sasClient.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - } - - @Test - public void blobSasAllPermissionsSuccess() { - // FE will reject a permission string it doesn't recognize - BlobSasPermission allPermissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - - if (Constants.SAS_SERVICE_VERSION.compareTo("2019-12-12") >= 0) { - allPermissions.setMovePermission(true) - .setExecutePermission(true) - .setDeleteVersionPermission(true) - .setTagsPermission(true); - } - if (Constants.SAS_SERVICE_VERSION.compareTo("2020-02-10") >= 0) { - allPermissions.setPermanentDeletePermission(true); - } - - if (Constants.SAS_SERVICE_VERSION.compareTo("2020-06-12") >= 0) { - allPermissions.setImmutabilityPolicyPermission(true); - } - - BlobServiceSasSignatureValues sasValues = generateValues(allPermissions); - - String sas = sasClient.generateSas(sasValues); - - BlockBlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient(); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - client.downloadStream(os); - BlobProperties properties = client.getProperties(); - - assertEquals(DATA.getDefaultText(), os.toString()); - assertTrue(validateSasProperties(properties)); - } - - @SuppressWarnings("deprecation") - @Test - public void blobSasReadPermissions() { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - if (Constants.SAS_SERVICE_VERSION.compareTo("2019-12-12") >= 0) { - permissions.setMovePermission(true).setExecutePermission(true); - } - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - String sas = sasClient.generateSas(sasValues); - - BlockBlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient(); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - client.download(os); - BlobProperties properties = client.getProperties(); - assertEquals(DATA.getDefaultText(), os.toString()); - assertTrue(validateSasProperties(properties)); - } - - @Test - public void canUseConnectionStringWithSasAndQuestionMark() { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - String sas = sasClient.generateSas(sasValues); - - String connectionString = String.format("BlobEndpoint=%s;SharedAccessSignature=%s;", - ENVIRONMENT.getPrimaryAccount().getBlobEndpoint(), "?" + sas); - - BlobClient client = instrument(new BlobClientBuilder()).connectionString(connectionString) - .containerName(sasClient.getContainerName()) - .blobName(sasClient.getBlobName()) - .buildClient(); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - client.downloadStream(os); - BlobProperties properties = client.getProperties(); - assertEquals(DATA.getDefaultText(), os.toString()); - assertTrue(validateSasProperties(properties)); - } - - // RBAC replication lag - @Test - public void blobSasUserDelegation() { - liveTestScenarioWithRetry(() -> { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - if (Constants.SAS_SERVICE_VERSION.compareTo("2019-12-12") >= 0) { - permissions.setMovePermission(true).setExecutePermission(true); - } - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - String sas = sasClient.generateUserDelegationSas(sasValues, getUserDelegationInfo()); - - BlockBlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient(); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - client.downloadStream(os); - BlobProperties properties = client.getProperties(); - - assertEquals(DATA.getDefaultText(), os.toString()); - assertTrue(validateSasProperties(properties)); - }); - } - - @SuppressWarnings("deprecation") - @Test - public void blobSasSnapshot() { - BlockBlobClient snapshotBlob - = new SpecializedBlobClientBuilder().blobClient(sasClient.createSnapshot()).buildBlockBlobClient(); - String snapshotId = snapshotBlob.getSnapshotId(); - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true); - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - String sas = snapshotBlob.generateSas(sasValues); - - // base blob with snapshot SAS - AppendBlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getAppendBlobClient(); - // snapshot-level SAS shouldn't be able to access base blob - assertThrows(BlobStorageException.class, () -> client.download(new ByteArrayOutputStream())); - - // blob snapshot with snapshot SAS - AppendBlobClient snapClient - = getBlobClient(sas, cc.getBlobContainerUrl(), blobName, snapshotId).getAppendBlobClient(); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - snapClient.downloadStream(os); - - BlobProperties properties = snapClient.getProperties(); - assertEquals(DATA.getDefaultText(), os.toString()); - - assertTrue(validateSasProperties(properties)); - } - - // RBAC replication lag - @SuppressWarnings("deprecation") - @Test - public void blobSasSnapshotUserDelegation() { - liveTestScenarioWithRetry(() -> { - BlockBlobClient snapshotBlob - = new SpecializedBlobClientBuilder().blobClient(sasClient.createSnapshot()).buildBlockBlobClient(); - String snapshotId = snapshotBlob.getSnapshotId(); - - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true); - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - String sas = snapshotBlob.generateUserDelegationSas(sasValues, getUserDelegationInfo()); - - // base blob with snapshot SAS - BlockBlobClient client1 = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient(); - // snapshot-level SAS shouldn't be able to access base blob - assertThrows(BlobStorageException.class, () -> client1.download(new ByteArrayOutputStream())); - - // blob snapshot with snapshot SAS - BlockBlobClient client2 - = getBlobClient(sas, cc.getBlobContainerUrl(), blobName, snapshotId).getBlockBlobClient(); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - client2.downloadStream(os); - - BlobProperties properties = client2.getProperties(); - assertEquals(DATA.getDefaultText(), os.toString()); - assertTrue(validateSasProperties(properties)); - }); - } - - // RBAC replication lag - @Test - public void containerSasUserDelegation() { - liveTestScenarioWithRetry(() -> { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sasWithPermissions = cc.generateUserDelegationSas(sasValues, getUserDelegationInfo()); - - BlobContainerClient client = getContainerClient(sasWithPermissions, cc.getBlobContainerUrl()); - assertDoesNotThrow(() -> client.listBlobs().iterator().hasNext()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void blobSasTags() { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setTagsPermission(true); - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - String sas = sasClient.generateSas(sasValues); - BlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - client.setTags(tags); - Map t = client.getTags(); - assertEquals(tags, t); - } - - @Test - public void blobSasTagsFail() { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true); - /* No tags permission */ - - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - String sas = sasClient.generateSas(sasValues); - BlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - assertThrows(BlobStorageException.class, () -> client.setTags(tags)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void containerSasTags() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true) - .setDeleteVersionPermission(true) - .setTagsPermission(true); - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sas = cc.generateSas(sasValues); - BlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - client.setTags(tags); - Map t = client.getTags(); - - assertEquals(tags, t); - } - - @Test - public void containerSasTagsFail() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true); - /* No tags permission. */ - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sas = sasClient.generateSas(sasValues); - BlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - assertThrows(BlobStorageException.class, () -> client.setTags(tags)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void containerSasFilterBlobs() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true) - .setDeleteVersionPermission(true) - .setTagsPermission(true) - .setFilterPermission(true); - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sas = cc.generateSas(sasValues); - BlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - client.setTags(tags); - - assertDoesNotThrow(() -> cc.findBlobsByTags("\"foo\"='bar'").iterator().hasNext()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-04-10") - @Test - public void containerSasFilterBlobsFail() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setAddPermission(true) - .setListPermission(true) - .setDeleteVersionPermission(true); - // no filter or tags permission - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions); - String sas = cc.generateSas(sasValues); - BlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName); - - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - //client.setTags(tags); - - assertThrows(BlobStorageException.class, () -> client.setTags(tags)); - - //assertThrows(BlobStorageException.class, () -> cc.findBlobsByTags("\"foo\"='bar'").iterator().hasNext()); - } - - // RBAC replication lag - @Test - public void blobUserDelegationSaoid() { - liveTestScenarioWithRetry(() -> { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true); - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - UserDelegationKey key = getOAuthServiceClient().getUserDelegationKey(null, expiryTime); - - String keyOid = testResourceNamer.recordValueFromConfig(key.getSignedObjectId()); - key.setSignedObjectId(keyOid); - - String keyTid = testResourceNamer.recordValueFromConfig(key.getSignedTenantId()); - key.setSignedTenantId(keyTid); - - String saoid = testResourceNamer.randomUuid(); - - BlobServiceSasSignatureValues sasValues - = new BlobServiceSasSignatureValues(expiryTime, permissions).setPreauthorizedAgentObjectId(saoid); - String sasWithPermissions = sasClient.generateUserDelegationSas(sasValues, key); - - BlobClient client = getBlobClient(sasWithPermissions, cc.getBlobContainerUrl(), blobName); - client.getProperties(); - - assertDoesNotThrow(() -> sasWithPermissions.contains("saoid=" + saoid)); - }); - } - - // RBAC replication lag - @Test - public void containerUserDelegationCorrelationId() { - liveTestScenarioWithRetry(() -> { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setListPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - UserDelegationKey key = getOAuthServiceClient().getUserDelegationKey(null, expiryTime); - - String keyOid = testResourceNamer.recordValueFromConfig(key.getSignedObjectId()); - key.setSignedObjectId(keyOid); - - String keyTid = testResourceNamer.recordValueFromConfig(key.getSignedTenantId()); - key.setSignedTenantId(keyTid); - - String cid = testResourceNamer.randomUuid(); - - BlobServiceSasSignatureValues sasValues - = new BlobServiceSasSignatureValues(expiryTime, permissions).setCorrelationId(cid); - String sasWithPermissions = cc.generateUserDelegationSas(sasValues, key); - - BlobContainerClient client = getContainerClient(sasWithPermissions, cc.getBlobContainerUrl()); - client.listBlobs().iterator().hasNext(); - - assertDoesNotThrow(() -> sasWithPermissions.contains("scid=" + cid)); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-02-10") - @Test - public void containerUserDelegationCorrelationIdError() { - BlobContainerSasPermission permissions = new BlobContainerSasPermission().setListPermission(true); - - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - UserDelegationKey key = getOAuthServiceClient().getUserDelegationKey(null, expiryTime); - - String keyOid = testResourceNamer.recordValueFromConfig(key.getSignedObjectId()); - key.setSignedObjectId(keyOid); - - String keyTid = testResourceNamer.recordValueFromConfig(key.getSignedTenantId()); - key.setSignedTenantId(keyTid); - - String cid = "invalidcid"; - - BlobServiceSasSignatureValues sasValues - = new BlobServiceSasSignatureValues(expiryTime, permissions).setCorrelationId(cid); - String sasWithPermissions = cc.generateUserDelegationSas(sasValues, key); - - BlobContainerClient client = getContainerClient(sasWithPermissions, cc.getBlobContainerUrl()); - assertThrows(BlobStorageException.class, () -> client.listBlobs().iterator().hasNext()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void blobSasEncryptionScope(boolean userDelegation) { - BlobSasPermission permissions = new BlobSasPermission().setReadPermission(true).setWritePermission(true); - - BlobContainerClientBuilder builder - = getContainerClientBuilder(cc.getBlobContainerUrl()).encryptionScope("testscope1") - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()); - - BlockBlobClient sharedKeyClient = builder.buildClient().getBlobClient(generateBlobName()).getBlockBlobClient(); - - // Generate a sas token using a client that has an encryptionScope - BlobServiceSasSignatureValues sasValues = generateValues(permissions); - - String sas; - if (userDelegation) { - sas = sharedKeyClient.generateUserDelegationSas(sasValues, getUserDelegationInfo()); - } else { - sas = sharedKeyClient.generateSas(sasValues); - } - - // Generate a sasClient that does not have an encryptionScope - sasClient = builder.sasToken(sas) - .encryptionScope(null) - .buildClient() - .getBlobClient(sharedKeyClient.getBlobName()) - .getBlockBlobClient(); - - // Uploading using the encryption scope sas should force the use of the encryptionScope - sasClient.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - assertEquals("testscope1", sasClient.getProperties().getEncryptionScope()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @Test - public void accountSasEncryptionScope() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true).setWritePermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), - ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()).encryptionScope("testscope1") - .buildClient() - .generateAccountSas(sasValues); - BlockBlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient(); - - // Uploading using the encryption scope sas should force the use of the encryptionScope - client.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - - assertEquals("testscope1", client.getProperties().getEncryptionScope()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void accountSasTagsAndFilterTags() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setDeleteVersionPermission(true) - .setListPermission(true) - .setUpdatePermission(true) - .setProcessMessages(true) - .setFilterTagsPermission(true) - .setAddPermission(true) - .setTagsPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - BlockBlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient(); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - client.setTags(tags); - - Map t = client.getTags(); - - assertEquals(tags, t); - - BlobServiceClient serviceClient = getServiceClient(sas, primaryBlobServiceClient.getAccountUrl()); - assertDoesNotThrow(() -> serviceClient.findBlobsByTags("\"foo\"='bar'").iterator().hasNext()); - } - - @Test - public void accountSasTagsFail() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setDeleteVersionPermission(true) - .setListPermission(true) - .setUpdatePermission(true) - .setProcessMessages(true) - .setFilterTagsPermission(true) - .setAddPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - BlockBlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient(); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - assertThrows(BlobStorageException.class, () -> client.setTags(tags)); - } - - @Test - public void accountSasFilterTagsFail() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true) - .setWritePermission(true) - .setCreatePermission(true) - .setDeletePermission(true) - .setDeleteVersionPermission(true) - .setListPermission(true) - .setUpdatePermission(true) - .setProcessMessages(true) - .setAddPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - BlobServiceClient client = getServiceClient(sas, primaryBlobServiceClient.getAccountUrl()); - - assertThrows(BlobStorageException.class, () -> client.findBlobsByTags("\"foo\"='bar'").iterator().hasNext()); - } - - @Test - public void accountSasBlobRead() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - BlockBlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient(); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - client.downloadStream(os); - - assertEquals(DATA.getDefaultText(), os.toString()); - } - - @Test - public void accountSasBlobDeleteFails() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - BlockBlobClient client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient(); - assertThrows(BlobStorageException.class, client::delete); - } - - @Test - public void accountSasCreateContainerFails() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions - = new AccountSasPermission().setReadPermission(true).setCreatePermission(false); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - BlobServiceClient sc = getServiceClient(sas, primaryBlobServiceClient.getAccountUrl()); - assertThrows(BlobStorageException.class, () -> sc.createBlobContainer(generateContainerName())); - } - - @Test - public void accountSasCreateContainerSucceeds() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true).setCreatePermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - BlobServiceClient sc = getServiceClient(sas, primaryBlobServiceClient.getAccountUrl()); - assertDoesNotThrow(() -> sc.createBlobContainer(generateContainerName())); - } - - @Test - public void accountSasOnEndpoint() throws IOException { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true).setCreatePermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - - BlobServiceClient sc = getServiceClient(primaryBlobServiceClient.getAccountUrl() + "?" + sas); - sc.createBlobContainer(generateContainerName()); - - BlobContainerClient cc - = getContainerClientBuilder(primaryBlobServiceClient.getAccountUrl() + "/" + containerName + "?" + sas) - .buildClient(); - assertDoesNotThrow(cc::getProperties); - - BlobClient bc = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - primaryBlobServiceClient.getAccountUrl() + "/" + containerName + "/" + blobName + "?" + sas); - File file = getRandomFile(256); - file.deleteOnExit(); - assertDoesNotThrow(() -> bc.uploadFromFile(file.toPath().toString(), true)); - } - - @Test - public void canUseSasToAuthenticate() { - AccountSasService service = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceType - = new AccountSasResourceType().setContainer(true).setService(true).setObject(true); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true); - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasSignatureValues sasValues - = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType); - String sas = primaryBlobServiceClient.generateAccountSas(sasValues); - - assertDoesNotThrow(() -> instrument( - new BlobClientBuilder().endpoint(cc.getBlobContainerUrl()).blobName(blobName).sasToken(sas)).buildClient() - .getProperties()); - - assertDoesNotThrow(() -> instrument(new BlobClientBuilder().endpoint(cc.getBlobContainerUrl()) - .blobName(blobName) - .credential(new AzureSasCredential(sas))).buildClient().getProperties()); - - assertDoesNotThrow( - () -> instrument(new BlobClientBuilder().endpoint(cc.getBlobContainerUrl() + "?" + sas).blobName(blobName)) - .buildClient() - .getProperties()); - - assertDoesNotThrow(() -> instrument( - new SpecializedBlobClientBuilder().endpoint(cc.getBlobContainerUrl()).blobName(blobName).sasToken(sas)) - .buildBlockBlobClient() - .getProperties()); - - assertDoesNotThrow(() -> instrument(new SpecializedBlobClientBuilder().endpoint(cc.getBlobContainerUrl()) - .blobName(blobName) - .credential(new AzureSasCredential(sas))).buildBlockBlobClient().getProperties()); - - assertDoesNotThrow(() -> instrument( - new SpecializedBlobClientBuilder().endpoint(cc.getBlobContainerUrl() + "?" + sas).blobName(blobName)) - .buildBlockBlobClient() - .getProperties()); - - assertDoesNotThrow( - () -> instrument(new BlobContainerClientBuilder().endpoint(cc.getBlobContainerUrl()).sasToken(sas)) - .buildClient() - .getProperties()); - - assertDoesNotThrow(() -> instrument( - new BlobContainerClientBuilder().endpoint(cc.getBlobContainerUrl()).credential(new AzureSasCredential(sas))) - .buildClient() - .getProperties()); - - assertDoesNotThrow( - () -> instrument(new BlobContainerClientBuilder().endpoint(cc.getBlobContainerUrl() + "?" + sas)) - .buildClient() - .getProperties()); - - assertDoesNotThrow( - () -> instrument(new BlobServiceClientBuilder().endpoint(cc.getBlobContainerUrl()).sasToken(sas)) - .buildClient() - .getProperties()); - - assertDoesNotThrow(() -> instrument( - new BlobServiceClientBuilder().endpoint(cc.getBlobContainerUrl()).credential(new AzureSasCredential(sas))) - .buildClient() - .getProperties()); - - assertDoesNotThrow( - () -> instrument(new BlobServiceClientBuilder().endpoint(cc.getBlobContainerUrl() + "?" + sas)) - .buildClient() - .getProperties()); - } - - private BlobServiceSasSignatureValues generateValues(BlobSasPermission permission) { - return new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), permission) - .setStartTime(testResourceNamer.now().minusDays(1)) - .setProtocol(SasProtocol.HTTPS_HTTP) - .setCacheControl("cache") - .setContentDisposition("disposition") - .setContentEncoding("encoding") - .setContentLanguage("language") - .setContentType("type"); - } - - private boolean validateSasProperties(BlobProperties properties) { - boolean ret; - ret = properties.getCacheControl().equals("cache"); - ret &= properties.getContentDisposition().equals("disposition"); - ret &= properties.getContentEncoding().equals("encoding"); - ret &= properties.getContentLanguage().equals("language"); - return ret; - } - - private UserDelegationKey getUserDelegationInfo() { - UserDelegationKey key = getOAuthServiceClient().getUserDelegationKey(testResourceNamer.now().minusDays(1), - testResourceNamer.now().plusDays(1)); - String keyOid = testResourceNamer.recordValueFromConfig(key.getSignedObjectId()); - key.setSignedObjectId(keyOid); - String keyTid = testResourceNamer.recordValueFromConfig(key.getSignedTenantId()); - key.setSignedTenantId(keyTid); - return key; - } - - /* - This test will ensure that each field gets placed into the proper location within the string to sign and that null - values are handled correctly. We will validate the whole SAS with service calls as well as correct serialization of - individual parts later. - */ - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @MethodSource("blobSasImplUtilStringToSignSupplier") - public void blobSasImplUtilStringToSign(OffsetDateTime startTime, String identifier, SasIpRange ipRange, - SasProtocol protocol, String snapId, String cacheControl, String disposition, String encoding, String language, - String type, String versionId, String encryptionScope, String expectedStringToSign) { - OffsetDateTime e = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - BlobSasPermission p = new BlobSasPermission(); - p.setReadPermission(true); - BlobServiceSasSignatureValues v = new BlobServiceSasSignatureValues(e, p); - - String expected = String.format(expectedStringToSign, ENVIRONMENT.getPrimaryAccount().getName()); - - v.setStartTime(startTime); - - if (ipRange != null) { - SasIpRange ipR = new SasIpRange(); - ipR.setIpMin("ip"); - v.setSasIpRange(ipR); - } - - v.setIdentifier(identifier) - .setProtocol(protocol) - .setCacheControl(cacheControl) - .setContentDisposition(disposition) - .setContentEncoding(encoding) - .setContentLanguage(language) - .setContentType(type); - - BlobSasImplUtil implUtil - = new BlobSasImplUtil(v, "containerName", "blobName", snapId, versionId, encryptionScope); - - String sasToken = implUtil.generateSas(ENVIRONMENT.getPrimaryAccount().getCredential(), Context.NONE); - - CommonSasQueryParameters token - = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getCommonSasQueryParameters(); - - assertEquals(token.getSignature(), ENVIRONMENT.getPrimaryAccount().getCredential().computeHmac256(expected)); - } - - /* - We don't test the blob or containerName properties because canonicalized resource is always added as at least - /blob/accountName. We test canonicalization of resources later. Again, this is not to test a fully functional - sas but the construction of the string to sign. - Signed resource is tested elsewhere, as we work some minor magic in choosing which value to use. - */ - private static Stream blobSasImplUtilStringToSignSupplier() { - return Stream.of( - Arguments.of(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC), null, null, null, null, null, null, - null, null, null, null, null, - "r\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, "id", null, null, null, null, null, null, null, null, null, null, "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\nid\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, new SasIpRange(), null, null, null, null, null, null, null, null, null, "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\nip\n\n" + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, SasProtocol.HTTPS_ONLY, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n" + SasProtocol.HTTPS_ONLY + "\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, "snapId", null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nbs\nsnapId\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, "control", null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\ncontrol\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, "disposition", null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\ndisposition\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "encoding", null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\nencoding\n\n"), - Arguments.of(null, null, null, null, null, null, null, null, "language", null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\nlanguage\n"), - Arguments.of(null, null, null, null, null, null, null, null, null, "type", null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\ntype"), - Arguments.of(null, null, null, null, null, null, null, null, null, null, "versionId", null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nbv\nversionId\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, null, null, null, null, "encryptionScope", - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\nencryptionScope\n\n\n\n\n")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @MethodSource("blobSasImplUtilStringToSignUserDelegationKeySupplier") - public void blobSasImplUtilStringToSignUserDelegationKey(OffsetDateTime startTime, String keyOid, String keyTid, - OffsetDateTime keyStart, OffsetDateTime keyExpiry, String keyService, String keyVersion, String keyValue, - SasIpRange ipRange, SasProtocol protocol, String snapId, String cacheControl, String disposition, - String encoding, String language, String type, String versionId, String saoid, String cid, - String encryptionScope, String expectedStringToSign) { - OffsetDateTime e = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - BlobSasPermission p = new BlobSasPermission().setReadPermission(true); - BlobServiceSasSignatureValues v = new BlobServiceSasSignatureValues(e, p); - - String expected = String.format(expectedStringToSign, ENVIRONMENT.getPrimaryAccount().getName()); - - v.setStartTime(startTime); - - if (ipRange != null) { - SasIpRange ipR = new SasIpRange(); - ipR.setIpMin("ip"); - v.setSasIpRange(ipR); - } - - v.setProtocol(protocol) - .setCacheControl(cacheControl) - .setContentDisposition(disposition) - .setContentEncoding(encoding) - .setContentLanguage(language) - .setContentType(type) - .setPreauthorizedAgentObjectId(saoid) - .setCorrelationId(cid); - - UserDelegationKey key = new UserDelegationKey().setSignedObjectId(keyOid) - .setSignedTenantId(keyTid) - .setSignedStart(keyStart) - .setSignedExpiry(keyExpiry) - .setSignedService(keyService) - .setSignedVersion(keyVersion) - .setValue(keyValue); - - BlobSasImplUtil implUtil - = new BlobSasImplUtil(v, "containerName", "blobName", snapId, versionId, encryptionScope); - String sasToken - = implUtil.generateUserDelegationSas(key, ENVIRONMENT.getPrimaryAccount().getName(), Context.NONE); - CommonSasQueryParameters token - = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getCommonSasQueryParameters(); - - assertEquals(token.getSignature(), StorageImplUtils.computeHMac256(key.getValue(), expected)); - } - - /* - We test string to sign functionality directly related toUserDelegation sas specific parameters - */ - private static Stream blobSasImplUtilStringToSignUserDelegationKeySupplier() { - return Stream.of( - Arguments.of(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC), null, null, null, null, null, null, - "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, null, null, - null, null, null, - "r\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, "11111111-1111-1111-1111-111111111111", null, null, null, null, null, - "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, null, null, - null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n11111111-1111-1111-1111-111111111111\n\n\n\n\n\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, "22222222-2222-2222-2222-222222222222", null, null, null, null, - "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, null, null, - null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n22222222-2222-2222-2222-222222222222\n\n\n\n\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, OffsetDateTime.of(LocalDateTime.of(2018, 1, 1, 0, 0), ZoneOffset.UTC), null, - null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, - null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n2018-01-01T00:00:00Z\n\n\n\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, OffsetDateTime.of(LocalDateTime.of(2018, 1, 1, 0, 0), ZoneOffset.UTC), - null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, - null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n2018-01-01T00:00:00Z\n\n\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, "b", null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\nb\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, "2018-06-17", - "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, null, null, null, null, null, null, null, null, - null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n2018-06-17\n\n\n\n\n\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", - new SasIpRange(), null, null, null, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\nip\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - SasProtocol.HTTPS_ONLY, null, null, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n" + SasProtocol.HTTPS_ONLY + "\n" - + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, "snapId", null, null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nbs\nsnapId\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, "control", null, null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\ncontrol\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, "disposition", null, null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\ndisposition\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, "encoding", null, null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\nencoding\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, "language", null, null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\nlanguage\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, "type", null, null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\ntype"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, "versionId", null, null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nbv\nversionId\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, null, "saoid", null, null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\nsaoid\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, null, null, "cid", null, - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\ncid\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\n\n\n\n\n\n"), - Arguments.of(null, null, null, null, null, null, null, "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=", null, - null, null, null, null, null, null, null, null, null, null, "encryptionScope", - "r\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n\n\n\n" + Constants.SAS_SERVICE_VERSION - + "\nb\n\nencryptionScope\n\n\n\n\n")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @MethodSource("blobSasImplUtilCanonicalizedResourceSupplier") - public void blobSasImplUtilCanonicalizedResource(String containerName, String blobName, String snapId, - OffsetDateTime expiryTime, String expectedResource, String expectedStringToSign) { - BlobServiceSasSignatureValues v = new BlobServiceSasSignatureValues(expiryTime, new BlobSasPermission()); - BlobSasImplUtil implUtil = new BlobSasImplUtil(v, containerName, blobName, snapId, null, null); - - expectedStringToSign = String.format(expectedStringToSign, - Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiryTime), ENVIRONMENT.getPrimaryAccount().getName()); - - String token = implUtil.generateSas(ENVIRONMENT.getPrimaryAccount().getCredential(), Context.NONE); - - CommonSasQueryParameters queryParams = new CommonSasQueryParameters(SasImplUtils.parseQueryString(token), true); - - assertEquals(queryParams.getSignature(), - ENVIRONMENT.getPrimaryAccount().getCredential().computeHmac256(expectedStringToSign)); - assertEquals(expectedResource, queryParams.getResource()); - } - - private static Stream blobSasImplUtilCanonicalizedResourceSupplier() { - return Stream.of( - Arguments.of("c", "b", "id", OffsetDateTime.now(), "bs", - "\n\n%s\n" + "/blob/%s/c/b\n\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nbs\nid\n\n\n\n\n\n"), - Arguments.of("c", "b", null, OffsetDateTime.now(), "b", - "\n\n%s\n" + "/blob/%s/c/b\n\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nb\n\n\n\n\n\n\n"), - Arguments.of("c", null, null, OffsetDateTime.now(), "c", - "\n\n%s\n" + "/blob/%s/c\n\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nc\n\n\n\n\n\n\n")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-12-06") - @ParameterizedTest - @MethodSource("accountSasImplUtilStringToSignSupplier") - public void accountSasImplUtilStringToSign(OffsetDateTime startTime, SasIpRange ipRange, SasProtocol protocol, - String encryptionScope, String expectedStringToSign) { - AccountSasPermission p = new AccountSasPermission().setReadPermission(true); - OffsetDateTime e = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - AccountSasService s = new AccountSasService().setBlobAccess(true); - AccountSasResourceType rt = new AccountSasResourceType().setObject(true); - AccountSasSignatureValues v = new AccountSasSignatureValues(e, p, s, rt).setStartTime(startTime); - if (ipRange != null) { - SasIpRange ipR = new SasIpRange(); - ipR.setIpMin("ip"); - v.setSasIpRange(ipR); - } - - v.setProtocol(protocol); - - AccountSasImplUtil implUtil = new AccountSasImplUtil(v, encryptionScope); - String sasToken = implUtil.generateSas(ENVIRONMENT.getPrimaryAccount().getCredential(), Context.NONE); - CommonSasQueryParameters token - = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getCommonSasQueryParameters(); - - assertEquals(token.getSignature(), - ENVIRONMENT.getPrimaryAccount() - .getCredential() - .computeHmac256(String.format(expectedStringToSign, ENVIRONMENT.getPrimaryAccount().getName()))); - } - - private static Stream accountSasImplUtilStringToSignSupplier() { - return Stream.of( - Arguments.of(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC), null, null, null, - "%s" + "\nr\nb\no\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n\n\n" + Constants.SAS_SERVICE_VERSION + "\n\n"), - Arguments.of(null, new SasIpRange(), null, null, - "%s" + "\nr\nb\no\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\nip\n\n" + Constants.SAS_SERVICE_VERSION + "\n\n"), - Arguments.of(null, null, SasProtocol.HTTPS_ONLY, null, - "%s" + "\nr\nb\no\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.SAS_SERVICE_VERSION + "\n\n"), - Arguments.of(null, null, null, "encryptionScope", - "%s" + "\nr\nb\no\n\n" - + Constants.ISO_8601_UTC_DATE_FORMATTER - .format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) - + "\n\n\n" + Constants.SAS_SERVICE_VERSION + "\nencryptionScope\n")); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceApiTests.java deleted file mode 100644 index bec72862df0c..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceApiTests.java +++ /dev/null @@ -1,1346 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.Response; -import com.azure.core.test.http.NoOpHttpClient; -import com.azure.core.util.Context; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.models.BlobAnalyticsLogging; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobContainerItem; -import com.azure.storage.blob.models.BlobContainerListDetails; -import com.azure.storage.blob.models.BlobCorsRule; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobMetrics; -import com.azure.storage.blob.models.BlobRetentionPolicy; -import com.azure.storage.blob.models.BlobServiceProperties; -import com.azure.storage.blob.models.BlobServiceStatistics; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.GeoReplicationStatus; -import com.azure.storage.blob.models.ListBlobContainersOptions; -import com.azure.storage.blob.models.StaticWebsite; -import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.blob.models.TaggedBlobItem; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.options.UndeleteBlobContainerOptions; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.RetryPolicyType; -import com.azure.storage.common.policy.ServiceTimeoutPolicy; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import com.azure.storage.common.test.shared.StorageCommonTestUtils; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.PlaybackOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.ResourceLock; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.io.ByteArrayInputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ServiceApiTests extends BlobTestBase { - private BlobServiceClient anonymousClient; - private String tagKey; - private String tagValue; - - @BeforeEach - public void setup() { - // We shouldn't be getting to the network layer anyway - anonymousClient = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .httpClient(getHttpClient()) - .buildClient(); - - tagKey = testResourceNamer.randomName(prefix, 20); - tagValue = testResourceNamer.randomName(prefix, 20); - } - - private void setInitialProperties() { - BlobRetentionPolicy disabled = new BlobRetentionPolicy().setEnabled(false); - primaryBlobServiceClient - .setProperties(new BlobServiceProperties().setStaticWebsite(new StaticWebsite().setEnabled(false)) - .setDeleteRetentionPolicy(disabled) - .setCors(null) - .setHourMetrics(new BlobMetrics().setVersion("1.0").setEnabled(false).setRetentionPolicy(disabled)) - .setMinuteMetrics(new BlobMetrics().setVersion("1.0").setEnabled(false).setRetentionPolicy(disabled)) - .setLogging(new BlobAnalyticsLogging().setVersion("1.0").setRetentionPolicy(disabled)) - .setDefaultServiceVersion("2018-03-28")); - } - - private void resetProperties() { - BlobRetentionPolicy disabled = new BlobRetentionPolicy().setEnabled(false); - primaryBlobServiceClient - .setProperties(new BlobServiceProperties().setStaticWebsite(new StaticWebsite().setEnabled(false)) - .setDeleteRetentionPolicy(disabled) - .setCors(null) - .setHourMetrics(new BlobMetrics().setVersion("1.0").setEnabled(false).setRetentionPolicy(disabled)) - .setMinuteMetrics(new BlobMetrics().setVersion("1.0").setEnabled(false).setRetentionPolicy(disabled)) - .setLogging(new BlobAnalyticsLogging().setVersion("1.0").setRetentionPolicy(disabled)) - .setDefaultServiceVersion("2018-03-28")); - } - - @Test - public void listContainers() { - PagedIterable response - = primaryBlobServiceClient.listBlobContainers(new ListBlobContainersOptions().setPrefix(prefix), null); - - for (BlobContainerItem c : response) { - assertTrue(c.getName().startsWith(prefix)); - assertNotNull(c.getProperties().getLastModified()); - assertNotNull(c.getProperties().getETag()); - assertNotNull(c.getProperties().getLeaseStatus()); - assertNotNull(c.getProperties().getLeaseState()); - assertNull(c.getProperties().getLeaseDuration()); - assertNull(c.getProperties().getPublicAccess()); - assertFalse(c.getProperties().isHasLegalHold()); - assertFalse(c.getProperties().isHasImmutabilityPolicy()); - assertFalse(c.getProperties().isEncryptionScopeOverridePrevented()); - assertNotNull(c.getProperties().getDefaultEncryptionScope()); - // !c.isDeleted() // Container soft delete - } - } - - @Test - public void listContainersMin() { - assertDoesNotThrow(() -> primaryBlobServiceClient.listBlobContainers().iterator().hasNext()); - } - - @Test - public void listContainersMarker() { - for (int i = 0; i < 10; i++) { - primaryBlobServiceClient.createBlobContainer(generateContainerName()); - } - - ListBlobContainersOptions options = new ListBlobContainersOptions().setMaxResultsPerPage(5); - PagedResponse firstPage - = primaryBlobServiceClient.listBlobContainers(options, null).iterableByPage().iterator().next(); - String marker = firstPage.getContinuationToken(); - String firstContainerName = firstPage.getValue().get(0).getName(); - - PagedResponse secondPage - = primaryBlobServiceClient.listBlobContainers().iterableByPage(marker).iterator().next(); - - // Assert that the second segment is indeed after the first alphabetically - assertTrue(firstContainerName.compareTo(secondPage.getValue().get(0).getName()) < 0); - } - - @Test - public void listContainersDetails() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - String containerName = generateContainerName(); - cc = primaryBlobServiceClient.createBlobContainerWithResponse(containerName, metadata, null, null).getValue(); - - assertEquals(metadata, - primaryBlobServiceClient - .listBlobContainers( - new ListBlobContainersOptions().setDetails(new BlobContainerListDetails().setRetrieveMetadata(true)) - .setPrefix(containerName), - null) - .iterator() - .next() - .getMetadata()); - } - - @Test - public void listContainersMaxResults() { - int numContainers = 5; - int pageResults = 3; - String containerNamePrefix = generateContainerName(); - - List containers = new ArrayList<>(); - for (int i = 0; i < numContainers; i++) { - containers.add(primaryBlobServiceClient.createBlobContainer(containerNamePrefix + i)); - } - - assertEquals(pageResults, primaryBlobServiceClient - .listBlobContainers( - new ListBlobContainersOptions().setPrefix(containerNamePrefix).setMaxResultsPerPage(pageResults), null) - .iterableByPage() - .iterator() - .next() - .getValue() - .size()); - - // cleanup: - for (BlobContainerClient container : containers) { - container.delete(); - } - } - - @Test - public void listContainersMaxResultsByPage() { - int numContainers = 5; - int pageResults = 3; - String containerNamePrefix = generateContainerName(); - - List containers = new ArrayList<>(); - for (int i = 0; i < numContainers; i++) { - containers.add(primaryBlobServiceClient.createBlobContainer(containerNamePrefix + i)); - } - - for (PagedResponse page : primaryBlobServiceClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(containerNamePrefix), null) - .iterableByPage(pageResults)) { - assertTrue(page.getValue().size() <= pageResults); - } - - // cleanup: - for (BlobContainerClient container : containers) { - container.delete(); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listDeleted() { - int numContainers = 5; - String containerNamePrefix = generateContainerName(); - - List containers = new ArrayList<>(); - for (int i = 0; i < numContainers; i++) { - containers.add(primaryBlobServiceClient.createBlobContainer(containerNamePrefix + i)); - } - - // delete each container - for (BlobContainerClient container : containers) { - container.delete(); - } - - PagedIterable listResult - = primaryBlobServiceClient.listBlobContainers(new ListBlobContainersOptions().setPrefix(containerNamePrefix) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true)), null); - - for (BlobContainerItem item : listResult) { - assertTrue(item.isDeleted()); - } - assertEquals(numContainers, listResult.stream().count()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listWithAllDetails() { - int numContainers = 5; - String containerNamePrefix = generateContainerName(); - - List containers = new ArrayList<>(); - for (int i = 0; i < numContainers; i++) { - containers.add(primaryBlobServiceClient.createBlobContainer(containerNamePrefix + i)); - } - - // delete each container - for (BlobContainerClient container : containers) { - container.delete(); - } - - PagedIterable listResult - = primaryBlobServiceClient.listBlobContainers( - new ListBlobContainersOptions().setPrefix(containerNamePrefix) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true).setRetrieveMetadata(true)), - null); - - for (BlobContainerItem item : listResult) { - assertTrue(item.isDeleted()); - } - assertEquals(numContainers, listResult.stream().count()); - } - - @Test - public void listContainersError() { - assertThrows(BlobStorageException.class, - () -> primaryBlobServiceClient.listBlobContainers().streamByPage("garbage continuation token").count()); - } - - @Test - public void listContainersAnonymous() { - assertThrows(IllegalStateException.class, () -> anonymousClient.listBlobContainers().iterator()); - } - - @Test - public void listContainersWithTimeoutStillBackedByPagedStream() { - int numContainers = 5; - int pageResults = 3; - - List containers = new ArrayList<>(); - for (int i = 0; i < numContainers; i++) { - containers.add(primaryBlobServiceClient.createBlobContainer(generateContainerName())); - } - - // when: "Consume results by page, then should still have paging functionality"" - assertDoesNotThrow( - () -> primaryBlobServiceClient - .listBlobContainers(new ListBlobContainersOptions().setMaxResultsPerPage(pageResults), - Duration.ofSeconds(10)) - .streamByPage() - .count()); - - // cleanup: - for (BlobContainerClient container : containers) { - container.delete(); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - @ResourceLock("ServiceProperties") - public void listSystemContainers() { - setInitialProperties(); - - try { - BlobRetentionPolicy retentionPolicy = new BlobRetentionPolicy().setDays(5).setEnabled(true); - BlobAnalyticsLogging logging - = new BlobAnalyticsLogging().setRead(true).setVersion("1.0").setRetentionPolicy(retentionPolicy); - BlobServiceProperties serviceProps = new BlobServiceProperties().setLogging(logging); - - // Ensure $logs container exists. These will be reverted in test cleanup - primaryBlobServiceClient.setPropertiesWithResponse(serviceProps, null, null); - - sleepIfRunningAgainstService(30 * 1000); // allow the service properties to take effect - - PagedIterable containers - = primaryBlobServiceClient.listBlobContainers(new ListBlobContainersOptions() - .setDetails(new BlobContainerListDetails().setRetrieveSystemContainers(true)), null); - - assertTrue(containers.stream().anyMatch(c -> c.getName().equals("$logs"))); - } finally { - resetProperties(); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsMin() { - assertDoesNotThrow(() -> primaryBlobServiceClient.findBlobsByTags("\"key\"='value'").iterator().hasNext()); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void findBlobsQuery() { - BlobContainerClient containerClient = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - BlobClient blobClient = containerClient.getBlobClient(generateBlobName()); - blobClient - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(Collections.singletonMap("key", "value")), null, null); - blobClient = containerClient.getBlobClient(generateBlobName()); - blobClient - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(Collections.singletonMap("bar", "foo")), null, null); - blobClient = containerClient.getBlobClient(generateBlobName()); - blobClient.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - sleepIfRunningAgainstService(10 * 1000); // To allow tags to index - - PagedIterable results = primaryBlobServiceClient.findBlobsByTags( - String.format("@container='%s' AND \"bar\"='foo'", containerClient.getBlobContainerName())); - - assertEquals(1, results.stream().count()); - Map tags = results.iterator().next().getTags(); - assertEquals(1, tags.size()); - assertEquals("foo", tags.get("bar")); - - // cleanup: - containerClient.delete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsMarker() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - Map tags = Collections.singletonMap(tagKey, tagValue); - for (int i = 0; i < 10; i++) { - cc.getBlobClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags), - null, null); - } - - sleepIfRunningAgainstService(10 * 1000); // To allow tags to index - - PagedResponse firstPage - = primaryBlobServiceClient - .findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(5), null, - Context.NONE) - .iterableByPage() - .iterator() - .next(); - String marker = firstPage.getContinuationToken(); - String firstBlobName = firstPage.getValue().get(0).getName(); - - PagedResponse secondPage - = primaryBlobServiceClient - .findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(5), null, - Context.NONE) - .iterableByPage(marker) - .iterator() - .next(); - - // Assert that the second segment is indeed after the first alphabetically - assertTrue(firstBlobName.compareTo(secondPage.getValue().get(0).getName()) < 0); - - // cleanup: - cc.delete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsMaxResults() { - int numBlobs = 7; - int pageResults = 3; - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - Map tags = Collections.singletonMap(tagKey, tagValue); - - for (int i = 0; i < numBlobs; i++) { - cc.getBlobClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags), - null, null); - } - - for (PagedResponse page : primaryBlobServiceClient - .findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(pageResults), - null, Context.NONE) - .iterableByPage()) { - assertTrue(page.getValue().size() <= pageResults); - } - - // cleanup: - cc.delete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsMaxResultsByPage() { - int numBlobs = 7; - int pageResults = 3; - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - Map tags = Collections.singletonMap(tagKey, tagValue); - - for (int i = 0; i < numBlobs; i++) { - cc.getBlobClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags), - null, null); - } - - for (PagedResponse page : primaryBlobServiceClient - .findBlobsByTags(new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)), null, Context.NONE) - .iterableByPage(pageResults)) { - assertTrue(page.getValue().size() <= pageResults); - } - - // cleanup: - cc.delete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsByPage() { - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - Map tags = Collections.singletonMap(tagKey, tagValue); - - int numBlobs = 15; - int pageResults = 10; - - for (int i = 0; i < numBlobs; i++) { - cc.getBlobClient(generateBlobName()) - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()).setTags(tags), null, - null); - } - - sleepIfRunningAgainstService(10 * 1000); // To allow tags to index - - String query = String.format("\"%s\"='%s'", tagKey, tagValue); - FindBlobsOptions searchOptions = new FindBlobsOptions(query).setMaxResultsPerPage(12); - - PagedResponse response1 - = primaryBlobServiceClient.findBlobsByTags(searchOptions, null, Context.NONE) - .iterableByPage(pageResults) - .iterator() - .next(); - assertEquals(pageResults, response1.getValue().size()); - - PagedResponse response2 - = primaryBlobServiceClient.findBlobsByTags(searchOptions, null, Context.NONE) - .iterableByPage() - .iterator() - .next(); - // since no number is specified, it should use the max number specified in options - assertEquals(12, response2.getValue().size()); - } - - @Test - public void findBlobsError() { - assertThrows(BlobStorageException.class, - () -> primaryBlobServiceClient.findBlobsByTags("garbageTag").streamByPage().count()); - - } - - @Test - public void findBlobsAnonymous() { - // Invalid query, but the anonymous check will fail before hitting the wire - assertThrows(IllegalStateException.class, () -> anonymousClient.findBlobsByTags("foo=bar").iterator().next()); - - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsWithTimeoutStillBackedByPagedStream() { - int numBlobs = 5; - int pageResults = 3; - BlobContainerClient cc = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - Map tags = Collections.singletonMap(tagKey, tagValue); - - for (int i = 0; i < numBlobs; i++) { - cc.getBlobClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags), - null, null); - } - - // when: "Consume results by page, then still have paging functionality" - assertDoesNotThrow(() -> primaryBlobServiceClient.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(pageResults), - Duration.ofSeconds(10), Context.NONE).streamByPage().count()); - - // cleanup: - cc.delete(); - } - - private static void validatePropsSet(BlobServiceProperties sent, BlobServiceProperties received) { - assertEquals(sent.getLogging().isRead(), received.getLogging().isRead()); - assertEquals(sent.getLogging().isWrite(), received.getLogging().isWrite()); - assertEquals(sent.getLogging().isDelete(), received.getLogging().isDelete()); - assertEquals(sent.getLogging().getVersion(), received.getLogging().getVersion()); - assertEquals(sent.getLogging().getRetentionPolicy().isEnabled(), - received.getLogging().getRetentionPolicy().isEnabled()); - assertEquals(sent.getLogging().getRetentionPolicy().getDays(), - received.getLogging().getRetentionPolicy().getDays()); - assertEquals(sent.getCors().size(), received.getCors().size()); - assertEquals(sent.getCors().get(0).getAllowedMethods(), received.getCors().get(0).getAllowedMethods()); - assertEquals(sent.getCors().get(0).getAllowedHeaders(), received.getCors().get(0).getAllowedHeaders()); - assertEquals(sent.getCors().get(0).getAllowedOrigins(), received.getCors().get(0).getAllowedOrigins()); - assertEquals(sent.getCors().get(0).getExposedHeaders(), received.getCors().get(0).getExposedHeaders()); - assertEquals(sent.getCors().get(0).getMaxAgeInSeconds(), received.getCors().get(0).getMaxAgeInSeconds()); - assertEquals(sent.getDefaultServiceVersion(), received.getDefaultServiceVersion()); - assertEquals(sent.getHourMetrics().isEnabled(), received.getHourMetrics().isEnabled()); - assertEquals(sent.getHourMetrics().isIncludeApis(), received.getHourMetrics().isIncludeApis()); - assertEquals(sent.getHourMetrics().getRetentionPolicy().isEnabled(), - received.getHourMetrics().getRetentionPolicy().isEnabled()); - assertEquals(sent.getHourMetrics().getRetentionPolicy().getDays(), - received.getHourMetrics().getRetentionPolicy().getDays()); - assertEquals(sent.getHourMetrics().getVersion(), received.getHourMetrics().getVersion()); - assertEquals(sent.getMinuteMetrics().isEnabled(), received.getMinuteMetrics().isEnabled()); - assertEquals(sent.getMinuteMetrics().isIncludeApis(), received.getMinuteMetrics().isIncludeApis()); - assertEquals(sent.getMinuteMetrics().getRetentionPolicy().isEnabled(), - received.getMinuteMetrics().getRetentionPolicy().isEnabled()); - assertEquals(sent.getMinuteMetrics().getRetentionPolicy().getDays(), - received.getMinuteMetrics().getRetentionPolicy().getDays()); - assertEquals(sent.getMinuteMetrics().getVersion(), received.getMinuteMetrics().getVersion()); - assertEquals(sent.getDeleteRetentionPolicy().isEnabled(), received.getDeleteRetentionPolicy().isEnabled()); - assertEquals(sent.getDeleteRetentionPolicy().getDays(), received.getDeleteRetentionPolicy().getDays()); - assertEquals(sent.getStaticWebsite().isEnabled(), received.getStaticWebsite().isEnabled()); - assertEquals(sent.getStaticWebsite().getIndexDocument(), received.getStaticWebsite().getIndexDocument()); - assertEquals(sent.getStaticWebsite().getErrorDocument404Path(), - received.getStaticWebsite().getErrorDocument404Path()); - } - - @Test - @ResourceLock("ServiceProperties") - public void setGetProperties() { - setInitialProperties(); - - try { - BlobRetentionPolicy retentionPolicy = new BlobRetentionPolicy().setDays(5).setEnabled(true); - BlobAnalyticsLogging logging - = new BlobAnalyticsLogging().setRead(true).setVersion("1.0").setRetentionPolicy(retentionPolicy); - List corsRules = new ArrayList<>(); - corsRules.add(new BlobCorsRule().setAllowedMethods("GET,PUT,HEAD") - .setAllowedOrigins("*") - .setAllowedHeaders("x-ms-version") - .setExposedHeaders("x-ms-client-request-id") - .setMaxAgeInSeconds(10)); - String defaultServiceVersion = "2016-05-31"; - BlobMetrics hourMetrics = new BlobMetrics().setEnabled(true) - .setVersion("1.0") - .setRetentionPolicy(retentionPolicy) - .setIncludeApis(true); - BlobMetrics minuteMetrics = new BlobMetrics().setEnabled(true) - .setVersion("1.0") - .setRetentionPolicy(retentionPolicy) - .setIncludeApis(true); - StaticWebsite website = new StaticWebsite().setEnabled(true) - .setIndexDocument("myIndex.html") - .setErrorDocument404Path("custom/error/path.html"); - - BlobServiceProperties sentProperties = new BlobServiceProperties().setLogging(logging) - .setCors(corsRules) - .setDefaultServiceVersion(defaultServiceVersion) - .setMinuteMetrics(minuteMetrics) - .setHourMetrics(hourMetrics) - .setDeleteRetentionPolicy(retentionPolicy) - .setStaticWebsite(website); - - HttpHeaders headers - = primaryBlobServiceClient.setPropertiesWithResponse(sentProperties, null, null).getHeaders(); - - // Service properties may take up to 30s to take effect. If they weren't already in place, wait. - sleepIfRunningAgainstService(30 * 1000); - - BlobServiceProperties receivedProperties = primaryBlobServiceClient.getProperties(); - - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - validatePropsSet(sentProperties, receivedProperties); - } finally { - resetProperties(); - } - } - - // In java, we don't have support from the validator for checking the bounds on days. The service will catch these. - @Test - @ResourceLock("ServiceProperties") - public void setPropsMin() { - setInitialProperties(); - - try { - BlobRetentionPolicy retentionPolicy = new BlobRetentionPolicy().setDays(5).setEnabled(true); - BlobAnalyticsLogging logging - = new BlobAnalyticsLogging().setRead(true).setVersion("1.0").setRetentionPolicy(retentionPolicy); - List corsRules = new ArrayList<>(); - corsRules.add(new BlobCorsRule().setAllowedMethods("GET,PUT,HEAD") - .setAllowedOrigins("*") - .setAllowedHeaders("x-ms-version") - .setExposedHeaders("x-ms-client-request-id") - .setMaxAgeInSeconds(10)); - String defaultServiceVersion = "2016-05-31"; - BlobMetrics hourMetrics = new BlobMetrics().setEnabled(true) - .setVersion("1.0") - .setRetentionPolicy(retentionPolicy) - .setIncludeApis(true); - BlobMetrics minuteMetrics = new BlobMetrics().setEnabled(true) - .setVersion("1.0") - .setRetentionPolicy(retentionPolicy) - .setIncludeApis(true); - StaticWebsite website = new StaticWebsite().setEnabled(true) - .setIndexDocument("myIndex.html") - .setErrorDocument404Path("custom/error/path.html"); - - BlobServiceProperties sentProperties = new BlobServiceProperties().setLogging(logging) - .setCors(corsRules) - .setDefaultServiceVersion(defaultServiceVersion) - .setMinuteMetrics(minuteMetrics) - .setHourMetrics(hourMetrics) - .setDeleteRetentionPolicy(retentionPolicy) - .setStaticWebsite(website); - - assertResponseStatusCode(primaryBlobServiceClient.setPropertiesWithResponse(sentProperties, null, null), - 202); - } finally { - resetProperties(); - } - } - - private static Stream setAndGetServiceVersionSupplier() { - return Stream.of(Arguments.of(BlobServiceVersion.V2020_02_10, BlobServiceVersion.V2020_02_10), - Arguments.of(null, BlobServiceVersion.getLatest())); - } - - @ParameterizedTest - @MethodSource("setAndGetServiceVersionSupplier") - public void setAndGetServiceVersion(BlobServiceVersion input, BlobServiceVersion expected) { - BlobServiceClient serviceClient - = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .serviceVersion(input) - .buildClient(); - - assertEquals(expected, serviceClient.getServiceVersion()); - } - - @Test - @ResourceLock("ServiceProperties") - public void setPropsCorsCheck() { - setInitialProperties(); - - try { - BlobServiceProperties serviceProperties = primaryBlobServiceClient.getProperties(); - - // Some properties are not set and this test validates that they are not null when sent to the service - BlobCorsRule rule = new BlobCorsRule().setAllowedOrigins("microsoft.com") - .setMaxAgeInSeconds(60) - .setAllowedMethods("GET") - .setAllowedHeaders("x-ms-version"); - - serviceProperties.setCors(Collections.singletonList(rule)); - assertResponseStatusCode(primaryBlobServiceClient.setPropertiesWithResponse(serviceProperties, null, null), - 202); - } finally { - resetProperties(); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - @ResourceLock("ServiceProperties") - public void setPropsStaticWebsite() { - setInitialProperties(); - - try { - BlobServiceProperties serviceProperties = primaryBlobServiceClient.getProperties(); - String errorDocument404Path = "error/404.html"; - String defaultIndexDocumentPath = "index.html"; - - serviceProperties.setStaticWebsite(new StaticWebsite().setEnabled(true) - .setErrorDocument404Path(errorDocument404Path) - .setDefaultIndexDocumentPath(defaultIndexDocumentPath)); - - Response resp = primaryBlobServiceClient.setPropertiesWithResponse(serviceProperties, null, null); - - assertResponseStatusCode(resp, 202); - StaticWebsite staticWebsite = primaryBlobServiceClient.getProperties().getStaticWebsite(); - assertTrue(staticWebsite.isEnabled()); - assertEquals(errorDocument404Path, staticWebsite.getErrorDocument404Path()); - assertEquals(defaultIndexDocumentPath, staticWebsite.getDefaultIndexDocumentPath()); - } finally { - resetProperties(); - } - } - - @Test - @ResourceLock("ServiceProperties") - public void setPropsError() { - assertThrows(Exception.class, () -> getServiceClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - "https://error.blob.core.windows.net").setProperties(new BlobServiceProperties())); - } - - @Test - @ResourceLock("ServiceProperties") - public void setPropsAnonymous() { - assertThrows(IllegalStateException.class, () -> anonymousClient.setProperties(new BlobServiceProperties())); - } - - @Test - @ResourceLock("ServiceProperties") - public void getPropsMin() { - setInitialProperties(); - - try { - assertResponseStatusCode(primaryBlobServiceClient.getPropertiesWithResponse(null, null), 200); - } finally { - resetProperties(); - } - } - - @Test - public void getPropsError() { - assertThrows(Exception.class, () -> getServiceClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - "https://error.blob.core.windows.net").getProperties()); - } - - @Test - public void getPropsAnonymous() { - assertThrows(IllegalStateException.class, () -> anonymousClient.getProperties()); - } - - @Test - public void getUserDelegationKey() { - OffsetDateTime start = testResourceNamer.now(); - OffsetDateTime expiry = start.plusDays(1); - - Response response - = getOAuthServiceClient().getUserDelegationKeyWithResponse(start, expiry, null, null); - - assertResponseStatusCode(response, 200); - assertNotNull(response.getValue()); - assertNotNull(response.getValue().getSignedObjectId()); - assertNotNull(response.getValue().getSignedTenantId()); - assertNotNull(response.getValue().getSignedStart()); - assertNotNull(response.getValue().getSignedExpiry()); - assertNotNull(response.getValue().getSignedService()); - assertNotNull(response.getValue().getSignedVersion()); - assertNotNull(response.getValue().getValue()); - } - - @Test - public void getUserDelegationKeyMin() { - OffsetDateTime expiry = testResourceNamer.now().plusDays(1); - - Response response - = getOAuthServiceClient().getUserDelegationKeyWithResponse(null, expiry, null, null); - - assertResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("getUserDelegationKeyErrorSupplier") - public void getUserDelegationKeyError(OffsetDateTime start, OffsetDateTime expiry, - Class exception) { - assertThrows(exception, () -> getOAuthServiceClient().getUserDelegationKey(start, expiry)); - } - - private static Stream getUserDelegationKeyErrorSupplier() { - return Stream.of(Arguments.of(null, null, NullPointerException.class), - Arguments.of(OffsetDateTime.now(), OffsetDateTime.now().minusDays(1), IllegalArgumentException.class)); - } - - @Test - public void getUserDelegationKeyAnonymous() { - assertThrows(IllegalStateException.class, - () -> anonymousClient.getUserDelegationKey(null, testResourceNamer.now().plusDays(1))); - } - - @Test - public void getStats() { - BlobServiceClient serviceClient = getServiceClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - ENVIRONMENT.getPrimaryAccount().getBlobEndpointSecondary()); - Response response = serviceClient.getStatisticsWithResponse(null, null); - - assertNotNull(response.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(response.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(response.getHeaders().getValue(HttpHeaderName.DATE)); - assertNotNull(response.getValue().getGeoReplication()); - - // The LastSyncTime will return a DateTimeRfc1123 if the replication status is LIVE - // but there are two other statuses, unavailable and bootstrap, which will return null. - if (response.getValue().getGeoReplication().getStatus() == GeoReplicationStatus.LIVE) { - assertNotNull(response.getValue().getGeoReplication().getLastSyncTime()); - } else { - assertNull(response.getValue().getGeoReplication().getLastSyncTime()); - } - } - - @Test - public void getStatsMin() { - BlobServiceClient serviceClient = getServiceClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - ENVIRONMENT.getPrimaryAccount().getBlobEndpointSecondary()); - - assertResponseStatusCode(serviceClient.getStatisticsWithResponse(null, null), 200); - } - - @Test - public void getStatsMinSimple() { - BlobServiceClient serviceClient = getServiceClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - ENVIRONMENT.getPrimaryAccount().getBlobEndpointSecondary()); - - assertNotNull(serviceClient.getStatistics()); - } - - @Test - public void getStatsError() { - assertThrows(BlobStorageException.class, () -> primaryBlobServiceClient.getStatistics()); - } - - @Test - public void getStatsAnonymous() { - assertThrows(IllegalStateException.class, () -> anonymousClient.getStatistics()); - } - - @Test - public void getAccountInfo() { - Response response = primaryBlobServiceClient.getAccountInfoWithResponse(null, null); - - assertNotNull(response.getHeaders().getValue(HttpHeaderName.DATE)); - assertNotNull(response.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(response.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(response.getValue().getAccountKind()); - assertNotNull(response.getValue().getSkuName()); - } - - @Test - public void getAccountInfoMin() { - assertResponseStatusCode(primaryBlobServiceClient.getAccountInfoWithResponse(null, null), 200); - } - - @Test - public void getAccountInfoSimple() { - assertNotNull(primaryBlobServiceClient.getAccountInfo()); - } - - // This test validates a fix for a bug that caused NPE to be thrown when the account did not exist. - @Test - @ResourceLock("ServiceProperties") - public void invalidAccountName() throws MalformedURLException { - URL badURL = new URL("http://fake.blobfake.core.windows.net"); - BlobServiceClient client - = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), badURL.toString()) - .retryOptions(new RequestRetryOptions(RetryPolicyType.FIXED, 2, 60, 100L, 1000L, null)) - .buildClient(); - - assertThrows(RuntimeException.class, client::getProperties); - } - - @Test - public void getAccountInfoAnonymous() { - assertThrows(IllegalStateException.class, () -> anonymousClient.getAccountInfo()); - } - - @Test - public void getAccountSasAnonymous() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true); - AccountSasService services = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceTypes = new AccountSasResourceType().setService(true); - - assertThrows(IllegalStateException.class, () -> anonymousClient - .generateAccountSas(new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes))); - } - - @Test - public void builderCpkValidation() { - String endpoint - = BlobUrlParts.parse(primaryBlobServiceClient.getAccountUrl()).setScheme("http").toUrl().toString(); - BlobServiceClientBuilder builder = new BlobServiceClientBuilder() - .customerProvidedKey(new CustomerProvidedKey(Base64.getEncoder().encodeToString(getRandomByteArray(256)))) - .endpoint(endpoint); - - assertThrows(IllegalArgumentException.class, builder::buildClient); - } - - @Test - public void builderBearerTokenValidation() { - String endpoint - = BlobUrlParts.parse(primaryBlobServiceClient.getAccountUrl()).setScheme("http").toUrl().toString(); - BlobServiceClientBuilder builder - = new BlobServiceClientBuilder().credential(new DefaultAzureCredentialBuilder().build()).endpoint(endpoint); - - assertThrows(IllegalArgumentException.class, builder::buildClient); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void restoreContainer() { - BlobContainerClient cc1 = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - cc1.create(); - String blobName = generateBlobName(); - cc1.getBlobClient(blobName).upload(DATA.getDefaultInputStream(), 7); - cc1.delete(); - BlobContainerItem blobContainerItem - = primaryBlobServiceClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(cc1.getBlobContainerName()) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true)), null) - .stream() - .iterator() - .next(); - - sleepIfRunningAgainstService(30000); - - BlobContainerClient restoredContainerClient = primaryBlobServiceClient - .undeleteBlobContainer(blobContainerItem.getName(), blobContainerItem.getVersion()); - - assertEquals(1, restoredContainerClient.listBlobs().stream().count()); - assertEquals(blobName, restoredContainerClient.listBlobs().stream().iterator().next().getName()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @PlaybackOnly - @Test - public void restoreContainerIntoOtherContainer() { - BlobContainerClient cc1 = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - cc1.create(); - String blobName = generateBlobName(); - cc1.getBlobClient(blobName).upload(DATA.getDefaultInputStream(), 7); - cc1.delete(); - BlobContainerItem blobContainerItem = primaryBlobServiceClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(cc1.getBlobContainerName()) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true)), null) - .iterator() - .next(); - - sleepIfRunningAgainstService(30000); - - BlobContainerClient restoredContainerClient - = primaryBlobServiceClient - .undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(blobContainerItem.getName(), blobContainerItem.getVersion()), null, - Context.NONE) - .getValue(); - - assertEquals(1, restoredContainerClient.listBlobs().stream().count()); - assertEquals(blobName, restoredContainerClient.listBlobs().stream().iterator().next().getName()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void restoreContainerWithResponse() { - BlobContainerClient cc1 = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - cc1.create(); - String blobName = generateBlobName(); - cc1.getBlobClient(blobName).upload(DATA.getDefaultInputStream(), 7); - cc1.delete(); - BlobContainerItem blobContainerItem = primaryBlobServiceClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(cc1.getBlobContainerName()) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true)), null) - .iterator() - .next(); - - sleepIfRunningAgainstService(30000); - - Response response = primaryBlobServiceClient.undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(blobContainerItem.getName(), blobContainerItem.getVersion()), - Duration.ofMinutes(1), Context.NONE); - BlobContainerClient restoredContainerClient = response.getValue(); - - assertNotNull(response); - assertResponseStatusCode(response, 201); - assertEquals(1, restoredContainerClient.listBlobs().stream().count()); - assertEquals(blobName, restoredContainerClient.listBlobs().stream().iterator().next().getName()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void restoreContainerError() { - assertThrows(BlobStorageException.class, - () -> primaryBlobServiceClient.undeleteBlobContainer(generateContainerName(), "01D60F8BB59A4652")); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void restoreContainerIntoExistingContainerError() { - BlobContainerClient cc1 = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - cc1.create(); - String blobName = generateBlobName(); - cc1.getBlobClient(blobName).upload(DATA.getDefaultInputStream(), 7); - cc1.delete(); - BlobContainerItem blobContainerItem = primaryBlobServiceClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(cc1.getBlobContainerName()) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true)), null) - .iterator() - .next(); - - sleepIfRunningAgainstService(30000); - - BlobContainerClient cc2 = primaryBlobServiceClient.createBlobContainer(generateContainerName()); - assertThrows(BlobStorageException.class, - () -> primaryBlobServiceClient.undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(blobContainerItem.getName(), blobContainerItem.getVersion()) - .setDestinationContainerName(cc2.getBlobContainerName()), - null, Context.NONE)); - } - - @Test - public void oAuthOnSecondary() { - BlobServiceClientBuilder secondaryBuilder - = getServiceClientBuilder(null, ENVIRONMENT.getPrimaryAccount().getBlobEndpointSecondary()); - BlobServiceClient secondaryClient - = secondaryBuilder.credential(StorageCommonTestUtils.getTokenCredential(interceptorManager)).buildClient(); - - assertDoesNotThrow(secondaryClient::getProperties); - } - - @ParameterizedTest - @MethodSource("sasTokenDoesNotShowUpOnInvalidUriSupplier") - public void sasTokenDoesNotShowUpOnInvalidUri(String service, String container) { - /* random sas token. this does not actually authenticate anything. */ - String mockSas - = "?sv=2019-10-10&ss=b&srt=sco&sp=r&se=2019-06-04T12:04:58Z&st=2090-05-04T04:04:58Z&spr=http&sig=doesntmatter"; - - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { - BlobServiceClient client = new BlobServiceClientBuilder().endpoint(service) - .sasToken(mockSas) - .httpClient(new NoOpHttpClient()) - .buildClient(); - client.getBlobContainerClient(container).getBlobClient("blobname"); - }); - - assertFalse(e.getMessage().contains(mockSas)); - - } - - /* Note: the check is on the blob builder as well but I can't test it this way since we encode all blob names - so - it will not be invalid. */ - private static Stream sasTokenDoesNotShowUpOnInvalidUriSupplier() { - return Stream.of(Arguments.of("https://doesntmatter. blob.core.windows.net", "containername"), - Arguments.of("https://doesntmatter.blob.core.windows.net", "container name")); - } - - @Test - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - public void perCallPolicy() { - BlobServiceClient sc = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), - primaryBlobServiceClient.getAccountUrl()).addPolicy(getPerCallVersionPolicy()).buildClient(); - - Response response = sc.getPropertiesWithResponse(null, null); - assertEquals("2017-11-09", response.getHeaders().getValue(X_MS_VERSION)); - } - - @Test - public void createContainerIfNotExists() { - String containerName = generateContainerName(); - Response response - = primaryBlobServiceClient.createBlobContainerIfNotExistsWithResponse(containerName, null, null); - Response response2 - = primaryBlobServiceClient.createBlobContainerIfNotExistsWithResponse(containerName, null, null); - - assertResponseStatusCode(response, 201); - assertResponseStatusCode(response2, 409); - } - - @Test - public void deleteContainerIfExists() { - String containerName = generateContainerName(); - primaryBlobServiceClient.createBlobContainer(containerName); - - Response response - = primaryBlobServiceClient.deleteBlobContainerIfExistsWithResponse(containerName, null); - - assertTrue(response.getValue()); - assertResponseStatusCode(response, 202); - } - - @Test - public void deleteContainerMin() { - String containerName = generateContainerName(); - primaryBlobServiceClient.createBlobContainer(containerName); - - primaryBlobServiceClient.deleteBlobContainer(containerName); - assertFalse(primaryBlobServiceClient.getBlobContainerClient(containerName).exists()); - } - - @Test - public void deleteContainerIfExistsMin() { - String containerName = generateContainerName(); - primaryBlobServiceClient.createBlobContainer(containerName); - - assertTrue(primaryBlobServiceClient.deleteBlobContainerIfExists(containerName)); - } - - @Test - public void deleteContainerIfExistsContainerDoesNotExist() { - assertFalse(primaryBlobServiceClient.deleteBlobContainerIfExists(generateContainerName())); - } - - // We can't guarantee that the requests will always happen before the container is garbage collected - @PlaybackOnly - @Test - public void deleteContainerIfExistsAlreadyDeleted() { - String containerName = generateContainerName(); - primaryBlobServiceClient.createBlobContainer(containerName); - - Response response - = primaryBlobServiceClient.deleteBlobContainerIfExistsWithResponse(containerName, null); - Response response2 - = primaryBlobServiceClient.deleteBlobContainerIfExistsWithResponse(containerName, null); - - assertResponseStatusCode(response, 202); - // Confirming the behavior of the api when the container is in the deleting state. - // After delete has been called once but before it has been garbage collected - assertResponseStatusCode(response2, 202); - } - - @LiveOnly - @Test - public void serviceTimeoutPolicy() { - BlobServiceClient serviceClient - = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .addPolicy(new ServiceTimeoutPolicy(Duration.ofSeconds(1))) - .buildClient(); - - BlobContainerClient blobContainerClient = serviceClient.getBlobContainerClient(generateContainerName()); - blobContainerClient.createIfNotExists(); - BlobClient blobClient = blobContainerClient.getBlobClient(generateBlobName()); - - // testing with large dataset that is guaranteed to take longer than the specified timeout (1 second) - byte[] randomData = getRandomByteArray(256 * Constants.MB); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blobClient.uploadWithResponse(new BlobParallelUploadOptions(input), null, null)); - - assertEquals(BlobErrorCode.OPERATION_TIMED_OUT, e.getErrorCode()); - } - - @Test - public void defaultAudience() { - BlobServiceClient aadService - = getServiceClientBuilderWithTokenCredential(cc.getBlobContainerUrl()).audience(null).buildClient(); - - assertNotNull(aadService.getProperties()); - } - - @Test - public void storageAccountAudience() { - BlobServiceClient aadService = getServiceClientBuilderWithTokenCredential(cc.getBlobContainerUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(cc.getAccountName())) - .buildClient(); - - assertNotNull(aadService.getProperties()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - BlobServiceClient aadService = getServiceClientBuilderWithTokenCredential(cc.getBlobContainerUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildClient(); - - assertNotNull(aadService.getProperties()); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", cc.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - BlobServiceClient aadService - = getServiceClientBuilderWithTokenCredential(cc.getBlobContainerUrl()).audience(audience).buildClient(); - - assertNotNull(aadService.getProperties()); - } - - // public void renameBlob() container() { - // setup: - // def oldName = generateContainerName() - // def newName = generateContainerName() - // primaryBlobServiceClient.createBlobContainer(oldName) - // - // when: - // def renamedContainer = primaryBlobServiceClient.renameBlobContainer(oldName, newName) - // - // then: - // renamedContainer.getPropertiesWithResponse(null, null, null), 200); - // - // cleanup: - // renamedContainer.delete() - // } - // - // public void renameBlob() container sas() { - // setup: - // def oldName = generateContainerName() - // def newName = generateContainerName() - // primaryBlobServiceClient.createBlobContainer(oldName) - // def sas = primaryBlobServiceClient.generateAccountSas(new AccountSasSignatureValues(testResourceNamer.now().plusHours(1), AccountSasPermission.parse("rwdxlacuptf"), AccountSasService.parse("b"), AccountSasResourceType.parse("c"))) - // def serviceClient = getServiceClient(sas, primaryBlobServiceClient.getAccountUrl()) - // - // when: - // def renamedContainer = serviceClient.renameBlobContainer(oldName, newName) - // - // then: - // renamedContainer.getPropertiesWithResponse(null, null, null), 200); - // - // cleanup: - // renamedContainer.delete() - // } - // - // @ParameterizedTest - // public void renameBlob() container AC() { - // setup: - // leaseID = setupContainerLeaseCondition(cc, leaseID) - // BlobRequestConditions cac = new BlobRequestConditions() - // .setLeaseId(leaseID) - // - // expect: - // primaryBlobServiceClient.renameBlobContainerWithResponse(cc.getBlobContainerName(), - // new BlobContainerRenameOptions(generateContainerName()).setRequestConditions(cac), - // null, null), 200); - // - // where: - // leaseID || _ - // null || _ - // receivedLeaseID || _ - // } - // - // @ParameterizedTest - // public void renameBlob() container AC fail() { - // setup: - // BlobRequestConditions cac = new BlobRequestConditions() - // .setLeaseId(leaseID) - // - // when: - // primaryBlobServiceClient.renameBlobContainerWithResponse(cc.getBlobContainerName(), - // new BlobContainerRenameOptions(generateContainerName()).setRequestConditions(cac), - // null, null) - // - // then: - // assertThrows(BlobStorageException.class, () -> - // - // where: - // leaseID || _ - // garbageLeaseID || _ - // } - // - // @ParameterizedTest - // public void renameBlob() container AC illegal() { - // setup: - // BlobRequestConditions ac = new BlobRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch).setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified).setTagsConditions(tags) - // - // when: - // primaryBlobServiceClient.renameBlobContainerWithResponse(cc.getBlobContainerName(), - // new BlobContainerRenameOptions(generateContainerName()).setRequestConditions(ac), - // null, null) - // - // then: - // thrown(UnsupportedOperationException) - // - // where: - // modified | unmodified | match | noneMatch | tags - // oldDate | null | null | null | null - // null | newDate | null | null | null - // null | null | receivedEtag | null | null - // null | null | null | garbageEtag | null - // null | null | null | null | "tags" - // } - // - // public void renameBlob() container error() { - // setup: - // def oldName = generateContainerName() - // def newName = generateContainerName() - // - // when: - // primaryBlobServiceClient.renameBlobContainer(oldName, newName) - // - // then: - // assertThrows(BlobStorageException.class, () -> - // } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAsyncApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAsyncApiTests.java deleted file mode 100644 index 55d8bd119202..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAsyncApiTests.java +++ /dev/null @@ -1,1172 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.Response; -import com.azure.core.test.TestMode; -import com.azure.core.test.http.NoOpHttpClient; -import com.azure.core.util.Context; -import com.azure.core.util.paging.ContinuablePage; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.models.BlobAnalyticsLogging; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobContainerItem; -import com.azure.storage.blob.models.BlobContainerListDetails; -import com.azure.storage.blob.models.BlobCorsRule; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobMetrics; -import com.azure.storage.blob.models.BlobRetentionPolicy; -import com.azure.storage.blob.models.BlobServiceProperties; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.GeoReplicationStatus; -import com.azure.storage.blob.models.ListBlobContainersOptions; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.StaticWebsite; -import com.azure.storage.blob.models.TaggedBlobItem; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.FindBlobsOptions; -import com.azure.storage.blob.options.UndeleteBlobContainerOptions; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.RetryPolicyType; -import com.azure.storage.common.policy.ServiceTimeoutPolicy; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import com.azure.storage.common.test.shared.StorageCommonTestUtils; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.PlaybackOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.ResourceLock; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.io.ByteArrayInputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ServiceAsyncApiTests extends BlobTestBase { - - private BlobServiceAsyncClient anonymousClient; - private String tagKey; - private String tagValue; - - @BeforeEach - public void setup() { - // We shouldn't be getting to the network layer anyway - anonymousClient = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .httpClient(getHttpClient()) - .buildAsyncClient(); - - tagKey = testResourceNamer.randomName(prefix, 20); - tagValue = testResourceNamer.randomName(prefix, 20); - } - - private Mono setInitialProperties() { - BlobRetentionPolicy disabled = new BlobRetentionPolicy().setEnabled(false); - return primaryBlobServiceAsyncClient - .setProperties(new BlobServiceProperties().setStaticWebsite(new StaticWebsite().setEnabled(false)) - .setDeleteRetentionPolicy(disabled) - .setCors(null) - .setHourMetrics(new BlobMetrics().setVersion("1.0").setEnabled(false).setRetentionPolicy(disabled)) - .setMinuteMetrics(new BlobMetrics().setVersion("1.0").setEnabled(false).setRetentionPolicy(disabled)) - .setLogging(new BlobAnalyticsLogging().setVersion("1.0").setRetentionPolicy(disabled)) - .setDefaultServiceVersion("2018-03-28")); - } - - @Test - public void listContainers() { - StepVerifier - .create(primaryBlobServiceAsyncClient.listBlobContainers(new ListBlobContainersOptions().setPrefix(prefix))) - .thenConsumeWhile(c -> { - assertTrue(c.getName().startsWith(prefix)); - assertNotNull(c.getProperties().getLastModified()); - assertNotNull(c.getProperties().getETag()); - assertNotNull(c.getProperties().getLeaseStatus()); - assertNotNull(c.getProperties().getLeaseState()); - assertNull(c.getProperties().getLeaseDuration()); - assertNull(c.getProperties().getPublicAccess()); - assertFalse(c.getProperties().isHasLegalHold()); - assertFalse(c.getProperties().isHasImmutabilityPolicy()); - assertFalse(c.getProperties().isEncryptionScopeOverridePrevented()); - assertNotNull(c.getProperties().getDefaultEncryptionScope()); - return true; - }) - .verifyComplete(); - } - - @Test - public void listContainersMin() { - StepVerifier.create(primaryBlobServiceAsyncClient.listBlobContainers()) - .thenConsumeWhile(r -> true) - .verifyComplete(); - } - - @Test - public void listContainersMarker() { - Flux createContainers = Flux.range(0, 10) - .flatMap(i -> primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName())); - - ListBlobContainersOptions options = new ListBlobContainersOptions().setMaxResultsPerPage(5); - - Flux> pagedFlux - = primaryBlobServiceAsyncClient.listBlobContainers(options).byPage(); - - Mono firstContainerNameMono = pagedFlux.next().flatMap(firstPage -> { - String marker = firstPage.getContinuationToken(); - String firstContainerName = firstPage.getValue().get(0).getName(); - - return primaryBlobServiceAsyncClient.listBlobContainers().byPage(marker).next().map(secondPage -> { - assertTrue(firstContainerName.compareTo(secondPage.getValue().get(0).getName()) < 0); - return firstContainerName; - }); - }); - - StepVerifier.create(createContainers.then(firstContainerNameMono)).expectNextCount(1).verifyComplete(); - } - - @Test - public void listContainersDetails() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - String containerName = generateContainerName(); - - Flux response - = primaryBlobServiceAsyncClient.createBlobContainerWithResponse(containerName, metadata, null, null) - .flatMapMany(r -> { - ccAsync = r.getValue(); - return primaryBlobServiceAsyncClient.listBlobContainers(new ListBlobContainersOptions() - .setDetails(new BlobContainerListDetails().setRetrieveMetadata(true)) - .setPrefix(containerName)); - }); - - StepVerifier.create(response).assertNext(r -> assertEquals(metadata, r.getMetadata())).verifyComplete(); - } - - @Test - public void listContainersMaxResults() { - int numContainers = 5; - int pageResults = 3; - String containerNamePrefix = generateContainerName(); - - Mono> containersMono = Flux.range(0, numContainers) - .flatMap(i -> primaryBlobServiceAsyncClient.createBlobContainer(containerNamePrefix + i)) - .collectList(); - - StepVerifier - .create(containersMono.flatMapMany(containers -> primaryBlobServiceAsyncClient - .listBlobContainers( - new ListBlobContainersOptions().setPrefix(containerNamePrefix).setMaxResultsPerPage(pageResults)) - .byPage())) - .assertNext(r -> assertEquals(pageResults, r.getValue().size())) - .expectNextCount(1) - .verifyComplete(); - } - - @Test - public void listContainersMaxResultsByPage() { - int numContainers = 5; - int pageResults = 3; - String containerNamePrefix = generateContainerName(); - - Mono> containersMono = Flux.range(0, numContainers) - .flatMap(i -> primaryBlobServiceAsyncClient.createBlobContainer(containerNamePrefix + i)) - .collectList(); - - StepVerifier.create(containersMono.flatMapMany(containers -> primaryBlobServiceAsyncClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(containerNamePrefix)) - .byPage(pageResults))).thenConsumeWhile(r -> { - assertTrue(r.getValue().size() <= pageResults); - return true; - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listDeleted() { - int numContainers = 5; - String containerNamePrefix = generateContainerName(); - - Mono> containersMono = Flux.range(0, numContainers) - .flatMap(i -> primaryBlobServiceAsyncClient.createBlobContainer(containerNamePrefix + i)) - .collectList(); - - Flux response = containersMono.flatMapMany(containers -> Flux.fromIterable(containers) - .flatMap(BlobContainerAsyncClient::delete) - .thenMany(primaryBlobServiceAsyncClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(containerNamePrefix) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true))))); - - StepVerifier.create(response).thenConsumeWhile(r -> { - assertTrue(r.isDeleted()); - return true; - }).verifyComplete(); - - StepVerifier - .create(primaryBlobServiceAsyncClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(containerNamePrefix) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true))) - .count()) - .assertNext(r -> assertEquals(numContainers, r)) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void listWithAllDetails() { - int numContainers = 5; - String containerNamePrefix = generateContainerName(); - - Mono> containersMono = Flux.range(0, numContainers) - .flatMap(i -> primaryBlobServiceAsyncClient.createBlobContainer(containerNamePrefix + i)) - .collectList(); - - Flux response - = containersMono.flatMapMany(containers -> Flux.fromIterable(containers) - .flatMap(BlobContainerAsyncClient::delete) - .thenMany(primaryBlobServiceAsyncClient.listBlobContainers(new ListBlobContainersOptions() - .setPrefix(containerNamePrefix) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true).setRetrieveMetadata(true))))); - - StepVerifier.create(response).thenConsumeWhile(r -> { - assertTrue(r.isDeleted()); - return true; - }).verifyComplete(); - - StepVerifier - .create(primaryBlobServiceAsyncClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(containerNamePrefix) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true).setRetrieveMetadata(true))) - .count()) - .assertNext(r -> assertEquals(numContainers, r)) - .verifyComplete(); - } - - @Test - public void listContainersError() { - StepVerifier - .create(primaryBlobServiceAsyncClient.listBlobContainers().byPage("garbage continuation token").count()) - .verifyError(BlobStorageException.class); - } - - @Test - public void listContainersAnonymous() { - StepVerifier.create(anonymousClient.listBlobContainers()).verifyError(IllegalStateException.class); - } - - @Test - public void listContainersWithTimeoutStillBackedByPagedFlux() { - int numContainers = 5; - int pageResults = 3; - - Mono> containersMono = Flux.range(0, numContainers) - .flatMap(i -> primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName())) - .collectList(); - - StepVerifier.create(containersMono.flatMapMany(containers -> primaryBlobServiceAsyncClient - .listBlobContainersWithOptionalTimeout(new ListBlobContainersOptions().setMaxResultsPerPage(pageResults), - Duration.ofSeconds(10)) - .byPage() - .count())).expectNextCount(1).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - @ResourceLock("ServiceProperties") - public void listSystemContainers() { - BlobRetentionPolicy retentionPolicy = new BlobRetentionPolicy().setDays(5).setEnabled(true); - BlobAnalyticsLogging logging - = new BlobAnalyticsLogging().setRead(true).setVersion("1.0").setRetentionPolicy(retentionPolicy); - BlobServiceProperties serviceProps = new BlobServiceProperties().setLogging(logging); - - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 30000L; - - // Ensure $logs container exists. These will be reverted in test cleanup - Flux response - = setInitialProperties().then(primaryBlobServiceAsyncClient.setPropertiesWithResponse(serviceProps)) - .then(Mono.delay(Duration.ofMillis(delay))) - .thenMany(primaryBlobServiceAsyncClient.listBlobContainers(new ListBlobContainersOptions() - .setDetails(new BlobContainerListDetails().setRetrieveSystemContainers(true)))); - - StepVerifier.create(response) - .recordWith(ArrayList::new) - .thenConsumeWhile(x -> true) - .consumeRecordedWith(r -> assertTrue(r.stream().anyMatch(c -> c.getName().equals("$logs")))) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsMin() { - StepVerifier.create(primaryBlobServiceAsyncClient.findBlobsByTags("\"key\"='value'")) - .thenConsumeWhile(r -> true) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void findBlobsQuery() { - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 10000L; - - Flux response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMapMany(cc -> { - BlobAsyncClient blobClient = cc.getBlobAsyncClient(generateBlobName()); - return blobClient - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(Collections.singletonMap("key", "value"))) - .then(cc.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(Collections.singletonMap("bar", "foo")))) - .then(cc.getBlobAsyncClient(generateBlobName()).upload(DATA.getDefaultFlux(), null)) - .then(Mono.delay(Duration.ofMillis(delay))) - .thenMany(primaryBlobServiceAsyncClient.findBlobsByTags( - String.format("@container='%s' AND \"bar\"='foo'", cc.getBlobContainerName()))); - }); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(1, r.getTags().size()); - assertEquals("foo", r.getTags().get("bar")); - }).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsMarker() { - Mono containerMono - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()); - Map tags = Collections.singletonMap(tagKey, tagValue); - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 10000L; - - Flux response = containerMono.flatMapMany(cc -> { - Flux> upload = Flux.range(0, 10) - .flatMap(i -> cc.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags))); - return upload.then(Mono.just(cc)); - }) - .flatMap(cc -> Mono.delay(Duration.ofMillis(delay)) - .then(primaryBlobServiceAsyncClient.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(5), null, - Context.NONE).byPage().next()) - .flatMap(firstPage -> { - String marker = firstPage.getContinuationToken(); - String firstBlobName = firstPage.getValue().get(0).getName(); - return primaryBlobServiceAsyncClient.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(5), - null, Context.NONE).byPage(marker).next().map(secondPage -> { - assertTrue(firstBlobName.compareTo(secondPage.getValue().get(0).getName()) < 0); - return cc; - }); - })); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsMaxResults() { - int numBlobs = 7; - int pageResults = 3; - Map tags = Collections.singletonMap(tagKey, tagValue); - - Flux> response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMapMany(cc -> { - Flux> upload = Flux.range(0, numBlobs) - .flatMap(i -> cc.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags))); - return upload.thenMany(primaryBlobServiceAsyncClient - .findBlobsByTags(new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)) - .setMaxResultsPerPage(pageResults), null, Context.NONE) - .byPage()); - }); - - StepVerifier.create(response).thenConsumeWhile(r -> { - assertTrue(r.getValue().size() <= pageResults); - return true; - }).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsMaxResultsByPage() { - int numBlobs = 7; - int pageResults = 3; - Map tags = Collections.singletonMap(tagKey, tagValue); - - Flux> response - = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMapMany(cc -> { - Flux> upload = Flux.range(0, numBlobs) - .flatMap(i -> cc.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags))); - return upload.thenMany(primaryBlobServiceAsyncClient - .findBlobsByTags(new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue))) - .byPage(pageResults)); - }); - - StepVerifier.create(response).thenConsumeWhile(r -> { - assertTrue(r.getValue().size() <= pageResults); - return true; - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsByPageAsync() { - BlobContainerAsyncClient containerAsyncClient - = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - Map tags = Collections.singletonMap(tagKey, tagValue); - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 10000L; - - Mono createContainer = containerAsyncClient.create(); - - Flux> upload = Flux.range(0, 15) - .flatMap(i -> ccAsync.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultInputStream()).setTags(tags))); - - String query = String.format("\"%s\"='%s'", tagKey, tagValue); - FindBlobsOptions searchOptions = new FindBlobsOptions(query).setMaxResultsPerPage(12); - - Mono> list = Mono.delay(Duration.ofMillis(delay)) - .then(primaryBlobServiceAsyncClient.findBlobsByTags(searchOptions) - .byPage(10) // byPage should take precedence - .take(1, true) - .concatMapIterable(ContinuablePage::getElements) - .collectList()); - - Mono> list2 = primaryBlobServiceAsyncClient.findBlobsByTags(searchOptions) - .byPage() // since no number is specified, it should use the max number specified in options - .take(1, true) - .concatMapIterable(ContinuablePage::getElements) - .collectList(); - - StepVerifier.create(createContainer.thenMany(upload).then(list)) - .assertNext(r -> assertEquals(10, r.size())) - .verifyComplete(); - - StepVerifier.create(list2).assertNext(r -> assertEquals(12, r.size())).verifyComplete(); - } - - @Test - public void findBlobsError() { - StepVerifier.create(primaryBlobServiceAsyncClient.findBlobsByTags("garbageTag").byPage().count()) - .verifyError(BlobStorageException.class); - } - - @Test - public void findBlobsAnonymous() { - // Invalid query, but the anonymous check will fail before hitting the wire - StepVerifier.create(anonymousClient.findBlobsByTags("foo=bar")).verifyError(IllegalStateException.class); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void findBlobsWithTimeoutStillBackedByPagedFlux() { - int numBlobs = 5; - int pageResults = 3; - Map tags = Collections.singletonMap(tagKey, tagValue); - - Mono response = primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName()).flatMap(cc -> { - Flux> upload = Flux.range(0, numBlobs) - .flatMap(i -> cc.getBlobAsyncClient(generateBlobName()) - .uploadWithResponse( - new BlobParallelUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()) - .setTags(tags))); - // when: "Consume results by page, then still have paging functionality" - return upload.then(primaryBlobServiceAsyncClient.findBlobsByTags( - new FindBlobsOptions(String.format("\"%s\"='%s'", tagKey, tagValue)).setMaxResultsPerPage(pageResults)) - .byPage() - .count()); - }); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - private static void validatePropsSet(BlobServiceProperties sent, BlobServiceProperties received) { - assertEquals(sent.getLogging().isRead(), received.getLogging().isRead()); - assertEquals(sent.getLogging().isWrite(), received.getLogging().isWrite()); - assertEquals(sent.getLogging().isDelete(), received.getLogging().isDelete()); - assertEquals(sent.getLogging().getVersion(), received.getLogging().getVersion()); - assertEquals(sent.getLogging().getRetentionPolicy().isEnabled(), - received.getLogging().getRetentionPolicy().isEnabled()); - assertEquals(sent.getLogging().getRetentionPolicy().getDays(), - received.getLogging().getRetentionPolicy().getDays()); - assertEquals(sent.getCors().size(), received.getCors().size()); - assertEquals(sent.getCors().get(0).getAllowedMethods(), received.getCors().get(0).getAllowedMethods()); - assertEquals(sent.getCors().get(0).getAllowedHeaders(), received.getCors().get(0).getAllowedHeaders()); - assertEquals(sent.getCors().get(0).getAllowedOrigins(), received.getCors().get(0).getAllowedOrigins()); - assertEquals(sent.getCors().get(0).getExposedHeaders(), received.getCors().get(0).getExposedHeaders()); - assertEquals(sent.getCors().get(0).getMaxAgeInSeconds(), received.getCors().get(0).getMaxAgeInSeconds()); - assertEquals(sent.getDefaultServiceVersion(), received.getDefaultServiceVersion()); - assertEquals(sent.getHourMetrics().isEnabled(), received.getHourMetrics().isEnabled()); - assertEquals(sent.getHourMetrics().isIncludeApis(), received.getHourMetrics().isIncludeApis()); - assertEquals(sent.getHourMetrics().getRetentionPolicy().isEnabled(), - received.getHourMetrics().getRetentionPolicy().isEnabled()); - assertEquals(sent.getHourMetrics().getRetentionPolicy().getDays(), - received.getHourMetrics().getRetentionPolicy().getDays()); - assertEquals(sent.getHourMetrics().getVersion(), received.getHourMetrics().getVersion()); - assertEquals(sent.getMinuteMetrics().isEnabled(), received.getMinuteMetrics().isEnabled()); - assertEquals(sent.getMinuteMetrics().isIncludeApis(), received.getMinuteMetrics().isIncludeApis()); - assertEquals(sent.getMinuteMetrics().getRetentionPolicy().isEnabled(), - received.getMinuteMetrics().getRetentionPolicy().isEnabled()); - assertEquals(sent.getMinuteMetrics().getRetentionPolicy().getDays(), - received.getMinuteMetrics().getRetentionPolicy().getDays()); - assertEquals(sent.getMinuteMetrics().getVersion(), received.getMinuteMetrics().getVersion()); - assertEquals(sent.getDeleteRetentionPolicy().isEnabled(), received.getDeleteRetentionPolicy().isEnabled()); - assertEquals(sent.getDeleteRetentionPolicy().getDays(), received.getDeleteRetentionPolicy().getDays()); - assertEquals(sent.getStaticWebsite().isEnabled(), received.getStaticWebsite().isEnabled()); - assertEquals(sent.getStaticWebsite().getIndexDocument(), received.getStaticWebsite().getIndexDocument()); - assertEquals(sent.getStaticWebsite().getErrorDocument404Path(), - received.getStaticWebsite().getErrorDocument404Path()); - } - - @Test - @ResourceLock("ServiceProperties") - public void setGetProperties() { - BlobRetentionPolicy retentionPolicy = new BlobRetentionPolicy().setDays(5).setEnabled(true); - BlobAnalyticsLogging logging - = new BlobAnalyticsLogging().setRead(true).setVersion("1.0").setRetentionPolicy(retentionPolicy); - List corsRules = new ArrayList<>(); - corsRules.add(new BlobCorsRule().setAllowedMethods("GET,PUT,HEAD") - .setAllowedOrigins("*") - .setAllowedHeaders("x-ms-version") - .setExposedHeaders("x-ms-client-request-id") - .setMaxAgeInSeconds(10)); - String defaultServiceVersion = "2016-05-31"; - BlobMetrics hourMetrics = new BlobMetrics().setEnabled(true) - .setVersion("1.0") - .setRetentionPolicy(retentionPolicy) - .setIncludeApis(true); - BlobMetrics minuteMetrics = new BlobMetrics().setEnabled(true) - .setVersion("1.0") - .setRetentionPolicy(retentionPolicy) - .setIncludeApis(true); - StaticWebsite website = new StaticWebsite().setEnabled(true) - .setIndexDocument("myIndex.html") - .setErrorDocument404Path("custom/error/path.html"); - - BlobServiceProperties sentProperties = new BlobServiceProperties().setLogging(logging) - .setCors(corsRules) - .setDefaultServiceVersion(defaultServiceVersion) - .setMinuteMetrics(minuteMetrics) - .setHourMetrics(hourMetrics) - .setDeleteRetentionPolicy(retentionPolicy) - .setStaticWebsite(website); - - StepVerifier - .create( - setInitialProperties().then(primaryBlobServiceAsyncClient.setPropertiesWithResponse(sentProperties))) - .assertNext(r -> { - assertNotNull(r.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(r.getHeaders().getValue(X_MS_VERSION)); - }) - .verifyComplete(); - - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 30000L; - - Mono response - = Mono.delay(Duration.ofMillis(delay)).then(primaryBlobServiceAsyncClient.getProperties()); - - StepVerifier.create(response).assertNext(r -> validatePropsSet(sentProperties, r)).verifyComplete(); - } - - // In java, we don't have support from the validator for checking the bounds on days. The service will catch these. - @Test - @ResourceLock("ServiceProperties") - public void setPropsMin() { - BlobRetentionPolicy retentionPolicy = new BlobRetentionPolicy().setDays(5).setEnabled(true); - BlobAnalyticsLogging logging - = new BlobAnalyticsLogging().setRead(true).setVersion("1.0").setRetentionPolicy(retentionPolicy); - List corsRules = new ArrayList<>(); - corsRules.add(new BlobCorsRule().setAllowedMethods("GET,PUT,HEAD") - .setAllowedOrigins("*") - .setAllowedHeaders("x-ms-version") - .setExposedHeaders("x-ms-client-request-id") - .setMaxAgeInSeconds(10)); - String defaultServiceVersion = "2016-05-31"; - BlobMetrics hourMetrics = new BlobMetrics().setEnabled(true) - .setVersion("1.0") - .setRetentionPolicy(retentionPolicy) - .setIncludeApis(true); - BlobMetrics minuteMetrics = new BlobMetrics().setEnabled(true) - .setVersion("1.0") - .setRetentionPolicy(retentionPolicy) - .setIncludeApis(true); - StaticWebsite website = new StaticWebsite().setEnabled(true) - .setIndexDocument("myIndex.html") - .setErrorDocument404Path("custom/error/path.html"); - - BlobServiceProperties sentProperties = new BlobServiceProperties().setLogging(logging) - .setCors(corsRules) - .setDefaultServiceVersion(defaultServiceVersion) - .setMinuteMetrics(minuteMetrics) - .setHourMetrics(hourMetrics) - .setDeleteRetentionPolicy(retentionPolicy) - .setStaticWebsite(website); - - Mono> response - = setInitialProperties().then(primaryBlobServiceAsyncClient.setPropertiesWithResponse(sentProperties)); - - assertAsyncResponseStatusCode(response, 202); - } - - @Test - @ResourceLock("ServiceProperties") - public void setPropsCorsCheck() { - // Some properties are not set and this test validates that they are not null when sent to the service - BlobCorsRule rule = new BlobCorsRule().setAllowedOrigins("microsoft.com") - .setMaxAgeInSeconds(60) - .setAllowedMethods("GET") - .setAllowedHeaders("x-ms-version"); - - Mono> response - = setInitialProperties().then(primaryBlobServiceAsyncClient.getProperties()).flatMap(r -> { - r.setCors(Collections.singletonList(rule)); - return primaryBlobServiceAsyncClient.setPropertiesWithResponse(r); - }); - - assertAsyncResponseStatusCode(response, 202); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - @ResourceLock("ServiceProperties") - public void setPropsStaticWebsite() { - String errorDocument404Path = "error/404.html"; - String defaultIndexDocumentPath = "index.html"; - - Mono> response - = setInitialProperties().then(primaryBlobServiceAsyncClient.getProperties()).flatMap(r -> { - r.setStaticWebsite(new StaticWebsite().setEnabled(true) - .setErrorDocument404Path(errorDocument404Path) - .setDefaultIndexDocumentPath(defaultIndexDocumentPath)); - return primaryBlobServiceAsyncClient.setPropertiesWithResponse(r); - }); - - assertAsyncResponseStatusCode(response, 202); - - Mono response2 = primaryBlobServiceAsyncClient.getProperties(); - - StepVerifier.create(response2).assertNext(r -> { - assertTrue(r.getStaticWebsite().isEnabled()); - assertEquals(errorDocument404Path, r.getStaticWebsite().getErrorDocument404Path()); - assertEquals(defaultIndexDocumentPath, r.getStaticWebsite().getDefaultIndexDocumentPath()); - }).verifyComplete(); - } - - @Test - @ResourceLock("ServiceProperties") - public void setPropsError() { - StepVerifier - .create(getServiceAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - "https://error.blob.core.windows.net").setProperties(new BlobServiceProperties())) - .verifyError(Exception.class); - } - - @Test - @ResourceLock("ServiceProperties") - public void setPropsAnonymous() { - StepVerifier.create(anonymousClient.setProperties(new BlobServiceProperties())) - .verifyError(IllegalStateException.class); - } - - @Test - @ResourceLock("ServiceProperties") - public void getPropsMin() { - Mono> response - = setInitialProperties().then(primaryBlobServiceAsyncClient.getPropertiesWithResponse()); - assertAsyncResponseStatusCode(response, 200); - } - - @Test - public void getPropsError() { - StepVerifier.create(getServiceAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - "https://error.blob.core.windows.net").getProperties()).verifyError(Exception.class); - } - - @Test - public void getPropsAnonymous() { - StepVerifier.create(anonymousClient.getProperties()).verifyError(IllegalStateException.class); - } - - @Test - public void getUserDelegationKey() { - OffsetDateTime start = testResourceNamer.now(); - OffsetDateTime expiry = start.plusDays(1); - - StepVerifier.create(getOAuthServiceAsyncClient().getUserDelegationKeyWithResponse(start, expiry)) - .assertNext(r -> { - assertResponseStatusCode(r, 200); - assertNotNull(r.getValue()); - assertNotNull(r.getValue().getSignedObjectId()); - assertNotNull(r.getValue().getSignedTenantId()); - assertNotNull(r.getValue().getSignedStart()); - assertNotNull(r.getValue().getSignedExpiry()); - assertNotNull(r.getValue().getSignedService()); - assertNotNull(r.getValue().getSignedVersion()); - assertNotNull(r.getValue().getValue()); - }) - .verifyComplete(); - } - - @Test - public void getUserDelegationKeyMin() { - OffsetDateTime expiry = testResourceNamer.now().plusDays(1); - - assertAsyncResponseStatusCode(getOAuthServiceAsyncClient().getUserDelegationKeyWithResponse(null, expiry), 200); - } - - @ParameterizedTest - @MethodSource("getUserDelegationKeyErrorSupplier") - public void getUserDelegationKeyError(OffsetDateTime start, OffsetDateTime expiry, - Class exception) { - StepVerifier.create(getOAuthServiceAsyncClient().getUserDelegationKey(start, expiry)).verifyError(exception); - } - - private static Stream getUserDelegationKeyErrorSupplier() { - return Stream.of(Arguments.of(null, null, NullPointerException.class), - Arguments.of(OffsetDateTime.now(), OffsetDateTime.now().minusDays(1), IllegalArgumentException.class)); - } - - @Test - public void getUserDelegationKeyAnonymous() { - StepVerifier.create(anonymousClient.getUserDelegationKey(null, testResourceNamer.now().plusDays(1))) - .verifyError(IllegalStateException.class); - } - - @Test - public void getStats() { - BlobServiceAsyncClient serviceClient = getServiceAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - ENVIRONMENT.getPrimaryAccount().getBlobEndpointSecondary()); - StepVerifier.create(serviceClient.getStatisticsWithResponse()).assertNext(r -> { - assertNotNull(r.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(r.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(r.getHeaders().getValue(HttpHeaderName.DATE)); - assertNotNull(r.getValue().getGeoReplication()); - // The LastSyncTime will return a DateTimeRfc1123 if the replication status is LIVE - // but there are two other statuses, unavailable and bootstrap, which will return null. - if (r.getValue().getGeoReplication().getStatus() == GeoReplicationStatus.LIVE) { - assertNotNull(r.getValue().getGeoReplication().getLastSyncTime()); - } else { - assertNull(r.getValue().getGeoReplication().getLastSyncTime()); - } - }).verifyComplete(); - } - - @Test - public void getStatsMin() { - BlobServiceAsyncClient serviceClient = getServiceAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - ENVIRONMENT.getPrimaryAccount().getBlobEndpointSecondary()); - - assertAsyncResponseStatusCode(serviceClient.getStatisticsWithResponse(), 200); - } - - @Test - public void getStatsError() { - StepVerifier.create(primaryBlobServiceAsyncClient.getStatistics()).verifyError(BlobStorageException.class); - } - - @Test - public void getStatsAnonymous() { - StepVerifier.create(anonymousClient.getStatistics()).verifyError(IllegalStateException.class); - } - - @Test - public void getAccountInfo() { - StepVerifier.create(primaryBlobServiceAsyncClient.getAccountInfoWithResponse()).assertNext(r -> { - assertNotNull(r.getHeaders().getValue(HttpHeaderName.DATE)); - assertNotNull(r.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(r.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(r.getValue().getAccountKind()); - assertNotNull(r.getValue().getSkuName()); - }).verifyComplete(); - } - - @Test - public void getAccountInfoMin() { - assertAsyncResponseStatusCode(primaryBlobServiceAsyncClient.getAccountInfoWithResponse(), 200); - } - - // This test validates a fix for a bug that caused NPE to be thrown when the account did not exist. - @Test - @ResourceLock("ServiceProperties") - public void invalidAccountName() throws MalformedURLException { - URL badURL = new URL("http://fake.blobfake.core.windows.net"); - BlobServiceAsyncClient client - = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), badURL.toString()) - .retryOptions(new RequestRetryOptions(RetryPolicyType.FIXED, 2, 60, 100L, 1000L, null)) - .buildAsyncClient(); - - StepVerifier.create(client.getProperties()).expectError(); - } - - @Test - public void getAccountInfoAnonymous() { - StepVerifier.create(anonymousClient.getAccountInfo()).verifyError(IllegalStateException.class); - } - - @Test - public void getAccountSasAnonymous() { - OffsetDateTime expiryTime = testResourceNamer.now().plusDays(1); - AccountSasPermission permissions = new AccountSasPermission().setReadPermission(true); - AccountSasService services = new AccountSasService().setBlobAccess(true); - AccountSasResourceType resourceTypes = new AccountSasResourceType().setService(true); - - assertThrows(IllegalStateException.class, () -> anonymousClient - .generateAccountSas(new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes))); - } - - @Test - public void builderCpkValidation() { - String endpoint - = BlobUrlParts.parse(primaryBlobServiceAsyncClient.getAccountUrl()).setScheme("http").toUrl().toString(); - BlobServiceClientBuilder builder = new BlobServiceClientBuilder() - .customerProvidedKey(new CustomerProvidedKey(Base64.getEncoder().encodeToString(getRandomByteArray(256)))) - .endpoint(endpoint); - - assertThrows(IllegalArgumentException.class, builder::buildAsyncClient); - } - - @Test - public void builderBearerTokenValidation() { - String endpoint - = BlobUrlParts.parse(primaryBlobServiceAsyncClient.getAccountUrl()).setScheme("http").toUrl().toString(); - BlobServiceClientBuilder builder - = new BlobServiceClientBuilder().credential(new DefaultAzureCredentialBuilder().build()).endpoint(endpoint); - - assertThrows(IllegalArgumentException.class, builder::buildAsyncClient); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void restoreContainerAsync() { - BlobContainerAsyncClient cc1 - = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - String blobName = generateBlobName(); - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 30000L; - - Mono blobContainerItemMono = cc1.create() - .then(cc1.getBlobAsyncClient(blobName).upload(DATA.getDefaultFlux(), new ParallelTransferOptions())) - .then(cc1.delete()) - .then(Mono.delay(Duration.ofMillis(delay))) - .then(primaryBlobServiceAsyncClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(cc1.getBlobContainerName()) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true))) - .next()); - - Mono restoredContainerClientMono - = blobContainerItemMono.flatMap(blobContainerItem -> primaryBlobServiceAsyncClient - .undeleteBlobContainer(blobContainerItem.getName(), blobContainerItem.getVersion())); - - StepVerifier - .create(restoredContainerClientMono - .flatMap(restoredContainerClient -> restoredContainerClient.listBlobs().collectList())) - .assertNext(it -> { - assertEquals(1, it.size()); - assertEquals(blobName, it.get(0).getName()); - }) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @PlaybackOnly - @Test - public void restoreContainerIntoOtherContainer() { - BlobContainerAsyncClient cc1 - = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - String blobName = generateBlobName(); - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 30000L; - - Mono> response = cc1.create() - .then(cc1.getBlobAsyncClient(blobName).upload(DATA.getDefaultFlux(), null)) - .then(primaryBlobServiceAsyncClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(cc1.getBlobContainerName()) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true))) - .next()) - .flatMap(blobContainerItem -> Mono.delay(Duration.ofMillis(delay)) - .then(primaryBlobServiceAsyncClient.undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(blobContainerItem.getName(), blobContainerItem.getVersion()))) - .flatMap(r -> r.getValue().listBlobs().collectList())); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(1, r.size()); - assertEquals(blobName, r.get(0).getName()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void restoreContainerAsyncWithResponse() { - BlobContainerAsyncClient cc1 - = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - String blobName = generateBlobName(); - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 30000L; - - Mono blobContainerItemMono = cc1.create() - .then(cc1.getBlobAsyncClient(blobName).upload(DATA.getDefaultFlux(), new ParallelTransferOptions())) - .then(cc1.delete()) - .then(Mono.delay(Duration.ofMillis(delay))) - .then(primaryBlobServiceAsyncClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(cc1.getBlobContainerName()) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true))) - .next()); - - Mono> responseMono = blobContainerItemMono - .flatMap(blobContainerItem -> primaryBlobServiceAsyncClient.undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(blobContainerItem.getName(), blobContainerItem.getVersion()))); - - StepVerifier.create(responseMono).assertNext(it -> { - assertNotNull(it); - assertEquals(201, it.getStatusCode()); - assertNotNull(it.getValue()); - assertEquals(cc1.getBlobContainerName(), it.getValue().getBlobContainerName()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void restoreContainerError() { - StepVerifier - .create(primaryBlobServiceAsyncClient.undeleteBlobContainer(generateContainerName(), "01D60F8BB59A4652")) - .verifyError(BlobStorageException.class); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void restoreContainerIntoExistingContainerError() { - BlobContainerAsyncClient cc1 - = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - String blobName = generateBlobName(); - long delay = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 30000L; - - Mono> response = cc1.create() - .then(cc1.getBlobAsyncClient(blobName).upload(DATA.getDefaultFlux(), null)) - .then(cc1.delete()) - .then(primaryBlobServiceAsyncClient - .listBlobContainers(new ListBlobContainersOptions().setPrefix(cc1.getBlobContainerName()) - .setDetails(new BlobContainerListDetails().setRetrieveDeleted(true))) - .next()) - .flatMap(blobContainerItem -> Mono.delay(Duration.ofMillis(delay)) - .then(primaryBlobServiceAsyncClient.createBlobContainer(generateContainerName())) - .flatMap(cc2 -> primaryBlobServiceAsyncClient.undeleteBlobContainerWithResponse( - new UndeleteBlobContainerOptions(blobContainerItem.getName(), blobContainerItem.getVersion()) - .setDestinationContainerName(cc2.getBlobContainerName())))); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void oAuthOnSecondary() { - BlobServiceClientBuilder secondaryBuilder - = getServiceClientBuilder(null, ENVIRONMENT.getPrimaryAccount().getBlobEndpointSecondary()); - BlobServiceAsyncClient secondaryClient - = secondaryBuilder.credential(StorageCommonTestUtils.getTokenCredential(interceptorManager)) - .buildAsyncClient(); - - StepVerifier.create(secondaryClient.getProperties()).expectNextCount(1).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("sasTokenDoesNotShowUpOnInvalidUriSupplier") - public void sasTokenDoesNotShowUpOnInvalidUri(String service, String container) { - /* random sas token. this does not actually authenticate anything. */ - String mockSas - = "?sv=2019-10-10&ss=b&srt=sco&sp=r&se=2019-06-04T12:04:58Z&st=2090-05-04T04:04:58Z&spr=http&sig=doesntmatter"; - - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { - BlobServiceAsyncClient client = new BlobServiceClientBuilder().endpoint(service) - .sasToken(mockSas) - .httpClient(new NoOpHttpClient()) - .buildAsyncClient(); - client.getBlobContainerAsyncClient(container).getBlobAsyncClient("blobname"); - }); - - assertFalse(e.getMessage().contains(mockSas)); - - } - - /* Note: the check is on the blob builder as well but I can't test it this way since we encode all blob names - so - it will not be invalid. */ - private static Stream sasTokenDoesNotShowUpOnInvalidUriSupplier() { - return Stream.of(Arguments.of("https://doesntmatter. blob.core.windows.net", "containername"), - Arguments.of("https://doesntmatter.blob.core.windows.net", "container name")); - } - - @Test - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - public void perCallPolicy() { - BlobServiceAsyncClient sc = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), - primaryBlobServiceAsyncClient.getAccountUrl()).addPolicy(getPerCallVersionPolicy()).buildAsyncClient(); - - StepVerifier.create(sc.getPropertiesWithResponse()) - .assertNext(r -> assertEquals("2017-11-09", r.getHeaders().getValue(X_MS_VERSION))) - .verifyComplete(); - } - - @Test - public void createContainerIfNotExists() { - String containerName = generateContainerName(); - assertAsyncResponseStatusCode( - primaryBlobServiceAsyncClient.createBlobContainerIfNotExistsWithResponse(containerName, null), 201); - assertAsyncResponseStatusCode( - primaryBlobServiceAsyncClient.createBlobContainerIfNotExistsWithResponse(containerName, null), 409); - } - - @Test - public void deleteContainerIfExists() { - String containerName = generateContainerName(); - - StepVerifier - .create(primaryBlobServiceAsyncClient.createBlobContainer(containerName) - .then(primaryBlobServiceAsyncClient.deleteBlobContainerIfExistsWithResponse(containerName))) - .assertNext(r -> { - assertTrue(r.getValue()); - assertResponseStatusCode(r, 202); - }) - .verifyComplete(); - } - - @Test - public void deleteContainerIfExistsMin() { - String containerName = generateContainerName(); - - StepVerifier - .create(primaryBlobServiceAsyncClient.createBlobContainer(containerName) - .then(primaryBlobServiceAsyncClient.deleteBlobContainerIfExists(containerName))) - .expectNext(true) - .verifyComplete(); - } - - @Test - public void deleteContainerIfExistsContainerDoesNotExist() { - StepVerifier.create(primaryBlobServiceAsyncClient.deleteBlobContainerIfExists(generateContainerName())) - .expectNext(false) - .verifyComplete(); - } - - // We can't guarantee that the requests will always happen before the container is garbage collected - @PlaybackOnly - @Test - public void deleteContainerIfExistsAlreadyDeleted() { - String containerName = generateContainerName(); - - assertAsyncResponseStatusCode(primaryBlobServiceAsyncClient.createBlobContainer(containerName) - .then(primaryBlobServiceAsyncClient.deleteBlobContainerIfExistsWithResponse(containerName)), 202); - // Confirming the behavior of the api when the container is in the deleting state. - // After delete has been called once but before it has been garbage collected - assertAsyncResponseStatusCode( - primaryBlobServiceAsyncClient.deleteBlobContainerIfExistsWithResponse(containerName), 202); - } - - @LiveOnly - @Test - public void serviceTimeoutPolicy() { - BlobServiceAsyncClient serviceClient - = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .addPolicy(new ServiceTimeoutPolicy(Duration.ofSeconds(1))) - .buildAsyncClient(); - - // testing with large dataset that is guaranteed to take longer than the specified timeout (1 second) - byte[] randomData = getRandomByteArray(256 * Constants.MB); - ByteArrayInputStream input = new ByteArrayInputStream(randomData); - - BlobContainerAsyncClient blobContainerClient - = serviceClient.getBlobContainerAsyncClient(generateContainerName()); - BlobAsyncClient blobClient = blobContainerClient.getBlobAsyncClient(generateBlobName()); - - StepVerifier.create(blobContainerClient.createIfNotExists() - .then(blobClient.uploadWithResponse(new BlobParallelUploadOptions(input)))).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.OPERATION_TIMED_OUT, e.getErrorCode()); - }); - } - - @Test - public void defaultAudience() { - BlobServiceAsyncClient aadService - = getServiceClientBuilderWithTokenCredential(ccAsync.getBlobContainerUrl()).audience(null) - .buildAsyncClient(); - - StepVerifier.create(aadService.getProperties()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - @Test - public void storageAccountAudience() { - BlobServiceAsyncClient aadService = getServiceClientBuilderWithTokenCredential(ccAsync.getBlobContainerUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(ccAsync.getAccountName())) - .buildAsyncClient(); - - StepVerifier.create(aadService.getProperties()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - BlobServiceAsyncClient aadService = getServiceClientBuilderWithTokenCredential(ccAsync.getBlobContainerUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildAsyncClient(); - - StepVerifier.create(aadService.getProperties()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", ccAsync.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - BlobServiceAsyncClient aadService - = getServiceClientBuilderWithTokenCredential(ccAsync.getBlobContainerUrl()).audience(audience) - .buildAsyncClient(); - - StepVerifier.create(aadService.getProperties()).assertNext(Assertions::assertNotNull).verifyComplete(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SoftDeleteAsyncTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SoftDeleteAsyncTests.java deleted file mode 100644 index 0fd6a18fd9fa..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SoftDeleteAsyncTests.java +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaderName; -import com.azure.storage.blob.models.BlobListDetails; -import com.azure.storage.blob.models.ListBlobsOptions; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import reactor.test.StepVerifier; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class SoftDeleteAsyncTests extends BlobTestBase { - private BlobContainerAsyncClient containerClient; - private BlobAsyncClient blobClient; - - @BeforeEach - public void setup() { - containerClient = softDeleteServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - containerClient.create().block(); - blobClient = containerClient.getBlobAsyncClient(generateBlobName()); - blobClient.getBlockBlobAsyncClient().upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()).block(); - } - - @AfterEach - public void cleanup() { - containerClient.delete().block(); - } - - @Test - public void undeleteMin() { - assertAsyncResponseStatusCode(blobClient.delete().then(blobClient.undeleteWithResponse()), 200); - } - - @Test - public void undelete() { - StepVerifier.create(blobClient.delete().then(blobClient.undeleteWithResponse())) - .then(() -> blobClient.getProperties()) - .assertNext(r -> { - assertNotNull(r.getHeaders().getValue(X_MS_REQUEST_ID)); - assertNotNull(r.getHeaders().getValue(X_MS_VERSION)); - assertNotNull(r.getHeaders().getValue(HttpHeaderName.DATE)); - }) - .verifyComplete(); - } - - @Test - public void listBlobsFlatOptionsDeleted() { - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveDeletedBlobs(true)).setPrefix(prefix); - StepVerifier.create(blobClient.delete().thenMany(containerClient.listBlobs(options))) - .assertNext(r -> assertEquals(blobClient.getBlobName(), r.getName())) - .verifyComplete(); - } - - @Test - public void listBlobsHierOptionsDeleted() { - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveDeletedBlobs(true)).setPrefix(prefix); - StepVerifier.create(blobClient.delete().thenMany(containerClient.listBlobsByHierarchy("", options))) - .assertNext(r -> assertEquals(blobClient.getBlobName(), r.getName())) - .verifyComplete(); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SoftDeleteTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SoftDeleteTests.java deleted file mode 100644 index 6c7e5a553925..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SoftDeleteTests.java +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobListDetails; -import com.azure.storage.blob.models.ListBlobsOptions; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.Iterator; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class SoftDeleteTests extends BlobTestBase { - private BlobContainerClient containerClient; - private BlobClient blobClient; - - @BeforeEach - public void setup() { - containerClient = softDeleteServiceClient.getBlobContainerClient(generateContainerName()); - containerClient.create(); - blobClient = containerClient.getBlobClient(generateBlobName()); - blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - } - - @AfterEach - public void cleanup() { - containerClient.delete(); - } - - @Test - public void undeleteMin() { - blobClient.delete(); - assertResponseStatusCode(blobClient.undeleteWithResponse(null, null), 200); - } - - @Test - public void undeleteSimple() { - blobClient.delete(); - assertFalse(blobClient.exists()); - - blobClient.undelete(); - assertTrue(blobClient.exists()); - } - - @Test - public void undelete() { - blobClient.delete(); - - HttpHeaders undeleteHeaders = blobClient.undeleteWithResponse(null, null).getHeaders(); - blobClient.getProperties(); - - assertNotNull(undeleteHeaders.getValue(X_MS_REQUEST_ID)); - assertNotNull(undeleteHeaders.getValue(X_MS_VERSION)); - assertNotNull(undeleteHeaders.getValue(HttpHeaderName.DATE)); - } - - @Test - public void listBlobsFlatOptionsDeleted() { - blobClient.delete(); - - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveDeletedBlobs(true)).setPrefix(prefix); - Iterator blobs = containerClient.listBlobs(options, null).iterator(); - - assertEquals(blobClient.getBlobName(), blobs.next().getName()); - assertFalse(blobs.hasNext()); - } - - @Test - public void listBlobsHierOptionsDeleted() { - blobClient.delete(); - - ListBlobsOptions options - = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveDeletedBlobs(true)).setPrefix(prefix); - Iterator blobs = containerClient.listBlobsByHierarchy("", options, null).iterator(); - - assertEquals(blobClient.getBlobName(), blobs.next().getName()); - assertFalse(blobs.hasNext()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/VersioningAsyncTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/VersioningAsyncTests.java deleted file mode 100644 index 0932185a0a18..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/VersioningAsyncTests.java +++ /dev/null @@ -1,493 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.rest.Response; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.polling.AsyncPollResponse; -import com.azure.core.util.polling.PollerFlux; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobListDetails; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.specialized.BlobAsyncClientBase; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.function.Tuple2; -import reactor.util.function.Tuple3; -import reactor.util.function.Tuple4; - -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class VersioningAsyncTests extends BlobTestBase { - - private BlobContainerAsyncClient blobContainerClient; - private BlobAsyncClient blobClient; - private final String contentV1 = "contentV1"; - private final String contentV2 = "contentV2"; - - @BeforeEach - public void setup() { - String blobName = generateBlobName(); - String containerName = generateContainerName(); - blobContainerClient = versionedBlobServiceAsyncClient.createBlobContainer(containerName).block(); - blobClient = blobContainerClient.getBlobAsyncClient(blobName); - } - - @AfterEach - public void cleanup() { - blobContainerClient.delete().block(); - } - - @Test - public void createBlockBlobWithVersion() { - Mono> response = blobClient.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .flatMap(r -> Mono.zip(Mono.just(r), - blobClient.getBlockBlobAsyncClient().upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true))); - - StepVerifier.create(response).assertNext(r -> { - assertNotNull(r.getT1().getVersionId()); - assertNotNull(r.getT2().getVersionId()); - assertNotEquals(r.getT1().getVersionId(), r.getT2().getVersionId()); - }).verifyComplete(); - } - - @Test - public void createPageBlobWithVersion() { - Mono> response = blobClient.getPageBlobAsyncClient() - .create(512) - .flatMap(r -> Mono.zip(Mono.just(r), blobClient.getPageBlobAsyncClient().create(512, true))); - - StepVerifier.create(response).assertNext(r -> { - assertNotNull(r.getT1().getVersionId()); - assertNotNull(r.getT2().getVersionId()); - assertNotEquals(r.getT1().getVersionId(), r.getT2().getVersionId()); - }).verifyComplete(); - } - - @Test - public void createAppendBlobWithVersion() { - Mono> response = blobClient.getAppendBlobAsyncClient() - .create() - .flatMap(r -> Mono.zip(Mono.just(r), blobClient.getAppendBlobAsyncClient().create(true))); - - StepVerifier.create(response).assertNext(r -> { - assertNotNull(r.getT1().getVersionId()); - assertNotNull(r.getT2().getVersionId()); - assertNotEquals(r.getT1().getVersionId(), r.getT2().getVersionId()); - }).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @Test - public void downloadBlobByVersion() { - Flux inputV1 = Flux.just(ByteBuffer.wrap(contentV1.getBytes(StandardCharsets.UTF_8))); - Flux inputV2 = Flux.just(ByteBuffer.wrap(contentV2.getBytes(StandardCharsets.UTF_8))); - - Mono response1 = blobClient.getBlockBlobAsyncClient() - .upload(inputV1, contentV1.length()) - .flatMap( - r -> FluxUtil.collectBytesInByteBufferStream(blobClient.getVersionClient(r.getVersionId()).download())); - - Mono response2 = blobClient.getBlockBlobAsyncClient() - .upload(inputV2, contentV2.length(), true) - .flatMap( - r -> FluxUtil.collectBytesInByteBufferStream(blobClient.getVersionClient(r.getVersionId()).download())); - - StepVerifier.create(response1) - .assertNext(r -> TestUtils.assertArraysEqual(r, contentV1.getBytes(StandardCharsets.UTF_8))) - .verifyComplete(); - - StepVerifier.create(response2) - .assertNext(r -> TestUtils.assertArraysEqual(r, contentV2.getBytes(StandardCharsets.UTF_8))) - .verifyComplete(); - } - - @Test - public void downloadBlobByVersionStreaming() { - Flux inputV1 = Flux.just(ByteBuffer.wrap(contentV1.getBytes(StandardCharsets.UTF_8))); - Flux inputV2 = Flux.just(ByteBuffer.wrap(contentV2.getBytes(StandardCharsets.UTF_8))); - - Mono response1 = blobClient.getBlockBlobAsyncClient() - .upload(inputV1, contentV1.length()) - .flatMap(r -> FluxUtil - .collectBytesInByteBufferStream(blobClient.getVersionClient(r.getVersionId()).downloadStream())); - - Mono response2 = blobClient.getBlockBlobAsyncClient() - .upload(inputV2, contentV2.length(), true) - .flatMap(r -> FluxUtil - .collectBytesInByteBufferStream(blobClient.getVersionClient(r.getVersionId()).downloadStream())); - - StepVerifier.create(response1) - .assertNext(r -> TestUtils.assertArraysEqual(r, contentV1.getBytes(StandardCharsets.UTF_8))) - .verifyComplete(); - - StepVerifier.create(response2) - .assertNext(r -> TestUtils.assertArraysEqual(r, contentV2.getBytes(StandardCharsets.UTF_8))) - .verifyComplete(); - } - - @Test - public void downloadBlobByVersionBinaryData() { - Flux inputV1 = Flux.just(ByteBuffer.wrap(contentV1.getBytes(StandardCharsets.UTF_8))); - Flux inputV2 = Flux.just(ByteBuffer.wrap(contentV2.getBytes(StandardCharsets.UTF_8))); - - Mono response1 = blobClient.getBlockBlobAsyncClient() - .upload(inputV1, contentV1.length()) - .flatMap(r -> blobClient.getVersionClient(r.getVersionId()).downloadContent()); - - Mono response2 = blobClient.getBlockBlobAsyncClient() - .upload(inputV2, contentV2.length(), true) - .flatMap(r -> blobClient.getVersionClient(r.getVersionId()).downloadContent()); - - StepVerifier.create(response1).assertNext(r -> assertEquals(r.toString(), contentV1)).verifyComplete(); - - StepVerifier.create(response2).assertNext(r -> assertEquals(r.toString(), contentV2)).verifyComplete(); - } - - @Test - public void deleteBlobByVersion() { - Flux inputV1 = Flux.just(ByteBuffer.wrap(contentV1.getBytes(StandardCharsets.UTF_8))); - Flux inputV2 = Flux.just(ByteBuffer.wrap(contentV2.getBytes(StandardCharsets.UTF_8))); - - Mono> response = blobClient.getBlockBlobAsyncClient() - .upload(inputV1, contentV1.length()) - .flatMap(r -> Mono.zip(Mono.just(r), - blobClient.getBlockBlobAsyncClient().upload(inputV2, contentV2.length(), true))) - .flatMap(tuple -> blobClient.getVersionClient(tuple.getT1().getVersionId()) - .delete() - .then(Mono.zip(Mono.just(tuple.getT1()), Mono.just(tuple.getT2())))) - .flatMap(r -> Mono.zip(blobClient.getVersionClient(r.getT1().getVersionId()).exists(), - blobClient.getVersionClient(r.getT2().getVersionId()).exists())); - - StepVerifier.create(response).assertNext(r -> { - assertFalse(r.getT1()); - assertTrue(r.getT2()); - }).verifyComplete(); - } - - @Test - public void deleteBlobByVersionUsingSASToken() { - Flux inputV1 = Flux.just(ByteBuffer.wrap(contentV1.getBytes(StandardCharsets.UTF_8))); - Flux inputV2 = Flux.just(ByteBuffer.wrap(contentV2.getBytes(StandardCharsets.UTF_8))); - - Mono> response = blobClient.getBlockBlobAsyncClient() - .upload(inputV1, contentV1.length()) - .flatMap(r -> Mono.zip(Mono.just(r), - blobClient.getBlockBlobAsyncClient().upload(inputV2, contentV2.length(), true))) - .flatMap(r -> { - BlobSasPermission permission = new BlobSasPermission().setDeleteVersionPermission(true); - String sasToken = blobClient.getVersionClient(r.getT1().getVersionId()) - .generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), permission)); - - BlobAsyncClient sasClient - = getBlobAsyncClient(blobClient.getVersionClient(r.getT1().getVersionId()).getBlobUrl(), sasToken); - return sasClient.delete().then(Mono.zip(Mono.just(r.getT1()), Mono.just(r.getT2()))); - }) - .flatMap(r -> Mono.zip(blobClient.getVersionClient(r.getT1().getVersionId()).exists(), - blobClient.getVersionClient(r.getT2().getVersionId()).exists())); - - StepVerifier.create(response).assertNext(r -> { - assertFalse(r.getT1()); - assertTrue(r.getT2()); - }).verifyComplete(); - } - - @Test - public void deleteBlobByVersionUsingContainerSASToken() { - Flux inputV1 = Flux.just(ByteBuffer.wrap(contentV1.getBytes(StandardCharsets.UTF_8))); - Flux inputV2 = Flux.just(ByteBuffer.wrap(contentV2.getBytes(StandardCharsets.UTF_8))); - - Mono> response = blobClient.getBlockBlobAsyncClient() - .upload(inputV1, contentV1.length()) - .flatMap(r -> Mono.zip(Mono.just(r), - blobClient.getBlockBlobAsyncClient().upload(inputV2, contentV2.length(), true))) - .flatMap(r -> { - BlobSasPermission permission = new BlobSasPermission().setDeleteVersionPermission(true); - String sasToken = blobContainerClient - .generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), permission)); - - BlobAsyncClient sasClient - = getBlobAsyncClient(blobClient.getVersionClient(r.getT1().getVersionId()).getBlobUrl(), sasToken); - return sasClient.delete().then(Mono.zip(Mono.just(r.getT1()), Mono.just(r.getT2()))); - }) - .flatMap(r -> Mono.zip(blobClient.getVersionClient(r.getT1().getVersionId()).exists(), - blobClient.getVersionClient(r.getT2().getVersionId()).exists())); - - StepVerifier.create(response).assertNext(r -> { - assertFalse(r.getT1()); - assertTrue(r.getT2()); - }).verifyComplete(); - } - - @Test - public void deleteBlobByVersionUsingAccountSASToken() { - Flux inputV1 = Flux.just(ByteBuffer.wrap(contentV1.getBytes(StandardCharsets.UTF_8))); - Flux inputV2 = Flux.just(ByteBuffer.wrap(contentV2.getBytes(StandardCharsets.UTF_8))); - - Mono> response = blobClient.getBlockBlobAsyncClient() - .upload(inputV1, contentV1.length()) - .flatMap(r -> Mono.zip(Mono.just(r), - blobClient.getBlockBlobAsyncClient().upload(inputV2, contentV2.length(), true))) - .flatMap(r -> { - AccountSasPermission permission = new AccountSasPermission().setDeleteVersionPermission(true); - String sasToken = versionedBlobServiceAsyncClient - .generateAccountSas(new AccountSasSignatureValues(testResourceNamer.now().plusDays(1), permission, - new AccountSasService().setBlobAccess(true), new AccountSasResourceType().setObject(true))); - - BlobAsyncClient sasClient - = getBlobAsyncClient(blobClient.getVersionClient(r.getT1().getVersionId()).getBlobUrl(), sasToken); - return sasClient.delete().then(Mono.zip(Mono.just(r.getT1()), Mono.just(r.getT2()))); - }) - .flatMap(r -> Mono.zip(blobClient.getVersionClient(r.getT1().getVersionId()).exists(), - blobClient.getVersionClient(r.getT2().getVersionId()).exists())); - - StepVerifier.create(response).assertNext(r -> { - assertFalse(r.getT1()); - assertTrue(r.getT2()); - }).verifyComplete(); - } - - @Test - public void getBlobPropertiesByVersion() { - String key = "key"; - String valV2 = "val2"; - String valV3 = "val3"; - - Mono> response = blobClient.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .flatMap(r -> Mono.zip(Mono.just(r), - blobClient.getBlockBlobAsyncClient() - .setMetadataWithResponse(Collections.singletonMap(key, valV2), null), - blobClient.getBlockBlobAsyncClient() - .setMetadataWithResponse(Collections.singletonMap(key, valV3), null))) - .flatMap(r -> { - String versionId1 = r.getT1().getVersionId(); - String versionId2 = r.getT2().getHeaders().getValue(X_MS_VERSION_ID); - String versionId3 = r.getT3().getHeaders().getValue(X_MS_VERSION_ID); - return Mono.zip(blobClient.getVersionClient(versionId1).getProperties(), - blobClient.getVersionClient(versionId2).getProperties(), - blobClient.getVersionClient(versionId3).getProperties()); - }); - - StepVerifier.create(response).assertNext(r -> { - assertNull(r.getT1().getMetadata().get(key)); - assertEquals(valV2, r.getT2().getMetadata().get(key)); - assertEquals(valV3, r.getT3().getMetadata().get(key)); - }).verifyComplete(); - } - - @Test - public void listBlobsWithVersion() { - Mono>> response = blobClient - .getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .flatMap(blobItemV1 -> blobClient.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .flatMap(blobItemV2 -> blobClient.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .flatMap(blobItemV3 -> blobContainerClient - .listBlobs(new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveVersions(true)), - null) - .collectList() - .flatMap(list -> Mono.zip(Mono.just(blobItemV1), Mono.just(blobItemV2), Mono.just(blobItemV3), - Mono.just(list)))))); - - StepVerifier.create(response).assertNext(tuple -> { - BlockBlobItem blobItemV1 = tuple.getT1(); - BlockBlobItem blobItemV2 = tuple.getT2(); - BlockBlobItem blobItemV3 = tuple.getT3(); - List blobItems = tuple.getT4(); - - assertEquals(blobItemV1.getVersionId(), blobItems.get(0).getVersionId()); - assertNull(blobItems.get(0).isCurrentVersion()); - - assertEquals(blobItemV2.getVersionId(), blobItems.get(1).getVersionId()); - assertNull(blobItems.get(1).isCurrentVersion()); - - assertEquals(blobItemV3.getVersionId(), blobItems.get(2).getVersionId()); - assertTrue(blobItems.get(2).isCurrentVersion()); - }).verifyComplete(); - } - - @Test - public void listBlobsWithoutVersion() { - Flux> response = blobClient.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(blobClient.getBlockBlobAsyncClient().upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true)) - .then(blobClient.getBlockBlobAsyncClient().upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true)) - .flatMapMany(r -> Flux.zip( - blobContainerClient.listBlobs( - new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveVersions(false)), null), - Flux.just(r))); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(r.getT2().getVersionId(), r.getT1().getVersionId())) - .verifyComplete(); - } - - @Test - public void beginCopyBlobsWithVersion() { - BlobAsyncClient sourceBlob = blobContainerClient.getBlobAsyncClient(generateBlobName()); - - Flux, BlockBlobItem>> response - = sourceBlob.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(blobClient.getBlockBlobAsyncClient().upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .flatMapMany(r -> { - PollerFlux poller - = setPlaybackPollerFluxPollInterval(blobClient.beginCopy(sourceBlob.getBlobUrl(), null)); - return Flux.zip(poller, Flux.just(r)); - }); - - StepVerifier.create(response).assertNext(r -> { - assertNotNull(r.getT1().getValue().getVersionId()); - assertNotEquals(r.getT2().getVersionId(), r.getT1().getValue().getVersionId()); - }).verifyComplete(); - } - - @Test - public void copyFromUrlBlobsWithVersion() { - BlobAsyncClient sourceBlob = blobContainerClient.getBlobAsyncClient(generateBlobName()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono, BlockBlobItem>> response = blobClient.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .flatMap(blobItemV1 -> sourceBlob.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(Mono.zip( - blobClient.copyFromUrlWithResponse(sourceBlob.getBlobUrl() + "?" + sas, null, null, null, null), - Mono.just(blobItemV1)))); - - StepVerifier.create(response).assertNext(r -> { - assertNotNull(r.getT1().getHeaders().getValue(X_MS_VERSION_ID)); - assertNotEquals(r.getT2().getVersionId(), r.getT1().getHeaders().getValue(X_MS_VERSION_ID)); - }).verifyComplete(); - } - - @Test - public void setTierWithVersion() { - Flux inputV1 = Flux.just(ByteBuffer.wrap(contentV1.getBytes(StandardCharsets.UTF_8))); - Flux inputV2 = Flux.just(ByteBuffer.wrap(contentV2.getBytes(StandardCharsets.UTF_8))); - - Mono> response = blobClient.getBlockBlobAsyncClient() - .upload(inputV1, contentV1.length()) - .flatMap(r -> Mono.zip(Mono.just(r), - blobClient.getBlockBlobAsyncClient().upload(inputV2, contentV2.length(), true))) - .flatMap(r -> blobClient.getVersionClient(r.getT1().getVersionId()) - .setAccessTier(AccessTier.COOL) - .then(Mono.zip(blobClient.getVersionClient(r.getT1().getVersionId()).getProperties(), - blobClient.getProperties()))); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(AccessTier.COOL, r.getT1().getAccessTier()); - assertNotEquals(AccessTier.COOL, r.getT2().getAccessTier()); - }).verifyComplete(); - } - - @Test - public void setTierWithVersionError() { - Flux inputV1 = Flux.just(ByteBuffer.wrap(contentV1.getBytes(StandardCharsets.UTF_8))); - blobClient.getBlockBlobAsyncClient().upload(inputV1, contentV1.length()); - String fakeVersion = "2020-04-17T20:37:16.5129130Z"; - - StepVerifier.create(blobClient.getVersionClient(fakeVersion).setAccessTier(AccessTier.COOL)) - .verifyError(BlobStorageException.class); - } - - @Test - public void blobPropertiesShouldContainVersionInformation() { - Mono> response = blobClient - .getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .flatMap(r -> Mono.zip(Mono.just(r), - blobClient.getBlockBlobAsyncClient().upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true))) - .flatMap(tuple -> Mono.zip(blobClient.getVersionClient(tuple.getT1().getVersionId()).getProperties(), - blobClient.getVersionClient(tuple.getT2().getVersionId()).getProperties(), Mono.just(tuple.getT1()), - Mono.just(tuple.getT2()))); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(r.getT1().getVersionId(), r.getT3().getVersionId()); - assertNull(r.getT1().isCurrentVersion()); - assertEquals(r.getT2().getVersionId(), r.getT4().getVersionId()); - assertTrue(r.getT2().isCurrentVersion()); - }).verifyComplete(); - } - - @Test - public void doNotLookForSnapshotOfVersion() { - StepVerifier - .create(blobClient.getBlockBlobAsyncClient().upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .assertNext(Assertions::assertNotNull) - .verifyComplete(); - - assertThrows(IllegalArgumentException.class, () -> blobClient.getVersionClient("a").getSnapshotClient("b")); - } - - @Test - public void doNotLookForVersionOfSnapshot() { - StepVerifier - .create(blobClient.getBlockBlobAsyncClient().upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .assertNext(Assertions::assertNotNull) - .verifyComplete(); - - assertThrows(IllegalArgumentException.class, () -> blobClient.getSnapshotClient("a").getVersionClient("b")); - } - - @Test - public void snapshotCreatesNewVersion() { - Mono>> response = blobClient.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .flatMap(r -> Mono.zip(Mono.just(r), blobClient.createSnapshotWithResponse(null, null))); - - StepVerifier.create(response).assertNext(r -> { - assertNotNull(r.getT2().getHeaders().getValue(X_MS_VERSION_ID)); - assertNotEquals(r.getT1().getVersionId(), r.getT2().getHeaders().getValue(X_MS_VERSION_ID)); - }).verifyComplete(); - } - - @Test - public void versionedBlobURLContainsVersion() { - Mono> response = blobClient.getBlockBlobAsyncClient() - .upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .flatMap( - r -> Mono.zip(Mono.just(blobClient.getVersionClient(r.getVersionId()).getBlobUrl()), Mono.just(r))); - - StepVerifier.create(response) - .assertNext(r -> assertTrue(r.getT1().contains(r.getT2().getVersionId()))) - .verifyComplete(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/VersioningTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/VersioningTests.java deleted file mode 100644 index 801b5db4d319..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/VersioningTests.java +++ /dev/null @@ -1,390 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob; - -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.Response; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.polling.SyncPoller; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.BlobCopyInfo; -import com.azure.storage.blob.models.BlobItem; -import com.azure.storage.blob.models.BlobListDetails; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.sas.AccountSasPermission; -import com.azure.storage.common.sas.AccountSasResourceType; -import com.azure.storage.common.sas.AccountSasService; -import com.azure.storage.common.sas.AccountSasSignatureValues; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.Iterator; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class VersioningTests extends BlobTestBase { - private BlobContainerClient blobContainerClient; - private BlobClient blobClient; - private final String contentV1 = "contentV1"; - private final String contentV2 = "contentV2"; - - @BeforeEach - public void setup() { - String blobName = generateBlobName(); - String containerName = generateContainerName(); - blobContainerClient = versionedBlobServiceClient.createBlobContainer(containerName); - blobClient = blobContainerClient.getBlobClient(blobName); - } - - @AfterEach - public void cleanup() { - blobContainerClient.delete(); - } - - @Test - public void createBlockBlobWithVersion() { - BlockBlobItem blobItemV1 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - BlockBlobItem blobItemV2 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - - assertNotNull(blobItemV1.getVersionId()); - assertNotNull(blobItemV2.getVersionId()); - assertNotEquals(blobItemV1.getVersionId(), blobItemV2.getVersionId()); - } - - @Test - public void createPageBlobWithVersion() { - PageBlobItem blobItemV1 = blobClient.getPageBlobClient().create(512); - PageBlobItem blobItemV2 = blobClient.getPageBlobClient().create(512, true); - - assertNotNull(blobItemV1.getVersionId()); - assertNotNull(blobItemV2.getVersionId()); - assertNotEquals(blobItemV1.getVersionId(), blobItemV2.getVersionId()); - } - - @Test - public void createAppendBlobWithVersion() { - AppendBlobItem blobItemV1 = blobClient.getAppendBlobClient().create(); - AppendBlobItem blobItemV2 = blobClient.getAppendBlobClient().create(true); - - assertNotNull(blobItemV1.getVersionId()); - assertNotNull(blobItemV2.getVersionId()); - assertNotEquals(blobItemV1.getVersionId(), blobItemV2.getVersionId()); - } - - @SuppressWarnings("deprecation") - @Test - public void downloadBlobByVersion() { - ByteArrayInputStream inputV1 = new ByteArrayInputStream(contentV1.getBytes(StandardCharsets.UTF_8)); - ByteArrayInputStream inputV2 = new ByteArrayInputStream(contentV2.getBytes(StandardCharsets.UTF_8)); - BlockBlobItem blobItemV1 = blobClient.getBlockBlobClient().upload(inputV1, inputV1.available()); - BlockBlobItem blobItemV2 = blobClient.getBlockBlobClient().upload(inputV2, inputV2.available(), true); - - ByteArrayOutputStream outputV1 = new ByteArrayOutputStream(); - ByteArrayOutputStream outputV2 = new ByteArrayOutputStream(); - blobClient.getVersionClient(blobItemV1.getVersionId()).download(outputV1); - blobClient.getVersionClient(blobItemV2.getVersionId()).download(outputV2); - - TestUtils.assertArraysEqual(outputV1.toByteArray(), contentV1.getBytes(StandardCharsets.UTF_8)); - TestUtils.assertArraysEqual(outputV2.toByteArray(), contentV2.getBytes(StandardCharsets.UTF_8)); - } - - @Test - public void downloadBlobByVersionStreaming() { - ByteArrayInputStream inputV1 = new ByteArrayInputStream(contentV1.getBytes(StandardCharsets.UTF_8)); - ByteArrayInputStream inputV2 = new ByteArrayInputStream(contentV2.getBytes(StandardCharsets.UTF_8)); - BlockBlobItem blobItemV1 = blobClient.getBlockBlobClient().upload(inputV1, inputV1.available()); - BlockBlobItem blobItemV2 = blobClient.getBlockBlobClient().upload(inputV2, inputV2.available(), true); - - ByteArrayOutputStream outputV1 = new ByteArrayOutputStream(); - ByteArrayOutputStream outputV2 = new ByteArrayOutputStream(); - blobClient.getVersionClient(blobItemV1.getVersionId()).downloadStream(outputV1); - blobClient.getVersionClient(blobItemV2.getVersionId()).downloadStream(outputV2); - - TestUtils.assertArraysEqual(outputV1.toByteArray(), contentV1.getBytes(StandardCharsets.UTF_8)); - TestUtils.assertArraysEqual(outputV2.toByteArray(), contentV2.getBytes(StandardCharsets.UTF_8)); - } - - @Test - public void downloadBlobByVersionBinaryData() { - ByteArrayInputStream inputV1 = new ByteArrayInputStream(contentV1.getBytes(StandardCharsets.UTF_8)); - ByteArrayInputStream inputV2 = new ByteArrayInputStream(contentV2.getBytes(StandardCharsets.UTF_8)); - BlockBlobItem blobItemV1 = blobClient.getBlockBlobClient().upload(inputV1, inputV1.available()); - BlockBlobItem blobItemV2 = blobClient.getBlockBlobClient().upload(inputV2, inputV2.available(), true); - - BinaryData outputV1 = blobClient.getVersionClient(blobItemV1.getVersionId()).downloadContent(); - BinaryData outputV2 = blobClient.getVersionClient(blobItemV2.getVersionId()).downloadContent(); - - assertEquals(outputV1.toString(), contentV1); - assertEquals(outputV2.toString(), contentV2); - } - - @Test - public void deleteBlobByVersion() { - ByteArrayInputStream inputV1 = new ByteArrayInputStream(contentV1.getBytes(StandardCharsets.UTF_8)); - ByteArrayInputStream inputV2 = new ByteArrayInputStream(contentV2.getBytes(StandardCharsets.UTF_8)); - BlockBlobItem blobItemV1 = blobClient.getBlockBlobClient().upload(inputV1, inputV1.available()); - BlockBlobItem blobItemV2 = blobClient.getBlockBlobClient().upload(inputV2, inputV2.available(), true); - - blobClient.getVersionClient(blobItemV1.getVersionId()).delete(); - - assertFalse(blobClient.getVersionClient(blobItemV1.getVersionId()).exists()); - assertTrue(blobClient.getVersionClient(blobItemV2.getVersionId()).exists()); - } - - @Test - public void deleteBlobByVersionUsingSASToken() { - ByteArrayInputStream inputV1 = new ByteArrayInputStream(contentV1.getBytes(StandardCharsets.UTF_8)); - ByteArrayInputStream inputV2 = new ByteArrayInputStream(contentV2.getBytes(StandardCharsets.UTF_8)); - BlockBlobItem blobItemV1 = blobClient.getBlockBlobClient().upload(inputV1, inputV1.available()); - BlockBlobItem blobItemV2 = blobClient.getBlockBlobClient().upload(inputV2, inputV2.available(), true); - - BlobSasPermission permission = new BlobSasPermission().setDeleteVersionPermission(true); - String sasToken = blobClient.getVersionClient(blobItemV1.getVersionId()) - .generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), permission)); - - BlobClient sasClient - = getBlobClient(blobClient.getVersionClient(blobItemV1.getVersionId()).getBlobUrl(), sasToken); - - sasClient.delete(); - - assertFalse(blobClient.getVersionClient(blobItemV1.getVersionId()).exists()); - assertTrue(blobClient.getVersionClient(blobItemV2.getVersionId()).exists()); - } - - @Test - public void deleteBlobByVersionUsingContainerSASToken() { - ByteArrayInputStream inputV1 = new ByteArrayInputStream(contentV1.getBytes(StandardCharsets.UTF_8)); - ByteArrayInputStream inputV2 = new ByteArrayInputStream(contentV2.getBytes(StandardCharsets.UTF_8)); - BlockBlobItem blobItemV1 = blobClient.getBlockBlobClient().upload(inputV1, inputV1.available()); - BlockBlobItem blobItemV2 = blobClient.getBlockBlobClient().upload(inputV2, inputV2.available(), true); - - BlobSasPermission permission = new BlobSasPermission().setDeleteVersionPermission(true); - String sasToken = blobContainerClient - .generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), permission)); - - BlobClient sasClient - = getBlobClient(blobClient.getVersionClient(blobItemV1.getVersionId()).getBlobUrl(), sasToken); - - sasClient.delete(); - - assertFalse(blobClient.getVersionClient(blobItemV1.getVersionId()).exists()); - assertTrue(blobClient.getVersionClient(blobItemV2.getVersionId()).exists()); - } - - @Test - public void deleteBlobByVersionUsingAccountSASToken() { - ByteArrayInputStream inputV1 = new ByteArrayInputStream(contentV1.getBytes(StandardCharsets.UTF_8)); - ByteArrayInputStream inputV2 = new ByteArrayInputStream(contentV2.getBytes(StandardCharsets.UTF_8)); - BlockBlobItem blobItemV1 = blobClient.getBlockBlobClient().upload(inputV1, inputV1.available()); - BlockBlobItem blobItemV2 = blobClient.getBlockBlobClient().upload(inputV2, inputV2.available(), true); - - AccountSasPermission permission = new AccountSasPermission().setDeleteVersionPermission(true); - String sasToken = versionedBlobServiceClient - .generateAccountSas(new AccountSasSignatureValues(testResourceNamer.now().plusDays(1), permission, - new AccountSasService().setBlobAccess(true), new AccountSasResourceType().setObject(true))); - - BlobClient sasClient - = getBlobClient(blobClient.getVersionClient(blobItemV1.getVersionId()).getBlobUrl(), sasToken); - - sasClient.delete(); - - assertFalse(blobClient.getVersionClient(blobItemV1.getVersionId()).exists()); - assertTrue(blobClient.getVersionClient(blobItemV2.getVersionId()).exists()); - } - - @Test - public void getBlobPropertiesByVersion() { - String key = "key"; - String valV2 = "val2"; - String valV3 = "val3"; - BlockBlobItem blobItemV1 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - Response responseV2 = blobClient.getBlockBlobClient() - .setMetadataWithResponse(Collections.singletonMap(key, valV2), null, null, Context.NONE); - Response responseV3 = blobClient.getBlockBlobClient() - .setMetadataWithResponse(Collections.singletonMap(key, valV3), null, null, Context.NONE); - String versionId1 = blobItemV1.getVersionId(); - String versionId2 = responseV2.getHeaders().getValue(X_MS_VERSION_ID); - String versionId3 = responseV3.getHeaders().getValue(X_MS_VERSION_ID); - - String receivedValV1 = blobClient.getVersionClient(versionId1).getProperties().getMetadata().get(key); - String receivedValV2 = blobClient.getVersionClient(versionId2).getProperties().getMetadata().get(key); - String receivedValV3 = blobClient.getVersionClient(versionId3).getProperties().getMetadata().get(key); - - assertNull(receivedValV1); - assertEquals(valV2, receivedValV2); - assertEquals(valV3, receivedValV3); - } - - @Test - public void listBlobsWithVersion() { - BlockBlobItem blobItemV1 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - BlockBlobItem blobItemV2 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - BlockBlobItem blobItemV3 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - - PagedIterable blobs = blobContainerClient - .listBlobs(new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveVersions(true)), null); - - Iterator iterator = blobs.stream().iterator(); - assertEquals(3, blobs.stream().count()); - BlobItem resultingBlobItem1 = iterator.next(); - assertEquals(blobItemV1.getVersionId(), resultingBlobItem1.getVersionId()); - assertNull(resultingBlobItem1.isCurrentVersion()); - BlobItem resultingBlobItem2 = iterator.next(); - assertEquals(blobItemV2.getVersionId(), resultingBlobItem2.getVersionId()); - assertNull(resultingBlobItem2.isCurrentVersion()); - BlobItem resultingBlobItem3 = iterator.next(); - assertEquals(blobItemV3.getVersionId(), resultingBlobItem3.getVersionId()); - assertTrue(resultingBlobItem3.isCurrentVersion()); - } - - @Test - public void listBlobsWithoutVersion() { - blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - BlockBlobItem blobItemV3 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - - PagedIterable blobs = blobContainerClient - .listBlobs(new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveVersions(false)), null); - - assertEquals(1, blobs.stream().count()); - assertEquals(blobItemV3.getVersionId(), blobs.stream().iterator().next().getVersionId()); - } - - @Test - public void beginCopyBlobsWithVersion() { - BlockBlobItem blobItemV1 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - BlobClient sourceBlob = blobContainerClient.getBlobClient(generateBlobName()); - sourceBlob.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - SyncPoller poller - = setPlaybackSyncPollerPollInterval(blobClient.beginCopy(sourceBlob.getBlobUrl(), null)); - BlobCopyInfo copyInfo = poller.waitForCompletion().getValue(); - - assertNotNull(copyInfo.getVersionId()); - assertNotEquals(blobItemV1.getVersionId(), copyInfo.getVersionId()); - } - - @Test - public void copyFromUrlBlobsWithVersion() { - BlockBlobItem blobItemV1 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - BlobClient sourceBlob = blobContainerClient.getBlobClient(generateBlobName()); - sourceBlob.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - Response response = blobClient.copyFromUrlWithResponse(sourceBlob.getBlobUrl() + "?" + sas, null, null, - null, null, null, Context.NONE); - String versionIdAfterCopy = response.getHeaders().getValue(X_MS_VERSION_ID); - - assertNotNull(versionIdAfterCopy); - assertNotEquals(blobItemV1.getVersionId(), versionIdAfterCopy); - } - - @Test - public void setTierWithVersion() { - ByteArrayInputStream inputV1 = new ByteArrayInputStream(contentV1.getBytes(StandardCharsets.UTF_8)); - ByteArrayInputStream inputV2 = new ByteArrayInputStream(contentV2.getBytes(StandardCharsets.UTF_8)); - BlockBlobItem blobItemV1 = blobClient.getBlockBlobClient().upload(inputV1, inputV1.available()); - blobClient.getBlockBlobClient().upload(inputV2, inputV2.available(), true); - - blobClient.getVersionClient(blobItemV1.getVersionId()).setAccessTier(AccessTier.COOL); - - assertEquals(AccessTier.COOL, - blobClient.getVersionClient(blobItemV1.getVersionId()).getProperties().getAccessTier()); - assertNotEquals(AccessTier.COOL, blobClient.getProperties().getAccessTier()); - } - - @Test - public void setTierWithVersionError() { - ByteArrayInputStream inputV1 = new ByteArrayInputStream(contentV1.getBytes(StandardCharsets.UTF_8)); - blobClient.getBlockBlobClient().upload(inputV1, inputV1.available()); - String fakeVersion = "2020-04-17T20:37:16.5129130Z"; - - assertThrows(BlobStorageException.class, - () -> blobClient.getVersionClient(fakeVersion).setAccessTier(AccessTier.COOL)); - } - - @Test - public void blobPropertiesShouldContainVersionInformation() { - BlockBlobItem blobItemV1 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - BlockBlobItem blobItemV2 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - - BlobProperties propertiesV1 = blobClient.getVersionClient(blobItemV1.getVersionId()).getProperties(); - BlobProperties propertiesV2 = blobClient.getVersionClient(blobItemV2.getVersionId()).getProperties(); - - assertEquals(propertiesV1.getVersionId(), blobItemV1.getVersionId()); - assertEquals(propertiesV2.getVersionId(), blobItemV2.getVersionId()); - assertNull(propertiesV1.isCurrentVersion()); - assertTrue(propertiesV2.isCurrentVersion()); - } - - @Test - public void doNotLookForSnapshotOfVersion() { - blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - assertThrows(IllegalArgumentException.class, () -> blobClient.getVersionClient("a").getSnapshotClient("b")); - } - - @Test - public void doNotLookForVersionOfSnapshot() { - blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - assertThrows(IllegalArgumentException.class, () -> blobClient.getSnapshotClient("a").getVersionClient("b")); - } - - @Test - public void snapshotCreatesNewVersion() { - BlockBlobItem blobItemV1 - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - String versionIdAfterSnapshot = blobClient.createSnapshotWithResponse(null, null, null, Context.NONE) - .getHeaders() - .getValue(X_MS_VERSION_ID); - - assertNotNull(versionIdAfterSnapshot); - assertNotEquals(blobItemV1.getVersionId(), versionIdAfterSnapshot); - } - - @Test - public void versionedBlobURLContainsVersion() { - BlockBlobItem blobItem - = blobClient.getBlockBlobClient().upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - String blobUrl = blobClient.getVersionClient(blobItem.getVersionId()).getBlobUrl(); - - assertTrue(blobUrl.contains(blobItem.getVersionId())); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/generated/ServiceClientClientTestBase.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/generated/ServiceClientClientTestBase.java new file mode 100644 index 000000000000..a74d6c19804e --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/generated/ServiceClientClientTestBase.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.storage.blob.generated; + +// The Java test files under 'generated' package are generated for your reference. +// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. +// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. + +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; +import com.azure.core.test.utils.MockTokenCredential; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.storage.blob.AppendBlobClient; +import com.azure.storage.blob.BlockBlobClient; +import com.azure.storage.blob.ContainerBlobClient; +import com.azure.storage.blob.ContainerClient; +import com.azure.storage.blob.PageBlobClient; +import com.azure.storage.blob.ServiceClientClient; +import com.azure.storage.blob.ServiceClientClientBuilder; + +class ServiceClientClientTestBase extends TestProxyTestBase { + protected ServiceClientClient serviceClientClient; + + protected ContainerClient containerClient; + + protected ContainerBlobClient containerBlobClient; + + protected PageBlobClient pageBlobClient; + + protected AppendBlobClient appendBlobClient; + + protected BlockBlobClient blockBlobClient; + + @Override + protected void beforeTest() { + ServiceClientClientBuilder serviceClientClientbuilder + = new ServiceClientClientBuilder().url(Configuration.getGlobalConfiguration().get("URL", "url")) + .containerName(Configuration.getGlobalConfiguration().get("CONTAINERNAME", "containername")) + .blob(Configuration.getGlobalConfiguration().get("BLOB", "blob")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + serviceClientClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + serviceClientClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + serviceClientClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + serviceClientClient = serviceClientClientbuilder.buildClient(); + + ServiceClientClientBuilder containerClientbuilder + = new ServiceClientClientBuilder().url(Configuration.getGlobalConfiguration().get("URL", "url")) + .containerName(Configuration.getGlobalConfiguration().get("CONTAINERNAME", "containername")) + .blob(Configuration.getGlobalConfiguration().get("BLOB", "blob")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + containerClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + containerClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + containerClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + containerClient = containerClientbuilder.buildContainerClient(); + + ServiceClientClientBuilder containerBlobClientbuilder + = new ServiceClientClientBuilder().url(Configuration.getGlobalConfiguration().get("URL", "url")) + .containerName(Configuration.getGlobalConfiguration().get("CONTAINERNAME", "containername")) + .blob(Configuration.getGlobalConfiguration().get("BLOB", "blob")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + containerBlobClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + containerBlobClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + containerBlobClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + containerBlobClient = containerBlobClientbuilder.buildContainerBlobClient(); + + ServiceClientClientBuilder pageBlobClientbuilder + = new ServiceClientClientBuilder().url(Configuration.getGlobalConfiguration().get("URL", "url")) + .containerName(Configuration.getGlobalConfiguration().get("CONTAINERNAME", "containername")) + .blob(Configuration.getGlobalConfiguration().get("BLOB", "blob")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + pageBlobClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + pageBlobClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + pageBlobClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + pageBlobClient = pageBlobClientbuilder.buildPageBlobClient(); + + ServiceClientClientBuilder appendBlobClientbuilder + = new ServiceClientClientBuilder().url(Configuration.getGlobalConfiguration().get("URL", "url")) + .containerName(Configuration.getGlobalConfiguration().get("CONTAINERNAME", "containername")) + .blob(Configuration.getGlobalConfiguration().get("BLOB", "blob")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + appendBlobClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + appendBlobClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + appendBlobClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + appendBlobClient = appendBlobClientbuilder.buildAppendBlobClient(); + + ServiceClientClientBuilder blockBlobClientbuilder + = new ServiceClientClientBuilder().url(Configuration.getGlobalConfiguration().get("URL", "url")) + .containerName(Configuration.getGlobalConfiguration().get("CONTAINERNAME", "containername")) + .blob(Configuration.getGlobalConfiguration().get("BLOB", "blob")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + blockBlobClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + blockBlobClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + blockBlobClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + blockBlobClient = blockBlobClientbuilder.buildBlockBlobClient(); + + } +} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/implementation/util/StorageBlockingSinkTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/implementation/util/StorageBlockingSinkTests.java deleted file mode 100644 index fc54aa58cc75..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/implementation/util/StorageBlockingSinkTests.java +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.implementation.util; - -import com.azure.storage.common.implementation.Constants; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Sinks; -import reactor.core.scheduler.Schedulers; -import reactor.test.StepVerifier; - -import java.nio.ByteBuffer; -import java.time.Duration; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.TimeUnit; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class StorageBlockingSinkTests { - - // Use a delay of 5 ms to test. - // This is more than long enough to ensure that nothing odd happens in the blocking sink. - private static final int DELAY_MS = 5; - - @Test - public void min() { - StorageBlockingSink blockingSink = new StorageBlockingSink(); - - blockingSink.emitNext(ByteBuffer.wrap(new byte[0])); - blockingSink.emitCompleteOrThrow(); - - Flux flux = blockingSink.asFlux(); - StepVerifier.create(flux).expectNextMatches(buffer -> buffer.remaining() == 0).expectComplete().verify(); - } - - @ParameterizedTest - @ValueSource(ints = { 5, 10, 50, 100 }) - public void producerDelayedConsumer(int num) { - StorageBlockingSink blockingSink = new StorageBlockingSink(); - - blockingSink.asFlux() - .index() - .delayElements(Duration.ofMillis(DELAY_MS)) // This simulates the slower network bound IO - .doOnNext(tuple -> assertEquals(tuple.getT2().getLong(0), tuple.getT1())) // Check for data integrity - .subscribe(); - - for (int i = 0; i < num; i++) { - // This simulates a customer writing really fast to the OutputStream - blockingSink.emitNext(ByteBuffer.allocate(8).putLong(i)); - } - assertDoesNotThrow(blockingSink::emitCompleteOrThrow); - } - - @Test - void producerDelayedConsumerRandomBuffers() { - int num = 50; - ByteBuffer[] buffers = new ByteBuffer[num]; - for (int i = 0; i < num; i++) { - int size = ThreadLocalRandom.current().nextInt(8 * Constants.KB); - byte[] b = new byte[size]; - ThreadLocalRandom.current().nextBytes(b); - buffers[i] = ByteBuffer.wrap(b); - } - - StorageBlockingSink blockingSink = new StorageBlockingSink(); - blockingSink.asFlux() - .index() - .delayElements(Duration.ofMillis(DELAY_MS)) // This simulates the slower network bound IO - // Check for data integrity - .doOnNext(tuple -> assertEquals(buffers[Math.toIntExact(tuple.getT1())], tuple.getT2())) - .subscribe(); - - for (int i = 0; i < num; i++) { - blockingSink.emitNext(buffers[i]); - } - assertDoesNotThrow(blockingSink::emitCompleteOrThrow); - } - - @ParameterizedTest - @ValueSource(ints = { 5, 10, 50, 100 }) - void delayedProducerConsumer(int num) { - StorageBlockingSink blockingSink = new StorageBlockingSink(); - - blockingSink.asFlux() - .index() - .delayElements(Duration.ofMillis(DELAY_MS)) // This simulates the slower network bound IO - .doOnNext(tuple -> assertEquals(tuple.getT2().getLong(0), tuple.getT1())) // Check for data integrity - .subscribe(); - - for (int i = 0; i < num; i++) { - // This simulates a customer writing really slow to the OutputStream - blockingSink.emitNext(ByteBuffer.allocate(8).putLong(i)); - sleep(DELAY_MS); - } - assertDoesNotThrow(blockingSink::emitCompleteOrThrow); - } - - @Test - void delayedProducerConsumerRandomBuffers() { - int num = 50; - ByteBuffer[] buffers = new ByteBuffer[num]; - for (int i = 0; i < num; i++) { - int size = ThreadLocalRandom.current().nextInt(8 * Constants.KB); - byte[] b = new byte[size]; - ThreadLocalRandom.current().nextBytes(b); - buffers[i] = ByteBuffer.wrap(b); - } - - StorageBlockingSink blockingSink = new StorageBlockingSink(); - - blockingSink.asFlux() - .index() - // Check for data integrity - .doOnNext(tuple -> assertEquals(buffers[Math.toIntExact(tuple.getT1())], tuple.getT2())) - .subscribe(); - - for (int i = 0; i < num; i++) { - blockingSink.emitNext(buffers[i]); - sleep(DELAY_MS); // This simulates a customer writing really slow to the OutputStream - } - assertDoesNotThrow(blockingSink::emitCompleteOrThrow); - } - - @Test - void errorTerminated() { - StorageBlockingSink blockingSink = new StorageBlockingSink(); - - blockingSink.asFlux().subscribe(); - - blockingSink.emitNext(ByteBuffer.wrap(new byte[0])); - blockingSink.emitCompleteOrThrow(); - StorageBlockingSink finalBlockingSink = blockingSink; - IllegalStateException e - = assertThrows(IllegalStateException.class, () -> finalBlockingSink.emitNext(ByteBuffer.wrap(new byte[0]))); - - assertEquals(((Sinks.EmissionException) e.getCause()).getReason(), Sinks.EmitResult.FAIL_TERMINATED); - - blockingSink = new StorageBlockingSink(); - blockingSink.asFlux().subscribe(); - - blockingSink.emitCompleteOrThrow(); - StorageBlockingSink finalBlockingSink1 = blockingSink; - Sinks.EmissionException ex - = assertThrows(Sinks.EmissionException.class, finalBlockingSink1::emitCompleteOrThrow); - assertEquals(ex.getReason(), Sinks.EmitResult.FAIL_TERMINATED); - } - - @Test - void errorCancelled() throws InterruptedException { - StorageBlockingSink blockingSink = new StorageBlockingSink(); - final CountDownLatch latch = new CountDownLatch(1); - blockingSink.asFlux() - .timeout(Duration.ofMillis(DELAY_MS)) - .doFinally(s -> latch.countDown()) - .subscribeOn(Schedulers.boundedElastic()) - .subscribe(); - - latch.await(1, TimeUnit.MINUTES); - - StorageBlockingSink finalBlockingSink = blockingSink; - IllegalStateException e - = assertThrows(IllegalStateException.class, () -> finalBlockingSink.emitNext(ByteBuffer.wrap(new byte[0]))); - - assertEquals(((Sinks.EmissionException) e.getCause()).getReason(), Sinks.EmitResult.FAIL_CANCELLED); - - blockingSink = new StorageBlockingSink(); - final CountDownLatch latch2 = new CountDownLatch(1); - blockingSink.asFlux() - .timeout(Duration.ofMillis(DELAY_MS)) - .doFinally(s -> latch2.countDown()) - .subscribeOn(Schedulers.boundedElastic()) - .subscribe(); - - latch2.await(1, TimeUnit.MINUTES); - - StorageBlockingSink finalBlockingSink1 = blockingSink; - Sinks.EmissionException ex - = assertThrows(Sinks.EmissionException.class, finalBlockingSink1::emitCompleteOrThrow); - assertEquals(ex.getReason(), Sinks.EmitResult.FAIL_CANCELLED); - } - - private static void sleep(int millis) { - try { - Thread.sleep(millis); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobApiTests.java deleted file mode 100644 index 764edec70dd6..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobApiTests.java +++ /dev/null @@ -1,887 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.rest.Response; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.Context; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.AppendBlobRequestConditions; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.options.AppendBlobCreateOptions; -import com.azure.storage.blob.options.AppendBlobSealOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import com.azure.storage.common.test.shared.policy.TransientFailureInjectingHttpPipelinePolicy; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.OffsetDateTime; -import java.util.Base64; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -import static com.azure.storage.blob.specialized.AppendBlobClient.MAX_APPEND_BLOCKS; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class AppendBlobApiTests extends BlobTestBase { - - private AppendBlobClient bc; - private String blobName; - - @BeforeEach - public void setup() { - blobName = generateBlobName(); - bc = cc.getBlobClient(blobName).getAppendBlobClient(); - bc.create(); - } - - @Test - public void createDefaults() { - Response response = bc.createWithResponse(null, null, null, null, null); - assertEquals(201, response.getStatusCode()); - validateBasicHeaders(response.getHeaders()); - assertNull(response.getValue().getContentMd5()); - assertTrue(response.getValue().isServerEncrypted()); - } - - @Test - public void createMin() { - assertResponseStatusCode(bc.createWithResponse(null, null, null, null, null), 201); - } - - @Test - public void createError() { - assertThrows(BlobStorageException.class, () -> bc.createWithResponse(null, null, - new BlobRequestConditions().setIfMatch("garbage"), null, Context.NONE)); - } - - @ParameterizedTest - @MethodSource("createHeadersSupplier") - public void createHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) throws Exception { - - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - bc.createWithResponse(headers, null, null, null, null); - Response response = bc.getPropertiesWithResponse(null, null, null); - - // If the value isn't set the service will automatically set it - contentType = (contentType == null) ? "application/octet-stream" : contentType; - - validateBlobProperties(response, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentMD5, - contentType); - } - - private static Stream createHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of("control", "disposition", "encoding", "language", - Base64.getEncoder().encode(MessageDigest.getInstance("MD5").digest(DATA.getDefaultText().getBytes())), - "type")); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - bc.createWithResponse(null, metadata, null, null, Context.NONE); - - BlobProperties response = bc.getProperties(); - for (Map.Entry entry : metadata.entrySet()) { - assertEquals(entry.getValue(), response.getMetadata().get(entry.getKey())); - } - assertEquals(metadata, response.getMetadata()); - } - - private static Stream createMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createTagsSupplier") - public void createTags(String key1, String value1, String key2, String value2) { - HashMap tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - bc.createWithResponse(new AppendBlobCreateOptions().setTags(tags), null, Context.NONE); - - Response> response = bc.getTagsWithResponse(new BlobGetTagsOptions(), null, null); - for (Map.Entry entry : tags.entrySet()) { - assertEquals(entry.getValue(), response.getValue().get(entry.getKey())); - } - } - - private static Stream createTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createACSupplier") - public void createAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(bc.createWithResponse(null, null, bac, null, null), 201); - } - - private Stream createACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null), Arguments.of(null, NEW_DATE, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null), - Arguments.of(null, null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("createACFailSupplier") - public void createACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> bc.createWithResponse(null, null, bac, null, Context.NONE)); - } - - private Stream createACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null, null), - Arguments.of(null, OLD_DATE, null, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null, null), - Arguments.of(null, null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID, null), - Arguments.of(null, null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void createIfNotExistsDefaults() { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getAppendBlobClient(); - - Response createResponse - = bc.createIfNotExistsWithResponse(new AppendBlobCreateOptions(), null, null); - - assertResponseStatusCode(createResponse, 201); - validateBasicHeaders(createResponse.getHeaders()); - assertNull(createResponse.getValue().getContentMd5()); - assertTrue(createResponse.getValue().isServerEncrypted()); - } - - @Test - public void createIfNotExistsSimple() { - bc = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - - bc.createIfNotExists(); - assertTrue(bc.exists()); - } - - @Test - public void createIfNotExistsMin() { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getAppendBlobClient(); - - assertResponseStatusCode(bc.createIfNotExistsWithResponse(null, null, null), 201); - } - - @Test - public void createIfNotExistsOnABlobThatAlreadyExists() { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getAppendBlobClient(); - Response initialResponse - = bc.createIfNotExistsWithResponse(new AppendBlobCreateOptions(), null, null); - Response secondResponse - = bc.createIfNotExistsWithResponse(new AppendBlobCreateOptions(), null, null); - - assertResponseStatusCode(initialResponse, 201); - assertResponseStatusCode(secondResponse, 409); - } - - @ParameterizedTest - @MethodSource("createHeadersSupplier") - public void createIfNotExistsHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getAppendBlobClient(); - - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - AppendBlobCreateOptions options = new AppendBlobCreateOptions().setHeaders(headers); - - bc.createIfNotExistsWithResponse(options, null, null); - Response response = bc.getPropertiesWithResponse(null, null, null); - - // If the value isn't set the service will automatically set it - contentType = (contentType == null) ? "application/octet-stream" : contentType; - - validateBlobProperties(response, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentMD5, - contentType); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createIfNotExistsMetadata(String key1, String value1, String key2, String value2) { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getAppendBlobClient(); - - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - AppendBlobCreateOptions options = new AppendBlobCreateOptions().setMetadata(metadata); - - bc.createIfNotExistsWithResponse(options, null, Context.NONE); - BlobProperties response = bc.getProperties(); - - for (Map.Entry entry : metadata.entrySet()) { - assertEquals(entry.getValue(), response.getMetadata().get(entry.getKey())); - } - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createIfNotExistsTagsSupplier") - public void createIfNotExistsTags(String key1, String value1, String key2, String value2) { - bc.delete(); - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - bc.createIfNotExistsWithResponse(new AppendBlobCreateOptions().setTags(tags), null, Context.NONE); - Response> response = bc.getTagsWithResponse(new BlobGetTagsOptions(), null, null); - for (Map.Entry entry : tags.entrySet()) { - assertEquals(entry.getValue(), response.getValue().get(entry.getKey())); - } - } - - private Stream createIfNotExistsTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @Test - public void appendBlockDefaults() { - Response appendResponse = bc.appendBlockWithResponse(DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null); - - ByteArrayOutputStream downloadStream = new ByteArrayOutputStream(); - bc.downloadStream(downloadStream); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), downloadStream.toByteArray()); - - validateBasicHeaders(appendResponse.getHeaders()); - assertNotNull(appendResponse.getHeaders().getValue(X_MS_CONTENT_CRC64)); - assertNotNull(appendResponse.getValue().getBlobAppendOffset()); - assertNotNull(appendResponse.getValue().getBlobCommittedBlockCount()); - assertEquals(1, bc.getProperties().getCommittedBlockCount()); - } - - @Test - public void appendBlockMin() { - assertResponseStatusCode( - bc.appendBlockWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, null, null, null), - 201); - } - - @ParameterizedTest - @MethodSource("appendBlockIASupplier") - public void appendBlockIA(InputStream stream, long dataSize, Class exceptionType) { - assertThrows(exceptionType, () -> bc.appendBlock(stream, dataSize)); - } - - private static Stream appendBlockIASupplier() { - return Stream.of(Arguments.of(null, DATA.getDefaultDataSize(), NullPointerException.class), - Arguments.of(DATA.getDefaultInputStream(), DATA.getDefaultDataSize() + 1, UnexpectedLengthException.class), - Arguments.of(DATA.getDefaultInputStream(), DATA.getDefaultDataSize() - 1, UnexpectedLengthException.class)); - } - - @Test - public void appendBlockEmptyBody() { - assertThrows(BlobStorageException.class, () -> bc.appendBlock(new ByteArrayInputStream(new byte[0]), 0)); - } - - @Test - public void appendBlockNullBody() { - assertThrows(NullPointerException.class, () -> bc.appendBlock(new ByteArrayInputStream(null), 0)); - } - - @Test - public void appendBlockTransactionalMD5() throws NoSuchAlgorithmException { - byte[] md5 = MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()); - - assertResponseStatusCode( - bc.appendBlockWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), md5, null, null, null), - 201); - } - - @Test - public void appendBlockTransactionalMD5Fail() { - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> bc.appendBlockWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), - MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null, null, null)); - - assertExceptionStatusCodeAndMessage(e, 400, BlobErrorCode.MD5MISMATCH); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockSupplier") - public void appendBlockAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long appendPosE, Long maxSizeLTE, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE) - .setMaxSize(maxSizeLTE) - .setTagsConditions(tags); - - assertResponseStatusCode( - bc.appendBlockWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, bac, null, null), - 201); - } - - private static Stream appendBlockSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null, null, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null, null, null), - Arguments.of(null, null, null, null, null, 0L, null, null), - Arguments.of(null, null, null, null, null, null, 100L, null), - Arguments.of(null, null, null, null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("appendBlockFailSupplier") - public void appendBlockACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long appendPosE, Long maxSizeLTE, String tags) throws IOException { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE) - .setMaxSize(maxSizeLTE) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> bc.appendBlockWithResponse(DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, bac, null, null)); - - DATA.getDefaultInputStream().reset(); - } - - private static Stream appendBlockFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null, null, null, null), - Arguments.of(null, OLD_DATE, null, null, null, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null, null, null, null), - Arguments.of(null, null, null, RECEIVED_ETAG, null, null, null, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID, null, null, null), - Arguments.of(null, null, null, null, null, 1L, null, null), - Arguments.of(null, null, null, null, null, null, 1L, null), - Arguments.of(null, null, null, null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void appendBlockError() { - bc = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - assertThrows(BlobStorageException.class, - () -> bc.appendBlock(DATA.getDefaultInputStream(), DATA.getDefaultDataSize())); - } - - @Test - public void appendBlockRetryOnTransientFailure() { - AppendBlobClient clientWithFailure = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - bc.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getAppendBlobClient(); - - clientWithFailure.appendBlock(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - bc.downloadStream(os); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), os.toByteArray()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2022-11-02") - @Test - public void appendBlockHighThroughput() { - int size = 5 * Constants.MB; - byte[] randomData = getRandomByteArray(size); // testing upload of size greater than 4MB - ByteArrayInputStream uploadStream = new ByteArrayInputStream(randomData); - ByteArrayOutputStream downloadStream = new ByteArrayOutputStream(size); - - assertResponseStatusCode(bc.appendBlockWithResponse(uploadStream, size, null, null, null, null), 201); - - bc.downloadStream(downloadStream); // Check if block was appended correctly by downloading the block - TestUtils.assertArraysEqual(randomData, downloadStream.toByteArray()); - } - - @Test - public void appendBlockFromURLMin() { - byte[] data = getRandomByteArray(1024); - bc.appendBlock(new ByteArrayInputStream(data), data.length); - - AppendBlobClient destURL = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - destURL.create(); - - BlobRange blobRange = new BlobRange(0, (long) PageBlobClient.PAGE_BYTES); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - Response response = destURL.appendBlockFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, - blobRange, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - validateBasicHeaders(response.getHeaders()); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void appendBlockFromURLSourceErrorAndStatusCodeNewTest() { - AppendBlobClient destBlob = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - destBlob.createIfNotExists(); - - BlobStorageException e = assertThrows(BlobStorageException.class, () -> destBlob.appendBlockFromUrl(bc.getBlobUrl(), new BlobRange(0, (long) PageBlobClient.PAGE_BYTES))); - - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }*/ - - @Test - public void appendBlockFromURLRange() { - byte[] data = getRandomByteArray(4 * 1024); - bc.appendBlock(new ByteArrayInputStream(data), data.length); - - AppendBlobClient destURL = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - destURL.create(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - destURL.appendBlockFromUrl(bc.getBlobUrl() + "?" + sas, new BlobRange(2 * 1024, 1024L)); - - ByteArrayOutputStream downloadStream = new ByteArrayOutputStream(1024); - destURL.downloadStream(downloadStream); - TestUtils.assertArraysEqual(data, 2 * 1024, downloadStream.toByteArray(), 0, 1024); - } - - @Test - public void appendBlockFromURLMD5() { - byte[] data = getRandomByteArray(1024); - bc.appendBlock(new ByteArrayInputStream(data), data.length); - - AppendBlobClient destURL = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - destURL.create(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertDoesNotThrow(() -> destURL.appendBlockFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, - MessageDigest.getInstance("MD5").digest(data), null, null, null, Context.NONE)); - - } - - @Test - public void appendBlockFromURLMD5Fail() { - byte[] data = getRandomByteArray(1024); - bc.appendBlock(new ByteArrayInputStream(data), data.length); - - AppendBlobClient destURL = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - destURL.create(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertThrows(BlobStorageException.class, - () -> destURL.appendBlockFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, - MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null, null, null, Context.NONE)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockSupplier") - public void appendBlockFromURLDestinationAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, Long appendPosE, Long maxSizeLTE, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE) - .setMaxSize(maxSizeLTE) - .setTagsConditions(tags); - - AppendBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - sourceURL.create(); - sourceURL - .appendBlockWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, null, null, null) - .getStatusCode(); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertResponseStatusCode( - bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl() + "?" + sas, null, null, bac, null, null, null), - 201); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockFailSupplier") - public void appendBlockFromURLDestinationACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, Long maxSizeLTE, Long appendPosE, String tags) { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE) - .setMaxSize(maxSizeLTE) - .setTagsConditions(tags); - - AppendBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - sourceURL.create(); - sourceURL.appendBlockWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, null, null, - null); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertThrows(BlobStorageException.class, - () -> bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl() + "?" + sas, null, null, bac, null, null, - Context.NONE)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockFromURLSupplier") - public void appendBlockFromURLSourceAC(OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch) { - AppendBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - sourceURL.create(); - sourceURL.appendBlockWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, null, null, - null); - - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(setupBlobMatchCondition(sourceURL, sourceIfMatch)) - .setIfNoneMatch(sourceIfNoneMatch); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertResponseStatusCode( - bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl() + "?" + sas, null, null, null, smac, null, null), - 201); - } - - private static Stream appendBlockFromURLSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of(OLD_DATE, null, null, null), - Arguments.of(null, NEW_DATE, null, null), Arguments.of(null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, GARBAGE_ETAG)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockFromURLFailSupplier") - public void appendBlockFromURLSourceACFail(OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch) { - AppendBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - sourceURL.create(); - sourceURL.appendBlockWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, null, null, - null); - - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(sourceIfMatch) - .setIfNoneMatch(setupBlobMatchCondition(sourceURL, sourceIfNoneMatch)); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertThrows(BlobStorageException.class, - () -> bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl() + "?" + sas, null, null, null, smac, null, - Context.NONE)); - } - - private static Stream appendBlockFromURLFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null), Arguments.of(null, OLD_DATE, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null), Arguments.of(null, null, null, RECEIVED_ETAG)); - } - - @Test - public void getContainerName() { - assertEquals(containerName, bc.getContainerName()); - } - - @Test - public void getAppendBlobName() { - assertEquals(blobName, bc.getBlobName()); - } - - @Test - public void createOverwriteFalse() { - assertThrows(BlobStorageException.class, () -> bc.create()); - } - - @Test - public void createOverwriteTrue() { - assertDoesNotThrow(() -> bc.create(true)); - - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void sealDefaults() { - Response sealResponse = bc.sealWithResponse(null, null, null); - assertResponseStatusCode(sealResponse, 200); - assertEquals("true", sealResponse.getHeaders().getValue(X_MS_BLOB_SEALED)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void sealMin() { - bc.seal(); - - assertTrue(bc.getProperties().isSealed()); - assertTrue(bc.downloadStreamWithResponse(new ByteArrayOutputStream(), null, null, null, false, null, null) - .getDeserializedHeaders() - .isSealed()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void sealError() { - bc = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - assertThrows(BlobStorageException.class, () -> bc.seal()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("sealACSupplier") - public void sealAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long appendPosE) { - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE); - - assertResponseStatusCode(bc.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(bac), null, null), - 200); - - } - - private static Stream sealACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null), Arguments.of(null, NEW_DATE, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null), - Arguments.of(null, null, null, null, null, 0L)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("sealACFailSupplier") - public void sealACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long appendPosE) { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE); - - assertThrows(BlobStorageException.class, - () -> bc.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(bac), null, null)); - } - - private static Stream sealACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null, null), - Arguments.of(null, OLD_DATE, null, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null, null), - Arguments.of(null, null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID, null), - Arguments.of(null, null, null, null, null, 1L)); - } - - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - @Test - public void perCallPolicy() { - AppendBlobClient specialBlob - = getSpecializedBuilder(bc.getBlobUrl()).addPolicy(getPerCallVersionPolicy()).buildAppendBlobClient(); - - Response response = specialBlob.getPropertiesWithResponse(null, null, null); - assertEquals("2017-11-09", response.getHeaders().getValue(X_MS_VERSION)); - } - - @Test - public void defaultAudience() { - AppendBlobClient aadBlob - = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()).audience(null).buildAppendBlobClient(); - - assertTrue(aadBlob.exists()); - } - - @Test - public void storageAccountAudience() { - AppendBlobClient aadBlob = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(cc.getAccountName())) - .buildAppendBlobClient(); - - assertTrue(aadBlob.exists()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - AppendBlobClient aadBlob = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildAppendBlobClient(); - - assertNotNull(aadBlob.getProperties()); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", cc.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - AppendBlobClient aadBlob - = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()).audience(audience).buildAppendBlobClient(); - - assertTrue(aadBlob.exists()); - } - - @Test - public void getSnapshotClient() { - String fakeVersion = "2020-04-17T20:37:16.5129130Z"; - BlobClientBase fakeSnapshotClient = bc.getSnapshotClient(fakeVersion); - assertEquals(fakeVersion, fakeSnapshotClient.getSnapshotId()); - } - - @Test - public void getVersionClient() { - String fakeVersion = "2020-04-17T20:37:16.5129130Z"; - BlobClientBase fakeVersionClient = bc.getVersionClient(fakeVersion); - assertEquals(fakeVersion, fakeVersionClient.getVersionId()); - } - - @Test - public void getEncryptionScopeClient() { - String fakeScope = "fakeScope"; - BlobClientBase fakeEncryptionScopeClient = bc.getEncryptionScopeClient(fakeScope); - assertEquals(fakeScope, fakeEncryptionScopeClient.getEncryptionScope()); - } - - @Test - public void getCPKClient() { - CustomerProvidedKey fakeCPK = new CustomerProvidedKey(getRandomKey()); - BlobClientBase fakeCPKClient = bc.getCustomerProvidedKeyClient(fakeCPK); - assertEquals(fakeCPK.getKey(), fakeCPKClient.getCustomerProvidedKey().getEncryptionKey()); - } - - @Test - public void getMaxBlocks() { - assertEquals(MAX_APPEND_BLOCKS, bc.getMaxBlocks()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobAsyncApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobAsyncApiTests.java deleted file mode 100644 index 8f3106d453bd..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/AppendBlobAsyncApiTests.java +++ /dev/null @@ -1,931 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.rest.Response; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.AppendBlobItem; -import com.azure.storage.blob.models.AppendBlobRequestConditions; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.options.AppendBlobCreateOptions; -import com.azure.storage.blob.options.AppendBlobSealOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import com.azure.storage.common.test.shared.policy.TransientFailureInjectingHttpPipelinePolicy; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.nio.ByteBuffer; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.OffsetDateTime; -import java.util.Base64; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -import static com.azure.storage.blob.specialized.AppendBlobClient.MAX_APPEND_BLOCKS; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class AppendBlobAsyncApiTests extends BlobTestBase { - - private AppendBlobAsyncClient bc; - private String blobName; - - @BeforeEach - public void setup() { - blobName = generateBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getAppendBlobAsyncClient(); - bc.create().block(); - } - - @Test - public void createDefaults() { - StepVerifier.create(bc.createWithResponse(null, null, null)).assertNext(r -> { - assertEquals(201, r.getStatusCode()); - validateBasicHeaders(r.getHeaders()); - assertNull(r.getValue().getContentMd5()); - assertTrue(r.getValue().isServerEncrypted()); - }).verifyComplete(); - } - - @Test - public void createMin() { - assertAsyncResponseStatusCode(bc.createWithResponse(null, null, null), 201); - } - - @Test - public void createError() { - StepVerifier.create(bc.createWithResponse(null, null, new BlobRequestConditions().setIfMatch("garbage"))) - .verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("createHeadersSupplier") - public void createHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) throws Exception { - - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - contentType = (contentType == null) ? "application/octet-stream" : contentType; - String finalContentType = contentType; - - StepVerifier.create(bc.createWithResponse(headers, null, null).then(bc.getPropertiesWithResponse(null))) - .assertNext(p -> validateBlobProperties(p, cacheControl, contentDisposition, contentEncoding, - contentLanguage, contentMD5, finalContentType)) - .verifyComplete(); - } - - private static Stream createHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of("control", "disposition", "encoding", "language", - Base64.getEncoder().encode(MessageDigest.getInstance("MD5").digest(DATA.getDefaultText().getBytes())), - "type")); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - StepVerifier.create(bc.createWithResponse(null, metadata, null).then(bc.getProperties())).assertNext(p -> { - for (Map.Entry entry : metadata.entrySet()) { - assertEquals(entry.getValue(), p.getMetadata().get(entry.getKey())); - } - assertEquals(metadata, p.getMetadata()); - }).verifyComplete(); - } - - private static Stream createMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createTagsSupplier") - public void createTags(String key1, String value1, String key2, String value2) { - HashMap tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - StepVerifier.create(bc.createWithResponse(new AppendBlobCreateOptions().setTags(tags)) - .then(bc.getTagsWithResponse(new BlobGetTagsOptions()))).assertNext(r -> { - for (Map.Entry entry : tags.entrySet()) { - assertEquals(entry.getValue(), r.getValue().get(entry.getKey())); - } - }).verifyComplete(); - } - - private static Stream createTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createACSupplier") - public void createAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - return bc.createWithResponse(null, null, bac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - private Stream createACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null), Arguments.of(null, NEW_DATE, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null), - Arguments.of(null, null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("createACFailSupplier") - public void createACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - return bc.createWithResponse(null, null, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private Stream createACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null, null), - Arguments.of(null, OLD_DATE, null, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null, null), - Arguments.of(null, null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID, null), - Arguments.of(null, null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void createIfNotExistsDefaults() { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getAppendBlobAsyncClient(); - - StepVerifier.create(bc.createIfNotExistsWithResponse(new AppendBlobCreateOptions())).assertNext(r -> { - assertResponseStatusCode(r, 201); - validateBasicHeaders(r.getHeaders()); - assertNull(r.getValue().getContentMd5()); - assertTrue(r.getValue().isServerEncrypted()); - }).verifyComplete(); - } - - @Test - public void createIfNotExistsMin() { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getAppendBlobAsyncClient(); - - assertAsyncResponseStatusCode(bc.createIfNotExistsWithResponse(null), 201); - } - - @Test - public void createIfNotExistsSimple() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - StepVerifier.create(bc.createIfNotExists().then(bc.exists())) - .assertNext(Assertions::assertTrue) - .verifyComplete(); - } - - @Test - public void createIfNotExistsOnABlobThatAlreadyExists() { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getAppendBlobAsyncClient(); - - assertAsyncResponseStatusCode(bc.createIfNotExistsWithResponse(new AppendBlobCreateOptions()), 201); - assertAsyncResponseStatusCode(bc.createIfNotExistsWithResponse(new AppendBlobCreateOptions()), 409); - } - - @ParameterizedTest - @MethodSource("createHeadersSupplier") - public void createIfNotExistsHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getAppendBlobAsyncClient(); - - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - AppendBlobCreateOptions options = new AppendBlobCreateOptions().setHeaders(headers); - - // If the value isn't set the service will automatically set it - contentType = (contentType == null) ? "application/octet-stream" : contentType; - String finalContentType = contentType; - - StepVerifier.create(bc.createIfNotExistsWithResponse(options).then(bc.getPropertiesWithResponse(null))) - .assertNext(p -> validateBlobProperties(p, cacheControl, contentDisposition, contentEncoding, - contentLanguage, contentMD5, finalContentType)) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createIfNotExistsMetadata(String key1, String value1, String key2, String value2) { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getAppendBlobAsyncClient(); - - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - AppendBlobCreateOptions options = new AppendBlobCreateOptions().setMetadata(metadata); - - StepVerifier.create(bc.createIfNotExistsWithResponse(options).then(bc.getProperties())).assertNext(p -> { - for (Map.Entry entry : metadata.entrySet()) { - assertEquals(entry.getValue(), p.getMetadata().get(entry.getKey())); - } - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createIfNotExistsTagsSupplier") - public void createIfNotExistsTags(String key1, String value1, String key2, String value2) { - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - Mono>> response = bc.delete() - .then(bc.createIfNotExistsWithResponse(new AppendBlobCreateOptions().setTags(tags))) - .then(bc.getTagsWithResponse(new BlobGetTagsOptions())); - - StepVerifier.create(response).assertNext(r -> { - for (Map.Entry entry : tags.entrySet()) { - assertEquals(entry.getValue(), r.getValue().get(entry.getKey())); - } - }).verifyComplete(); - } - - private Stream createIfNotExistsTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @Test - public void appendBlockDefaults() { - StepVerifier.create(bc.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null)) - .assertNext(r -> { - validateBasicHeaders(r.getHeaders()); - assertNotNull(r.getHeaders().getValue(X_MS_CONTENT_CRC64)); - assertNotNull(r.getValue().getBlobAppendOffset()); - assertNotNull(r.getValue().getBlobCommittedBlockCount()); - }) - .verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(bc.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @Test - public void appendBlockMin() { - assertAsyncResponseStatusCode( - bc.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null), 201); - } - - @ParameterizedTest - @MethodSource("appendBlockIASupplier") - public void appendBlockIA(Flux stream, long dataSize, Class exceptionType) { - StepVerifier.create(bc.appendBlock(stream, dataSize)).verifyError(exceptionType); - } - - private static Stream appendBlockIASupplier() { - return Stream.of(Arguments.of(null, DATA.getDefaultDataSize(), NullPointerException.class), - Arguments.of(DATA.getDefaultFlux(), DATA.getDefaultDataSize() + 1, UnexpectedLengthException.class), - Arguments.of(DATA.getDefaultFlux(), DATA.getDefaultDataSize() - 1, UnexpectedLengthException.class)); - } - - @Test - public void appendBlockEmptyBody() { - StepVerifier.create(bc.appendBlock(Flux.just(ByteBuffer.wrap(new byte[0])), 0)) - .verifyError(BlobStorageException.class); - } - - @Test - public void appendBlockNullBody() { - assertThrows(NullPointerException.class, () -> bc.appendBlock(Flux.just((ByteBuffer) null), 0)); - } - - @Test - public void appendBlockTransactionalMD5() throws NoSuchAlgorithmException { - byte[] md5 = MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()); - - assertAsyncResponseStatusCode( - bc.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), md5, null), 201); - } - - @Test - public void appendBlockTransactionalMD5Fail() throws NoSuchAlgorithmException { - StepVerifier.create(bc.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), - MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null)).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertExceptionStatusCodeAndMessage(e, 400, BlobErrorCode.MD5MISMATCH); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockSupplier") - public void appendBlockAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long appendPosE, Long maxSizeLTE, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE) - .setMaxSize(maxSizeLTE) - .setTagsConditions(tags); - return bc.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, bac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - private static Stream appendBlockSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null, null, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null, null, null), - Arguments.of(null, null, null, null, null, 0L, null, null), - Arguments.of(null, null, null, null, null, null, 100L, null), - Arguments.of(null, null, null, null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("appendBlockFailSupplier") - public void appendBlockACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long appendPosE, Long maxSizeLTE, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE) - .setMaxSize(maxSizeLTE) - .setTagsConditions(tags); - return bc.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream appendBlockFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null, null, null, null), - Arguments.of(null, OLD_DATE, null, null, null, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null, null, null, null), - Arguments.of(null, null, null, RECEIVED_ETAG, null, null, null, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID, null, null, null), - Arguments.of(null, null, null, null, null, 1L, null, null), - Arguments.of(null, null, null, null, null, null, 1L, null), - Arguments.of(null, null, null, null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void appendBlockError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - StepVerifier.create(bc.appendBlock(DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .verifyError(BlobStorageException.class); - } - - @Test - public void appendBlockRetryOnTransientFailure() { - AppendBlobAsyncClient clientWithFailure = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - bc.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getAppendBlobAsyncClient(); - - StepVerifier - .create(clientWithFailure.appendBlock(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(FluxUtil.collectBytesInByteBufferStream(bc.downloadStream()))) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2022-11-02") - @Test - public void appendBlockHighThroughput() { - int size = 5 * Constants.MB; - byte[] randomData = getRandomByteArray(size); // testing upload of size greater than 4MB - Flux uploadStream = Flux.just(ByteBuffer.wrap(randomData)); - - assertAsyncResponseStatusCode(bc.appendBlockWithResponse(uploadStream, size, null, null), 201); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(bc.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(randomData, r)) - .verifyComplete(); - } - - @Test - public void appendBlockFromURLMin() { - byte[] data = getRandomByteArray(1024); - - AppendBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - BlobRange blobRange = new BlobRange(0, (long) PageBlobClient.PAGE_BYTES); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono> response = bc.appendBlock(Flux.just(ByteBuffer.wrap(data)), data.length) - .then(destURL.create()) - .then(destURL.appendBlockFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, blobRange, null, null, null)); - - StepVerifier.create(response).assertNext(r -> { - assertResponseStatusCode(r, 201); - validateBasicHeaders(r.getHeaders()); - }).verifyComplete(); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void appendBlockFromURLSourceErrorAndStatusCodeNewTest() { - AppendBlobAsyncClient destBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - StepVerifier.create(destBlob.createIfNotExists().then(destBlob.appendBlockFromUrl(bc.getBlobUrl(), new BlobRange(0, (long) PageBlobClient.PAGE_BYTES)))) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }); - }*/ - - @Test - public void appendBlockFromURLRange() { - byte[] data = getRandomByteArray(4 * 1024); - - AppendBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono response = bc.appendBlock(Flux.just(ByteBuffer.wrap(data)), data.length) - .then(destURL.create()) - .then(destURL.appendBlockFromUrl(bc.getBlobUrl() + "?" + sas, new BlobRange(2 * 1024, 1024L))) - .then(FluxUtil.collectBytesInByteBufferStream(destURL.downloadStream())); - - StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(data, 2 * 1024, r, 0, 1024)) - .verifyComplete(); - } - - @Test - public void appendBlockFromURLMD5() throws NoSuchAlgorithmException { - byte[] data = getRandomByteArray(1024); - - AppendBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono> response = bc.appendBlock(Flux.just(ByteBuffer.wrap(data)), data.length) - .then(destURL.create()) - .then(destURL.appendBlockFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, - MessageDigest.getInstance("MD5").digest(data), null, null)); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @Test - public void appendBlockFromURLMD5Fail() throws NoSuchAlgorithmException { - byte[] data = getRandomByteArray(1024); - - AppendBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono> response = bc.appendBlock(Flux.just(ByteBuffer.wrap(data)), data.length) - .then(destURL.create()) - .then(destURL.appendBlockFromUrlWithResponse(bc.getBlobUrl() + "?" + sas, null, - MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null, null)); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockSupplier") - public void appendBlockFromURLDestinationAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, Long appendPosE, Long maxSizeLTE, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE) - .setMaxSize(maxSizeLTE) - .setTagsConditions(tags); - - AppendBlobAsyncClient sourceURL - = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - String sas - = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - return sourceURL.create() - .then( - sourceURL.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null)) - .then(bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl() + "?" + sas, null, null, bac, null)); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockFailSupplier") - public void appendBlockFromURLDestinationACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, Long maxSizeLTE, Long appendPosE, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE) - .setMaxSize(maxSizeLTE) - .setTagsConditions(tags); - - AppendBlobAsyncClient sourceURL - = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - String sas - = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - return sourceURL.create() - .then(sourceURL.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, - null)) - .then(bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl() + "?" + sas, null, null, bac, - null)); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockFromURLSupplier") - public void appendBlockFromURLSourceAC(OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch) { - AppendBlobAsyncClient sourceURL = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - Mono> response = sourceURL.create() - .then(sourceURL.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null)) - .then(setupBlobMatchCondition(sourceURL, sourceIfMatch)) - .flatMap(condition -> { - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(convertNull(condition)) - .setIfNoneMatch(sourceIfNoneMatch); - - String sas - = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - return bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl() + "?" + sas, null, null, null, smac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - private static Stream appendBlockFromURLSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of(OLD_DATE, null, null, null), - Arguments.of(null, NEW_DATE, null, null), Arguments.of(null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, GARBAGE_ETAG)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("appendBlockFromURLFailSupplier") - public void appendBlockFromURLSourceACFail(OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch) { - AppendBlobAsyncClient sourceURL = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - - Mono> response = sourceURL.create() - .then(sourceURL.appendBlockWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null)) - .then(setupBlobMatchCondition(sourceURL, sourceIfNoneMatch)) - .flatMap(condition -> { - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(sourceIfMatch) - .setIfNoneMatch(convertNull(condition)); - - String sas - = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - return bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl() + "?" + sas, null, null, null, smac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream appendBlockFromURLFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null), Arguments.of(null, OLD_DATE, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null), Arguments.of(null, null, null, RECEIVED_ETAG)); - } - - @Test - public void getContainerName() { - assertEquals(containerName, bc.getContainerName()); - } - - @Test - public void getAppendBlobName() { - assertEquals(blobName, bc.getBlobName()); - } - - @Test - public void createOverwriteFalse() { - StepVerifier.create(bc.create()).verifyError(BlobStorageException.class); - } - - @Test - public void createOverwriteTrue() { - StepVerifier.create(bc.create(true)).expectNextCount(1).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void sealDefaults() { - StepVerifier.create(bc.sealWithResponse(null)).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals("true", r.getHeaders().getValue(X_MS_BLOB_SEALED)); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void sealMin() { - StepVerifier.create(bc.seal().then(bc.getProperties())) - .assertNext(p -> assertTrue(p.isSealed())) - .verifyComplete(); - - StepVerifier.create(bc.downloadStreamWithResponse(null, null, null, false)) - .assertNext(r -> assertTrue(r.getDeserializedHeaders().isSealed())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void sealError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getAppendBlobAsyncClient(); - StepVerifier.create(bc.seal()).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("sealACSupplier") - public void sealAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long appendPosE) { - - Mono> response = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), BlobTestBase::convertNulls) - .flatMap(conditions -> { - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE); - return bc.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(bac)); - }); - - assertAsyncResponseStatusCode(response, 200); - - } - - private static Stream sealACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null), Arguments.of(null, NEW_DATE, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null), - Arguments.of(null, null, null, null, null, 0L)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("sealACFailSupplier") - public void sealACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long appendPosE) { - - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - AppendBlobRequestConditions bac = new AppendBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setAppendPosition(appendPosE); - return bc.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(bac)); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream sealACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null, null), - Arguments.of(null, OLD_DATE, null, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null, null), - Arguments.of(null, null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID, null), - Arguments.of(null, null, null, null, null, 1L)); - } - - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - @Test - public void perCallPolicy() { - AppendBlobAsyncClient specialBlob - = getSpecializedBuilder(bc.getBlobUrl()).addPolicy(getPerCallVersionPolicy()).buildAppendBlobAsyncClient(); - - StepVerifier.create(specialBlob.getPropertiesWithResponse(null)) - .assertNext(r -> assertEquals("2017-11-09", r.getHeaders().getValue(X_MS_VERSION))) - .verifyComplete(); - } - - @Test - public void defaultAudience() { - AppendBlobAsyncClient aadBlob - = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()).audience(null).buildAppendBlobAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - - @Test - public void storageAccountAudience() { - AppendBlobAsyncClient aadBlob = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(ccAsync.getAccountName())) - .buildAppendBlobAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - AppendBlobAsyncClient aadBlob = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildAppendBlobAsyncClient(); - - StepVerifier.create(aadBlob.getProperties()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", ccAsync.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - AppendBlobAsyncClient aadBlob - = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()).audience(audience).buildAppendBlobAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - - @Test - public void getSnapshotClient() { - String fakeVersion = "2020-04-17T20:37:16.5129130Z"; - BlobAsyncClientBase fakeSnapshotClient = bc.getSnapshotClient(fakeVersion); - assertEquals(fakeVersion, fakeSnapshotClient.getSnapshotId()); - } - - @Test - public void getVersionClient() { - String fakeVersion = "2020-04-17T20:37:16.5129130Z"; - BlobAsyncClientBase fakeVersionClient = bc.getVersionClient(fakeVersion); - assertEquals(fakeVersion, fakeVersionClient.getVersionId()); - } - - @Test - public void getEncryptionScopeClient() { - String fakeScope = "fakeScope"; - BlobAsyncClientBase fakeEncryptionScopeClient = bc.getEncryptionScopeAsyncClient(fakeScope); - assertEquals(fakeScope, fakeEncryptionScopeClient.getEncryptionScope()); - } - - @Test - public void getCPKClient() { - CustomerProvidedKey fakeCPK = new CustomerProvidedKey(getRandomKey()); - BlobAsyncClientBase fakeCPKClient = bc.getCustomerProvidedKeyAsyncClient(fakeCPK); - assertEquals(fakeCPK.getKey(), fakeCPKClient.getCustomerProvidedKey().getEncryptionKey()); - } - - @Test - public void getMaxBlocks() { - assertEquals(MAX_APPEND_BLOCKS, bc.getMaxBlocks()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseApiTests.java deleted file mode 100644 index 32f5f577c3c1..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseApiTests.java +++ /dev/null @@ -1,851 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.test.utils.TestUtils; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.BlobQueryArrowField; -import com.azure.storage.blob.models.BlobQueryArrowFieldType; -import com.azure.storage.blob.models.BlobQueryArrowSerialization; -import com.azure.storage.blob.models.BlobQueryDelimitedSerialization; -import com.azure.storage.blob.models.BlobQueryError; -import com.azure.storage.blob.models.BlobQueryJsonSerialization; -import com.azure.storage.blob.models.BlobQueryParquetSerialization; -import com.azure.storage.blob.models.BlobQueryProgress; -import com.azure.storage.blob.models.BlobQuerySerialization; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.options.BlobQueryOptions; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Mono; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.Consumer; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class BlobBaseApiTests extends BlobTestBase { - private BlobClient bc; - - @BeforeEach - public void setup() { - String blobName = generateBlobName(); - bc = cc.getBlobClient(blobName); - bc.upload(new ByteArrayInputStream(new byte[0]), 0); - } - - /* Quick Query Tests. */ - - // Generates and uploads a CSV file - private void uploadCsv(BlobQueryDelimitedSerialization s, int numCopies) { - String header = String.join(String.valueOf(s.getColumnSeparator()), "rn1", "rn2", "rn3", "rn4") - .concat(String.valueOf(s.getRecordSeparator())); - byte[] headers = header.getBytes(); - - String csv = String.join(String.valueOf(s.getColumnSeparator()), "100", "200", "300", "400") - .concat(String.valueOf(s.getRecordSeparator())) - .concat(String.join(String.valueOf(s.getColumnSeparator()), "300", "400", "500", "600") - .concat(String.valueOf(s.getRecordSeparator()))); - - byte[] csvData = csv.getBytes(); - int headerLength = s.isHeadersPresent() ? headers.length : 0; - byte[] data = new byte[headerLength + csvData.length * numCopies]; - if (s.isHeadersPresent()) { - System.arraycopy(headers, 0, data, 0, headers.length); - } - - for (int i = 0; i < numCopies; i++) { - int o = i * csvData.length + headerLength; - System.arraycopy(csvData, 0, data, o, csvData.length); - } - - InputStream inputStream = new ByteArrayInputStream(data); - bc.upload(inputStream, data.length, true); - } - - private void uploadSmallJson(int numCopies) { - StringBuilder b = new StringBuilder(); - b.append("{\n"); - for (int i = 0; i < numCopies; i++) { - String toAppend = "\t\"name%d\": \"owner%d\",\n"; - b.append(String.format(toAppend, i, i)); - } - b.append('}'); - - InputStream inputStream = new ByteArrayInputStream(b.toString().getBytes()); - bc.upload(inputStream, b.length(), true); - } - - private byte[] readFromInputStream(InputStream stream, int numBytesToRead) throws IOException { - byte[] queryData = new byte[numBytesToRead]; - - int totalRead = 0; - int bytesRead = 0; - int length = numBytesToRead; - - while (bytesRead != -1 && totalRead < numBytesToRead) { - bytesRead = stream.read(queryData, totalRead, length); - if (bytesRead != -1) { - totalRead += bytesRead; - length -= bytesRead; - } - } - - stream.close(); - return queryData; - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @ValueSource( - ints = { - 1, // 32 bytes - 32, // 1 KB - 256, // 8 KB - 400, // 12 ish KB - 4000, // 125 KB - }) - public void queryMin(int numCopies) { - BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - - liveTestScenarioWithRetry(() -> { - uploadCsv(ser, numCopies); - String expression = "SELECT * from BlobStorage"; - - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - bc.downloadStream(downloadData); - byte[] downloadedData = downloadData.toByteArray(); - - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStream(expression); - byte[] queryData; - try { - queryData = readFromInputStream(qqStream, downloadedData.length); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - TestUtils.assertArraysEqual(downloadedData, queryData); - - /* Output Stream. */ - ByteArrayOutputStream os = new ByteArrayOutputStream(); - bc.query(os, expression); - TestUtils.assertArraysEqual(downloadedData, os.toByteArray()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("queryCsvSerializationSeparatorSupplier") - public void queryCsvSerializationSeparator(char recordSeparator, char columnSeparator, boolean headersPresentIn, - boolean headersPresentOut) { - BlobQueryDelimitedSerialization serIn - = new BlobQueryDelimitedSerialization().setRecordSeparator(recordSeparator) - .setColumnSeparator(columnSeparator) - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(headersPresentIn); - BlobQueryDelimitedSerialization serOut - = new BlobQueryDelimitedSerialization().setRecordSeparator(recordSeparator) - .setColumnSeparator(columnSeparator) - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(headersPresentOut); - uploadCsv(serIn, 32); - String expression = "SELECT * from BlobStorage"; - - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - bc.downloadStream(downloadData); - byte[] downloadedData = downloadData.toByteArray(); - - liveTestScenarioWithRetry(() -> { - /* Input Stream. */ - InputStream qqStream = bc - .openQueryInputStreamWithResponse( - new BlobQueryOptions(expression).setInputSerialization(serIn).setOutputSerialization(serOut)) - .getValue(); - byte[] queryData; - try { - queryData = readFromInputStream(qqStream, downloadedData.length); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - - if (headersPresentIn && !headersPresentOut) { - /* Account for 16 bytes of header. */ - TestUtils.assertArraysEqual(downloadedData, 16, queryData, 0, downloadedData.length - 16); - - for (int k = downloadedData.length - 16; k < downloadedData.length; k++) { - assertEquals((byte) 0, queryData[k]); - } - } else { - TestUtils.assertArraysEqual(downloadedData, queryData); - } - - /* Output Stream. */ - ByteArrayOutputStream os = new ByteArrayOutputStream(); - bc.queryWithResponse( - new BlobQueryOptions(expression, os).setInputSerialization(serIn).setOutputSerialization(serOut), null, - null); - byte[] osData = os.toByteArray(); - - if (headersPresentIn && !headersPresentOut) { - assertEquals(downloadedData.length - 16, osData.length); - - /* Account for 16 bytes of header. */ - TestUtils.assertArraysEqual(downloadedData, 16, osData, 0, downloadedData.length - 16); - } else { - TestUtils.assertArraysEqual(downloadedData, osData); - } - }); - } - - private static Stream queryCsvSerializationSeparatorSupplier() { - return Stream.of(Arguments.of('\n', ',', false, false), /* Default. */ - Arguments.of('\n', ',', true, true), /* Headers. */ - Arguments.of('\n', ',', true, false), /* Headers. */ - Arguments.of('\t', ',', false, false), /* Record separator. */ - Arguments.of('\r', ',', false, false), Arguments.of('<', ',', false, false), - Arguments.of('>', ',', false, false), Arguments.of('&', ',', false, false), - Arguments.of('\\', ',', false, false), Arguments.of(',', '.', false, false), /* Column separator. */ - // Arguments.of(',', '\n', false, false), /* Keep getting a qq error: Field delimiter and record delimiter must be different characters. */ - Arguments.of(',', ';', false, false), Arguments.of('\n', '\t', false, false), /* Record separator. */ - // Arguments.of('\n', '\r', false, false), /* Keep getting a qq error: Field delimiter and record delimiter must be different characters. */ - Arguments.of('\n', '<', false, false), Arguments.of('\n', '>', false, false), - Arguments.of('\n', '&', false, false), Arguments.of('\n', '\\', false, false)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryCsvSerializationEscapeAndFieldQuote() { - BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\\') /* Escape set here. */ - .setFieldQuote('"') /* Field quote set here*/ - .setHeadersPresent(false); - uploadCsv(ser, 32); - String expression = "SELECT * from BlobStorage"; - - liveTestScenarioWithRetry(() -> { - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - bc.downloadStream(downloadData); - byte[] downloadedData = downloadData.toByteArray(); - - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse( - new BlobQueryOptions(expression).setInputSerialization(ser).setOutputSerialization(ser)).getValue(); - byte[] queryData; - try { - queryData = readFromInputStream(qqStream, downloadedData.length); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - - TestUtils.assertArraysEqual(downloadedData, queryData); - - /* Output Stream. */ - ByteArrayOutputStream os = new ByteArrayOutputStream(); - bc.queryWithResponse( - new BlobQueryOptions(expression, os).setInputSerialization(ser).setOutputSerialization(ser), null, - null); - byte[] osData = os.toByteArray(); - - TestUtils.assertArraysEqual(downloadedData, osData); - }); - } - - /* Note: Input delimited tested everywhere */ - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @ValueSource(ints = { 1, 10, 100, 1000 }) - public void queryInputJson(int numCopies) { - BlobQueryJsonSerialization ser = new BlobQueryJsonSerialization().setRecordSeparator('\n'); - uploadSmallJson(numCopies); - String expression = "SELECT * from BlobStorage"; - - liveTestScenarioWithRetry(() -> { - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - bc.downloadStream(downloadData); - downloadData.write(10); /* writing extra new line */ - byte[] downloadedData = downloadData.toByteArray(); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - BlobQueryOptions options - = new BlobQueryOptions(expression, os).setInputSerialization(ser).setOutputSerialization(ser); - - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse(options).getValue(); - byte[] queryData; - try { - queryData = readFromInputStream(qqStream, downloadedData.length); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - TestUtils.assertArraysEqual(downloadedData, queryData); - - /* Output Stream. */ - bc.queryWithResponse(options, null, null); - byte[] osData = os.toByteArray(); - - TestUtils.assertArraysEqual(downloadedData, osData); - }); - - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void queryInputParquet() { - String fileName = "parquet.parquet"; - ClassLoader classLoader = getClass().getClassLoader(); - File f = new File(Objects.requireNonNull(classLoader.getResource(fileName)).getFile()); - BlobQueryParquetSerialization ser = new BlobQueryParquetSerialization(); - bc.uploadFromFile(f.getAbsolutePath(), true); - byte[] expectedData = "0,mdifjt55.ea3,mdifjt55.ea3\n".getBytes(); - - String expression = "select * from blobstorage where id < 1;"; - - BlobQueryOptions optionsIs = new BlobQueryOptions(expression).setInputSerialization(ser); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - BlobQueryOptions optionsOs = new BlobQueryOptions(expression, os).setInputSerialization(ser); - - liveTestScenarioWithRetry(() -> { - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse(optionsIs).getValue(); - byte[] queryData; - try { - queryData = readFromInputStream(qqStream, expectedData.length); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - TestUtils.assertArraysEqual(queryData, expectedData); - /* Output Stream. */ - bc.queryWithResponse(optionsOs, null, null); - byte[] osData = os.toByteArray(); - TestUtils.assertArraysEqual(osData, expectedData); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryInputCsvOutputJson() { - BlobQueryDelimitedSerialization inSer = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - uploadCsv(inSer, 1); - BlobQueryJsonSerialization outSer = new BlobQueryJsonSerialization().setRecordSeparator('\n'); - String expression = "SELECT * from BlobStorage"; - byte[] expectedData = "{\"_1\":\"100\",\"_2\":\"200\",\"_3\":\"300\",\"_4\":\"400\"}".getBytes(); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - BlobQueryOptions options - = new BlobQueryOptions(expression, os).setInputSerialization(inSer).setOutputSerialization(outSer); - - liveTestScenarioWithRetry(() -> { - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse(options).getValue(); - byte[] queryData; - try { - queryData = readFromInputStream(qqStream, expectedData.length); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - - TestUtils.assertArraysEqual(expectedData, 0, queryData, 0, expectedData.length); - - /* Output Stream. */ - bc.queryWithResponse(options, null, null); - byte[] osData = os.toByteArray(); - - TestUtils.assertArraysEqual(expectedData, 0, osData, 0, expectedData.length); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryInputJsonOutputCsv() { - BlobQueryJsonSerialization inSer = new BlobQueryJsonSerialization().setRecordSeparator('\n'); - uploadSmallJson(2); - BlobQueryDelimitedSerialization outSer = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - String expression = "SELECT * from BlobStorage"; - byte[] expectedData = "owner0,owner1\n".getBytes(); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - BlobQueryOptions options - = new BlobQueryOptions(expression, os).setInputSerialization(inSer).setOutputSerialization(outSer); - - liveTestScenarioWithRetry(() -> { - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse(options).getValue(); - byte[] queryData; - try { - queryData = readFromInputStream(qqStream, expectedData.length); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - - TestUtils.assertArraysEqual(expectedData, 0, queryData, 0, expectedData.length); - - /* Output Stream. */ - bc.queryWithResponse(options, null, null); - byte[] osData = os.toByteArray(); - - TestUtils.assertArraysEqual(expectedData, 0, osData, 0, expectedData.length); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryInputCsvOutputArrow() { - BlobQueryDelimitedSerialization inSer = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - uploadCsv(inSer, 32); - - liveTestScenarioWithRetry(() -> { - List schema = new ArrayList<>(); - schema.add( - new BlobQueryArrowField(BlobQueryArrowFieldType.DECIMAL).setName("Name").setPrecision(4).setScale(2)); - BlobQueryArrowSerialization outSer = new BlobQueryArrowSerialization().setSchema(schema); - String expression = "SELECT _2 from BlobStorage WHERE _1 > 250;"; - ByteArrayOutputStream os = new ByteArrayOutputStream(); - BlobQueryOptions options = new BlobQueryOptions(expression, os).setOutputSerialization(outSer); - - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse(options).getValue(); - try { - readFromInputStream(qqStream, 920); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - - /* Output Stream. */ - assertDoesNotThrow(() -> bc.queryWithResponse(options, null, null)); - }); - - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryNonFatalError() { - BlobQueryDelimitedSerialization base = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - uploadCsv(base.setColumnSeparator('.'), 32); - final MockErrorConsumer receiver = new MockErrorConsumer("InvalidColumnOrdinal"); - String expression = "SELECT _1 from BlobStorage WHERE _2 > 250"; - final BlobQueryOptions options - = new BlobQueryOptions(expression).setInputSerialization(base.setColumnSeparator(',')) - .setOutputSerialization(base.setColumnSeparator(',')) - .setErrorConsumer(receiver); - - liveTestScenarioWithRetry(() -> { - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse(options).getValue(); - try { - readFromInputStream(qqStream, Constants.KB); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - - assertDoesNotThrow(() -> receiver.numErrors > 0); - - /* Output Stream. */ - MockErrorConsumer receiver2 = new MockErrorConsumer("InvalidColumnOrdinal"); - BlobQueryOptions options2 = new BlobQueryOptions(expression, new ByteArrayOutputStream()) - .setInputSerialization(base.setColumnSeparator(',')) - .setOutputSerialization(base.setColumnSeparator(',')) - .setErrorConsumer(receiver2); - bc.queryWithResponse(options2, null, null); - - assertDoesNotThrow(() -> receiver2.numErrors > 0); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryFatalError() { - BlobQueryDelimitedSerialization base = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(true); - uploadCsv(base.setColumnSeparator('.'), 32); - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions options = new BlobQueryOptions(expression, new ByteArrayOutputStream()) - .setInputSerialization(new BlobQueryJsonSerialization()); - - liveTestScenarioWithRetry(() -> { - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse(options).getValue(); - assertThrows(Throwable.class, () -> readFromInputStream(qqStream, Constants.KB)); - - /* Output Stream. */ - //Exceptions.ReactiveException.class - assertThrows(Throwable.class, () -> bc.queryWithResponse(options, null, null)); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryProgressReceiver() { - BlobQueryDelimitedSerialization base = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - - uploadCsv(base.setColumnSeparator('.'), 32); - - final MockProgressConsumer mockReceiver = new MockProgressConsumer(); - long sizeofBlobToRead = bc.getProperties().getBlobSize(); - String expression = "SELECT * from BlobStorage"; - final BlobQueryOptions options = new BlobQueryOptions(expression).setProgressConsumer(mockReceiver); - - liveTestScenarioWithRetry(() -> { - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse(options).getValue(); - - /* The QQ Avro stream has the following pattern n * (data record -> progress record) -> end record */ - // 1KB of data will only come back as a single data record. - /* Pretend to read more data because the input stream will not parse records following the data record if it - doesn't need to. */ - try { - readFromInputStream(qqStream, Constants.MB); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - - // At least the size of blob to read will be in the progress list - assertTrue(mockReceiver.progressList.contains(sizeofBlobToRead)); - - /* Output Stream. */ - MockProgressConsumer mockReceiver2 = new MockProgressConsumer(); - BlobQueryOptions options2 - = new BlobQueryOptions(expression, new ByteArrayOutputStream()).setProgressConsumer(mockReceiver2); - bc.queryWithResponse(options2, null, null); - - assertTrue(mockReceiver2.progressList.contains(sizeofBlobToRead)); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @LiveOnly // Large amount of data. - @Test - public void queryMultipleRecordsWithProgressReceiver() { - BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - uploadCsv(ser, 512000); - - MockProgressConsumer mockReceiver = new MockProgressConsumer(); - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions options = new BlobQueryOptions(expression).setProgressConsumer(mockReceiver); - - liveTestScenarioWithRetry(() -> { - /* Input Stream. */ - InputStream qqStream = bc.openQueryInputStreamWithResponse(options).getValue(); - - /* The Avro stream has the following pattern - n * (data record -> progress record) -> end record */ - // 1KB of data will only come back as a single data record. - /* Pretend to read more data because the input stream will not parse records following the data record if it - doesn't need to. */ - try { - readFromInputStream(qqStream, 16 * Constants.MB); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - - long temp = 0; - // Make sure theyre all increasingly bigger - for (long progress : mockReceiver.progressList) { - assertTrue(progress >= temp); - temp = progress; - } - - /* Output Stream. */ - MockProgressConsumer mockReceiver2 = new MockProgressConsumer(); - temp = 0; - BlobQueryOptions options2 - = new BlobQueryOptions(expression, new ByteArrayOutputStream()).setProgressConsumer(mockReceiver2); - bc.queryWithResponse(options2, null, null); - - // Make sure theyre all increasingly bigger - for (long progress : mockReceiver2.progressList) { - assertTrue(progress >= temp); - temp = progress; - } - }); - - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void querySnapshot() { - BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - uploadCsv(ser, 32); - String expression = "SELECT * from BlobStorage"; - - /* Create snapshot of blob. */ - BlobClientBase snapshotClient = bc.createSnapshot(); - bc.upload(new ByteArrayInputStream(new byte[0]), 0, true); /* Make the blob empty. */ - - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - snapshotClient.download(downloadData); - byte[] downloadedData = downloadData.toByteArray(); - - liveTestScenarioWithRetry(() -> { - /* Input Stream. */ - InputStream qqStream = snapshotClient.openQueryInputStream(expression); - byte[] queryData; - try { - queryData = readFromInputStream(qqStream, downloadedData.length); - } catch (IOException e) { - throw LOGGER.logExceptionAsError(new RuntimeException(e)); - } - - TestUtils.assertArraysEqual(queryData, downloadedData); - - /* Output Stream. */ - ByteArrayOutputStream os = new ByteArrayOutputStream(); - snapshotClient.query(os, expression); - byte[] osData = os.toByteArray(); - - TestUtils.assertArraysEqual(osData, downloadedData); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @CsvSource({ "true, false", "false, true" }) - public void queryInputOutputIA(boolean input, boolean output) { - /* Mock random impl of QQ Serialization*/ - BlobQuerySerialization ser = new RandomOtherSerialization(); - BlobQuerySerialization inSer = input ? ser : null; - BlobQuerySerialization outSer = output ? ser : null; - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions options - = new BlobQueryOptions(expression, new ByteArrayOutputStream()).setInputSerialization(inSer) - .setOutputSerialization(outSer); - - liveTestScenarioWithRetry(() -> { - assertThrows(IllegalArgumentException.class, - () -> bc.openQueryInputStreamWithResponse(options).getValue()); /* Don't need to call read. */ - assertThrows(IllegalArgumentException.class, () -> bc.queryWithResponse(options, null, null)); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void nullQueryResponse() { - String expression = "garbage"; - BlobQueryOptions options = new BlobQueryOptions(expression); - - BlobAsyncClientBase clientMock = mock(BlobAsyncClientBase.class); - when(clientMock.queryWithResponse(options)).thenReturn(Mono.empty()); - when(clientMock.getServiceVersion()).thenReturn(BlobServiceVersion.getLatest()); - BlobClientBase bc = new BlobClientBase(clientMock); - - assertThrows(IllegalStateException.class, () -> bc.openQueryInputStreamWithResponse(options)); - } - - private static class RandomOtherSerialization implements BlobQuerySerialization { - - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryArrowInputIA() { - BlobQueryArrowSerialization inSer = new BlobQueryArrowSerialization(); - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions options = new BlobQueryOptions(expression).setInputSerialization(inSer); - - liveTestScenarioWithRetry(() -> { - assertThrows(IllegalArgumentException.class, - () -> bc.openQueryInputStreamWithResponse(options).getValue() /* Don't need to call read. */); - BlobQueryOptions options2 - = new BlobQueryOptions(expression, new ByteArrayOutputStream()).setInputSerialization(inSer); - assertThrows(IllegalArgumentException.class, () -> bc.queryWithResponse(options2, null, null)); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void queryParquetOutputIA() { - BlobQueryParquetSerialization outSer = new BlobQueryParquetSerialization(); - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions options = new BlobQueryOptions(expression).setOutputSerialization(outSer); - - liveTestScenarioWithRetry(() -> { - assertThrows(IllegalArgumentException.class, - () -> bc.openQueryInputStreamWithResponse(options).getValue() /* Don't need to call read. */); - - BlobQueryOptions options2 - = new BlobQueryOptions(expression, new ByteArrayOutputStream()).setOutputSerialization(outSer); - assertThrows(IllegalArgumentException.class, () -> bc.queryWithResponse(options2, null, null)); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryError() { - liveTestScenarioWithRetry(() -> { - bc = cc.getBlobClient(generateBlobName()); - assertThrows(BlobStorageException.class, - () -> bc.openQueryInputStream("SELECT * from BlobStorage") /* Don't need to call read. */); - assertThrows(BlobStorageException.class, - () -> bc.query(new ByteArrayOutputStream(), "SELECT * from BlobStorage")); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("queryACSupplier") - public void queryAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions optionsIs = new BlobQueryOptions(expression).setRequestConditions(bac); - BlobQueryOptions optionsOs - = new BlobQueryOptions(expression, new ByteArrayOutputStream()).setRequestConditions(bac); - - liveTestScenarioWithRetry(() -> { - InputStream stream = bc.openQueryInputStreamWithResponse(optionsIs).getValue(); - try { - stream.read(); - } catch (IOException e) { - throw new RuntimeException(e); - } - assertDoesNotThrow(stream::close); - assertDoesNotThrow(() -> bc.queryWithResponse(optionsOs, null, null)); - }); - } - - private static Stream queryACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null), Arguments.of(null, NEW_DATE, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null), - Arguments.of(null, null, null, null, null, "\"foo\" = 'bar'")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void queryACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions optionsIs = new BlobQueryOptions(expression).setRequestConditions(bac); - BlobQueryOptions optionsOs - = new BlobQueryOptions(expression, new ByteArrayOutputStream()).setRequestConditions(bac); - - assertThrows(BlobStorageException.class, - () -> bc.openQueryInputStreamWithResponse(optionsIs).getValue() /* Don't need to call read. */); - - assertThrows(BlobStorageException.class, () -> bc.queryWithResponse(optionsOs, null, null)); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void copyFromURLSourceErrorAndStatusCode() { - BlockBlobClient destBlob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - BlobStorageException e = assertThrows(BlobStorageException.class, () -> destBlob.copyFromUrl(bc.getBlobUrl())); - - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }*/ - - static class MockProgressConsumer implements Consumer { - - List progressList; - - MockProgressConsumer() { - this.progressList = new ArrayList<>(); - } - - @Override - public void accept(BlobQueryProgress progress) { - progressList.add(progress.getBytesScanned()); - } - } - - static class MockErrorConsumer implements Consumer { - - String expectedType; - int numErrors; - - MockErrorConsumer(String expectedType) { - this.expectedType = expectedType; - this.numErrors = 0; - } - - @Override - public void accept(BlobQueryError nonFatalError) { - assertFalse(nonFatalError.isFatal()); - assertEquals(nonFatalError.getName(), expectedType); - numErrors++; - } - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseAsyncApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseAsyncApiTests.java deleted file mode 100644 index ac7c458a7819..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseAsyncApiTests.java +++ /dev/null @@ -1,606 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobQueryArrowField; -import com.azure.storage.blob.models.BlobQueryArrowFieldType; -import com.azure.storage.blob.models.BlobQueryArrowSerialization; -import com.azure.storage.blob.models.BlobQueryAsyncResponse; -import com.azure.storage.blob.models.BlobQueryDelimitedSerialization; -import com.azure.storage.blob.models.BlobQueryError; -import com.azure.storage.blob.models.BlobQueryJsonSerialization; -import com.azure.storage.blob.models.BlobQueryParquetSerialization; -import com.azure.storage.blob.models.BlobQueryProgress; -import com.azure.storage.blob.models.BlobQuerySerialization; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.options.BlobQueryOptions; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.function.Tuple2; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.nio.ByteBuffer; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.Consumer; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BlobBaseAsyncApiTests extends BlobTestBase { - - private BlobAsyncClient bc; - - @BeforeEach - public void setup() { - String blobName = generateBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName); - bc.upload(Flux.just(ByteBuffer.wrap(new byte[0])), null).block(); - } - - /* Quick Query Tests. */ - - // Generates and uploads a CSV file - private Mono uploadCsv(BlobQueryDelimitedSerialization s, int numCopies) { - String header = String.join(String.valueOf(s.getColumnSeparator()), "rn1", "rn2", "rn3", "rn4") - .concat(String.valueOf(s.getRecordSeparator())); - byte[] headers = header.getBytes(); - - String csv = String.join(String.valueOf(s.getColumnSeparator()), "100", "200", "300", "400") - .concat(String.valueOf(s.getRecordSeparator())) - .concat(String.join(String.valueOf(s.getColumnSeparator()), "300", "400", "500", "600") - .concat(String.valueOf(s.getRecordSeparator()))); - - byte[] csvData = csv.getBytes(); - int headerLength = s.isHeadersPresent() ? headers.length : 0; - byte[] data = new byte[headerLength + csvData.length * numCopies]; - if (s.isHeadersPresent()) { - System.arraycopy(headers, 0, data, 0, headers.length); - } - - for (int i = 0; i < numCopies; i++) { - int o = i * csvData.length + headerLength; - System.arraycopy(csvData, 0, data, o, csvData.length); - } - - Flux uploadStream = Flux.just(ByteBuffer.wrap(data)); - return bc.upload(uploadStream, null, true); - } - - private Mono uploadSmallJson(int numCopies) { - StringBuilder b = new StringBuilder(); - b.append("{\n"); - for (int i = 0; i < numCopies; i++) { - String toAppend = "\t\"name%d\": \"owner%d\",\n"; - b.append(String.format(toAppend, i, i)); - } - b.append('}'); - - Flux uploadStream = Flux.just(ByteBuffer.wrap(b.toString().getBytes())); - return bc.upload(uploadStream, null, true); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @ValueSource( - ints = { - 1, // 32 bytes - 32, // 1 KB - 256, // 8 KB - 400, // 12 ish KB - 4000, // 125 KB - }) - public void queryMin(int numCopies) { - BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - - liveTestScenarioWithRetry(() -> { - String expression = "SELECT * from BlobStorage"; - - Mono> response - = uploadCsv(ser, numCopies).then(Mono.zip(FluxUtil.collectBytesInByteBufferStream(bc.downloadStream()), - FluxUtil.collectBytesInByteBufferStream(bc.query(expression)))); - - StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(r.getT1(), r.getT2())) - .verifyComplete(); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("queryCsvSerializationSeparatorSupplier") - public void queryCsvSerializationSeparator(char recordSeparator, char columnSeparator, boolean headersPresentIn, - boolean headersPresentOut) { - BlobQueryDelimitedSerialization serIn - = new BlobQueryDelimitedSerialization().setRecordSeparator(recordSeparator) - .setColumnSeparator(columnSeparator) - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(headersPresentIn); - BlobQueryDelimitedSerialization serOut - = new BlobQueryDelimitedSerialization().setRecordSeparator(recordSeparator) - .setColumnSeparator(columnSeparator) - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(headersPresentOut); - String expression = "SELECT * from BlobStorage"; - - liveTestScenarioWithRetry(() -> { - Mono> response - = uploadCsv(serIn, 32).then(Mono.zip(FluxUtil.collectBytesInByteBufferStream(bc.downloadStream()), - bc.queryWithResponse( - new BlobQueryOptions(expression).setInputSerialization(serIn).setOutputSerialization(serOut)) - .flatMap(piece -> FluxUtil.collectBytesInByteBufferStream(piece.getValue())))); - - /* Output Stream. */ - StepVerifier.create(response).assertNext(r -> { - if (headersPresentIn && !headersPresentOut) { - assertEquals(r.getT1().length - 16, r.getT2().length); - - /* Account for 16 bytes of header. */ - TestUtils.assertArraysEqual(r.getT1(), 16, r.getT2(), 0, r.getT1().length - 16); - } else { - TestUtils.assertArraysEqual(r.getT1(), r.getT2()); - } - }).verifyComplete(); - }); - } - - private static Stream queryCsvSerializationSeparatorSupplier() { - return Stream.of(Arguments.of('\n', ',', false, false), /* Default. */ - Arguments.of('\n', ',', true, true), /* Headers. */ - Arguments.of('\n', ',', true, false), /* Headers. */ - Arguments.of('\t', ',', false, false), /* Record separator. */ - Arguments.of('\r', ',', false, false), Arguments.of('<', ',', false, false), - Arguments.of('>', ',', false, false), Arguments.of('&', ',', false, false), - Arguments.of('\\', ',', false, false), Arguments.of(',', '.', false, false), /* Column separator. */ - // Arguments.of(',', '\n', false, false), /* Keep getting a qq error: Field delimiter and record delimiter must be different characters. */ - Arguments.of(',', ';', false, false), Arguments.of('\n', '\t', false, false), /* Record separator. */ - // Arguments.of('\n', '\r', false, false), /* Keep getting a qq error: Field delimiter and record delimiter must be different characters. */ - Arguments.of('\n', '<', false, false), Arguments.of('\n', '>', false, false), - Arguments.of('\n', '&', false, false), Arguments.of('\n', '\\', false, false)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryCsvSerializationEscapeAndFieldQuote() { - BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\\') /* Escape set here. */ - .setFieldQuote('"') /* Field quote set here*/ - .setHeadersPresent(false); - String expression = "SELECT * from BlobStorage"; - - liveTestScenarioWithRetry(() -> { - Mono> response - = uploadCsv(ser, 32).then(Mono.zip(FluxUtil.collectBytesInByteBufferStream(bc.downloadStream()), - bc.queryWithResponse( - new BlobQueryOptions(expression).setInputSerialization(ser).setOutputSerialization(ser)) - .flatMap(piece -> FluxUtil.collectBytesInByteBufferStream(piece.getValue())))); - - StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(r.getT1(), r.getT2())) - .verifyComplete(); - }); - } - - /* Note: Input delimited tested everywhere */ - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @ValueSource(ints = { 1, 10, 100, 1000 }) - public void queryInputJson(int numCopies) { - BlobQueryJsonSerialization ser = new BlobQueryJsonSerialization().setRecordSeparator('\n'); - String expression = "SELECT * from BlobStorage"; - - liveTestScenarioWithRetry(() -> { - ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); - BlobQueryOptions options - = new BlobQueryOptions(expression).setInputSerialization(ser).setOutputSerialization(ser); - - Mono response - = uploadSmallJson(numCopies).then(FluxUtil.writeToOutputStream(bc.downloadStream(), downloadData)) - .then(bc.queryWithResponse(options)) - .flatMap(piece -> FluxUtil.collectBytesInByteBufferStream(piece.getValue())); - - StepVerifier.create(response).assertNext(r -> { - downloadData.write(10); - byte[] downloadedData = downloadData.toByteArray(); - TestUtils.assertArraysEqual(downloadedData, r); - }).verifyComplete(); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void queryInputParquet() { - String fileName = "parquet.parquet"; - ClassLoader classLoader = getClass().getClassLoader(); - File f = new File(Objects.requireNonNull(classLoader.getResource(fileName)).getFile()); - BlobQueryParquetSerialization ser = new BlobQueryParquetSerialization(); - byte[] expectedData = "0,mdifjt55.ea3,mdifjt55.ea3\n".getBytes(); - - String expression = "select * from blobstorage where id < 1;"; - - BlobQueryOptions optionsOs = new BlobQueryOptions(expression).setInputSerialization(ser); - - liveTestScenarioWithRetry(() -> StepVerifier - .create(bc.uploadFromFile(f.getAbsolutePath(), true) - .then(bc.queryWithResponse(optionsOs) - .flatMap(piece -> FluxUtil.collectBytesInByteBufferStream(piece.getValue())))) - .assertNext(r -> TestUtils.assertArraysEqual(expectedData, r)) - .verifyComplete()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryInputCsvOutputJson() { - BlobQueryDelimitedSerialization inSer = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - BlobQueryJsonSerialization outSer = new BlobQueryJsonSerialization().setRecordSeparator('\n'); - String expression = "SELECT * from BlobStorage"; - byte[] expectedData = "{\"_1\":\"100\",\"_2\":\"200\",\"_3\":\"300\",\"_4\":\"400\"}".getBytes(); - BlobQueryOptions options - = new BlobQueryOptions(expression).setInputSerialization(inSer).setOutputSerialization(outSer); - - liveTestScenarioWithRetry(() -> StepVerifier - .create(uploadCsv(inSer, 1).then(bc.queryWithResponse(options) - .flatMap(piece -> FluxUtil.collectBytesInByteBufferStream(piece.getValue())))) - .assertNext(r -> TestUtils.assertArraysEqual(expectedData, 0, r, 0, expectedData.length)) - .verifyComplete()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryInputJsonOutputCsv() { - BlobQueryJsonSerialization inSer = new BlobQueryJsonSerialization().setRecordSeparator('\n'); - BlobQueryDelimitedSerialization outSer = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - String expression = "SELECT * from BlobStorage"; - byte[] expectedData = "owner0,owner1\n".getBytes(); - BlobQueryOptions options - = new BlobQueryOptions(expression).setInputSerialization(inSer).setOutputSerialization(outSer); - - liveTestScenarioWithRetry(() -> StepVerifier - .create(uploadSmallJson(2).then(bc.queryWithResponse(options)) - .flatMap(piece -> FluxUtil.collectBytesInByteBufferStream(piece.getValue()))) - .assertNext(r -> TestUtils.assertArraysEqual(expectedData, 0, r, 0, expectedData.length)) - .verifyComplete()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryInputCsvOutputArrow() { - BlobQueryDelimitedSerialization inSer = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - - liveTestScenarioWithRetry(() -> { - List schema = new ArrayList<>(); - schema.add( - new BlobQueryArrowField(BlobQueryArrowFieldType.DECIMAL).setName("Name").setPrecision(4).setScale(2)); - BlobQueryArrowSerialization outSer = new BlobQueryArrowSerialization().setSchema(schema); - String expression = "SELECT _2 from BlobStorage WHERE _1 > 250;"; - BlobQueryOptions options = new BlobQueryOptions(expression).setOutputSerialization(outSer); - - StepVerifier.create(uploadCsv(inSer, 32).then(bc.queryWithResponse(options))) - .expectNextCount(1) - .verifyComplete(); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryNonFatalError() { - BlobQueryDelimitedSerialization base = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - String expression = "SELECT _1 from BlobStorage WHERE _2 > 250"; - - liveTestScenarioWithRetry(() -> { - MockErrorConsumer receiver2 = new MockErrorConsumer("InvalidColumnOrdinal"); - BlobQueryOptions options2 - = new BlobQueryOptions(expression).setInputSerialization(base.setColumnSeparator(',')) - .setOutputSerialization(base.setColumnSeparator(',')) - .setErrorConsumer(receiver2); - - StepVerifier.create(uploadCsv(base.setColumnSeparator('.'), 32).then(bc.queryWithResponse(options2))) - .expectNextCount(1) - .verifyComplete(); - - assertDoesNotThrow(() -> receiver2.numErrors > 0); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryFatalError() { - BlobQueryDelimitedSerialization base = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(true); - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions options - = new BlobQueryOptions(expression).setInputSerialization(new BlobQueryJsonSerialization()); - - liveTestScenarioWithRetry(() -> StepVerifier - .create(uploadCsv(base.setColumnSeparator('.'), 32).then( - bc.queryWithResponse(options).flatMap(r -> FluxUtil.collectBytesInByteBufferStream(r.getValue())))) - .verifyError(Throwable.class)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryProgressReceiver() { - BlobQueryDelimitedSerialization base = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - - String expression = "SELECT * from BlobStorage"; - - liveTestScenarioWithRetry(() -> { - MockProgressConsumer mockReceiver2 = new MockProgressConsumer(); - BlobQueryOptions options2 = new BlobQueryOptions(expression).setProgressConsumer(mockReceiver2); - - Mono> response = uploadCsv(base.setColumnSeparator('.'), 32).then(Mono.zip( - bc.getProperties(), - bc.queryWithResponse(options2).flatMap(r -> FluxUtil.collectBytesInByteBufferStream(r.getValue())))); - - StepVerifier.create(response) - .assertNext(r -> assertTrue(mockReceiver2.progressList.contains(r.getT1().getBlobSize()))) - .verifyComplete(); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @LiveOnly // Large amounts of data - @Test - public void queryMultipleRecordsWithProgressReceiver() { - BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - - String expression = "SELECT * from BlobStorage"; - - liveTestScenarioWithRetry(() -> { - MockProgressConsumer mockReceiver2 = new MockProgressConsumer(); - long temp = 0; - BlobQueryOptions options2 = new BlobQueryOptions(expression).setProgressConsumer(mockReceiver2); - - StepVerifier.create(uploadCsv(ser, 512000).then(bc.queryWithResponse(options2))) - .expectNextCount(1) - .verifyComplete(); - - // Make sure theyre all increasingly bigger - for (long progress : mockReceiver2.progressList) { - assertTrue(progress >= temp); - temp = progress; - } - }); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void querySnapshot() { - BlobQueryDelimitedSerialization ser = new BlobQueryDelimitedSerialization().setRecordSeparator('\n') - .setColumnSeparator(',') - .setEscapeChar('\0') - .setFieldQuote('\0') - .setHeadersPresent(false); - String expression = "SELECT * from BlobStorage"; - - Mono> response = uploadCsv(ser, 32).then(bc.createSnapshot()) - .flatMap(r -> bc.upload(Flux.just(ByteBuffer.wrap(new byte[0])), null, true) - .then(Mono.zip(FluxUtil.collectBytesInByteBufferStream(r.download()), - FluxUtil.collectBytesInByteBufferStream(r.query(expression))))); - - liveTestScenarioWithRetry(() -> StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(r.getT1(), r.getT2())) - .verifyComplete()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @CsvSource({ "true, false", "false, true" }) - public void queryInputOutputIA(boolean input, boolean output) { - /* Mock random impl of QQ Serialization*/ - BlobQuerySerialization ser = new RandomOtherSerialization(); - BlobQuerySerialization inSer = input ? ser : null; - BlobQuerySerialization outSer = output ? ser : null; - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions options - = new BlobQueryOptions(expression).setInputSerialization(inSer).setOutputSerialization(outSer); - - liveTestScenarioWithRetry( - () -> StepVerifier.create(bc.queryWithResponse(options)).verifyError(IllegalArgumentException.class)); - } - - private static class RandomOtherSerialization implements BlobQuerySerialization { - - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryArrowInputIA() { - BlobQueryArrowSerialization inSer = new BlobQueryArrowSerialization(); - String expression = "SELECT * from BlobStorage"; - - liveTestScenarioWithRetry(() -> { - BlobQueryOptions options2 = new BlobQueryOptions(expression).setInputSerialization(inSer); - StepVerifier.create(bc.queryWithResponse(options2)).verifyError(IllegalArgumentException.class); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-10-02") - @Test - public void queryParquetOutputIA() { - BlobQueryParquetSerialization outSer = new BlobQueryParquetSerialization(); - String expression = "SELECT * from BlobStorage"; - - liveTestScenarioWithRetry(() -> { - BlobQueryOptions options2 = new BlobQueryOptions(expression).setOutputSerialization(outSer); - StepVerifier.create(bc.queryWithResponse(options2)).verifyError(IllegalArgumentException.class); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void queryError() { - liveTestScenarioWithRetry(() -> { - bc = ccAsync.getBlobAsyncClient(generateBlobName()); - - StepVerifier.create(bc.query("SELECT * from BlobStorage")).verifyError(BlobStorageException.class); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("queryACSupplier") - public void queryAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions optionsOs = new BlobQueryOptions(expression).setRequestConditions(bac); - return bc.queryWithResponse(optionsOs); - }); - - liveTestScenarioWithRetry(() -> StepVerifier.create(response).expectNextCount(1).verifyComplete()); - } - - private static Stream queryACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null), Arguments.of(null, NEW_DATE, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null), - Arguments.of(null, null, null, null, null, "\"foo\" = 'bar'")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void queryACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - String expression = "SELECT * from BlobStorage"; - BlobQueryOptions optionsOs = new BlobQueryOptions(expression).setRequestConditions(bac); - - return bc.queryWithResponse(optionsOs); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void copyFromURLSourceErrorAndStatusCode() { - BlockBlobAsyncClient destBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - StepVerifier.create(destBlob.copyFromUrl(bc.getBlobUrl())) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }); - }*/ - - static class MockProgressConsumer implements Consumer { - - List progressList; - - MockProgressConsumer() { - this.progressList = new ArrayList<>(); - } - - @Override - public void accept(BlobQueryProgress progress) { - progressList.add(progress.getBytesScanned()); - } - } - - static class MockErrorConsumer implements Consumer { - - String expectedType; - int numErrors; - - MockErrorConsumer(String expectedType) { - this.expectedType = expectedType; - this.numErrors = 0; - } - - @Override - public void accept(BlobQueryError nonFatalError) { - assertFalse(nonFatalError.isFatal()); - assertEquals(nonFatalError.getName(), expectedType); - numErrors++; - } - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseTestHelper.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseTestHelper.java deleted file mode 100644 index 017741eb4d59..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseTestHelper.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -public class BlobBaseTestHelper { - public static String getEncryptionScope(BlobAsyncClientBase baseClient) { - return baseClient.getEncryptionScope(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobSeekableByteChannelTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobSeekableByteChannelTests.java deleted file mode 100644 index 4ff8054894a6..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobSeekableByteChannelTests.java +++ /dev/null @@ -1,334 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobDownloadAsyncResponse; -import com.azure.storage.blob.models.BlobDownloadHeaders; -import com.azure.storage.blob.models.BlobDownloadResponse; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobSeekableByteChannelReadResult; -import com.azure.storage.blob.models.ConsistentReadControl; -import com.azure.storage.blob.options.BlobSeekableByteChannelReadOptions; -import com.azure.storage.blob.options.BlockBlobSeekableByteChannelWriteOptions; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.StorageSeekableByteChannel; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.invocation.InvocationOnMock; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.ByteBuffer; -import java.nio.channels.SeekableByteChannel; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -import static com.azure.storage.blob.options.BlockBlobSeekableByteChannelWriteOptions.WriteMode.OVERWRITE; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class BlobSeekableByteChannelTests extends BlobTestBase { - - BlobClient bc; - BlockBlobClient blockClient; - - @BeforeEach - public void setup() { - bc = cc.getBlobClient(generateBlobName()); - blockClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - } - - @ParameterizedTest - @MethodSource("channelReadDataSupplier") - public void e2EChannelRead(int streamBufferSize, int copyBufferSize, int dataLength) throws IOException { - // given: "uploaded blob" - byte[] data = getRandomByteArray(dataLength); - bc.upload(BinaryData.fromBytes(data)); - - // when: "Channel initialized" - BlobSeekableByteChannelReadResult result = bc.openSeekableByteChannelRead( - new BlobSeekableByteChannelReadOptions().setReadSizeInBytes(streamBufferSize), null); - SeekableByteChannel channel = result.getChannel(); - - // then: "Channel initialized to position zero" - assertEquals(0, channel.position()); - assertNotNull(result.getProperties()); - assertEquals(data.length, result.getProperties().getBlobSize()); - - // when: "read from channel" - ByteArrayOutputStream downloadedData = new ByteArrayOutputStream(); - int copied = copy(channel, downloadedData, copyBufferSize); - - // then: "channel position updated accordingly" - assertEquals(dataLength, copied); - assertEquals(dataLength, channel.position()); - - // and: "expected data downloaded" - TestUtils.assertArraysEqual(data, downloadedData.toByteArray()); - } - - static Stream channelReadDataSupplier() { - return Stream.of(Arguments.of(50, 40, Constants.KB), Arguments.of(Constants.KB + 50, 40, Constants.KB)); - } - - /** - * Copies the InputStream contents to the destination byte channel. - * @param src Bytes source. - * @param dst Bytes destination. - * @param copySize Size of array to copy contents with. - * @return Total number of bytes read from src. - */ - private static int copy(SeekableByteChannel src, OutputStream dst, int copySize) throws IOException { - int read; - int totalRead = 0; - byte[] temp = new byte[copySize]; - ByteBuffer bb = ByteBuffer.wrap(temp); - while ((read = src.read(bb)) != -1) { - totalRead += read; - dst.write(temp, 0, read); - bb.clear(); - } - return totalRead; - } - - /** - * Copies the InputStream contents to the destination byte channel. - * @param src Bytes source. - * @param dst Bytes destination. - * @param copySize Size of array to copy contents with. - * @return Total number of bytes read from src. - */ - private static int copy(InputStream src, SeekableByteChannel dst, int copySize) throws IOException { - int read; - int totalRead = 0; - byte[] temp = new byte[copySize]; - while ((read = src.read(temp)) != -1) { - totalRead += read; - int written = 0; - while (written < read) { - written += dst.write(ByteBuffer.wrap(temp, written, read - written)); - } - } - return totalRead; - } - - @LiveOnly - @ParameterizedTest - @MethodSource("channelReadDataSupplier") - public void e2EChannelWriteBlock(int streamBufferSize, int copyBufferSize, int dataLength) throws IOException { - SeekableByteChannel channel = blockClient.openSeekableByteChannelWrite( - new BlockBlobSeekableByteChannelWriteOptions(OVERWRITE).setBlockSizeInBytes((long) streamBufferSize)); - - // then: "Channel initialized to position zero" - assertEquals(0, channel.position()); - - // when: "write to channel" - byte[] data = getRandomByteArray(dataLength); - int copied = copy(new ByteArrayInputStream(data), channel, copyBufferSize); - - // then: "channel position updated accordingly" - assertEquals(dataLength, copied); - assertEquals(dataLength, channel.position()); - - // when: "channel flushed" - channel.close(); - - // then: "appropriate data uploaded" - TestUtils.assertArraysEqual(data, blockClient.downloadContent().toBytes()); - } - - @ParameterizedTest - @CsvSource({ - "1024, " + Integer.MAX_VALUE, - "1024, " + (Integer.MAX_VALUE + 1000L), - "1024, " + (Long.MAX_VALUE / 2) }) - public void supportsGreaterThanMaxIntBlobSize(int toRead, long offset) throws Exception { - // Given: "data" - long blobSize = Long.MAX_VALUE; - ByteBuffer data = getRandomData(toRead); - - // And: "read behavior to blob where length > maxint" - BlobClientBase client = mock(BlobClientBase.class); - StorageSeekableByteChannelBlobReadBehavior behavior - = new StorageSeekableByteChannelBlobReadBehavior(client, ByteBuffer.allocate(0), -1, blobSize, null); - - // And: "StorageSeekableByteChannel" - StorageSeekableByteChannel channel = new StorageSeekableByteChannel(toRead, behavior, 0); - - // When: "seek" - channel.position(offset); - - // Then: "position set" - assertEquals(offset, channel.position()); - - when(client.downloadStreamWithResponse(any(), - argThat(r -> r != null && r.getOffset() == offset && r.getCount() == toRead), any(), any(), anyBoolean(), - any(), any())).thenAnswer((InvocationOnMock invocation) -> { - OutputStream os = invocation.getArgument(0); - os.write(data.array()); - String contentRange = "bytes " + offset + "-" + (offset + toRead - 1) + "/" + blobSize; - HttpHeaders headers = new HttpHeaders(); - headers.set(HttpHeaderName.CONTENT_RANGE, contentRange); - return new BlobDownloadResponse(new BlobDownloadAsyncResponse(null, 206, headers, null, - new BlobDownloadHeaders().setContentRange(contentRange))); - }); - - // When: "read" - ByteBuffer readBuffer = ByteBuffer.allocate(toRead); - int read = channel.read(readBuffer); - - // Then: "appropriate data read" - assertEquals(toRead, read); - TestUtils.assertArraysEqual(data.array(), readBuffer.array()); - - doThrow(new RuntimeException("Incorrect parameters")).when(client) - .downloadStreamWithResponse(any(), any(), any(), any(), anyBoolean(), any(), any()); - - // And: "channel position updated" - assertEquals(offset + toRead, channel.position()); - } - - @ParameterizedTest - @MethodSource("channelReadModeDataSupplier") - public void clientCreatesAppropriateChannelReadMode(BlobRequestConditions conditions, Integer blockSize, - ConsistentReadControl control, Long position) throws IOException { - BlobContainerClient versionedCC = versionedBlobServiceClient.getBlobContainerClient(generateContainerName()); - versionedCC.create(); - bc = versionedCC.getBlobClient(generateBlobName()); - - // when: "make channel in read mode" - bc.upload(BinaryData.fromBytes(getRandomByteArray(1024))); - StorageSeekableByteChannel channel = (StorageSeekableByteChannel) bc - .openSeekableByteChannelRead(new BlobSeekableByteChannelReadOptions().setRequestConditions(conditions) - .setReadSizeInBytes(blockSize) - .setConsistentReadControl(control) - .setInitialPosition(position), null) - .getChannel(); - - // then: "channel WriteBehavior is null" - assertNull(channel.getWriteBehavior()); - - // and: "channel ReadBehavior has appropriate values" - StorageSeekableByteChannelBlobReadBehavior readBehavior - = (StorageSeekableByteChannelBlobReadBehavior) channel.getReadBehavior(); - assertNotNull(readBehavior.getClient()); - - if (conditions != null) { - assertEquals(conditions, readBehavior.getRequestConditions()); - } - - if (control == null || control == ConsistentReadControl.ETAG) { - assertNotNull(readBehavior.getRequestConditions()); - assertNotNull(readBehavior.getRequestConditions().getIfMatch()); - } else if (control == ConsistentReadControl.VERSION_ID) { - assertNotEquals(readBehavior.getClient(), bc); - assertNotNull(readBehavior.getClient().getVersionId()); - assertEquals(conditions, readBehavior.getRequestConditions()); - } else { - assertEquals(conditions, readBehavior.getRequestConditions()); - } - - // and: "channel has appropriate values" - assertEquals(blockSize == null ? 4 * Constants.MB : blockSize, channel.getChunkSize()); - assertEquals(position == null ? 0 : position, channel.position()); - - versionedCC.delete(); - } - - static Stream channelReadModeDataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), - Arguments.of(new BlobRequestConditions(), null, ConsistentReadControl.NONE, null), - Arguments.of(new BlobRequestConditions(), null, ConsistentReadControl.ETAG, null), - Arguments.of(new BlobRequestConditions(), null, ConsistentReadControl.VERSION_ID, null), - Arguments.of(null, 500, null, null), Arguments.of(null, null, ConsistentReadControl.NONE, null), - Arguments.of(null, null, ConsistentReadControl.ETAG, null), - Arguments.of(null, null, ConsistentReadControl.VERSION_ID, null), Arguments.of(null, null, null, 800L)); - } - - @ParameterizedTest - @MethodSource("channelWriteModeDataSupplier") - public void clientCreatesAppropriateChannelWriteModeBlock( - BlockBlobSeekableByteChannelWriteOptions.WriteMode writeMode, Integer blockSize, BlobHttpHeaders headers, - Map metadata, Map tags, AccessTier tier, BlobRequestConditions conditions) - throws IOException { - // when: "make channel in write mode" - StorageSeekableByteChannel channel = (StorageSeekableByteChannel) blockClient - .openSeekableByteChannelWrite(new BlockBlobSeekableByteChannelWriteOptions(writeMode) - .setBlockSizeInBytes(blockSize != null ? Long.valueOf(blockSize) : null) - .setHeaders(headers) - .setMetadata(metadata) - .setTags(tags) - .setTier(tier) - .setRequestConditions(conditions)); - - // then: "channel ReadBehavior is null" - assertNull(channel.getReadBehavior()); - - // and: "channel WriteBehavior has appropriate values" - StorageSeekableByteChannelBlockBlobWriteBehavior writeBehavior - = (StorageSeekableByteChannelBlockBlobWriteBehavior) channel.getWriteBehavior(); - assertEquals(writeMode.toString().toLowerCase(), writeBehavior.getWriteMode().toString().toLowerCase()); - assertEquals(headers, writeBehavior.getHeaders()); - assertEquals(metadata, writeBehavior.getMetadata()); - assertEquals(tags, writeBehavior.getTags()); - assertEquals(tier, writeBehavior.getTier()); - assertEquals(conditions, writeBehavior.getRequestConditions()); - - // and: "channel has appropriate values" - assertEquals((blockSize == null ? 4 * Constants.MB : blockSize), channel.getChunkSize()); - assertEquals(0, channel.position()); - } - - static Stream channelWriteModeDataSupplier() { - Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - return Stream.of(Arguments.of(OVERWRITE, null, null, null, null, null, null), - Arguments.of(OVERWRITE, 500, null, null, null, null, null), - Arguments.of(OVERWRITE, null, new BlobHttpHeaders(), null, null, null, null), - Arguments.of(OVERWRITE, null, null, metadata, null, null, null), - Arguments.of(OVERWRITE, null, null, null, metadata, null, null), - Arguments.of(OVERWRITE, null, null, null, null, AccessTier.COOL, null), - Arguments.of(OVERWRITE, null, null, null, null, null, new BlobRequestConditions())); - } - - @Test - public void channelConsistentReadControlNullVersion() { - byte[] data = getRandomByteArray(Constants.KB); - bc.upload(BinaryData.fromBytes(data)); - - // Version ID set but not a versioned account - assertThrows(UnsupportedOperationException.class, - () -> bc.openSeekableByteChannelRead( - new BlobSeekableByteChannelReadOptions().setConsistentReadControl(ConsistentReadControl.VERSION_ID), - null)); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobApiTests.java deleted file mode 100644 index ea3afd3a19be..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobApiTests.java +++ /dev/null @@ -1,1732 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.rest.Response; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.BlobUrlParts; -import com.azure.storage.blob.implementation.models.BlockBlobsPutBlobFromUrlHeaders; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobCopySourceTagsMode; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.Block; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.BlockList; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.BlobUploadFromFileOptions; -import com.azure.storage.blob.options.BlobUploadFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobListBlocksOptions; -import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import com.azure.storage.common.test.shared.http.WireTapHttpClient; -import com.azure.storage.common.test.shared.policy.RequestAssertionPolicy; -import com.azure.storage.common.test.shared.policy.TransientFailureInjectingHttpPipelinePolicy; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@SuppressWarnings("deprecation") // Using old APIs for testing purposes -public class BlockBlobApiTests extends BlobTestBase { - private BlockBlobClient blockBlobClient; - private BlobClient blobClient; - private String blobName; - private final List createdFiles = new ArrayList<>(); - - @BeforeEach - public void setup() { - blobName = generateBlobName(); - blobClient = cc.getBlobClient(blobName); - blockBlobClient = blobClient.getBlockBlobClient(); - blockBlobClient.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - } - - @AfterEach - public void cleanup() { - createdFiles.forEach(File::delete); - } - - @Test - public void stageBlock() { - Response response = blockBlobClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null); - HttpHeaders headers = response.getHeaders(); - - assertResponseStatusCode(response, 201); - assertNotNull(headers.getValue(X_MS_CONTENT_CRC64)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(HttpHeaderName.DATE)); - assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - } - - @Test - public void stageBlockWithBinaryData() { - List binaryDataList = Arrays.asList(BinaryData.fromBytes(DATA.getDefaultBytes()), - BinaryData.fromString(DATA.getDefaultText()), BinaryData.fromFile(DATA.getDefaultFile()), - BinaryData.fromFlux(DATA.getDefaultFlux(), (long) DATA.getDefaultDataSize(), false).block(), - BinaryData.fromStream(DATA.getDefaultInputStream(), (long) DATA.getDefaultDataSize())); - - for (BinaryData binaryData : binaryDataList) { - Response response = blockBlobClient - .stageBlockWithResponse(new BlockBlobStageBlockOptions(getBlockID(), binaryData), null, null); - HttpHeaders headers = response.getHeaders(); - - assertResponseStatusCode(response, 201); - assertNotNull(headers.getValue(X_MS_CONTENT_CRC64)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(HttpHeaderName.DATE)); - assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - } - } - - @Test - public void stageBlockMin() { - assertResponseStatusCode(blockBlobClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null), 201); - assertEquals(blockBlobClient.listBlocks(BlockListType.ALL).getUncommittedBlocks().size(), 1); - } - - @ParameterizedTest - @MethodSource("stageBlockMinwithBinaryDataSupplier") - public void stageBlockMinWithBinaryData(BinaryData binaryData) { - assertResponseStatusCode(blockBlobClient - .stageBlockWithResponse(new BlockBlobStageBlockOptions(getBlockID(), binaryData), null, null), 201); - assertEquals(blockBlobClient.listBlocks(BlockListType.ALL).getUncommittedBlocks().size(), 1); - } - - private static Stream stageBlockMinwithBinaryDataSupplier() { - return Stream.of(Arguments.of(BinaryData.fromBytes(DATA.getDefaultBytes())), - Arguments.of(BinaryData.fromString(DATA.getDefaultText())), - Arguments.of(BinaryData.fromFile(DATA.getDefaultFile())), - Arguments.of(BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong()))); - } - - @Test - public void stageBlockMinwithBinaryDataFromFlux() { - BinaryData binaryData - = BinaryData.fromFlux(DATA.getDefaultFlux(), DATA.getDefaultDataSizeLong(), false).block(); - assertResponseStatusCode(blockBlobClient - .stageBlockWithResponse(new BlockBlobStageBlockOptions(getBlockID(), binaryData), null, null), 201); - assertEquals(blockBlobClient.listBlocks(BlockListType.ALL).getUncommittedBlocks().size(), 1); - } - - @ParameterizedTest - @MethodSource("stageBlockDoesNotTransformReplayableBinaryDataSupplier") - public void stageBlockDoesNotTransformReplayableBinaryData(BinaryData binaryData) { - WireTapHttpClient wireTap = new WireTapHttpClient(getHttpClient()); - BlockBlobClient wireTapClient - = getSpecializedBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), blockBlobClient.getBlobUrl()) - .httpClient(wireTap) - .buildBlockBlobClient(); - - assertResponseStatusCode( - wireTapClient.stageBlockWithResponse(new BlockBlobStageBlockOptions(getBlockID(), binaryData), null, null), - 201); - assertEquals(blockBlobClient.listBlocks(BlockListType.ALL).getUncommittedBlocks().size(), 1); - assertEquals(binaryData, wireTap.getLastRequest().getBodyAsBinaryData()); - } - - private static Stream stageBlockDoesNotTransformReplayableBinaryDataSupplier() { - return Stream.of(Arguments.of(BinaryData.fromBytes(DATA.getDefaultBytes())), - Arguments.of(BinaryData.fromString(DATA.getDefaultText())), - Arguments.of(BinaryData.fromFile(DATA.getDefaultFile()))); - } - - @ParameterizedTest - @MethodSource("stageBlockIllegalArgumentsSupplier") - public void stageBlockIllegalArguments(boolean getBlockId, InputStream stream, int dataSize, - Class exceptionType) { - String blockID = (getBlockId) ? getBlockID() : null; - assertThrows(exceptionType, () -> blockBlobClient.stageBlock(blockID, stream, dataSize)); - } - - private static Stream stageBlockIllegalArgumentsSupplier() { - return Stream.of( - Arguments.of(false, DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), BlobStorageException.class), - Arguments.of(true, null, DATA.getDefaultDataSize(), NullPointerException.class), - Arguments.of(true, DATA.getDefaultInputStream(), DATA.getDefaultDataSize() + 1, - UnexpectedLengthException.class), - Arguments.of(true, DATA.getDefaultInputStream(), DATA.getDefaultDataSize() - 1, - UnexpectedLengthException.class)); - } - - @Test - public void stageBlockIllegalArgumentsWithBinaryData() { - assertThrows(NullPointerException.class, () -> blockBlobClient.stageBlock(getBlockID(), null)); - - assertThrows(NullPointerException.class, - () -> blockBlobClient.stageBlock(getBlockID(), BinaryData.fromStream(DATA.getDefaultInputStream(), null))); - - BinaryData binaryData = BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong() + 1); - assertThrows(UnexpectedLengthException.class, () -> blockBlobClient.stageBlock(getBlockID(), binaryData)); - - BinaryData binaryData1 = BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong() - 1); - assertThrows(UnexpectedLengthException.class, () -> blockBlobClient.stageBlock(getBlockID(), binaryData1)); - } - - @Test - public void stageBlockEmptyBody() { - assertThrows(BlobStorageException.class, - () -> blockBlobClient.stageBlock(getBlockID(), new ByteArrayInputStream(new byte[0]), 0)); - } - - @Test - public void stageBlockTransactionalMD5() throws NoSuchAlgorithmException { - byte[] md5 = MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()); - - assertResponseStatusCode(blockBlobClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), md5, null, null, null), 201); - } - - @Test - public void stageBlockTransactionalMD5fail() { - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null, null, - null)); - - assertEquals(e.getErrorCode(), BlobErrorCode.MD5MISMATCH); - } - - @Test - public void stageBlockTransactionalMD5FailBinaryData() { - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.stageBlockWithResponse( - new BlockBlobStageBlockOptions(getBlockID(), BinaryData.fromBytes(DATA.getDefaultBytes())) - .setContentMd5(MessageDigest.getInstance("MD5").digest("garbage".getBytes())), - null, null)); - assertEquals(e.getErrorCode(), BlobErrorCode.MD5MISMATCH); - } - - @Test - public void stageBlockNullBody() { - assertThrows(NullPointerException.class, () -> blockBlobClient.stageBlock(getBlockID(), null, 0)); - } - - @Test - public void stageBlockLease() { - String leaseID = setupBlobLeaseCondition(blockBlobClient, RECEIVED_LEASE_ID); - - assertResponseStatusCode(blockBlobClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, leaseID, null, null), 201); - } - - @Test - public void stageBlockLeaseBinaryData() { - String leaseID = setupBlobLeaseCondition(blockBlobClient, RECEIVED_LEASE_ID); - - assertResponseStatusCode(blockBlobClient.stageBlockWithResponse( - new BlockBlobStageBlockOptions(getBlockID(), BinaryData.fromBytes(DATA.getDefaultBytes())) - .setLeaseId(leaseID), - null, null), 201); - } - - @Test - public void stageBlockLeaseFail() { - setupBlobLeaseCondition(blockBlobClient, RECEIVED_LEASE_ID); - - BlobStorageException e - = assertThrows(BlobStorageException.class, () -> blockBlobClient.stageBlockWithResponse(getBlockID(), - DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, GARBAGE_LEASE_ID, null, null)); - - assertEquals(e.getErrorCode(), BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION); - } - - @Test - public void stageBlockError() { - blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - assertThrows(BlobStorageException.class, - () -> blockBlobClient.stageBlock("id", DATA.getDefaultInputStream(), DATA.getDefaultDataSize())); - } - - @SuppressWarnings("deprecation") - @Test - public void stageBlockRetryOnTransientFailure() { - BlockBlobClient clientWithFailure = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - blobClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getBlockBlobClient(); - - byte[] data = getRandomByteArray(10); - String blockId = getBlockID(); - clientWithFailure.stageBlock(blockId, new ByteArrayInputStream(data), data.length); - blobClient.getBlockBlobClient().commitBlockList(Collections.singletonList(blockId), true); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - blobClient.download(os); - TestUtils.assertArraysEqual(data, os.toByteArray()); - } - - @SuppressWarnings("deprecation") - @Test - public void stageBlockRetryOnTransientFailureWithRetriableBinaryData() { - List binaryDataList = Arrays.asList(BinaryData.fromBytes(DATA.getDefaultBytes()), - BinaryData.fromString(DATA.getDefaultText()), BinaryData.fromFile(DATA.getDefaultFile())); - BlockBlobClient clientWithFailure = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - blobClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getBlockBlobClient(); - - for (BinaryData binaryData : binaryDataList) { - String blockId = getBlockID(); - clientWithFailure.stageBlock(blockId, binaryData); - blobClient.getBlockBlobClient().commitBlockList(Collections.singletonList(blockId), true); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - blobClient.download(os); - TestUtils.assertArraysEqual(os.toByteArray(), binaryData.toBytes()); - } - } - - @Test - public void stageBlockFromUrl() { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - String blockID = getBlockID(); - - String sas = blockBlobClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - HttpHeaders headers = bu2 - .stageBlockFromUrlWithResponse(blockID, blockBlobClient.getBlobUrl() + "?" + sas, null, null, null, null, - null, null) - .getHeaders(); - - assertNotNull(headers.getValue(X_MS_CONTENT_CRC64)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - - BlockList response = bu2.listBlocks(BlockListType.ALL); - assertEquals(response.getUncommittedBlocks().size(), 1); - assertEquals(response.getCommittedBlocks().size(), 0); - assertEquals(response.getUncommittedBlocks().get(0).getName(), blockID); - - bu2.commitBlockList(Collections.singletonList(blockID)); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - bu2.downloadStream(outputStream); - - assertEquals(ByteBuffer.wrap(outputStream.toByteArray()), DATA.getDefaultData()); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void stageBlockFromUrlSourceErrorAndStatusCode() { - BlockBlobClient destBlob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - String blockID = getBlockID(); - - BlobStorageException e = assertThrows(BlobStorageException.class, () -> destBlob.stageBlockFromUrl(blockID, blockBlobClient.getBlobUrl(), new BlobRange(0, (long) PageBlobClient.PAGE_BYTES))); - - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }*/ - - @Test - public void stageBlockFromUrlMin() { - BlockBlobClient bu2 = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - String blockID = getBlockID(); - - String sas = blockBlobClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - assertResponseStatusCode(bu2.stageBlockFromUrlWithResponse(blockID, blockBlobClient.getBlobUrl() + "?" + sas, - null, null, null, null, null, null), 201); - } - - @ParameterizedTest - @MethodSource("stageBlockFromURLIASupplier") - public void stageBlockFromURLIA(boolean getBlockId, String sourceURL, Class exceptionType) { - String blockID = (getBlockId) ? getBlockID() : null; - assertThrows(exceptionType, () -> blockBlobClient.stageBlockFromUrl(blockID, sourceURL, null)); - } - - private static Stream stageBlockFromURLIASupplier() { - return Stream.of(Arguments.of(false, "http://www.example.com", BlobStorageException.class), - Arguments.of(true, null, IllegalArgumentException.class)); - } - - @Test - public void stageBlockFromURLRange() { - BlockBlobClient destURL = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - String sas = blockBlobClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - destURL.stageBlockFromUrl(getBlockID(), blockBlobClient.getBlobUrl() + "?" + sas, new BlobRange(2L, 3L)); - BlockList blockList = destURL.listBlocks(BlockListType.UNCOMMITTED); - - assertEquals(blockList.getCommittedBlocks().size(), 0); - assertEquals(blockList.getUncommittedBlocks().size(), 1); - } - - @Test - public void stageBlockFromURLMD5() { - BlockBlobClient destURL = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - String sas = blockBlobClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - assertDoesNotThrow( - () -> destURL.stageBlockFromUrlWithResponse(getBlockID(), blockBlobClient.getBlobUrl() + "?" + sas, null, - MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()), null, null, null, null)); - } - - @Test - public void stageBlockFromURLMD5Fail() { - BlockBlobClient destURL = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - String sas = blockBlobClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - assertThrows(BlobStorageException.class, () -> destURL.stageBlockFromUrlWithResponse(getBlockID(), - blockBlobClient.getBlobUrl() + "?" + sas, null, "garbage".getBytes(), null, null, null, null)); - } - - @Test - public void stageBlockFromURLLease() { - String sas = blockBlobClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - assertDoesNotThrow( - () -> blockBlobClient.stageBlockFromUrlWithResponse(getBlockID(), blockBlobClient.getBlobUrl() + "?" + sas, - null, null, setupBlobLeaseCondition(blockBlobClient, RECEIVED_LEASE_ID), null, null, null)); - } - - @Test - public void stageBlockFromURLLeaseFail() { - String sas = blockBlobClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - assertThrows(BlobStorageException.class, () -> blockBlobClient.stageBlockFromUrlWithResponse(getBlockID(), - blockBlobClient.getBlobUrl() + "?" + sas, null, null, "garbage", null, null, null)); - } - - @Test - public void stageBlockFromURLError() { - blockBlobClient = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()) - .getBlobClient(generateBlobName()) - .getBlockBlobClient(); - - assertThrows(BlobStorageException.class, - () -> blockBlobClient.stageBlockFromUrl(getBlockID(), blockBlobClient.getBlobUrl(), null)); - } - - @ParameterizedTest - @MethodSource("stageBlockFromURLSourceACSupplier") - public void stageBlockFromURLSourceAC(OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch) { - String blockID = getBlockID(); - - BlockBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - sourceURL.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - sourceIfMatch = setupBlobMatchCondition(sourceURL, sourceIfMatch); - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(sourceIfMatch) - .setIfNoneMatch(sourceIfNoneMatch); - - assertResponseStatusCode(blockBlobClient.stageBlockFromUrlWithResponse(blockID, - sourceURL.getBlobUrl() + "?" + sas, null, null, null, smac, null, null), 201); - } - - private static Stream stageBlockFromURLSourceACSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of(OLD_DATE, null, null, null), - Arguments.of(null, NEW_DATE, null, null), Arguments.of(null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, GARBAGE_ETAG)); - } - - @ParameterizedTest - @MethodSource("stageBlockFromURLSourceACFailSupplier") - public void stageBlockFromURLSourceACFail(OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch) { - String blockID = getBlockID(); - - BlockBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - sourceURL.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(sourceIfMatch) - .setIfNoneMatch(setupBlobMatchCondition(sourceURL, sourceIfNoneMatch)); - - assertThrows(BlobStorageException.class, () -> blockBlobClient.stageBlockFromUrlWithResponse(blockID, - sourceURL.getBlobUrl() + "?" + sas, null, null, null, smac, null, null)); - } - - private static Stream stageBlockFromURLSourceACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null), Arguments.of(null, OLD_DATE, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null), Arguments.of(null, null, null, RECEIVED_ETAG)); - } - - @Test - public void commitBlockList() { - String blockID = getBlockID(); - blockBlobClient.stageBlock(blockID, DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - List ids = Collections.singletonList(blockID); - - Response response - = blockBlobClient.commitBlockListWithResponse(ids, null, null, null, null, null, null); - HttpHeaders headers = response.getHeaders(); - - assertResponseStatusCode(response, 201); - validateBasicHeaders(headers); - assertNotNull(headers.getValue(X_MS_CONTENT_CRC64)); - assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - } - - @Test - public void commitBlockListmin() { - blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - String blockID = getBlockID(); - blockBlobClient.stageBlock(blockID, DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - List ids = Collections.singletonList(blockID); - - assertNotNull(blockBlobClient.commitBlockList(ids)); - } - - @Test - public void commitBlockListMinNoOverwrite() { - BlobStorageException e - = assertThrows(BlobStorageException.class, () -> blockBlobClient.commitBlockList(new ArrayList<>())); - assertEquals(BlobErrorCode.BLOB_ALREADY_EXISTS, e.getErrorCode()); - } - - @Test - public void commitBlockListOverwrite() { - assertDoesNotThrow(() -> blockBlobClient.commitBlockList(new ArrayList<>(), true)); - } - - @Test - public void commitBlockListNull() { - assertResponseStatusCode(blockBlobClient.commitBlockListWithResponse(null, null, null, null, null, null, null), - 201); - } - - @ParameterizedTest - @MethodSource("commitBlockListHeadersSupplier") - public void commitBlockListHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - String blockID = getBlockID(); - blockBlobClient.stageBlock(blockID, DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - List ids = Collections.singletonList(blockID); - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - blockBlobClient.commitBlockListWithResponse(ids, headers, null, null, null, null, null); - Response response = blockBlobClient.getPropertiesWithResponse(null, null, null); - - // If the value isn't set the service will automatically set it - contentType = (contentType == null) ? "application/octet-stream" : contentType; - - validateBlobProperties(response, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentMD5, - contentType); - } - - private static Stream commitBlockListHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), Arguments.of("control", "disposition", - "encoding", "language", MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()), "type")); - } - - @ParameterizedTest - @MethodSource("commitBlockListMetadataSupplier") - public void commitBlockListMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - blockBlobClient.commitBlockListWithResponse(null, null, metadata, null, null, null, null); - Response response = blockBlobClient.getPropertiesWithResponse(null, null, null); - - assertResponseStatusCode(response, 200); - assertEquals(response.getValue().getMetadata(), metadata); - } - - private static Stream commitBlockListMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("commitBlockListTagsSupplier") - public void commitBlockListTags(String key1, String value1, String key2, String value2) { - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - blockBlobClient.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(null).setTags(tags), null, - null); - Response> response - = blockBlobClient.getTagsWithResponse(new BlobGetTagsOptions(), null, null); - - assertResponseStatusCode(response, 200); - assertEquals(response.getValue(), tags); - } - - private static Stream commitBlockListTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void commitBlockListAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - blockBlobClient.setTags(t); - match = setupBlobMatchCondition(blockBlobClient, match); - leaseID = setupBlobLeaseCondition(blockBlobClient, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(blockBlobClient.commitBlockListWithResponse(null, null, null, null, bac, null, null), - 201); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void commitBlockListACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - noneMatch = setupBlobMatchCondition(blockBlobClient, noneMatch); - setupBlobLeaseCondition(blockBlobClient, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.commitBlockListWithResponse(null, null, null, null, bac, null, null)); - assertTrue(e.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET - || e.getErrorCode() == BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION); - } - - @Test - public void commitBlockListError() { - blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - assertThrows(BlobStorageException.class, () -> blockBlobClient.commitBlockListWithResponse(new ArrayList<>(), - null, null, null, new BlobRequestConditions().setLeaseId("garbage"), null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void commitBlockListColdTier() { - blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - String blockID = getBlockID(); - blockBlobClient.stageBlock(blockID, DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - List ids = Collections.singletonList(blockID); - BlockBlobCommitBlockListOptions commitOptions - = new BlockBlobCommitBlockListOptions(ids).setTier(AccessTier.COLD); - - blockBlobClient.commitBlockListWithResponse(commitOptions, null, null); - BlobProperties properties = blockBlobClient.getProperties(); - - assertEquals(properties.getAccessTier(), AccessTier.COLD); - } - - @SuppressWarnings("deprecation") - @Test - public void getBlockList() { - List committedBlocks = Arrays.asList(getBlockID(), getBlockID()); - blockBlobClient.stageBlock(committedBlocks.get(0), DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - blockBlobClient.stageBlock(committedBlocks.get(1), DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - blockBlobClient.commitBlockList(committedBlocks, true); - - List uncommittedBlocks = Arrays.asList(getBlockID(), getBlockID()); - blockBlobClient.stageBlock(uncommittedBlocks.get(0), DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - blockBlobClient.stageBlock(uncommittedBlocks.get(1), DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - uncommittedBlocks.sort(String::compareTo); - - // When - BlockList blockList = blockBlobClient.listBlocks(BlockListType.ALL); - - // Then - Set actualCommittedBlocks = new HashSet<>(); - Set actualUncommittedBlocks = new HashSet<>(); - - for (Block block : blockList.getCommittedBlocks()) { - actualCommittedBlocks.add(block.getName()); - assertEquals(block.getSize(), DATA.getDefaultDataSize()); - } - - for (Block block : blockList.getUncommittedBlocks()) { - actualUncommittedBlocks.add(block.getName()); - assertEquals(block.getSize(), DATA.getDefaultDataSize()); - } - - assertEquals(new HashSet<>(committedBlocks), actualCommittedBlocks); - assertEquals(new HashSet<>(uncommittedBlocks), actualUncommittedBlocks); - - } - - @Test - public void getBlockListMin() { - assertDoesNotThrow(() -> blockBlobClient.listBlocks(BlockListType.ALL)); - } - - @ParameterizedTest - @MethodSource("getBlockListTypeSupplier") - public void getBlockListType(BlockListType type, int committedCount, int uncommittedCount) { - String blockID = getBlockID(); - blockBlobClient.stageBlock(blockID, DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - blockBlobClient.commitBlockList(Collections.singletonList(blockID), true); - blockBlobClient.stageBlock(getBlockID(), DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - - BlockList response = blockBlobClient.listBlocks(type); - - assertEquals(response.getCommittedBlocks().size(), committedCount); - assertEquals(response.getUncommittedBlocks().size(), uncommittedCount); - } - - private static Stream getBlockListTypeSupplier() { - return Stream.of(Arguments.of(BlockListType.ALL, 1, 1), Arguments.of(BlockListType.COMMITTED, 1, 0), - Arguments.of(BlockListType.UNCOMMITTED, 0, 1)); - } - - @Test - public void getBlockListTypeNull() { - assertDoesNotThrow(() -> blockBlobClient.listBlocks(null).getCommittedBlocks().iterator().hasNext()); - } - - @Test - public void getBlockListLease() { - String leaseID = setupBlobLeaseCondition(blockBlobClient, RECEIVED_LEASE_ID); - assertDoesNotThrow( - () -> blockBlobClient.listBlocksWithResponse(BlockListType.ALL, leaseID, null, Context.NONE)); - - } - - @Test - public void getBlockListLeaseFail() { - setupBlobLeaseCondition(blockBlobClient, GARBAGE_LEASE_ID); - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.listBlocksWithResponse(BlockListType.ALL, GARBAGE_LEASE_ID, null, Context.NONE)); - - assertEquals(e.getErrorCode(), BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getBlockListTags() { - Map t = new HashMap<>(); - t.put("foo", "bar"); - blockBlobClient.setTags(t); - - assertDoesNotThrow(() -> blockBlobClient.listBlocksWithResponse( - new BlockBlobListBlocksOptions(BlockListType.ALL).setIfTagsMatch("\"foo\" = 'bar'"), null, Context.NONE)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getBlockListTagsFail() { - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.listBlocksWithResponse( - new BlockBlobListBlocksOptions(BlockListType.ALL).setIfTagsMatch("\"notfoo\" = 'notbar'"), null, - Context.NONE)); - - assertEquals(e.getErrorCode(), BlobErrorCode.CONDITION_NOT_MET); - } - - @Test - public void getBlockListError() { - blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - assertThrows(BlobStorageException.class, - () -> blockBlobClient.listBlocks(BlockListType.ALL).getCommittedBlocks().iterator().hasNext()); - } - - @Test - public void upload() { - Response response = blockBlobClient.uploadWithResponse(DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - blockBlobClient.downloadStream(outStream); - TestUtils.assertArraysEqual(outStream.toByteArray(), DATA.getDefaultText().getBytes(StandardCharsets.UTF_8)); - validateBasicHeaders(response.getHeaders()); - assertNotNull(response.getHeaders().getValue(HttpHeaderName.CONTENT_MD5)); - assertTrue(Boolean.parseBoolean(response.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - } - - // Override name to prevent BinaryData.toString() invocation by test framework. - @Test - public void uploadBinaryData() { - List binaryDataList = Arrays.asList(BinaryData.fromBytes(DATA.getDefaultBytes()), - BinaryData.fromString(DATA.getDefaultText()), BinaryData.fromFile(DATA.getDefaultFile()), - BinaryData.fromFlux(DATA.getDefaultFlux(), (long) DATA.getDefaultDataSize(), false).block(), - BinaryData.fromStream(DATA.getDefaultInputStream(), (long) DATA.getDefaultDataSize())); - - for (BinaryData binaryData : binaryDataList) { - BlockBlobSimpleUploadOptions uploadOptions = new BlockBlobSimpleUploadOptions(binaryData); - Response response = blockBlobClient.uploadWithResponse(uploadOptions, null, null); - - assertResponseStatusCode(response, 201); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - blockBlobClient.download(outStream); - TestUtils.assertArraysEqual(outStream.toByteArray(), - DATA.getDefaultText().getBytes(StandardCharsets.UTF_8)); - validateBasicHeaders(response.getHeaders()); - assertNotNull(response.getHeaders().getValue(HttpHeaderName.CONTENT_MD5)); - assertTrue(Boolean.parseBoolean(response.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - } - } - - // Override name to prevent BinaryData.toString() invocation by test framework. - @ParameterizedTest - @MethodSource("stageBlockDoesNotTransformReplayableBinaryDataSupplier") - public void uploadDoesNotTransformReplayableBinaryData(BinaryData binaryData) { - BlockBlobSimpleUploadOptions uploadOptions = new BlockBlobSimpleUploadOptions(binaryData); - WireTapHttpClient wireTap = new WireTapHttpClient(getHttpClient()); - BlockBlobClient wireTapClient - = getSpecializedBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), blockBlobClient.getBlobUrl()) - .httpClient(wireTap) - .buildBlockBlobClient(); - Response response = wireTapClient.uploadWithResponse(uploadOptions, null, null); - - assertResponseStatusCode(response, 201); - // Check that replayable BinaryData contents are passed to http client unchanged. - assertEquals(wireTap.getLastRequest().getBodyAsBinaryData(), binaryData); - } - - /* Upload From File Tests: Need to run on liveMode only since blockBlob wil generate a `UUID.randomUUID()` - for getBlockID that will change every time test is run - */ - @LiveOnly - @ParameterizedTest - @MethodSource("uploadFromFileSupplier") - public void uploadFromFile(int fileSize, Long blockSize, int committedBlockCount) throws IOException { - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - BlobClient uploadBlobClient - = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), blobClient.getBlobUrl(), - new RequestAssertionPolicy( - request -> request.getBodyAsBinaryData() == null || request.getBodyAsBinaryData().isReplayable(), - "File upload should be sending replayable request data")); - - // Block length will be ignored for single shot. - uploadBlobClient.uploadFromFile(file.getPath(), new ParallelTransferOptions().setBlockSizeLong(blockSize), null, - null, null, null, null); - - File outFile = new File(file.getPath() + "result"); - createdFiles.add(outFile); - outFile.createNewFile(); - outFile.deleteOnExit(); - Files.deleteIfExists(outFile.toPath()); - - blobClient.downloadToFile(outFile.toPath().toString()); - - compareFiles(file, outFile, 0, fileSize); - - BlockList response = blobClient.getBlockBlobClient().listBlocks(BlockListType.COMMITTED); - assertEquals(response.getCommittedBlocks().size(), committedBlockCount); - } - - @SuppressWarnings("deprecation") - private static Stream uploadFromFileSupplier() { - return Stream.of(Arguments.of(0, null, 0), // Size is too small to trigger stage block uploading - Arguments.of(10, null, 0), // Size is too small to trigger stage block uploading - Arguments.of(10 * Constants.KB, null, 0), // Size is too small to trigger stage block uploading - Arguments.of(50 * Constants.MB, null, 0), // Size is too small to trigger stage block uploading - Arguments.of(BlockBlobClient.MAX_UPLOAD_BLOB_BYTES + 1, null, - // HTBB optimizations should trigger when file size is >100MB and defaults are used. - (int) Math.ceil( - (BlockBlobClient.MAX_UPLOAD_BLOB_BYTES + 1.0) / BlobClient.BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE)), - // Size is too small to trigger stage block uploading - Arguments.of(101 * Constants.MB, 4L * 1024 * 1024, 0)); - } - - @LiveOnly - @Test - public void uploadFromFileWithMetadata() throws IOException { - Map metadata = Collections.singletonMap("metadata", "value"); - File file = getRandomFile(Constants.KB); - file.deleteOnExit(); - createdFiles.add(file); - - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - - blobClient.uploadFromFile(file.getAbsolutePath(), null, null, metadata, null, null, null); - - assertEquals(metadata, blockBlobClient.getProperties().getMetadata()); - blockBlobClient.downloadStream(outStream); - TestUtils.assertArraysEqual(outStream.toByteArray(), Files.readAllBytes(file.toPath())); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @LiveOnly - @Test - public void uploadFromFileWithTags() throws IOException { - Map tags = Collections.singletonMap(testResourceNamer.randomName(prefix, 20), - testResourceNamer.randomName(prefix, 20)); - File file = getRandomFile(Constants.KB); - file.deleteOnExit(); - createdFiles.add(file); - - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - - blobClient.uploadFromFileWithResponse(new BlobUploadFromFileOptions(file.getAbsolutePath()).setTags(tags), null, - null); - - assertEquals(tags, blockBlobClient.getTags()); - blockBlobClient.downloadStream(outStream); - - TestUtils.assertArraysEqual(outStream.toByteArray(), Files.readAllBytes(file.toPath())); - } - - @LiveOnly - @Test - public void uploadFromFileDefaultNoOverwrite() throws IOException { - File file = getRandomFile(50); - file.deleteOnExit(); - createdFiles.add(file); - - BlobStorageException e - = assertThrows(BlobStorageException.class, () -> blobClient.uploadFromFile(file.toPath().toString())); - assertEquals(e.getErrorCode(), BlobErrorCode.BLOB_ALREADY_EXISTS); - } - - @LiveOnly - @Test - public void uploadFromFileOverwrite() throws IOException { - File file = getRandomFile(50); - file.deleteOnExit(); - createdFiles.add(file); - - blobClient.uploadFromFile(file.toPath().toString(), true); - } - - @ParameterizedTest - @MethodSource("uploadFromFileOptionsSupplier") - @LiveOnly - public void uploadFromFileOptions(int dataSize, Long singleUploadSize, Long blockSize, double expectedBlockCount) - throws IOException { - File file = getRandomFile(dataSize); - file.deleteOnExit(); - createdFiles.add(file); - - blobClient.uploadFromFile(file.toPath().toString(), - new ParallelTransferOptions().setBlockSizeLong(blockSize).setMaxSingleUploadSizeLong(singleUploadSize), - null, null, null, null, null); - - assertEquals(blobClient.getBlockBlobClient().listBlocks(BlockListType.COMMITTED).getCommittedBlocks().size(), - expectedBlockCount); - } - - @SuppressWarnings("deprecation") - private static Stream uploadFromFileOptionsSupplier() { - return Stream.of( - // Test that the default for singleUploadSize is the maximum - Arguments.of(BlockBlobClient.MAX_UPLOAD_BLOB_BYTES - 1, null, null, 0), - Arguments.of(BlockBlobClient.MAX_UPLOAD_BLOB_BYTES + 1, null, null, - /* This also validates the default for blockSize*/ - Math.ceil(((double) BlockBlobClient.MAX_UPLOAD_BLOB_BYTES + 1) - / (double) BlobClient.BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE)), - // Test that singleUploadSize is respected - Arguments.of(100, 50L, null, 1), - // Test that blockSize is respected - Arguments.of(100, 50L, 20L, 5)); - } - - @LiveOnly - @Test - // Reading from recordings will not allow for the timing of the test to work correctly. - public void uploadFromFileTimeout() throws IOException { - File file = getRandomFile(1024); - file.deleteOnExit(); - createdFiles.add(file); - - assertThrows(IllegalStateException.class, - () -> blobClient.uploadFromFile(file.getPath(), null, null, null, null, null, Duration.ofNanos(5L))); - } - - @Test - public void uploadMin() { - blockBlobClient.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true); - - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - blockBlobClient.download(outStream); - TestUtils.assertArraysEqual(outStream.toByteArray(), DATA.getDefaultText().getBytes(StandardCharsets.UTF_8)); - } - - // Override name to prevent BinaryData.toString() invocation by test framework. - @Test - public void uploadMinBinaryData() { - List binaryDataList = Arrays.asList(BinaryData.fromBytes(DATA.getDefaultBytes()), - BinaryData.fromString(DATA.getDefaultText()), BinaryData.fromFile(DATA.getDefaultFile()), - BinaryData.fromFlux(DATA.getDefaultFlux(), (long) DATA.getDefaultDataSize(), false).block(), - BinaryData.fromStream(DATA.getDefaultInputStream(), (long) DATA.getDefaultDataSize())); - - for (BinaryData binaryData : binaryDataList) { - blockBlobClient.upload(binaryData, true); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - blockBlobClient.downloadStream(outStream); - TestUtils.assertArraysEqual(outStream.toByteArray(), - DATA.getDefaultText().getBytes(StandardCharsets.UTF_8)); - } - } - - @ParameterizedTest - @MethodSource("uploadIllegalArgumentSupplier") - public void uploadIllegalArgument(InputStream stream, long dataSize, Class exceptionType) { - assertThrows(exceptionType, () -> blockBlobClient.upload(stream, dataSize)); - } - - private static Stream uploadIllegalArgumentSupplier() { - return Stream.of(Arguments.of(null, DATA.getDefaultDataSize(), NullPointerException.class), - Arguments.of(DATA.getDefaultInputStream(), DATA.getDefaultDataSize() + 1, UnexpectedLengthException.class), - Arguments.of(DATA.getDefaultInputStream(), DATA.getDefaultDataSize() - 1, UnexpectedLengthException.class)); - } - - @Test - public void uploadIllegalArgumentBinaryData() { - assertThrows(NullPointerException.class, () -> blockBlobClient.upload(null)); - - assertThrows(NullPointerException.class, - () -> blockBlobClient.upload(BinaryData.fromStream(DATA.getDefaultInputStream(), null))); - - BinaryData badLength1 = BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong() + 1); - assertThrows(UnexpectedLengthException.class, () -> blockBlobClient.upload(badLength1)); - - BinaryData badLength2 = BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong() - 1); - assertThrows(UnexpectedLengthException.class, () -> blockBlobClient.upload(badLength2)); - } - - @Test - public void uploadEmptyBody() { - assertResponseStatusCode(blockBlobClient.uploadWithResponse(new ByteArrayInputStream(new byte[0]), 0, null, - null, null, null, null, null, null), 201); - } - - @Test - public void uploadNullBody() { - assertThrows(NullPointerException.class, - () -> blockBlobClient.uploadWithResponse(null, 0, null, null, null, null, null, null, null)); - } - - @ParameterizedTest - @MethodSource("uploadHeadersSupplier") - public void uploadHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) throws NoSuchAlgorithmException { - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - blockBlobClient.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), headers, null, null, - null, null, null, null); - Response response = blockBlobClient.getPropertiesWithResponse(null, null, null); - - // If the value isn't set the service will automatically set it - contentMD5 - = (contentMD5 == null) ? MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()) : contentMD5; - contentType = (contentType == null) ? "application/octet-stream" : contentType; - validateBlobProperties(response, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentMD5, - contentType); - - } - - private static Stream uploadHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), Arguments.of("control", "disposition", - "encoding", "language", MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()), "type")); - } - - @Test - public void uploadTransactionalMD5() throws NoSuchAlgorithmException { - byte[] md5 = MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()); - - assertResponseStatusCode(blockBlobClient.uploadWithResponse(DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, md5, null, null, null), 201); - } - - @Test - public void uploadTransactionalMD5Fail() { - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null, null, - null)); - assertEquals(BlobErrorCode.MD5MISMATCH, e.getErrorCode()); - } - - @ParameterizedTest - @MethodSource("commitBlockListMetadataSupplier") - public void uploadMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - blockBlobClient.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, metadata, - null, null, null, null, null); - Response response = blockBlobClient.getPropertiesWithResponse(null, null, null); - assertResponseStatusCode(response, 200); - assertEquals(metadata, response.getValue().getMetadata()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("commitBlockListTagsSupplier") - public void uploadTags(String key1, String value1, String key2, String value2) { - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - blockBlobClient.uploadWithResponse( - new BlockBlobSimpleUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()).setTags(tags), - null, null); - Response> response - = blockBlobClient.getTagsWithResponse(new BlobGetTagsOptions(), null, null); - - assertResponseStatusCode(response, 200); - assertEquals(tags, response.getValue()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void uploadAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - blockBlobClient.setTags(t); - match = setupBlobMatchCondition(blockBlobClient, match); - leaseID = setupBlobLeaseCondition(blockBlobClient, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(blockBlobClient.uploadWithResponse(DATA.getDefaultInputStream(), - DATA.getDefaultDataSize(), null, null, null, null, bac, null, null), 201); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void uploadACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - noneMatch = setupBlobMatchCondition(blockBlobClient, noneMatch); - setupBlobLeaseCondition(blockBlobClient, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, - null, null, null, bac, null, null)); - - assertTrue(e.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET - || e.getErrorCode() == BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION); - } - - @Test - public void uploadError() { - blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - assertThrows(BlobStorageException.class, - () -> blockBlobClient.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, - null, null, null, new BlobRequestConditions().setLeaseId("id"), null, null)); - } - - @Test - public void uploadWithTier() { - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - bc.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, null, AccessTier.COOL, - null, null, null, null); - - assertEquals(bc.getProperties().getAccessTier(), AccessTier.COOL); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void uploadWithAccessTierCold() { - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.uploadWithResponse(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), null, null, AccessTier.COLD, - null, null, null, null); - assertEquals(bc.getProperties().getAccessTier(), AccessTier.COLD); - } - - @Test - public void uploadOverwriteFalse() { - assertThrows(BlobStorageException.class, - () -> blockBlobClient.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize())); - } - - @Test - public void uploadOverwriteTrue() { - assertDoesNotThrow(() -> blockBlobClient.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize(), true)); - } - - @Test - public void uploadRetryOnTransientFailure() { - BlockBlobClient clientWithFailure = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - blobClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getBlockBlobClient(); - - byte[] data = getRandomByteArray(10); - clientWithFailure.upload(new ByteArrayInputStream(data), data.length, true); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - blobClient.downloadStream(os); - TestUtils.assertArraysEqual(os.toByteArray(), data); - } - - @ParameterizedTest - @MethodSource("bufferedUploadSyncHandlePathingWithTransientFailureSupplier") - @LiveOnly - public void bufferedUploadSyncHandlePathingWithTransientFailure(int dataSize, int blockCount) { - /* - This test ensures that although we no longer mark and reset the source stream for buffered upload, it still - supports retries in all cases for the sync client. - */ - BlobClient clientWithFailure = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - blobClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()); - - byte[] data = getRandomByteArray(dataSize); - clientWithFailure.uploadWithResponse(new ByteArrayInputStream(data), dataSize, - new ParallelTransferOptions().setMaxSingleUploadSizeLong(2L * Constants.MB) - .setBlockSizeLong(2L * Constants.MB), - null, null, null, null, null, null); - - ByteArrayOutputStream os = new ByteArrayOutputStream(dataSize); - blobClient.downloadStream(os); - TestUtils.assertArraysEqual(data, os.toByteArray()); - - assertEquals(blobClient.getBlockBlobClient().listBlocks(BlockListType.ALL).getCommittedBlocks().size(), - blockCount); - } - - private static Stream bufferedUploadSyncHandlePathingWithTransientFailureSupplier() { - return Stream.of(Arguments.of(11110, 0), Arguments.of(2 * Constants.MB + 11, 2)); - } - - /* - def "Upload NRF progress"() { - setup: - def data = getRandomData(BlockBlobURL.MAX_UPLOAD_BLOB_BYTES + 1) - def numBlocks = data.remaining() / BlockBlobURL.MAX_STAGE_BLOCK_BYTES - long prevCount = 0 - def mockReceiver = Mock(IProgressReceiver) - - - when: - TransferManager.uploadFromNonReplayableFlowable(Flowable.just(data), bu, BlockBlobURL.MAX_STAGE_BLOCK_BYTES, 10, - new TransferManagerUploadToBlockBlobOptions(mockReceiver, null, null, null, 20)).blockingGet() - data.position(0) - - then: - // We should receive exactly one notification of the completed progress. - 1 * mockReceiver.reportProgress(data.remaining()) */ - - /* - We should receive at least one notification reporting an intermediary value per block, but possibly more - notifications will be received depending on the implementation. We specify numBlocks - 1 because the last block - will be the total size as above. Finally, we assert that the number reported monotonically increases. - */ - /*(numBlocks - 1.._) * mockReceiver.reportProgress(!data.remaining()) >> { long bytesTransferred -> - if (!(bytesTransferred > prevCount)) { - throw new IllegalArgumentException("Reported progress should monotonically increase") - } else { - prevCount = bytesTransferred - } - } - - // We should receive no notifications that report more progress than the size of the file. - 0 * mockReceiver.reportProgress({ it > data.remaining() }) - notThrown(IllegalArgumentException) - }*/ - - @LiveOnly - @Test - public void bufferedUploadOverwrite() throws IOException { - File file = getRandomFile(50); - file.deleteOnExit(); - createdFiles.add(file); - - blobClient.uploadFromFile(file.toPath().toString(), true); - assertDoesNotThrow(() -> blobClient.uploadFromFile(getRandomFile(50).toPath().toString(), true)); - } - - @Test - public void bufferedUploadNonMarkableStream() throws IOException { - File file = getRandomFile(10); - file.deleteOnExit(); - createdFiles.add(file); - - FileInputStream fileStream = new FileInputStream(file); - File outFile = getRandomFile(10); - createdFiles.add(outFile); - outFile.deleteOnExit(); - Files.deleteIfExists(outFile.toPath()); - - blobClient.upload(fileStream, file.length(), true); - blobClient.downloadToFile(outFile.toPath().toString(), true); - compareFiles(file, outFile, 0, file.length()); - } - - @Test - public void getContainerName() { - assertEquals(containerName, blockBlobClient.getContainerName()); - } - - @Test - public void getBlockBlobName() { - assertEquals(blobName, blockBlobClient.getBlobName()); - } - - @ParameterizedTest - @MethodSource("getBlobNameAndBuildClientSupplier") - public void getBlobNameAndBuildClient(String originalBlobName, String finalBlobName) { - BlobClient client = cc.getBlobClient(originalBlobName); - BlockBlobClient blockClient = cc.getBlobClient(client.getBlobName()).getBlockBlobClient(); - - assertEquals(blockClient.getBlobName(), finalBlobName); - } - - private static Stream getBlobNameAndBuildClientSupplier() { - return Stream.of(Arguments.of("blobName", "blobName"), Arguments.of("dir1/a%20b.txt", "dir1/a%20b.txt"), - Arguments.of("path/to]a blob", "path/to]a blob"), - Arguments.of("path%2Fto%5Da%20blob", "path%2Fto%5Da%20blob"), Arguments.of("斑點", "斑點"), - Arguments.of("%E6%96%91%E9%BB%9E", "%E6%96%91%E9%BB%9E"), Arguments.of("斑點", "斑點")); - } - - @Test - public void builderCpkValidation() { - URL endpoint = BlobUrlParts.parse(blockBlobClient.getBlobUrl()).setScheme("http").toUrl(); - SpecializedBlobClientBuilder builder = new SpecializedBlobClientBuilder() - .customerProvidedKey(new CustomerProvidedKey(Base64.getEncoder().encodeToString(getRandomByteArray(256)))) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildBlockBlobClient); - } - - @Test - public void builderBearerTokenValidation() { - URL endpoint = BlobUrlParts.parse(blockBlobClient.getBlobUrl()).setScheme("http").toUrl(); - SpecializedBlobClientBuilder builder - = new SpecializedBlobClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildBlockBlobClient); - } - - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - @Test - public void perCallPolicy() { - BlockBlobClient specialBlob - = getSpecializedBuilder(blockBlobClient.getBlobUrl()).addPolicy(getPerCallVersionPolicy()) - .buildBlockBlobClient(); - - HttpHeaders headers = specialBlob.getPropertiesWithResponse(null, null, null).getHeaders(); - assertEquals("2017-11-09", headers.getValue(X_MS_VERSION)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromUrlMin() { - BlobClient sourceBlob - = primaryBlobServiceClient.getBlobContainerClient(containerName).getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - if (blockBlobClient.exists()) { - blockBlobClient.delete(); - } - - BlockBlobItem blockBlobItem = blockBlobClient.uploadFromUrl(sourceBlob.getBlobUrl() + "?" + sas); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - blockBlobClient.download(os); - assertNotNull(blockBlobItem); - assertNotNull(blockBlobItem.getETag()); - assertNotNull(blockBlobItem.getLastModified()); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), os.toByteArray()); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void uploadFromUrlSourceErrorAndStatusCode() { - BlockBlobClient destBlob = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - - BlobStorageException e = assertThrows(BlobStorageException.class, () -> destBlob.uploadFromUrl(blockBlobClient.getBlobUrl())); - - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }*/ - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromUrlOverwrite() { - BlobClient sourceBlob - = primaryBlobServiceClient.getBlobContainerClient(containerName).getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - blockBlobClient.upload(new ByteArrayInputStream(new byte[0]), 0, true); - - BlockBlobItem blockBlobItem = blockBlobClient.uploadFromUrl(sourceBlob.getBlobUrl() + "?" + sas, true); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - blockBlobClient.download(os); - assertNotNull(blockBlobItem); - assertNotNull(blockBlobItem.getETag()); - assertNotNull(blockBlobItem.getLastModified()); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), os.toByteArray()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromUrlOverwriteFailsOnExistingBlob() { - BlobClient sourceBlob - = primaryBlobServiceClient.getBlobContainerClient(containerName).getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - blockBlobClient.upload(new ByteArrayInputStream(new byte[0]), 0, true); - - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.uploadFromUrl(sourceBlob.getBlobUrl() + "?" + sas, false)); - assertEquals(BlobErrorCode.BLOB_ALREADY_EXISTS, e.getErrorCode()); - - BlobStorageException e2 = assertThrows(BlobStorageException.class, - () -> blockBlobClient.uploadFromUrl(sourceBlob.getBlobUrl() + "?" + sas)); - assertEquals(BlobErrorCode.BLOB_ALREADY_EXISTS, e2.getErrorCode()); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromUrlMax() throws NoSuchAlgorithmException { - BlobClient sourceBlob - = primaryBlobServiceClient.getBlobContainerClient(containerName).getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - sourceBlob.setHttpHeaders(new BlobHttpHeaders().setContentLanguage("en-GB")); - byte[] sourceBlobMD5 = MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()); - BlobProperties sourceProperties = sourceBlob.getProperties(); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - blockBlobClient.upload(new ByteArrayInputStream(new byte[0]), 0, true); - BlobProperties destinationPropertiesBefore = blockBlobClient.getProperties(); - - BlobUploadFromUrlOptions options - = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas).setContentMd5(sourceBlobMD5) - .setCopySourceBlobProperties(true) - .setDestinationRequestConditions( - new BlobRequestConditions().setIfMatch(destinationPropertiesBefore.getETag())) - .setSourceRequestConditions(new BlobRequestConditions().setIfMatch(sourceProperties.getETag())) - .setHeaders(new BlobHttpHeaders().setContentType("text")) - .setTier(AccessTier.COOL); - Response response = blockBlobClient.uploadFromUrlWithResponse(options, null, null); - BlobProperties destinationProperties = blobClient.getProperties(); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - blockBlobClient.download(os); - - assertNotNull(response); - assertNotNull(response.getRequest()); - assertNotNull(response.getHeaders()); - BlockBlobItem blockBlobItem = response.getValue(); - assertNotNull(blockBlobItem); - assertNotNull(blockBlobItem.getETag()); - assertNotNull(blockBlobItem.getLastModified()); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), os.toByteArray()); - assertEquals("en-GB", destinationProperties.getContentLanguage()); - assertEquals("text", destinationProperties.getContentType()); - assertEquals(AccessTier.COOL, destinationProperties.getAccessTier()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromWithInvalidSourceMD5() throws NoSuchAlgorithmException { - BlobClient sourceBlob - = primaryBlobServiceClient.getBlobContainerClient(containerName).getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - byte[] sourceBlobMD5 = MessageDigest.getInstance("MD5").digest("garbage".getBytes(StandardCharsets.UTF_8)); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - blockBlobClient.upload(new ByteArrayInputStream(new byte[0]), 0, true); - - BlobUploadFromUrlOptions options - = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas).setContentMd5(sourceBlobMD5); - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.uploadFromUrlWithResponse(options, null, null)); - - assertEquals(e.getErrorCode(), BlobErrorCode.MD5MISMATCH); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @ParameterizedTest - @MethodSource("uploadFromUrlSourceRequestConditionsSupplier") - public void uploadFromUrlSourceRequestConditions(BlobRequestConditions requestConditions, BlobErrorCode errorCode) { - BlobClient sourceBlob - = primaryBlobServiceClient.getBlobContainerClient(containerName).getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - blockBlobClient.upload(new ByteArrayInputStream(new byte[0]), 0, true); - - BlobUploadFromUrlOptions options = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas) - .setSourceRequestConditions(requestConditions); - - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.uploadFromUrlWithResponse(options, null, null)); - assertEquals(e.getErrorCode(), errorCode); - } - - private static Stream uploadFromUrlSourceRequestConditionsSupplier() { - return Stream.of( - Arguments.of(new BlobRequestConditions().setIfMatch("dummy"), BlobErrorCode.SOURCE_CONDITION_NOT_MET), - Arguments.of(new BlobRequestConditions().setIfModifiedSince(OffsetDateTime.now().plusSeconds(20)), - BlobErrorCode.CANNOT_VERIFY_COPY_SOURCE), - Arguments.of(new BlobRequestConditions().setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)), - BlobErrorCode.CANNOT_VERIFY_COPY_SOURCE)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @ParameterizedTest - @MethodSource("uploadFromUrlDestinationRequestConditionsSupplier") - public void uploadFromUrlDestinationRequestConditions(BlobRequestConditions requestConditions, - BlobErrorCode errorCode) { - BlobClient sourceBlob - = primaryBlobServiceClient.getBlobContainerClient(containerName).getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - blockBlobClient.upload(new ByteArrayInputStream(new byte[0]), 0, true); - if (requestConditions.getLeaseId() != null) { - createLeaseClient(blobClient).acquireLease(60); - } - - BlobUploadFromUrlOptions options = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas) - .setDestinationRequestConditions(requestConditions); - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> blockBlobClient.uploadFromUrlWithResponse(options, null, null)); - assertEquals(e.getErrorCode(), errorCode); - } - - private static Stream uploadFromUrlDestinationRequestConditionsSupplier() { - return Stream.of( - Arguments.of(new BlobRequestConditions().setIfMatch("dummy"), BlobErrorCode.TARGET_CONDITION_NOT_MET), - Arguments.of(new BlobRequestConditions().setIfNoneMatch("*"), BlobErrorCode.BLOB_ALREADY_EXISTS), - Arguments.of(new BlobRequestConditions().setIfModifiedSince(OffsetDateTime.now().plusDays(10)), - BlobErrorCode.CONDITION_NOT_MET), - Arguments.of(new BlobRequestConditions().setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)), - BlobErrorCode.CONDITION_NOT_MET), - Arguments.of(new BlobRequestConditions().setLeaseId("9260fd2d-34c1-42b5-9217-8fb7c6484bfb"), - BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("uploadFromUrlCopySourceTagsSupplier") - public void uploadFromUrlCopySourceTags(BlobCopySourceTagsMode mode) { - Map sourceTags = Collections.singletonMap("foo", "bar"); - Map destTags = Collections.singletonMap("fizz", "buzz"); - blockBlobClient.setTags(sourceTags); - - String sas = blockBlobClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - BlobClient bc2 = cc.getBlobClient(generateBlobName()); - - BlobCopyFromUrlOptions options - = new BlobCopyFromUrlOptions(blockBlobClient.getBlobUrl() + "?" + sas).setCopySourceTagsMode(mode); - if (BlobCopySourceTagsMode.REPLACE == mode) { - options.setTags(destTags); - } - - bc2.copyFromUrlWithResponse(options, null, null); - Map receivedTags = bc2.getTags(); - - if (BlobCopySourceTagsMode.REPLACE == mode) { - assertEquals(receivedTags, destTags); - } else { - assertEquals(receivedTags, sourceTags); - } - } - - private static Stream uploadFromUrlCopySourceTagsSupplier() { - return Stream.of(Arguments.of(BlobCopySourceTagsMode.COPY), Arguments.of(BlobCopySourceTagsMode.REPLACE)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void uploadFromUrlAccessTierCold() { - BlobClient sourceBlob - = primaryBlobServiceClient.getBlobContainerClient(containerName).getBlobClient(generateBlobName()); - sourceBlob.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - if (blockBlobClient.exists()) { - blockBlobClient.delete(); - } - - BlobUploadFromUrlOptions uploadOptions - = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas).setTier(AccessTier.COLD); - blockBlobClient.uploadFromUrlWithResponse(uploadOptions, null, null); - BlobProperties properties = blockBlobClient.getProperties(); - - assertEquals(properties.getAccessTier(), AccessTier.COLD); - } - - @Test - public void blockBlobItemNullHeaders() { - HttpHeaders headers = new HttpHeaders(); - BlockBlobsPutBlobFromUrlHeaders hd = new BlockBlobsPutBlobFromUrlHeaders(headers); - - BlockBlobItem blockBlobItem = new BlockBlobItem(hd.getETag(), hd.getLastModified(), hd.getContentMD5(), - hd.isXMsRequestServerEncrypted(), hd.getXMsEncryptionKeySha256(), hd.getXMsEncryptionScope(), - hd.getXMsVersionId()); - - assertNull(blockBlobItem.getETag()); - assertNull(blockBlobItem.getLastModified()); - assertNull(blockBlobItem.getContentMd5()); - assertNull(blockBlobItem.isServerEncrypted()); - assertNull(blockBlobItem.getEncryptionKeySha256()); - assertNull(blockBlobItem.getEncryptionScope()); - assertNull(blockBlobItem.getVersionId()); - } - - @Test - public void defaultAudience() { - BlockBlobClient aadBlob = getSpecializedBuilderWithTokenCredential(blockBlobClient.getBlobUrl()).audience(null) - .buildBlockBlobClient(); - - assertTrue(aadBlob.exists()); - } - - @Test - public void storageAccountAudience() { - BlockBlobClient aadBlob = getSpecializedBuilderWithTokenCredential(blockBlobClient.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(cc.getAccountName())) - .buildBlockBlobClient(); - - assertTrue(aadBlob.exists()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - BlockBlobClient aadBlob = getSpecializedBuilderWithTokenCredential(blockBlobClient.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildBlockBlobClient(); - - assertNotNull(aadBlob.getProperties()); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", cc.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - BlockBlobClient aadBlob - = getSpecializedBuilderWithTokenCredential(blockBlobClient.getBlobUrl()).audience(audience) - .buildBlockBlobClient(); - - assertTrue(aadBlob.exists()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAsyncApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAsyncApiTests.java deleted file mode 100644 index 88fef0b12c91..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAsyncApiTests.java +++ /dev/null @@ -1,2694 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.rest.Response; -import com.azure.core.test.http.MockHttpResponse; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.ProgressListener; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobServiceClientBuilder; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.BlobUrlParts; -import com.azure.storage.blob.ProgressReceiver; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobCopySourceTagsMode; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.Block; -import com.azure.storage.blob.models.BlockBlobItem; -import com.azure.storage.blob.models.BlockList; -import com.azure.storage.blob.models.BlockListType; -import com.azure.storage.blob.models.CustomerProvidedKey; -import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.options.BlobCopyFromUrlOptions; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.BlobParallelUploadOptions; -import com.azure.storage.blob.options.BlobUploadFromFileOptions; -import com.azure.storage.blob.options.BlobUploadFromUrlOptions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobListBlocksOptions; -import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import com.azure.storage.common.test.shared.http.WireTapHttpClient; -import com.azure.storage.common.test.shared.policy.RequestAssertionPolicy; -import com.azure.storage.common.test.shared.policy.TransientFailureInjectingHttpPipelinePolicy; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.function.Tuple2; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.TimeoutException; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BlockBlobAsyncApiTests extends BlobTestBase { - - private BlockBlobAsyncClient blockBlobAsyncClient; - private BlobAsyncClient blobAsyncClient; - private String blobName; - private final List createdFiles = new ArrayList<>(); - - @BeforeEach - public void setup() { - blobName = generateBlobName(); - blobAsyncClient = ccAsync.getBlobAsyncClient(blobName); - blockBlobAsyncClient = blobAsyncClient.getBlockBlobAsyncClient(); - blockBlobAsyncClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true).block(); - } - - @AfterEach - public void cleanup() { - createdFiles.forEach(File::delete); - } - - @Test - public void stageBlock() { - StepVerifier - .create(blockBlobAsyncClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultFlux(), - DATA.getDefaultDataSize(), null, null)) - .assertNext(r -> { - HttpHeaders headers = r.getHeaders(); - - assertResponseStatusCode(r, 201); - assertNotNull(headers.getValue(X_MS_CONTENT_CRC64)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(HttpHeaderName.DATE)); - assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - }) - .verifyComplete(); - } - - @Test - public void stageBlockWithBinaryData() { - BinaryData.fromFlux(DATA.getDefaultFlux(), (long) DATA.getDefaultDataSize(), false).flatMap(flux -> { - List binaryDataList = Arrays.asList(BinaryData.fromBytes(DATA.getDefaultBytes()), - BinaryData.fromString(DATA.getDefaultText()), BinaryData.fromFile(DATA.getDefaultFile()), flux, - BinaryData.fromStream(DATA.getDefaultInputStream(), (long) DATA.getDefaultDataSize())); - - for (BinaryData binaryData : binaryDataList) { - StepVerifier - .create(blockBlobAsyncClient - .stageBlockWithResponse(new BlockBlobStageBlockOptions(getBlockID(), binaryData))) - .assertNext(it -> { - HttpHeaders headers = it.getHeaders(); - assertResponseStatusCode(it, 201); - assertNotNull(headers.getValue(X_MS_CONTENT_CRC64)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertNotNull(headers.getValue(HttpHeaderName.DATE)); - assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - }) - .verifyComplete(); - } - - return Mono.empty(); - }); - } - - @Test - public void stageBlockMin() { - assertAsyncResponseStatusCode(blockBlobAsyncClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultFlux(), - DATA.getDefaultDataSize(), null, null), 201); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)) - .assertNext(r -> assertEquals(1, r.getUncommittedBlocks().size())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("stageBlockMinwithBinaryDataSupplier") - public void stageBlockMinWithBinaryData(BinaryData binaryData) { - assertAsyncResponseStatusCode( - blockBlobAsyncClient.stageBlockWithResponse(new BlockBlobStageBlockOptions(getBlockID(), binaryData)), 201); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)) - .assertNext(r -> assertEquals(1, r.getUncommittedBlocks().size())) - .verifyComplete(); - } - - private static Stream stageBlockMinwithBinaryDataSupplier() { - return Stream.of(Arguments.of(BinaryData.fromBytes(DATA.getDefaultBytes())), - Arguments.of(BinaryData.fromString(DATA.getDefaultText())), - Arguments.of(BinaryData.fromFile(DATA.getDefaultFile())), - Arguments.of(BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong()))); - } - - @Test - public void stageBlockMinwithBinaryDataFromFlux() { - Mono> response = BinaryData.fromFlux(DATA.getDefaultFlux(), DATA.getDefaultDataSizeLong(), false) - .flatMap(r -> blockBlobAsyncClient.stageBlockWithResponse(new BlockBlobStageBlockOptions(getBlockID(), r))); - - assertAsyncResponseStatusCode(response, 201); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)) - .assertNext(r -> assertEquals(1, r.getUncommittedBlocks().size())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("stageBlockDoesNotTransformReplayableBinaryDataSupplier") - public void stageBlockDoesNotTransformReplayableBinaryData(BinaryData binaryData) { - WireTapHttpClient wireTap = new WireTapHttpClient(getHttpClient()); - BlockBlobAsyncClient wireTapClient - = getSpecializedBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), blockBlobAsyncClient.getBlobUrl()) - .httpClient(wireTap) - .buildBlockBlobAsyncClient(); - - assertAsyncResponseStatusCode( - wireTapClient.stageBlockWithResponse(new BlockBlobStageBlockOptions(getBlockID(), binaryData)), 201); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)) - .assertNext(r -> assertEquals(1, r.getUncommittedBlocks().size())) - .verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(wireTap.getLastRequest().getBody())) - .assertNext(r -> assertArrayEquals(binaryData.toBytes(), r)) - .verifyComplete(); - } - - private static Stream stageBlockDoesNotTransformReplayableBinaryDataSupplier() { - return Stream.of(Arguments.of(BinaryData.fromBytes(DATA.getDefaultBytes())), - Arguments.of(BinaryData.fromString(DATA.getDefaultText())), - Arguments.of(BinaryData.fromFile(DATA.getDefaultFile()))); - } - - @ParameterizedTest - @MethodSource("stageBlockIllegalArgumentsSupplier") - public void stageBlockIllegalArguments(boolean getBlockId, Flux stream, int dataSize, - Class exceptionType) { - String blockID = (getBlockId) ? getBlockID() : null; - StepVerifier.create(blockBlobAsyncClient.stageBlock(blockID, stream, dataSize)).verifyError(exceptionType); - } - - private static Stream stageBlockIllegalArgumentsSupplier() { - return Stream.of( - Arguments.of(false, DATA.getDefaultFlux(), DATA.getDefaultDataSize(), BlobStorageException.class), - Arguments.of(true, null, DATA.getDefaultDataSize(), NullPointerException.class), - Arguments.of(true, DATA.getDefaultFlux(), DATA.getDefaultDataSize() + 1, UnexpectedLengthException.class), - Arguments.of(true, DATA.getDefaultFlux(), DATA.getDefaultDataSize() - 1, UnexpectedLengthException.class)); - } - - @Test - public void stageBlockIllegalArgumentsWithBinaryData() { - //This is done without a parameterized test as the toString call updates the internal length being stored, - //resulting in incorrect test behavior. - try { - StepVerifier.create(blockBlobAsyncClient.stageBlock(getBlockID(), null)).verifyComplete(); - } catch (NullPointerException e) { - //StepVerifier cant handle the error in the creation of BlockBlobStageBlockOptions - assertEquals("The argument must not be null or an empty string. Argument name:" + " data must not be null.", - e.getMessage()); - } - - try { - BinaryData data = BinaryData.fromStream(DATA.getDefaultInputStream(), null); - StepVerifier.create(blockBlobAsyncClient.stageBlock(getBlockID(), data)).verifyComplete(); - } catch (NullPointerException e) { - //StepVerifier cant handle the error in the creation of BlockBlobStageBlockOptions - assertEquals( - "The argument must not be null or an empty string. Argument name: data must have" + " defined length.", - e.getMessage()); - } - - BinaryData binaryData = BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong() + 1); - StepVerifier.create(blockBlobAsyncClient.stageBlock(getBlockID(), binaryData)) - .verifyError(UnexpectedLengthException.class); - - BinaryData binaryData1 = BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong() - 1); - StepVerifier.create(blockBlobAsyncClient.stageBlock(getBlockID(), binaryData1)) - .verifyError(UnexpectedLengthException.class); - } - - @Test - public void stageBlockEmptyBody() { - StepVerifier.create(blockBlobAsyncClient.stageBlock(getBlockID(), Flux.just(ByteBuffer.wrap(new byte[0])), 0)) - .verifyError(BlobStorageException.class); - } - - @Test - public void stageBlockTransactionalMD5() throws NoSuchAlgorithmException { - byte[] md5 = MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()); - - assertAsyncResponseStatusCode(blockBlobAsyncClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultFlux(), - DATA.getDefaultDataSize(), md5, null), 201); - } - - @Test - public void stageBlockTransactionalMD5fail() throws NoSuchAlgorithmException { - StepVerifier - .create(blockBlobAsyncClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultFlux(), - DATA.getDefaultDataSize(), MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null)) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.MD5MISMATCH, e.getErrorCode()); - }); - } - - @Test - public void stageBlockTransactionalMD5FailBinaryData() throws NoSuchAlgorithmException { - StepVerifier - .create(blockBlobAsyncClient.stageBlockWithResponse( - new BlockBlobStageBlockOptions(getBlockID(), BinaryData.fromBytes(DATA.getDefaultBytes())) - .setContentMd5(MessageDigest.getInstance("MD5").digest("garbage".getBytes())))) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.MD5MISMATCH, e.getErrorCode()); - }); - } - - @Test - public void stageBlockNullBody() { - StepVerifier.create(blockBlobAsyncClient.stageBlock(getBlockID(), null, 0)) - .verifyError(NullPointerException.class); - } - - @Test - public void stageBlockLease() { - Mono> response - = setupBlobLeaseCondition(blockBlobAsyncClient, RECEIVED_LEASE_ID).flatMap(r -> blockBlobAsyncClient - .stageBlockWithResponse(getBlockID(), DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, r)); - - assertAsyncResponseStatusCode(response, 201); - } - - @Test - public void stageBlockLeaseBinaryData() { - Mono> response = setupBlobLeaseCondition(blockBlobAsyncClient, RECEIVED_LEASE_ID) - .flatMap(r -> blockBlobAsyncClient.stageBlockWithResponse( - new BlockBlobStageBlockOptions(getBlockID(), BinaryData.fromBytes(DATA.getDefaultBytes())) - .setLeaseId(r))); - - assertAsyncResponseStatusCode(response, 201); - } - - @Test - public void stageBlockLeaseFail() { - StepVerifier.create(setupBlobLeaseCondition(blockBlobAsyncClient, RECEIVED_LEASE_ID) - .then(blockBlobAsyncClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultFlux(), - DATA.getDefaultDataSize(), null, GARBAGE_LEASE_ID))) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION, e.getErrorCode()); - }); - } - - @Test - public void stageBlockError() { - blockBlobAsyncClient = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - StepVerifier.create(blockBlobAsyncClient.stageBlock("id", DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .verifyError(BlobStorageException.class); - } - - @Test - public void stageBlockRetryOnTransientFailure() { - BlockBlobAsyncClient clientWithFailure = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - blobAsyncClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getBlockBlobAsyncClient(); - - byte[] data = getRandomByteArray(10); - String blockId = getBlockID(); - - Mono response = clientWithFailure.stageBlock(blockId, Flux.just(ByteBuffer.wrap(data)), data.length) - .then(blobAsyncClient.getBlockBlobAsyncClient().commitBlockList(Collections.singletonList(blockId), true)) - .then(FluxUtil.collectBytesInByteBufferStream(blobAsyncClient.downloadStream())); - - StepVerifier.create(response).assertNext(r -> TestUtils.assertArraysEqual(data, r)).verifyComplete(); - } - - @Test - public void stageBlockRetryOnTransientFailureWithRetriableBinaryData() { - List binaryDataList = Arrays.asList(BinaryData.fromBytes(DATA.getDefaultBytes()), - BinaryData.fromString(DATA.getDefaultText()), BinaryData.fromFile(DATA.getDefaultFile())); - BlockBlobAsyncClient clientWithFailure = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - blobAsyncClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getBlockBlobAsyncClient(); - - for (BinaryData binaryData : binaryDataList) { - String blockId = getBlockID(); - - Mono response = clientWithFailure.stageBlock(blockId, binaryData) - .then( - blobAsyncClient.getBlockBlobAsyncClient().commitBlockList(Collections.singletonList(blockId), true)) - .then(FluxUtil.collectBytesInByteBufferStream(blobAsyncClient.downloadStream())); - - StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(binaryData.toBytes(), r)) - .verifyComplete(); - } - } - - @Test - public void stageBlockFromUrl() { - BlockBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - String blockID = getBlockID(); - - String sas - = blockBlobAsyncClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - StepVerifier - .create(bu2.stageBlockFromUrlWithResponse(blockID, blockBlobAsyncClient.getBlobUrl() + "?" + sas, null, - null, null, null)) - .assertNext(r -> { - HttpHeaders headers = r.getHeaders(); - assertNotNull(headers.getValue(X_MS_CONTENT_CRC64)); - assertNotNull(headers.getValue(X_MS_REQUEST_ID)); - assertNotNull(headers.getValue(X_MS_VERSION)); - assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - }) - .verifyComplete(); - - StepVerifier.create(bu2.listBlocks(BlockListType.ALL)).assertNext(r -> { - assertEquals(1, r.getUncommittedBlocks().size()); - assertEquals(0, r.getCommittedBlocks().size()); - assertEquals(blockID, r.getUncommittedBlocks().get(0).getName()); - }).verifyComplete(); - - StepVerifier.create(bu2.commitBlockList(Collections.singletonList(blockID)).thenMany(bu2.downloadStream())) - .assertNext(r -> assertEquals(DATA.getDefaultData(), r)) - .verifyComplete(); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void stageBlockFromUrlSourceErrorAndStatusCode() { - BlockBlobAsyncClient destBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - String blockID = getBlockID(); - - StepVerifier.create(destBlob.stageBlockFromUrl(blockID, blockBlobAsyncClient.getBlobUrl(), new BlobRange(0, (long) PageBlobClient.PAGE_BYTES))) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }); - }*/ - - @Test - public void stageBlockFromUrlMin() { - BlockBlobAsyncClient bu2 = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - String blockID = getBlockID(); - - String sas - = blockBlobAsyncClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertAsyncResponseStatusCode(bu2.stageBlockFromUrlWithResponse(blockID, - blockBlobAsyncClient.getBlobUrl() + "?" + sas, null, null, null, null), 201); - } - - @ParameterizedTest - @MethodSource("stageBlockFromURLIASupplier") - public void stageBlockFromURLIA(boolean getBlockId, String sourceURL, Class exceptionType) { - String blockID = (getBlockId) ? getBlockID() : null; - StepVerifier.create(blockBlobAsyncClient.stageBlockFromUrl(blockID, sourceURL, null)) - .verifyError(exceptionType); - } - - private static Stream stageBlockFromURLIASupplier() { - return Stream.of(Arguments.of(false, "http://www.example.com", BlobStorageException.class), - Arguments.of(true, null, IllegalArgumentException.class)); - } - - @Test - public void stageBlockFromURLRange() { - BlockBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - String sas - = blockBlobAsyncClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - StepVerifier.create(destURL - .stageBlockFromUrl(getBlockID(), blockBlobAsyncClient.getBlobUrl() + "?" + sas, new BlobRange(2L, 3L)) - .then(destURL.listBlocks(BlockListType.UNCOMMITTED))).assertNext(r -> { - assertEquals(0, r.getCommittedBlocks().size()); - assertEquals(1, r.getUncommittedBlocks().size()); - }).verifyComplete(); - } - - @Test - public void stageBlockFromURLMD5() throws NoSuchAlgorithmException { - BlockBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - String sas - = blockBlobAsyncClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - StepVerifier - .create(destURL.stageBlockFromUrlWithResponse(getBlockID(), blockBlobAsyncClient.getBlobUrl() + "?" + sas, - null, MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()), null, null)) - .expectNextCount(1) - .verifyComplete(); - } - - @Test - public void stageBlockFromURLMD5Fail() { - BlockBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - String sas - = blockBlobAsyncClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - StepVerifier - .create(destURL.stageBlockFromUrlWithResponse(getBlockID(), blockBlobAsyncClient.getBlobUrl() + "?" + sas, - null, "garbage".getBytes(), null, null)) - .verifyError(BlobStorageException.class); - } - - @Test - public void stageBlockFromURLLease() { - String sas - = blockBlobAsyncClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - Mono> response = setupBlobLeaseCondition(blockBlobAsyncClient, RECEIVED_LEASE_ID) - .flatMap(r -> blockBlobAsyncClient.stageBlockFromUrlWithResponse(getBlockID(), - blockBlobAsyncClient.getBlobUrl() + "?" + sas, null, null, r, null)); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @Test - public void stageBlockFromURLLeaseFail() { - String sas - = blockBlobAsyncClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - StepVerifier - .create(blockBlobAsyncClient.stageBlockFromUrlWithResponse(getBlockID(), - blockBlobAsyncClient.getBlobUrl() + "?" + sas, null, null, "garbage", null)) - .verifyError(BlobStorageException.class); - } - - @Test - public void stageBlockFromURLError() { - blockBlobAsyncClient = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()) - .getBlobAsyncClient(generateBlobName()) - .getBlockBlobAsyncClient(); - - StepVerifier - .create(blockBlobAsyncClient.stageBlockFromUrl(getBlockID(), blockBlobAsyncClient.getBlobUrl(), null)) - .verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("stageBlockFromURLSourceACSupplier") - public void stageBlockFromURLSourceAC(OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch) { - String blockID = getBlockID(); - - BlockBlobAsyncClient sourceURL = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - Mono> response = sourceURL.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(setupBlobMatchCondition(sourceURL, sourceIfMatch)) - .flatMap(condition -> { - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(convertNull(condition)) - .setIfNoneMatch(sourceIfNoneMatch); - return blockBlobAsyncClient.stageBlockFromUrlWithResponse(blockID, sourceURL.getBlobUrl() + "?" + sas, - null, null, null, smac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - private static Stream stageBlockFromURLSourceACSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of(OLD_DATE, null, null, null), - Arguments.of(null, NEW_DATE, null, null), Arguments.of(null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, GARBAGE_ETAG)); - } - - @ParameterizedTest - @MethodSource("stageBlockFromURLSourceACFailSupplier") - public void stageBlockFromURLSourceACFail(OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch) { - String blockID = getBlockID(); - BlockBlobAsyncClient sourceURL = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - Mono> response = sourceURL.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(setupBlobMatchCondition(sourceURL, sourceIfNoneMatch)) - .flatMap(condition -> { - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(sourceIfMatch) - .setIfNoneMatch(convertNull(condition)); - - return blockBlobAsyncClient.stageBlockFromUrlWithResponse(blockID, sourceURL.getBlobUrl() + "?" + sas, - null, null, null, smac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream stageBlockFromURLSourceACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null), Arguments.of(null, OLD_DATE, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null), Arguments.of(null, null, null, RECEIVED_ETAG)); - } - - @Test - public void commitBlockList() { - String blockID = getBlockID(); - List ids = Collections.singletonList(blockID); - - StepVerifier.create(blockBlobAsyncClient.stageBlock(blockID, DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(blockBlobAsyncClient.commitBlockListWithResponse(ids, null, null, null, null))).assertNext(r -> { - assertResponseStatusCode(r, 201); - HttpHeaders headers = r.getHeaders(); - validateBasicHeaders(headers); - assertNotNull(headers.getValue(X_MS_CONTENT_CRC64)); - assertTrue(Boolean.parseBoolean(headers.getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - }).verifyComplete(); - } - - @Test - public void commitBlockListmin() { - blockBlobAsyncClient = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - String blockID = getBlockID(); - List ids = Collections.singletonList(blockID); - - StepVerifier.create(blockBlobAsyncClient.stageBlock(blockID, DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(blockBlobAsyncClient.commitBlockList(ids))).expectNextCount(1).verifyComplete(); - } - - @Test - public void commitBlockListMinNoOverwrite() { - StepVerifier.create(blockBlobAsyncClient.commitBlockList(new ArrayList<>())).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.BLOB_ALREADY_EXISTS, e.getErrorCode()); - }); - } - - @Test - public void commitBlockListOverwrite() { - StepVerifier.create(blockBlobAsyncClient.commitBlockList(new ArrayList<>(), true)) - .expectNextCount(1) - .verifyComplete(); - } - - @Test - public void commitBlockListNull() { - assertAsyncResponseStatusCode(blockBlobAsyncClient.commitBlockListWithResponse(null, null, null, null, null), - 201); - } - - @ParameterizedTest - @MethodSource("commitBlockListHeadersSupplier") - public void commitBlockListHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - String blockID = getBlockID(); - List ids = Collections.singletonList(blockID); - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - // If the value isn't set the service will automatically set it - contentType = (contentType == null) ? "application/octet-stream" : contentType; - String finalContentType = contentType; - - Mono> response - = blockBlobAsyncClient.stageBlock(blockID, DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(blockBlobAsyncClient.commitBlockListWithResponse(ids, headers, null, null, null)) - .then(blockBlobAsyncClient.getPropertiesWithResponse(null)); - - StepVerifier.create(response) - .assertNext(r -> validateBlobProperties(r, cacheControl, contentDisposition, contentEncoding, - contentLanguage, contentMD5, finalContentType)) - .verifyComplete(); - } - - private static Stream commitBlockListHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), Arguments.of("control", "disposition", - "encoding", "language", MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()), "type")); - } - - @ParameterizedTest - @MethodSource("commitBlockListMetadataSupplier") - public void commitBlockListMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - StepVerifier.create(blockBlobAsyncClient.commitBlockListWithResponse(null, null, metadata, null, null) - .then(blockBlobAsyncClient.getPropertiesWithResponse(null))).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(metadata, r.getValue().getMetadata()); - }).verifyComplete(); - } - - private static Stream commitBlockListMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("commitBlockListTagsSupplier") - public void commitBlockListTags(String key1, String value1, String key2, String value2) { - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - StepVerifier.create( - blockBlobAsyncClient.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(null).setTags(tags)) - .then(blockBlobAsyncClient.getTagsWithResponse(new BlobGetTagsOptions()))) - .assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(tags, r.getValue()); - }) - .verifyComplete(); - } - - private static Stream commitBlockListTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void commitBlockListAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = blockBlobAsyncClient.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(blockBlobAsyncClient, leaseID), - setupBlobMatchCondition(blockBlobAsyncClient, match), BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return blockBlobAsyncClient.commitBlockListWithResponse(null, null, null, null, bac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void commitBlockListACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - - Mono> response = Mono - .zip(setupBlobLeaseCondition(blockBlobAsyncClient, leaseID), - setupBlobMatchCondition(blockBlobAsyncClient, noneMatch), BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return blockBlobAsyncClient.commitBlockListWithResponse(null, null, null, null, bac); - }); - - StepVerifier.create(response).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertTrue(e.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET - || e.getErrorCode() == BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION); - }); - } - - @Test - public void commitBlockListError() { - blockBlobAsyncClient = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - StepVerifier.create(blockBlobAsyncClient.commitBlockListWithResponse(new ArrayList<>(), null, null, null, - new BlobRequestConditions().setLeaseId("garbage"))).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void commitBlockListColdTier() { - blockBlobAsyncClient = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - String blockID = getBlockID(); - List ids = Collections.singletonList(blockID); - BlockBlobCommitBlockListOptions commitOptions - = new BlockBlobCommitBlockListOptions(ids).setTier(AccessTier.COLD); - - Mono response - = blockBlobAsyncClient.stageBlock(blockID, DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(blockBlobAsyncClient.commitBlockListWithResponse(commitOptions)) - .then(blockBlobAsyncClient.getProperties()); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(AccessTier.COLD, r.getAccessTier())) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - @Test - public void getBlockList() { - List committedBlocks = Arrays.asList(getBlockID(), getBlockID()); - - List uncommittedBlocks = Arrays.asList(getBlockID(), getBlockID()); - - uncommittedBlocks.sort(String::compareTo); - - Set actualCommittedBlocks = new HashSet<>(); - Set actualUncommittedBlocks = new HashSet<>(); - - Mono step - = blockBlobAsyncClient.stageBlock(committedBlocks.get(0), DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(blockBlobAsyncClient.stageBlock(committedBlocks.get(1), DATA.getDefaultFlux(), - DATA.getDefaultDataSize())) - .then(blockBlobAsyncClient.commitBlockList(committedBlocks, true)) - .then(blockBlobAsyncClient.stageBlock(uncommittedBlocks.get(0), DATA.getDefaultFlux(), - DATA.getDefaultDataSize())) - .then(blockBlobAsyncClient.stageBlock(uncommittedBlocks.get(1), DATA.getDefaultFlux(), - DATA.getDefaultDataSize())) - .then(blockBlobAsyncClient.listBlocks(BlockListType.ALL)); - - StepVerifier.create(step).assertNext(r -> { - for (Block block : r.getCommittedBlocks()) { - actualCommittedBlocks.add(block.getName()); - assertEquals(DATA.getDefaultDataSize(), block.getSize()); - } - - for (Block block : r.getUncommittedBlocks()) { - actualUncommittedBlocks.add(block.getName()); - assertEquals(DATA.getDefaultDataSize(), block.getSize()); - } - - }).verifyComplete(); - - assertEquals(new HashSet<>(committedBlocks), actualCommittedBlocks); - assertEquals(new HashSet<>(uncommittedBlocks), actualUncommittedBlocks); - } - - @Test - public void getBlockListMin() { - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)).expectNextCount(1).verifyComplete(); - } - - @ParameterizedTest - @MethodSource("getBlockListTypeSupplier") - public void getBlockListType(BlockListType type, int committedCount, int uncommittedCount) { - String blockID = getBlockID(); - - Mono response - = blockBlobAsyncClient.stageBlock(blockID, DATA.getDefaultFlux(), DATA.getDefaultDataSize()) - .then(blockBlobAsyncClient.commitBlockList(Collections.singletonList(blockID), true)) - .then(blockBlobAsyncClient.stageBlock(getBlockID(), DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .then(blockBlobAsyncClient.listBlocks(type)); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(committedCount, r.getCommittedBlocks().size()); - assertEquals(uncommittedCount, r.getUncommittedBlocks().size()); - }).verifyComplete(); - } - - private static Stream getBlockListTypeSupplier() { - return Stream.of(Arguments.of(BlockListType.ALL, 1, 1), Arguments.of(BlockListType.COMMITTED, 1, 0), - Arguments.of(BlockListType.UNCOMMITTED, 0, 1)); - } - - @Test - public void getBlockListTypeNull() { - StepVerifier.create(blockBlobAsyncClient.listBlocks(null)) - .assertNext(r -> assertDoesNotThrow(() -> r.getCommittedBlocks().iterator().hasNext())) - .verifyComplete(); - } - - @Test - public void getBlockListLease() { - Mono> response = setupBlobLeaseCondition(blockBlobAsyncClient, RECEIVED_LEASE_ID) - .flatMap(r -> blockBlobAsyncClient.listBlocksWithResponse(BlockListType.ALL, r)); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @Test - public void getBlockListLeaseFail() { - StepVerifier - .create(setupBlobLeaseCondition(blockBlobAsyncClient, GARBAGE_LEASE_ID) - .then(blockBlobAsyncClient.listBlocksWithResponse(BlockListType.ALL, GARBAGE_LEASE_ID))) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION, e.getErrorCode()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getBlockListTags() { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - StepVerifier - .create(blockBlobAsyncClient.setTags(t) - .then(blockBlobAsyncClient.listBlocksWithResponse( - new BlockBlobListBlocksOptions(BlockListType.ALL).setIfTagsMatch("\"foo\" = 'bar'")))) - .expectNextCount(1) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @Test - public void getBlockListTagsFail() { - StepVerifier - .create(blockBlobAsyncClient.listBlocksWithResponse( - new BlockBlobListBlocksOptions(BlockListType.ALL).setIfTagsMatch("\"notfoo\" = 'notbar'"))) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.CONDITION_NOT_MET, e.getErrorCode()); - }); - } - - @Test - public void getBlockListError() { - blockBlobAsyncClient = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)).verifyError(BlobStorageException.class); - } - - @Test - public void upload() { - StepVerifier - .create(blockBlobAsyncClient.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, - null, null, null, null)) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - validateBasicHeaders(r.getHeaders()); - assertNotNull(r.getHeaders().getValue(HttpHeaderName.CONTENT_MD5)); - assertTrue(Boolean.parseBoolean(r.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - }) - .verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(blockBlobAsyncClient.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(r, DATA.getDefaultBytes())) - .verifyComplete(); - } - - // Override name to prevent BinaryData.toString() invocation by test framework. - @Test - public void uploadBinaryData() { - BinaryData.fromFlux(DATA.getDefaultFlux(), (long) DATA.getDefaultDataSize(), false).flatMap(flux -> { - List binaryDataList = Arrays.asList(BinaryData.fromBytes(DATA.getDefaultBytes()), - BinaryData.fromString(DATA.getDefaultText()), BinaryData.fromFile(DATA.getDefaultFile()), flux, - BinaryData.fromStream(DATA.getDefaultInputStream(), (long) DATA.getDefaultDataSize())); - - for (BinaryData binaryData : binaryDataList) { - BlockBlobSimpleUploadOptions uploadOptions = new BlockBlobSimpleUploadOptions(binaryData); - StepVerifier.create(blockBlobAsyncClient.uploadWithResponse(uploadOptions)).assertNext(r -> { - assertResponseStatusCode(r, 201); - validateBasicHeaders(r.getHeaders()); - assertNotNull(r.getHeaders().getValue(HttpHeaderName.CONTENT_MD5)); - assertTrue(Boolean.parseBoolean(r.getHeaders().getValue(X_MS_REQUEST_SERVER_ENCRYPTED))); - }).verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(blockBlobAsyncClient.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(r, DATA.getDefaultBytes())) - .verifyComplete(); - } - return Mono.empty(); - }); - } - - // Override name to prevent BinaryData.toString() invocation by test framework. - @ParameterizedTest - @MethodSource("stageBlockDoesNotTransformReplayableBinaryDataSupplier") - public void uploadDoesNotTransformReplayableBinaryData(BinaryData binaryData) { - BlockBlobSimpleUploadOptions uploadOptions = new BlockBlobSimpleUploadOptions(binaryData); - WireTapHttpClient wireTap = new WireTapHttpClient(getHttpClient()); - BlockBlobAsyncClient wireTapClient - = getSpecializedBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), blockBlobAsyncClient.getBlobUrl()) - .httpClient(wireTap) - .buildBlockBlobAsyncClient(); - - assertAsyncResponseStatusCode(wireTapClient.uploadWithResponse(uploadOptions), 201); - - // Check that replayable BinaryData contents are passed to http client unchanged. - assertEquals(binaryData, wireTap.getLastRequest().getBodyAsBinaryData()); - } - - /* Upload From File Tests: Need to run on liveMode only since blockBlob wil generate a `UUID.randomUUID()` - for getBlockID that will change every time test is run - */ - @LiveOnly - @ParameterizedTest - @MethodSource("uploadFromFileSupplier") - public void uploadFromFile(int fileSize, Long blockSize, int committedBlockCount) throws IOException { - File file = getRandomFile(fileSize); - file.deleteOnExit(); - createdFiles.add(file); - - BlobAsyncClient uploadBlobAsyncClient - = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), blobAsyncClient.getBlobUrl(), - new RequestAssertionPolicy( - request -> request.getBodyAsBinaryData() == null || request.getBodyAsBinaryData().isReplayable(), - "File upload should be sending replayable request data")); - - // Block length will be ignored for single shot. - StepVerifier.create(uploadBlobAsyncClient.uploadFromFile(file.getPath(), - new ParallelTransferOptions().setBlockSizeLong(blockSize), null, null, null, null)).verifyComplete(); - - File outFile = new File(file.getPath() + "result"); - createdFiles.add(outFile); - outFile.createNewFile(); - outFile.deleteOnExit(); - Files.deleteIfExists(outFile.toPath()); - - Mono> tuple - = Mono.zip(blobAsyncClient.getBlockBlobAsyncClient().listBlocks(BlockListType.COMMITTED), - FluxUtil.collectBytesInByteBufferStream(blobAsyncClient.downloadStream())); - - StepVerifier.create(tuple).assertNext(r -> { - try { - FileOutputStream outStream = new FileOutputStream(outFile); - outStream.write(Objects.requireNonNull(r.getT2())); - outStream.close(); - compareFiles(file, outFile, 0, fileSize); - } catch (IOException e) { - throw new RuntimeException(e); - } - assertEquals(committedBlockCount, r.getT1().getCommittedBlocks().size()); - }).verifyComplete(); - } - - @SuppressWarnings("deprecation") - private static Stream uploadFromFileSupplier() { - return Stream.of(Arguments.of(0, null, 0), // Size is too small to trigger stage block uploading - Arguments.of(10, null, 0), // Size is too small to trigger stage block uploading - Arguments.of(10 * Constants.KB, null, 0), // Size is too small to trigger stage block uploading - Arguments.of(50 * Constants.MB, null, 0), // Size is too small to trigger stage block uploading - Arguments.of(BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES + 1, null, - // HTBB optimizations should trigger when file size is >100MB and defaults are used. - (int) Math.ceil((BlockBlobClient.MAX_UPLOAD_BLOB_BYTES + 1.0) - / BlobAsyncClient.BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE)), - // Size is too small to trigger stage block uploading - Arguments.of(101 * Constants.MB, 4L * 1024 * 1024, 0)); - } - - @LiveOnly - @Test - public void uploadFromFileWithMetadata() throws IOException { - Map metadata = Collections.singletonMap("metadata", "value"); - File file = getRandomFile(Constants.KB); - file.deleteOnExit(); - createdFiles.add(file); - - StepVerifier - .create(blobAsyncClient.uploadFromFile(file.getAbsolutePath(), null, null, metadata, null, null) - .then(blockBlobAsyncClient.getProperties())) - .assertNext(r -> assertEquals(metadata, r.getMetadata())) - .verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(blockBlobAsyncClient.downloadStream())) - .assertNext(r -> { - try { - TestUtils.assertArraysEqual(r, Files.readAllBytes(file.toPath())); - } catch (IOException e) { - throw new RuntimeException(e); - } - }) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @LiveOnly - @Test - public void uploadFromFileWithTags() throws IOException { - Map tags = Collections.singletonMap(testResourceNamer.randomName(prefix, 20), - testResourceNamer.randomName(prefix, 20)); - File file = getRandomFile(Constants.KB); - file.deleteOnExit(); - createdFiles.add(file); - - StepVerifier.create(blobAsyncClient - .uploadFromFileWithResponse(new BlobUploadFromFileOptions(file.getAbsolutePath()).setTags(tags)) - .then(blockBlobAsyncClient.getTags())).assertNext(r -> assertEquals(tags, r)).verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(blockBlobAsyncClient.downloadStream())) - .assertNext(r -> { - try { - TestUtils.assertArraysEqual(r, Files.readAllBytes(file.toPath())); - } catch (IOException e) { - throw new RuntimeException(e); - } - }) - .verifyComplete(); - } - - @LiveOnly - @Test - public void uploadFromFileDefaultNoOverwrite() throws IOException { - File file = getRandomFile(50); - file.deleteOnExit(); - createdFiles.add(file); - - StepVerifier.create(blobAsyncClient.uploadFromFile(file.toPath().toString())).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.BLOB_ALREADY_EXISTS, e.getErrorCode()); - }); - } - - @LiveOnly - @Test - public void uploadFromFileOverwrite() throws IOException { - File file = getRandomFile(50); - file.deleteOnExit(); - createdFiles.add(file); - - StepVerifier.create(blobAsyncClient.uploadFromFile(file.toPath().toString(), true)).verifyComplete(); - } - - /* - * Reports the number of bytes sent when uploading a file. This is different than other reporters which track the - * number of reportings as upload from file hooks into the loading data from disk data stream which is a hard-coded - * read size. - */ - @SuppressWarnings("deprecation") - static class FileUploadReporter implements ProgressReceiver { - private long reportedByteCount; - - @Override - public void reportProgress(long bytesTransferred) { - this.reportedByteCount = bytesTransferred; - } - - public long getReportedByteCount() { - return this.reportedByteCount; - } - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("uploadFromFileReporterSupplier") - @LiveOnly - public void uploadFromFileReporter(int size, Long blockSize, Integer bufferCount) throws IOException { - FileUploadReporter uploadReporter = new FileUploadReporter(); - File file = getRandomFile(size); - file.deleteOnExit(); - createdFiles.add(file); - - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxConcurrency(bufferCount) - .setProgressReceiver(uploadReporter) - .setMaxSingleUploadSizeLong(blockSize - 1); - - StepVerifier - .create(blobAsyncClient.uploadFromFile(file.toPath().toString(), parallelTransferOptions, null, null, null, - null)) - .verifyComplete(); - - assertEquals(size, uploadReporter.getReportedByteCount()); - } - - private static Stream uploadFromFileReporterSupplier() { - return Stream.of(Arguments.of(10 * Constants.MB, 10L * Constants.MB, 8), - Arguments.of(20 * Constants.MB, (long) Constants.MB, 5), - Arguments.of(10 * Constants.MB, 5L * Constants.MB, 2), - Arguments.of(10 * Constants.MB, 10L * Constants.KB, 100), Arguments.of(100, (long) Constants.MB, 2)); - } - - @ParameterizedTest - @MethodSource("uploadFromFileReporterSupplier") - @LiveOnly - public void uploadFromFileListener(int size, Long blockSize, Integer bufferCount) throws IOException { - FileUploadReporter uploadListener = new FileUploadReporter(); - File file = getRandomFile(size); - file.deleteOnExit(); - createdFiles.add(file); - - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxConcurrency(bufferCount) - .setProgressListener(uploadListener) - .setMaxSingleUploadSizeLong(blockSize - 1); - - StepVerifier - .create(blobAsyncClient.uploadFromFile(file.toPath().toString(), parallelTransferOptions, null, null, null, - null)) - .verifyComplete(); - - assertEquals(size, uploadListener.getReportedByteCount()); - } - - @ParameterizedTest - @MethodSource("uploadFromFileOptionsSupplier") - @LiveOnly - public void uploadFromFileOptions(int dataSize, Long singleUploadSize, Long blockSize, double expectedBlockCount) - throws IOException { - File file = getRandomFile(dataSize); - file.deleteOnExit(); - createdFiles.add(file); - - StepVerifier - .create(blobAsyncClient - .uploadFromFile(file.toPath().toString(), - new ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxSingleUploadSizeLong(singleUploadSize), - null, null, null, null) - .then(blobAsyncClient.getBlockBlobAsyncClient().listBlocks(BlockListType.COMMITTED))) - .assertNext(r -> assertEquals(expectedBlockCount, r.getCommittedBlocks().size())) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - private static Stream uploadFromFileOptionsSupplier() { - return Stream.of( - // Test that the default for singleUploadSize is the maximum - Arguments.of(BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES - 1, null, null, 0), - Arguments.of(BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES + 1, null, null, - /* This also validates the default for blockSize*/ - Math.ceil(((double) BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES + 1) - / (double) BlobClient.BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE)), - // Test that singleUploadSize is respected - Arguments.of(100, 50L, null, 1), - // Test that blockSize is respected - Arguments.of(100, 50L, 20L, 5)); - } - - @LiveOnly - @Test - // Reading from recordings will not allow for the timing of the test to work correctly. - public void uploadFromFileTimeout() throws IOException { - File file = getRandomFile(1024); - file.deleteOnExit(); - createdFiles.add(file); - - StepVerifier.create(blobAsyncClient.uploadFromFile(file.getPath()).timeout(Duration.ofNanos(5L))) - .verifyError(TimeoutException.class); - } - - @Test - public void uploadMin() { - StepVerifier - .create(blockBlobAsyncClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .then(FluxUtil.collectBytesInByteBufferStream(blockBlobAsyncClient.downloadStream()))) - .assertNext(r -> TestUtils.assertArraysEqual(r, DATA.getDefaultBytes())) - .verifyComplete(); - } - - // Override name to prevent BinaryData.toString() invocation by test framework. - @Test - public void uploadMinBinaryData() { - BinaryData.fromFlux(DATA.getDefaultFlux(), (long) DATA.getDefaultDataSize(), false).flatMap(flux -> { - List binaryDataList = Arrays.asList(BinaryData.fromBytes(DATA.getDefaultBytes()), - BinaryData.fromString(DATA.getDefaultText()), BinaryData.fromFile(DATA.getDefaultFile()), flux, - BinaryData.fromStream(DATA.getDefaultInputStream(), (long) DATA.getDefaultDataSize())); - - for (BinaryData binaryData : binaryDataList) { - StepVerifier - .create(blockBlobAsyncClient.upload(binaryData, true) - .then(FluxUtil.collectBytesInByteBufferStream(blockBlobAsyncClient.downloadStream()))) - .assertNext(r -> TestUtils.assertArraysEqual(r, DATA.getDefaultBytes())) - .verifyComplete(); - } - return Mono.empty(); - }); - } - - @ParameterizedTest - @MethodSource("uploadIllegalArgumentSupplier") - public void uploadIllegalArgument(Flux stream, long dataSize, - Class exceptionType) { - StepVerifier.create(blockBlobAsyncClient.upload(stream, dataSize)).verifyError(exceptionType); - } - - private static Stream uploadIllegalArgumentSupplier() { - return Stream.of(Arguments.of(null, DATA.getDefaultDataSize(), NullPointerException.class), - Arguments.of(DATA.getDefaultFlux(), DATA.getDefaultDataSize() + 1, UnexpectedLengthException.class), - Arguments.of(DATA.getDefaultFlux(), DATA.getDefaultDataSize() - 1, UnexpectedLengthException.class)); - } - - @Test - public void uploadIllegalArgumentBinaryData() { - assertThrows(NullPointerException.class, () -> blockBlobAsyncClient.upload(null)); - - assertThrows(NullPointerException.class, - () -> blockBlobAsyncClient.upload(BinaryData.fromStream(DATA.getDefaultInputStream(), null))); - - BinaryData badLength1 = BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong() + 1); - StepVerifier.create(blockBlobAsyncClient.upload(badLength1)).verifyError(UnexpectedLengthException.class); - - BinaryData badLength2 = BinaryData.fromStream(DATA.getDefaultInputStream(), DATA.getDefaultDataSizeLong() - 1); - StepVerifier.create(blockBlobAsyncClient.upload(badLength2)).verifyError(UnexpectedLengthException.class); - } - - @Test - public void uploadEmptyBody() { - assertAsyncResponseStatusCode(blockBlobAsyncClient.uploadWithResponse(Flux.just(ByteBuffer.wrap(new byte[0])), - 0, null, null, null, null, null), 201); - } - - @Test - public void uploadNullBody() { - StepVerifier.create(blockBlobAsyncClient.uploadWithResponse(null, 0, null, null, null, null, null)) - .verifyError(NullPointerException.class); - } - - @ParameterizedTest - @MethodSource("uploadHeadersSupplier") - public void uploadHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) throws NoSuchAlgorithmException { - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - // If the value isn't set the service will automatically set it - contentMD5 - = (contentMD5 == null) ? MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()) : contentMD5; - contentType = (contentType == null) ? "application/octet-stream" : contentType; - String finalContentType = contentType; - byte[] finalContentMD = contentMD5; - - StepVerifier - .create(blockBlobAsyncClient - .uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), headers, null, null, null, null) - .then(blockBlobAsyncClient.getPropertiesWithResponse(null))) - .assertNext(r -> validateBlobProperties(r, cacheControl, contentDisposition, contentEncoding, - contentLanguage, finalContentMD, finalContentType)) - .verifyComplete(); - } - - private static Stream uploadHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), Arguments.of("control", "disposition", - "encoding", "language", MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()), "type")); - } - - @Test - public void uploadTransactionalMD5() throws NoSuchAlgorithmException { - byte[] md5 = MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()); - - assertAsyncResponseStatusCode(blockBlobAsyncClient.uploadWithResponse(DATA.getDefaultFlux(), - DATA.getDefaultDataSize(), null, null, null, md5, null), 201); - } - - @Test - public void uploadTransactionalMD5Fail() throws NoSuchAlgorithmException { - StepVerifier - .create(blockBlobAsyncClient.stageBlockWithResponse(getBlockID(), DATA.getDefaultFlux(), - DATA.getDefaultDataSize(), MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null)) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.MD5MISMATCH, e.getErrorCode()); - }); - } - - @ParameterizedTest - @MethodSource("commitBlockListMetadataSupplier") - public void uploadMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - StepVerifier.create(blockBlobAsyncClient - .uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, metadata, null, null, null) - .then(blockBlobAsyncClient.getPropertiesWithResponse(null))).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(metadata, r.getValue().getMetadata()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("commitBlockListTagsSupplier") - public void uploadTags(String key1, String value1, String key2, String value2) { - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - StepVerifier.create(blockBlobAsyncClient - .uploadWithResponse( - new BlockBlobSimpleUploadOptions(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()).setTags(tags)) - .then(blockBlobAsyncClient.getTagsWithResponse(new BlobGetTagsOptions()))).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(tags, r.getValue()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void uploadAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = blockBlobAsyncClient.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(blockBlobAsyncClient, leaseID), - setupBlobMatchCondition(blockBlobAsyncClient, match), BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return blockBlobAsyncClient.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, - null, null, null, bac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void uploadACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - - Mono> response = Mono - .zip(setupBlobLeaseCondition(blockBlobAsyncClient, leaseID), - setupBlobMatchCondition(blockBlobAsyncClient, noneMatch), BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return blockBlobAsyncClient.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, - null, null, null, bac); - }); - - StepVerifier.create(response).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertTrue(e.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET - || e.getErrorCode() == BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION); - }); - } - - @Test - public void uploadError() { - blockBlobAsyncClient = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - StepVerifier - .create(blockBlobAsyncClient.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, - null, null, null, new BlobRequestConditions().setLeaseId("id"))) - .verifyError(BlobStorageException.class); - } - - @Test - public void uploadWithTier() { - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - StepVerifier - .create(bc.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null, AccessTier.COOL, - null, null).then(bc.getProperties())) - .assertNext(r -> assertEquals(AccessTier.COOL, r.getAccessTier())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void uploadWithAccessTierCold() { - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - StepVerifier - .create(bc.uploadWithResponse(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), null, null, AccessTier.COLD, - null, null).then(bc.getProperties())) - .assertNext(r -> assertEquals(AccessTier.COLD, r.getAccessTier())) - .verifyComplete(); - } - - @Test - public void uploadOverwriteFalse() { - StepVerifier.create(blockBlobAsyncClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize())) - .verifyError(BlobStorageException.class); - } - - @Test - public void uploadOverwriteTrue() { - StepVerifier.create(blockBlobAsyncClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true)) - .expectNextCount(1) - .verifyComplete(); - } - - @Test - public void uploadRetryOnTransientFailure() { - BlockBlobAsyncClient clientWithFailure = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - blobAsyncClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getBlockBlobAsyncClient(); - - clientWithFailure.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(blobAsyncClient.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(r, DATA.getDefaultBytes())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("bufferedUploadHandlePathingWithTransientFailureSupplier") - @LiveOnly - public void bufferedUploadHandlePathingWithTransientFailure(int dataSize, int blockCount) { - /* - This test ensures that although we no longer mark and reset the source stream for buffered upload, it still - supports retries in all cases for the sync client. - */ - BlobAsyncClient clientWithFailure = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - blobAsyncClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()); - - byte[] data = getRandomByteArray(dataSize); - - Mono response = clientWithFailure - .uploadWithResponse(new BlobParallelUploadOptions(BinaryData.fromBytes(data)) - .setParallelTransferOptions(new ParallelTransferOptions().setMaxSingleUploadSizeLong(2L * Constants.MB) - .setBlockSizeLong(2L * Constants.MB))) - .then(FluxUtil.collectBytesInByteBufferStream(blobAsyncClient.downloadStream())) - .flatMap(r -> { - TestUtils.assertArraysEqual(data, r); - return blobAsyncClient.getBlockBlobAsyncClient().listBlocks(BlockListType.ALL); - }); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(blockCount, r.getCommittedBlocks().size())) - .verifyComplete(); - } - - private static Stream bufferedUploadHandlePathingWithTransientFailureSupplier() { - return Stream.of(Arguments.of(11110, 0), Arguments.of(2 * Constants.MB + 11, 2)); - } - - @LiveOnly - @Test - public void bufferedUploadEmpty() { - StepVerifier.create(blobAsyncClient.upload(Flux.just(ByteBuffer.wrap(new byte[0])), null, true)) - .assertNext(it -> assertNotNull(it.getETag())) - .verifyComplete(); - - StepVerifier.create(blobAsyncClient.downloadStream()) - .assertNext(it -> assertEquals(0, it.remaining())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("bufferedUploadEmptyBuffersSupplier") - @LiveOnly - public void bufferedUploadEmptyBuffers(ByteBuffer buffer1, ByteBuffer buffer2, ByteBuffer buffer3, - byte[] expectedDownload) { - StepVerifier - .create(blobAsyncClient.upload(Flux.fromIterable(Arrays.asList(buffer1, buffer2, buffer3)), null, true)) - .assertNext(it -> assertNotNull(it.getETag())) - .verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(blobAsyncClient.downloadStream())) - .assertNext(it -> TestUtils.assertArraysEqual(it, expectedDownload)) - .verifyComplete(); - } - - private static Stream bufferedUploadEmptyBuffersSupplier() { - return Stream.of( - Arguments.of(ByteBuffer.wrap("Hello".getBytes(StandardCharsets.UTF_8)), - ByteBuffer.wrap(" ".getBytes(StandardCharsets.UTF_8)), - ByteBuffer.wrap("world!".getBytes(StandardCharsets.UTF_8)), - "Hello world!".getBytes(StandardCharsets.UTF_8)), - Arguments.of(ByteBuffer.wrap("Hello".getBytes(StandardCharsets.UTF_8)), - ByteBuffer.wrap(" ".getBytes(StandardCharsets.UTF_8)), ByteBuffer.wrap(new byte[0]), - "Hello ".getBytes(StandardCharsets.UTF_8)), - Arguments.of(ByteBuffer.wrap("Hello".getBytes(StandardCharsets.UTF_8)), ByteBuffer.wrap(new byte[0]), - ByteBuffer.wrap("world!".getBytes(StandardCharsets.UTF_8)), - "Helloworld!".getBytes(StandardCharsets.UTF_8)), - Arguments.of(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(" ".getBytes(StandardCharsets.UTF_8)), - ByteBuffer.wrap("world!".getBytes(StandardCharsets.UTF_8)), - " world!".getBytes(StandardCharsets.UTF_8))); - } - - // Only run these tests in live mode as they use variables that can't be captured. - @ParameterizedTest - @MethodSource("bufferedUploadSupplier") - @LiveOnly - public void bufferedUpload(int dataSize, long bufferSize, int numBuffs, int blockCount) { - BlobAsyncClient asyncClient = getPrimaryServiceClientForWrites(bufferSize) - .getBlobContainerAsyncClient(blobAsyncClient.getContainerName()) - .getBlobAsyncClient(blobAsyncClient.getBlobName()); - - ByteBuffer data = getRandomData(dataSize); - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(bufferSize) - .setMaxConcurrency(numBuffs) - .setMaxSingleUploadSizeLong(4L * Constants.MB); - data.position(0); - - // Due to memory issues, this check only runs on small to medium sized data sets. - if (dataSize < 100 * 1024 * 1024) { - StepVerifier - .create(asyncClient.upload(Flux.just(data), parallelTransferOptions, true) - .then(collectBytesInBuffer(blockBlobAsyncClient.downloadStream()))) - .assertNext(it -> assertEquals(data, it)) - .verifyComplete(); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)) - .assertNext(it -> assertEquals(blockCount, it.getCommittedBlocks().size())) - .verifyComplete(); - } else { - StepVerifier - .create(asyncClient.upload(Flux.just(data), parallelTransferOptions, true) - .then(blockBlobAsyncClient.listBlocks(BlockListType.ALL))) - .assertNext(it -> assertEquals(blockCount, it.getCommittedBlocks().size())) - .verifyComplete(); - } - } - - private static Stream bufferedUploadSupplier() { - return Stream.of(Arguments.of(35 * Constants.MB, 5 * Constants.MB, 2, 7), // Requires cycling through the same buffers multiple times. - Arguments.of(35 * Constants.MB, 5 * Constants.MB, 5, 7), // Most buffers may only be used once. - Arguments.of(100 * Constants.MB, 10 * Constants.MB, 2, 10), // Larger data set. - Arguments.of(100 * Constants.MB, 10 * Constants.MB, 5, 10), // Larger number of Buffs. - Arguments.of(10 * Constants.MB, Constants.MB, 10, 10), // Exactly enough buffer space to hold all the data. - Arguments.of(50 * Constants.MB, 10 * Constants.MB, 2, 5), // Larger data. - Arguments.of(10 * Constants.MB, 2 * Constants.MB, 4, 5), - Arguments.of(10 * Constants.MB, 3 * Constants.MB, 3, 4)); // Data does not squarely fit in buffers. - } - - @Test - public void uploadBinaryDataMin() { - StepVerifier - .create( - blobAsyncClient.upload(DATA.getDefaultBinaryData(), true).then(blockBlobAsyncClient.downloadContent())) - .assertNext(it -> TestUtils.assertArraysEqual(it.toBytes(), DATA.getDefaultBinaryData().toBytes())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("bufferedUploadComputeMd5Supplier") - @LiveOnly - public void bufferedUploadComputeMd5(int size, Long maxSingleUploadSize, Long blockSize, int byteBufferCount) { - List byteBufferList = new ArrayList<>(); - for (int i = 0; i < byteBufferCount; i++) { - byteBufferList.add(getRandomData(size)); - } - Flux flux = Flux.fromIterable(byteBufferList); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setMaxSingleUploadSizeLong(maxSingleUploadSize).setBlockSizeLong(blockSize); - - assertAsyncResponseStatusCode(Objects.requireNonNull(blobAsyncClient - .uploadWithResponse(new BlobParallelUploadOptions(flux).setParallelTransferOptions(parallelTransferOptions) - .setComputeMd5(true))), - 201); - - } - - private static Stream bufferedUploadComputeMd5Supplier() { - return Stream.of(Arguments.of(Constants.KB, null, null, 1), // Simple case where uploadFull is called. - Arguments.of(Constants.KB, (long) Constants.KB, 500L * Constants.KB, 1000), // uploadChunked 2 blocks staged - Arguments.of(Constants.KB, (long) Constants.KB, 5L * Constants.KB, 1000)); // uploadChunked 100 blocks staged - } - - @Test - public void uploadBinaryDataWithResponse() { - assertAsyncResponseStatusCode(Objects.requireNonNull( - blobAsyncClient.uploadWithResponse(new BlobParallelUploadOptions(DATA.getDefaultBinaryData()))), 201); - } - - private boolean compareListToBuffer(List buffers, ByteBuffer result) { - result.position(0); - for (ByteBuffer buffer : buffers) { - buffer.position(0); - result.limit(result.position() + buffer.remaining()); - if (!buffer.equals(result)) { - return false; - } - result.position(result.position() + buffer.remaining()); - } - return result.remaining() == 0; - } - - /* Reporter for testing Progress Receiver - * Will count the number of reports that are triggered */ - - @SuppressWarnings("deprecation") - static class Reporter implements ProgressReceiver { - private final long blockSize; - private long reportingCount; - - Reporter(long blockSize) { - this.blockSize = blockSize; - } - - @Override - public void reportProgress(long bytesTransferred) { - assertEquals(0, bytesTransferred % blockSize); - this.reportingCount += 1; - } - - long getReportingCount() { - return this.reportingCount; - } - } - - static class Listener implements ProgressListener { - private final long blockSize; - private long reportingCount; - - Listener(long blockSize) { - this.blockSize = blockSize; - } - - @Override - public void handleProgress(long bytesTransferred) { - assertEquals(0, bytesTransferred % blockSize); - this.reportingCount += 1; - } - - long getReportingCount() { - return this.reportingCount; - } - } - - // Only run these tests in live mode as they use variables that can't be captured. - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("bufferedUploadWithReporterSupplier") - @LiveOnly - public void bufferedUploadWithReporter(int size, long blockSize, int bufferCount) { - BlobAsyncClient asyncClient = getPrimaryServiceClientForWrites(blockSize) - .getBlobContainerAsyncClient(blobAsyncClient.getContainerName()) - .getBlobAsyncClient(blobAsyncClient.getBlobName()); - - Reporter uploadReporter = new Reporter(blockSize); - - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxConcurrency(bufferCount) - .setProgressReceiver(uploadReporter) - .setMaxSingleUploadSizeLong(4L * Constants.MB); - - StepVerifier - .create(asyncClient.uploadWithResponse(Flux.just(getRandomData(size)), parallelTransferOptions, null, null, - null, null)) - .assertNext(it -> { - assertEquals(201, it.getStatusCode()); - /* - * Verify that the reporting count is equal or greater than the size divided by block size in the case - * that operations need to be retried. Retry attempts will increment the reporting count. - */ - assertTrue(uploadReporter.getReportingCount() >= ((long) size / blockSize)); - }) - .verifyComplete(); - } - - private static Stream bufferedUploadWithReporterSupplier() { - return Stream.of(Arguments.of(10 * Constants.MB, 10L * Constants.MB, 8), - Arguments.of(20 * Constants.MB, Constants.MB, 5), Arguments.of(10 * Constants.MB, 5 * Constants.MB, 2), - Arguments.of(10 * Constants.MB, 512 * Constants.KB, 20)); - } - - // Only run these tests in live mode as they use variables that can't be captured. - @ParameterizedTest - @MethodSource("bufferedUploadWithReporterSupplier") - @LiveOnly - public void bufferedUploadWithListener(int size, long blockSize, int bufferCount) { - BlobAsyncClient asyncClient = getPrimaryServiceClientForWrites(blockSize) - .getBlobContainerAsyncClient(blobAsyncClient.getContainerName()) - .getBlobAsyncClient(blobAsyncClient.getBlobName()); - - Listener uploadListener = new Listener(blockSize); - - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxConcurrency(bufferCount) - .setProgressListener(uploadListener) - .setMaxSingleUploadSizeLong(4L * Constants.MB); - - StepVerifier - .create(asyncClient.uploadWithResponse(Flux.just(getRandomData(size)), parallelTransferOptions, null, null, - null, null)) - .assertNext(it -> { - assertResponseStatusCode(it, 201); - /* - * Verify that the reporting count is equal or greater than the size divided by block size in the case - * that operations need to be retried. Retry attempts will increment the reporting count. - */ - assertTrue(uploadListener.getReportingCount() >= ((long) size / blockSize)); - }) - .verifyComplete(); - } - - // Only run these tests in live mode as they use variables that can't be captured. - @ParameterizedTest - @MethodSource("bufferedUploadChunkedSourceSupplier") - @LiveOnly - public void bufferedUploadChunkedSource(int[] dataSizeList, long bufferSize, int numBuffers, int blockCount) { - /* - This test should validate that the upload should work regardless of what format the passed data is in because - it will be chunked appropriately. - */ - BlobAsyncClient asyncClient = getPrimaryServiceClientForWrites(bufferSize * Constants.MB) - .getBlobContainerAsyncClient(blobAsyncClient.getContainerName()) - .getBlobAsyncClient(blobAsyncClient.getBlobName()); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong(bufferSize * Constants.MB) - .setMaxConcurrency(numBuffers) - .setMaxSingleUploadSizeLong(4L * Constants.MB); - List dataList = new ArrayList<>(); - for (int size : dataSizeList) { - dataList.add(getRandomData(size * Constants.MB)); - } - Mono uploadOperation - = asyncClient.upload(Flux.fromIterable(dataList), parallelTransferOptions, true); - - StepVerifier.create(uploadOperation.then(collectBytesInBuffer(blockBlobAsyncClient.downloadStream()))) - .assertNext(it -> assertTrue(compareListToBuffer(dataList, it))) - .verifyComplete(); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)) - .assertNext(it -> assertEquals(blockCount, it.getCommittedBlocks().size())) - .verifyComplete(); - } - - private static Stream bufferedUploadChunkedSourceSupplier() { - return Stream.of( - // First item fits entirely in the buffer, next item spans two buffers - Arguments.of(new int[] { 7, 7 }, 10, 2, 2), - // Multiple items fit non-exactly in one buffer. - Arguments.of(new int[] { 3, 3, 3, 3, 3, 3, 3 }, 10, 2, 3), - // Data fits exactly and does not need chunking. - Arguments.of(new int[] { 10, 10 }, 10, 2, 2), - // Data needs chunking and does not fit neatly in buffers. Requires waiting for buffers to be released. - Arguments.of(new int[] { 50, 51, 49 }, 10, 2, 15)); - } - - @ParameterizedTest - @MethodSource("bufferedUploadHandlePathingSupplier") - @LiveOnly - public void bufferedUploadHandlePathing(int[] dataSizeList, int blockCount) { - List dataList = new ArrayList<>(); - for (int size : dataSizeList) { - dataList.add(getRandomData(size)); - } - Mono uploadOperation = blobAsyncClient.upload(Flux.fromIterable(dataList), - new ParallelTransferOptions().setMaxSingleUploadSizeLong(4L * Constants.MB), true); - - StepVerifier.create(uploadOperation.then(collectBytesInBuffer(blockBlobAsyncClient.downloadStream()))) - .assertNext(it -> assertTrue(compareListToBuffer(dataList, it))) - .verifyComplete(); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)) - .assertNext(it -> assertEquals(blockCount, it.getCommittedBlocks().size())) - .verifyComplete(); - } - - private static Stream bufferedUploadHandlePathingSupplier() { - return Stream.of(Arguments.of(new int[] { 4 * Constants.MB + 1, 10 }, 2), - Arguments.of(new int[] { 4 * Constants.MB }, 0), Arguments.of(new int[] { 10, 100, 1000, 10000 }, 0), - Arguments.of(new int[] { 4 * Constants.MB, 4 * Constants.MB }, 2)); - } - - @ParameterizedTest - @MethodSource("bufferedUploadHandlePathingSupplier") - @LiveOnly - public void bufferedUploadHandlePathingHotFlux(int[] dataSizeList, int blockCount) { - List dataList = new ArrayList<>(); - for (int size : dataSizeList) { - dataList.add(getRandomData(size)); - } - Mono uploadOperation - = blobAsyncClient.upload(Flux.fromIterable(dataList).publish().autoConnect(), - new ParallelTransferOptions().setMaxSingleUploadSizeLong(4L * Constants.MB), true); - - StepVerifier.create(uploadOperation.then(collectBytesInBuffer(blockBlobAsyncClient.downloadStream()))) - .assertNext(it -> assertTrue(compareListToBuffer(dataList, it))) - .verifyComplete(); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)) - .assertNext(it -> assertEquals(blockCount, it.getCommittedBlocks().size())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("bufferedUploadHandlePathingHotFluxWithTransientFailureSupplier") - @LiveOnly - public void bufferedUploadHandlePathingHotFluxWithTransientFailure(int[] dataSizeList, int blockCount) { - BlobAsyncClient clientWithFailure = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - blobAsyncClient.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()); - - List dataList = new ArrayList<>(); - for (int size : dataSizeList) { - dataList.add(getRandomData(size)); - } - Mono uploadOperation - = clientWithFailure.upload(Flux.fromIterable(dataList).publish().autoConnect(), - new ParallelTransferOptions().setMaxSingleUploadSizeLong(4L * Constants.MB), true); - - StepVerifier.create(uploadOperation.then(collectBytesInBuffer(blockBlobAsyncClient.downloadStream()))) - .assertNext(it -> assertTrue(compareListToBuffer(dataList, it))) - .verifyComplete(); - - StepVerifier.create(blockBlobAsyncClient.listBlocks(BlockListType.ALL)) - .assertNext(it -> assertEquals(blockCount, it.getCommittedBlocks().size())) - .verifyComplete(); - } - - private static Stream bufferedUploadHandlePathingHotFluxWithTransientFailureSupplier() { - return Stream.of(Arguments.of(new int[] { 10, 100, 1000, 10000 }, 0), - Arguments.of(new int[] { 4 * Constants.MB + 1, 10 }, 2), - Arguments.of(new int[] { 4 * Constants.MB, 4 * Constants.MB }, 2)); - } - - @Test - public void bufferedUploadIllegalArgumentsNull() { - StepVerifier - .create(blobAsyncClient.upload(null, - new ParallelTransferOptions().setBlockSizeLong(4L).setMaxConcurrency(4), true)) - .verifyErrorSatisfies(it -> assertInstanceOf(NullPointerException.class, it)); - } - - // todo isbr: Should think about moving this test out of here as this should be in a test class specific to ParallelTransferOptions that isn't recorded. - @ParameterizedTest - @MethodSource("bufferedUploadIllegalArgsOutOfBoundsSupplier") - public void bufferedUploadIllegalArgsOutOfBounds(long bufferSize, int numBuffs) { - assertThrows(IllegalArgumentException.class, - () -> new ParallelTransferOptions().setBlockSizeLong(bufferSize).setMaxConcurrency(numBuffs)); - } - - private static Stream bufferedUploadIllegalArgsOutOfBoundsSupplier() { - return Stream.of(Arguments.of(0, 5), Arguments.of(BlockBlobAsyncClient.MAX_STAGE_BLOCK_BYTES_LONG + 1, 5), - Arguments.of(5, 0)); - } - - // Only run these tests in live mode as they use variables that can't be captured. - @ParameterizedTest - @MethodSource("bufferedUploadHeadersSupplier") - @LiveOnly - public void bufferedUploadHeaders(int dataSize, String cacheControl, String contentDisposition, - String contentEncoding, String contentLanguage, boolean validateContentMD5, String contentType) - throws NoSuchAlgorithmException { - byte[] bytes = getRandomByteArray(dataSize); - byte[] contentMD5 = validateContentMD5 ? MessageDigest.getInstance("MD5").digest(bytes) : null; - Mono> uploadOperation - = blobAsyncClient.uploadWithResponse(Flux.just(ByteBuffer.wrap(bytes)), - new ParallelTransferOptions().setMaxSingleUploadSizeLong(4L * Constants.MB), - new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType), - null, null, null); - - StepVerifier.create(uploadOperation.then(blockBlobAsyncClient.getPropertiesWithResponse(null))) - .assertNext(it -> assertTrue(validateBlobProperties(it, cacheControl, contentDisposition, contentEncoding, - contentLanguage, contentMD5, contentType == null ? "application/octet-stream" : contentType))) - .verifyComplete(); - // HTTP default content type is application/octet-stream. - - } - - private static Stream bufferedUploadHeadersSupplier() { - return Stream.of( - // Depending on the size of the stream either Put Blob or Put Block List will be used. - // Put Blob will implicitly calculate the MD5 whereas Put Block List won't. - Arguments.of(DATA.getDefaultDataSize(), null, null, null, null, true, null), - Arguments.of(DATA.getDefaultDataSize(), "control", "disposition", "encoding", "language", true, "type"), - Arguments.of(6 * Constants.MB, null, null, null, null, false, null), - Arguments.of(6 * Constants.MB, "control", "disposition", "encoding", "language", true, "type")); - } - - // Only run these tests in live mode as they use variables that can't be captured. - @LiveOnly - @ParameterizedTest - @MethodSource("bufferedUploadMetadataSupplier") - public void bufferedUploadMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong(10L).setMaxConcurrency(10); - Mono> uploadOperation = blobAsyncClient.uploadWithResponse(Flux.just(getRandomData(10)), - parallelTransferOptions, null, metadata, null, null); - - StepVerifier.create(uploadOperation.then(blobAsyncClient.getPropertiesWithResponse(null))).assertNext(it -> { - assertResponseStatusCode(it, 200); - assertEquals(metadata, it.getValue().getMetadata()); - }).verifyComplete(); - } - - private static Stream bufferedUploadMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - // Only run these tests in live mode as they use variables that can't be captured. - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("bufferedUploadTagsSupplier") - @LiveOnly - public void bufferedUploadTags(String key1, String value1, String key2, String value2) { - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions(10, 10, null); - Mono> uploadOperation - = blobAsyncClient.uploadWithResponse(new BlobParallelUploadOptions(Flux.just(getRandomData(10))) - .setParallelTransferOptions(parallelTransferOptions) - .setTags(tags)); - - StepVerifier.create(uploadOperation.then(blobAsyncClient.getTagsWithResponse(null))).assertNext(it -> { - assertResponseStatusCode(it, 200); - assertEquals(tags, it.getValue()); - }).verifyComplete(); - } - - private static Stream bufferedUploadTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @ParameterizedTest - @MethodSource("bufferedUploadOptionsSupplier") - @LiveOnly - public void bufferedUploadOptions(int dataSize, Long singleUploadSize, Long blockSize, int expectedBlockCount) { - ByteBuffer data = getRandomData(dataSize); - - StepVerifier - .create(blobAsyncClient - .uploadWithResponse(Flux.just(data), - new ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxSingleUploadSizeLong(singleUploadSize), - null, null, null, null) - .then(Objects.requireNonNull(blobAsyncClient.getBlockBlobAsyncClient()) - .listBlocks(BlockListType.COMMITTED))) - .assertNext(r -> assertEquals(expectedBlockCount, r.getCommittedBlocks().size())) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - private static Stream bufferedUploadOptionsSupplier() { - return Stream.of( - // Test that the default for singleUploadSize is the maximum - Arguments.of(BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES - 1, null, null, 0), - // This also validates the default for blockSize - Arguments.of(BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES + 1, null, null, - (int) Math.ceil(((double) BlockBlobAsyncClient.MAX_UPLOAD_BLOB_BYTES + 1) - / (double) BlobClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE)/* "". This also validates the default for blockSize*/), - // Test that singleUploadSize is respected - Arguments.of(100, 50L, null, 1), - // Test that blockSize is respected - Arguments.of(100, 50L, 20L, 5)); - } - - @ParameterizedTest - @MethodSource("bufferedUploadWithLengthSupplier") - @LiveOnly - public void bufferedUploadWithLength(int dataSize, Long singleUploadSize, Long blockSize, int expectedBlockCount) { - Flux data = Flux.just(getRandomData(dataSize)); - Mono parallelUploadOptions = BinaryData.fromFlux(data, (long) dataSize) - .flatMap(r -> Mono.just(new BlobParallelUploadOptions(r) - .setParallelTransferOptions(new ParallelTransferOptions().setBlockSizeLong(blockSize) - .setMaxSingleUploadSizeLong(singleUploadSize)))); - - StepVerifier - .create(parallelUploadOptions.flatMap(r -> blobAsyncClient.uploadWithResponse(r)) - .then(Objects - .requireNonNull(blobAsyncClient.getBlockBlobAsyncClient().listBlocks(BlockListType.COMMITTED)))) - .assertNext(r -> assertEquals(expectedBlockCount, r.getCommittedBlocks().size())) - .verifyComplete(); - } - - private static Stream bufferedUploadWithLengthSupplier() { - return Stream.of(Arguments.of(100, 100L, null, 0), // Test that singleUploadSize is respected - Arguments.of(100, 50L, 20L, 5)); // Test that blockSize is respected - } - - // Only run these tests in live mode as they use variables that can't be captured. - @ParameterizedTest - @MethodSource("bufferedUploadACSupplier") - @LiveOnly - public void bufferedUploadAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID) { - Mono> response - = blockBlobAsyncClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .then(Mono.zip(setupBlobLeaseCondition(blockBlobAsyncClient, leaseID), - setupBlobMatchCondition(blockBlobAsyncClient, match), BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong(10L); - - return blobAsyncClient.uploadWithResponse(Flux.just(getRandomData(10)), parallelTransferOptions, - null, null, null, requestConditions); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - private static Stream bufferedUploadACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), Arguments.of(null, NEW_DATE, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null), Arguments.of(null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID)); - } - - // Only run these tests in live mode as they use variables that can't be captured. - @LiveOnly - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#fileACFailSupplier") - public void bufferedUploadACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID) { - Mono> response - = blockBlobAsyncClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .then(Mono.zip(setupBlobLeaseCondition(blockBlobAsyncClient, leaseID), - setupBlobMatchCondition(blockBlobAsyncClient, noneMatch), BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified); - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong(10L); - - return blobAsyncClient.uploadWithResponse(Flux.just(getRandomData(10)), parallelTransferOptions, - null, null, null, requestConditions); - }); - - StepVerifier.create(response).verifyErrorSatisfies(it -> { - assertInstanceOf(BlobStorageException.class, it); - BlobStorageException storageException = (BlobStorageException) it; - assertTrue(storageException.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET - || storageException.getErrorCode() == BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION); - }); - } - - // UploadBufferPool used to lock when the number of failed stage blocks exceeded the maximum number of buffers - // (discovered when a leaseId was invalid) - @ParameterizedTest - @CsvSource(value = { "16,7,2", "16,5,2" }) - @LiveOnly - public void uploadBufferPoolLockThreeOrMoreBuffers(int dataLength, int blockSize, int numBuffers) { - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong((long) blockSize).setMaxConcurrency(numBuffers); - - Mono> response - = blockBlobAsyncClient.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize(), true) - .then(setupBlobLeaseCondition(blockBlobAsyncClient, GARBAGE_LEASE_ID)) - .flatMap(r -> { - BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(r); - return blobAsyncClient.uploadWithResponse(Flux.just(getRandomData(dataLength)), - parallelTransferOptions, null, null, null, requestConditions); - }); - - StepVerifier.create(response).verifyErrorSatisfies(it -> assertInstanceOf(BlobStorageException.class, it)); - } - - @LiveOnly - @Test - public void bufferedUploadNetworkError() { - /* - This test uses a Flowable that does not allow multiple subscriptions and therefore ensures that we are - buffering properly to allow for retries even given this source behavior. - */ - - // Mock a response that will always be retried. - HttpResponse mockHttpResponse - = new MockHttpResponse(new HttpRequest(HttpMethod.PUT, "https://www.fake.com"), 500); - - // Mock a policy that will always then check that the data is still the same and return a retryable error. - ByteBuffer localData = DATA.getDefaultData(); - HttpPipelinePolicy mockPolicy - = (context, next) -> collectBytesInBuffer(context.getHttpRequest().getBody()).map(localData::equals) - .flatMap(it -> it ? Mono.just(mockHttpResponse) : Mono.error(new IllegalArgumentException())); - - // Build the pipeline - BlobAsyncClient blobAsyncClient - = new BlobServiceClientBuilder().credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .retryOptions(new RequestRetryOptions(null, 3, null, 500L, 1500L, null)) - .addPolicy(mockPolicy) - .buildAsyncClient() - .getBlobContainerAsyncClient(generateContainerName()) - .getBlobAsyncClient(generateBlobName()); - - // Try to upload the flowable, which will hit a retry. A normal upload would throw, but buffering prevents that. - ParallelTransferOptions parallelTransferOptions - = new ParallelTransferOptions().setBlockSizeLong(1024L).setMaxConcurrency(4); - // TODO: It could be that duplicates aren't getting made in the retry policy? Or before the retry policy? - - // A second subscription to a download stream will - StepVerifier - .create(blockBlobAsyncClient.upload(Flux.just(DATA.getDefaultData()), DATA.getDefaultDataSize(), true) - .then(blobAsyncClient.upload(blockBlobAsyncClient.downloadStream(), parallelTransferOptions, true))) - .verifyErrorSatisfies(it -> { - assertInstanceOf(BlobStorageException.class, it); - assertEquals(500, ((BlobStorageException) it).getStatusCode()); - }); - } - - @LiveOnly - @Test - public void bufferedUploadDefaultNoOverwrite() { - StepVerifier.create(blobAsyncClient.upload(DATA.getDefaultFlux(), null)) - .verifyError(IllegalArgumentException.class); - } - - @Test - public void uploadBinaryDataNoOverwrite() { - StepVerifier.create(blobAsyncClient.upload(DATA.getDefaultBinaryData())) - .verifyError(IllegalArgumentException.class); - } - - @LiveOnly - @Test - public void bufferedUploadNoOverwriteInterrupted() throws IOException { - File smallFile = getRandomFile(50); - smallFile.deleteOnExit(); - createdFiles.add(smallFile); - - /* - * Setup the data stream to trigger a small upload upon subscription. This will happen once the upload method - * has verified whether a blob with the given name already exists, so this will trigger once uploading begins. - */ - Flux data = Flux.just(getRandomData(Constants.MB)) - .repeat(257) - .doOnSubscribe(it -> blobAsyncClient.uploadFromFile(smallFile.toPath().toString()).subscribe()); - blobAsyncClient = ccAsync.getBlobAsyncClient(generateBlobName()); - - StepVerifier.create(blobAsyncClient.upload(data, null)).verifyErrorSatisfies(it -> { - assertInstanceOf(BlobStorageException.class, it); - assertEquals(BlobErrorCode.BLOB_ALREADY_EXISTS, ((BlobStorageException) it).getErrorCode()); - }); - } - - @LiveOnly - @Test - public void bufferedUploadWithSpecifiedLength() { - Flux fluxData = Flux.just(getRandomData(DATA.getDefaultDataSize())); - Mono> response = BinaryData.fromFlux(fluxData, DATA.getDefaultDataSizeLong()) - .flatMap(r -> blobAsyncClient.uploadWithResponse(new BlobParallelUploadOptions(r))); - - StepVerifier.create(response).assertNext(it -> assertNotNull(it.getValue().getETag())).verifyComplete(); - } - - @LiveOnly - @Test - public void bufferedUploadOverwrite() throws IOException { - File file = getRandomFile(50); - file.deleteOnExit(); - createdFiles.add(file); - - StepVerifier.create(blobAsyncClient.uploadFromFile(file.toPath().toString(), true) - .then(blobAsyncClient.uploadFromFile(getRandomFile(50).toPath().toString(), true))).verifyComplete(); - } - - @Test - public void bufferedUploadNonMarkableStream() throws IOException { - File file = getRandomFile(10); - file.deleteOnExit(); - createdFiles.add(file); - - File outFile = getRandomFile(10); - createdFiles.add(outFile); - outFile.deleteOnExit(); - Files.deleteIfExists(outFile.toPath()); - - StepVerifier - .create(blobAsyncClient.uploadFromFile(file.getPath(), true) - .then(blobAsyncClient.downloadToFile(outFile.toPath().toString(), true))) - .expectNextCount(1) - .verifyComplete(); - - compareFiles(file, outFile, 0, file.length()); - } - - @Test - public void getContainerName() { - assertEquals(containerName, blockBlobAsyncClient.getContainerName()); - } - - @Test - public void getBlockBlobName() { - assertEquals(blobName, blockBlobAsyncClient.getBlobName()); - } - - @ParameterizedTest - @MethodSource("getBlobNameAndBuildClientSupplier") - public void getBlobNameAndBuildClient(String originalBlobName, String finalBlobName) { - BlobAsyncClient client = ccAsync.getBlobAsyncClient(originalBlobName); - BlockBlobAsyncClient blockClient = ccAsync.getBlobAsyncClient(client.getBlobName()).getBlockBlobAsyncClient(); - - assertEquals(finalBlobName, blockClient.getBlobName()); - } - - private static Stream getBlobNameAndBuildClientSupplier() { - return Stream.of(Arguments.of("blobName", "blobName"), Arguments.of("dir1/a%20b.txt", "dir1/a%20b.txt"), - Arguments.of("path/to]a blob", "path/to]a blob"), - Arguments.of("path%2Fto%5Da%20blob", "path%2Fto%5Da%20blob"), Arguments.of("斑點", "斑點"), - Arguments.of("%E6%96%91%E9%BB%9E", "%E6%96%91%E9%BB%9E"), Arguments.of("斑點", "斑點")); - } - - @Test - public void builderCpkValidation() { - URL endpoint = BlobUrlParts.parse(blockBlobAsyncClient.getBlobUrl()).setScheme("http").toUrl(); - SpecializedBlobClientBuilder builder = new SpecializedBlobClientBuilder() - .customerProvidedKey(new CustomerProvidedKey(Base64.getEncoder().encodeToString(getRandomByteArray(256)))) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildBlockBlobAsyncClient); - } - - @Test - public void builderBearerTokenValidation() { - URL endpoint = BlobUrlParts.parse(blockBlobAsyncClient.getBlobUrl()).setScheme("http").toUrl(); - SpecializedBlobClientBuilder builder - = new SpecializedBlobClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) - .endpoint(endpoint.toString()); - - assertThrows(IllegalArgumentException.class, builder::buildBlockBlobAsyncClient); - } - - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - @Test - public void perCallPolicy() { - BlockBlobAsyncClient specialBlob - = getSpecializedBuilder(blockBlobAsyncClient.getBlobUrl()).addPolicy(getPerCallVersionPolicy()) - .buildBlockBlobAsyncClient(); - - StepVerifier.create(specialBlob.getPropertiesWithResponse(null)) - .assertNext(r -> assertEquals("2017-11-09", r.getHeaders().getValue(X_MS_VERSION))) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromUrlMin() { - BlobAsyncClient sourceBlob = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName) - .getBlobAsyncClient(generateBlobName()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - Mono response - = sourceBlob.upload(DATA.getDefaultFlux(), null).then(blockBlobAsyncClient.exists()).flatMap(r -> { - if (r) { - return blockBlobAsyncClient.delete(); - } - return Mono.empty(); - }).then(blockBlobAsyncClient.uploadFromUrl(sourceBlob.getBlobUrl() + "?" + sas)); - - StepVerifier.create(response).assertNext(r -> { - assertNotNull(r); - assertNotNull(r.getETag()); - assertNotNull(r.getLastModified()); - }).verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(blobAsyncClient.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void uploadFromUrlSourceErrorAndStatusCode() { - BlockBlobAsyncClient destBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - - StepVerifier.create(destBlob.uploadFromUrl(blockBlobAsyncClient.getBlobUrl())) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }); - }*/ - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromUrlOverwrite() { - BlobAsyncClient sourceBlob = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName) - .getBlobAsyncClient(generateBlobName()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - Mono response = sourceBlob.upload(DATA.getDefaultFlux(), null) - .then(blockBlobAsyncClient.upload(Flux.just(ByteBuffer.wrap(new byte[0])), 0, true)) - .then(blockBlobAsyncClient.uploadFromUrl(sourceBlob.getBlobUrl() + "?" + sas, true)); - - StepVerifier.create(response).assertNext(r -> { - assertNotNull(r); - assertNotNull(r.getETag()); - assertNotNull(r.getLastModified()); - }).verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(blobAsyncClient.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromUrlOverwriteFailsOnExistingBlob() { - BlobAsyncClient sourceBlob = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName) - .getBlobAsyncClient(generateBlobName()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - Mono response = sourceBlob.upload(DATA.getDefaultFlux(), null) - .then(blockBlobAsyncClient.upload(Flux.just(ByteBuffer.wrap(new byte[0])), 0, true)) - .then(blockBlobAsyncClient.uploadFromUrl(sourceBlob.getBlobUrl() + "?" + sas, false)); - - StepVerifier.create(response).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.BLOB_ALREADY_EXISTS, e.getErrorCode()); - }); - - StepVerifier.create(blockBlobAsyncClient.uploadFromUrl(sourceBlob.getBlobUrl() + "?" + sas)) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.BLOB_ALREADY_EXISTS, e.getErrorCode()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromUrlMax() throws NoSuchAlgorithmException { - BlobAsyncClient sourceBlob = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName) - .getBlobAsyncClient(generateBlobName()); - byte[] sourceBlobMD5 = MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - Mono> response = sourceBlob.upload(DATA.getDefaultFlux(), null) - .then(sourceBlob.setHttpHeaders(new BlobHttpHeaders().setContentLanguage("en-GB"))) - .then(blockBlobAsyncClient.upload(Flux.just(ByteBuffer.wrap(new byte[0])), 0, true)) - .then(Mono.zip(sourceBlob.getProperties(), blockBlobAsyncClient.getProperties())) - .flatMap(tuple -> { - BlobUploadFromUrlOptions options = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas) - .setContentMd5(sourceBlobMD5) - .setCopySourceBlobProperties(true) - .setDestinationRequestConditions(new BlobRequestConditions().setIfMatch(tuple.getT2().getETag())) - .setSourceRequestConditions(new BlobRequestConditions().setIfMatch(tuple.getT1().getETag())) - .setHeaders(new BlobHttpHeaders().setContentType("text")) - .setTier(AccessTier.COOL); - return blockBlobAsyncClient.uploadFromUrlWithResponse(options); - }); - - StepVerifier.create(response).assertNext(r -> { - assertNotNull(r); - assertNotNull(r.getRequest()); - assertNotNull(r.getHeaders()); - BlockBlobItem blockBlobItem = r.getValue(); - assertNotNull(blockBlobItem); - assertNotNull(blockBlobItem.getETag()); - assertNotNull(blockBlobItem.getLastModified()); - }).verifyComplete(); - - StepVerifier.create(blobAsyncClient.getProperties()).assertNext(r -> { - assertEquals("en-GB", r.getContentLanguage()); - assertEquals("text", r.getContentType()); - assertEquals(AccessTier.COOL, r.getAccessTier()); - }).verifyComplete(); - - StepVerifier.create(FluxUtil.collectBytesInByteBufferStream(blockBlobAsyncClient.downloadStream())) - .assertNext(r -> TestUtils.assertArraysEqual(DATA.getDefaultBytes(), r)) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @Test - public void uploadFromWithInvalidSourceMD5() throws NoSuchAlgorithmException { - BlobAsyncClient sourceBlob = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName) - .getBlobAsyncClient(generateBlobName()); - byte[] sourceBlobMD5 = MessageDigest.getInstance("MD5").digest("garbage".getBytes(StandardCharsets.UTF_8)); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - BlobUploadFromUrlOptions options - = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas).setContentMd5(sourceBlobMD5); - - Mono> response = sourceBlob.upload(DATA.getDefaultFlux(), null) - .then(blockBlobAsyncClient.upload(Flux.just(ByteBuffer.wrap(new byte[0])), 0, true)) - .then(blockBlobAsyncClient.uploadFromUrlWithResponse(options)); - - StepVerifier.create(response).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.MD5MISMATCH, e.getErrorCode()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @ParameterizedTest - @MethodSource("uploadFromUrlSourceRequestConditionsSupplier") - public void uploadFromUrlSourceRequestConditions(BlobRequestConditions requestConditions, BlobErrorCode errorCode) { - BlobAsyncClient sourceBlob = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName) - .getBlobAsyncClient(generateBlobName()); - - Mono> response = sourceBlob.upload(DATA.getDefaultFlux(), null).flatMap(r -> { - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - BlobUploadFromUrlOptions options = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas) - .setSourceRequestConditions(requestConditions); - return blockBlobAsyncClient.upload(Flux.just(ByteBuffer.wrap(new byte[0])), 0, true) - .then(blockBlobAsyncClient.uploadFromUrlWithResponse(options)); - }); - - StepVerifier.create(response).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(errorCode, e.getErrorCode()); - }); - } - - private static Stream uploadFromUrlSourceRequestConditionsSupplier() { - return Stream.of( - Arguments.of(new BlobRequestConditions().setIfMatch("dummy"), BlobErrorCode.SOURCE_CONDITION_NOT_MET), - Arguments.of(new BlobRequestConditions().setIfModifiedSince(OffsetDateTime.now().plusSeconds(10)), - BlobErrorCode.CANNOT_VERIFY_COPY_SOURCE), - Arguments.of(new BlobRequestConditions().setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)), - BlobErrorCode.CANNOT_VERIFY_COPY_SOURCE)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2020-04-08") - @ParameterizedTest - @MethodSource("uploadFromUrlDestinationRequestConditionsSupplier") - public void uploadFromUrlDestinationRequestConditions(BlobRequestConditions requestConditions, - BlobErrorCode errorCode) { - BlobAsyncClient sourceBlob = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName) - .getBlobAsyncClient(generateBlobName()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - BlobUploadFromUrlOptions options = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas) - .setDestinationRequestConditions(requestConditions); - - Mono> response = sourceBlob.upload(DATA.getDefaultFlux(), null) - .then(blockBlobAsyncClient.upload(Flux.just(ByteBuffer.wrap(new byte[0])), 0, true)) - .flatMap(r -> { - if (requestConditions.getLeaseId() != null) { - return createLeaseAsyncClient(blobAsyncClient).acquireLease(60); - } - return Mono.empty(); - }) - .then(blockBlobAsyncClient.uploadFromUrlWithResponse(options)); - - StepVerifier.create(response).verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(errorCode, e.getErrorCode()); - }); - } - - private static Stream uploadFromUrlDestinationRequestConditionsSupplier() { - return Stream.of( - Arguments.of(new BlobRequestConditions().setIfMatch("dummy"), BlobErrorCode.TARGET_CONDITION_NOT_MET), - Arguments.of(new BlobRequestConditions().setIfNoneMatch("*"), BlobErrorCode.BLOB_ALREADY_EXISTS), - Arguments.of(new BlobRequestConditions().setIfModifiedSince(OffsetDateTime.now().plusDays(10)), - BlobErrorCode.CONDITION_NOT_MET), - Arguments.of(new BlobRequestConditions().setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)), - BlobErrorCode.CONDITION_NOT_MET), - Arguments.of(new BlobRequestConditions().setLeaseId("9260fd2d-34c1-42b5-9217-8fb7c6484bfb"), - BlobErrorCode.LEASE_ID_MISMATCH_WITH_BLOB_OPERATION)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("uploadFromUrlCopySourceTagsSupplier") - public void uploadFromUrlCopySourceTags(BlobCopySourceTagsMode mode) { - Map sourceTags = Collections.singletonMap("foo", "bar"); - Map destTags = Collections.singletonMap("fizz", "buzz"); - - String sas - = blockBlobAsyncClient.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - BlobAsyncClient bc2 = ccAsync.getBlobAsyncClient(generateBlobName()); - - BlobCopyFromUrlOptions options - = new BlobCopyFromUrlOptions(blockBlobAsyncClient.getBlobUrl() + "?" + sas).setCopySourceTagsMode(mode); - if (BlobCopySourceTagsMode.REPLACE == mode) { - options.setTags(destTags); - } - - StepVerifier - .create( - blockBlobAsyncClient.setTags(sourceTags).then(bc2.copyFromUrlWithResponse(options)).then(bc2.getTags())) - .assertNext(r -> { - if (BlobCopySourceTagsMode.REPLACE == mode) { - assertEquals(destTags, r); - } else { - assertEquals(sourceTags, r); - } - }) - .verifyComplete(); - } - - private static Stream uploadFromUrlCopySourceTagsSupplier() { - return Stream.of(Arguments.of(BlobCopySourceTagsMode.COPY), Arguments.of(BlobCopySourceTagsMode.REPLACE)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-12-02") - @Test - public void uploadFromUrlAccessTierCold() { - BlobAsyncClient sourceBlob = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(containerName) - .getBlobAsyncClient(generateBlobName()); - String sas = sourceBlob.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - BlobUploadFromUrlOptions uploadOptions - = new BlobUploadFromUrlOptions(sourceBlob.getBlobUrl() + "?" + sas).setTier(AccessTier.COLD); - - Mono response - = sourceBlob.upload(DATA.getDefaultFlux(), null).then(blockBlobAsyncClient.exists()).flatMap(r -> { - if (r) { - return blockBlobAsyncClient.delete(); - } - return Mono.empty(); - }) - .then(blockBlobAsyncClient.uploadFromUrlWithResponse(uploadOptions)) - .then(blockBlobAsyncClient.getProperties()); - - StepVerifier.create(response) - .assertNext(r -> assertEquals(AccessTier.COLD, r.getAccessTier())) - .verifyComplete(); - } - - @Test - public void defaultAudience() { - BlockBlobAsyncClient aadBlob - = getSpecializedBuilderWithTokenCredential(blockBlobAsyncClient.getBlobUrl()).audience(null) - .buildBlockBlobAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - - @Test - public void storageAccountAudience() { - BlockBlobAsyncClient aadBlob = getSpecializedBuilderWithTokenCredential(blockBlobAsyncClient.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(ccAsync.getAccountName())) - .buildBlockBlobAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - BlockBlobAsyncClient aadBlob = getSpecializedBuilderWithTokenCredential(blockBlobAsyncClient.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildBlockBlobAsyncClient(); - - StepVerifier.create(aadBlob.getProperties()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", ccAsync.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - BlockBlobAsyncClient aadBlob - = getSpecializedBuilderWithTokenCredential(blockBlobAsyncClient.getBlobUrl()).audience(audience) - .buildBlockBlobAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseMockFlux.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseMockFlux.java deleted file mode 100644 index e5a943fedb5f..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseMockFlux.java +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.HttpHeader; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.test.http.MockHttpResponse; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.DownloadRetryOptions; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.util.concurrent.TimeoutException; - -public class DownloadResponseMockFlux { - static final int DR_TEST_SCENARIO_SUCCESSFUL_ONE_CHUNK = 0; // Data emitted in one chunk - static final int DR_TEST_SCENARIO_SUCCESSFUL_MULTI_CHUNK = 1; // Data emitted in multiple chunks - static final int DR_TEST_SCENARIO_SUCCESSFUL_STREAM_FAILURES = 2; // Stream failures successfully handled - static final int DR_TEST_SCENARIO_MAX_RETRIES_EXCEEDED = 3; // We appropriate honor max retries - static final int DR_TEST_SCENARIO_NON_RETRYABLE_ERROR = 4; // We will not retry on a non-retryable error - static final int DR_TEST_SCENARIO_ERROR_GETTER_MIDDLE = 6; // Throwing an error from the getter - static final int DR_TEST_SCENARIO_NO_MULTIPLE_SUBSCRIPTION = 9; // We do not subscribe to the same stream twice - static final int DR_TEST_SCENARIO_TIMEOUT = 10; // ReliableDownload with timeout after not receiving items for 60s - static final int DR_TEST_SCENARIO_ERROR_AFTER_ALL_DATA = 11; // Don't actually issue another retry if we've read all the data and the source failed at the end - - private final int scenario; - private final ByteBuffer scenarioData; - - private int tryNumber; - private DownloadRetryOptions options; - private boolean subscribed = false; //// Only used for multiple subscription test. - - public DownloadResponseMockFlux(int scenario, BlobTestBase testBase) { - this.scenario = scenario; - - if (scenario == DR_TEST_SCENARIO_SUCCESSFUL_ONE_CHUNK) { - this.scenarioData = testBase.getRandomData(512 * 1024); - } else if (scenario == DR_TEST_SCENARIO_SUCCESSFUL_MULTI_CHUNK - || scenario == DR_TEST_SCENARIO_SUCCESSFUL_STREAM_FAILURES - || scenario == DR_TEST_SCENARIO_NO_MULTIPLE_SUBSCRIPTION - || scenario == DR_TEST_SCENARIO_ERROR_AFTER_ALL_DATA - || scenario == DR_TEST_SCENARIO_MAX_RETRIES_EXCEEDED - || scenario == DR_TEST_SCENARIO_NON_RETRYABLE_ERROR - || scenario == DR_TEST_SCENARIO_ERROR_GETTER_MIDDLE - || scenario == DR_TEST_SCENARIO_TIMEOUT) { - this.scenarioData = testBase.getRandomData(1024); - } else { - throw new IllegalArgumentException("Invalid download resource test scenario."); - } - } - - /* - For internal construction on NO_MULTIPLE_SUBSCRIPTION test - */ - public DownloadResponseMockFlux(int scenario, int tryNumber, ByteBuffer scenarioData, - DownloadRetryOptions options) { - this.scenario = scenario; - this.tryNumber = tryNumber; - this.scenarioData = scenarioData; - this.options = options; - } - - public ByteBuffer getScenarioData() { - return this.scenarioData; - } - - public int getTryNumber() { - return this.tryNumber; - } - - private Flux getDownloadStream(long offset, Long count) { - switch (this.scenario) { - case DR_TEST_SCENARIO_SUCCESSFUL_ONE_CHUNK: - return Flux.just(scenarioData.duplicate()); - - case DR_TEST_SCENARIO_SUCCESSFUL_MULTI_CHUNK: - return Flux.range(0, 4).map(it -> { - ByteBuffer toSend = this.scenarioData.duplicate(); - toSend.position(it * 256); - toSend.limit((it + 1) * 256); - return toSend; - }); - - case DR_TEST_SCENARIO_NO_MULTIPLE_SUBSCRIPTION: - case DR_TEST_SCENARIO_SUCCESSFUL_STREAM_FAILURES: - // Java 8 compiler didn't like the previous fall-through case structure - if (this.scenario == DR_TEST_SCENARIO_NO_MULTIPLE_SUBSCRIPTION) { - if (this.subscribed) { - return Flux.error(new IllegalStateException("Cannot subscribe to the same flux twice")); - } - this.subscribed = true; - } - - if (this.tryNumber <= 3) { - // tryNumber is 1 indexed, so we have to sub 1. - if (offset != (this.tryNumber - 1L) * 256 - || count != this.scenarioData.remaining() - (this.tryNumber - 1L) * 256) { - return Flux.error(new IllegalArgumentException("Info values are incorrect.")); - } - - ByteBuffer toSend = this.scenarioData.duplicate(); - toSend.position((this.tryNumber - 1) * 256); - toSend.limit(this.tryNumber * 256); - - Flux dataStream = Flux.just(toSend); - - // A slightly odd but sufficient means of exercising the different retriable exceptions. - Exception e = tryNumber % 2 == 0 ? new IOException() : new TimeoutException(); - - return dataStream.concatWith(Flux.error(e)); - } - if (offset != (this.tryNumber - 1L) * 256 - || count != this.scenarioData.remaining() - (this.tryNumber - 1L) * 256) { - return Flux.error(new IllegalArgumentException("Info values are incorrect.")); - } - ByteBuffer toSend = this.scenarioData.duplicate(); - toSend.position((this.tryNumber - 1) * 256); - toSend.limit(this.tryNumber * 256); - - return Flux.just(toSend); - - case DR_TEST_SCENARIO_ERROR_AFTER_ALL_DATA: - return Flux.just(scenarioData.duplicate()).concatWith(Flux.error(new IOException("Exception at end"))); - - case DR_TEST_SCENARIO_MAX_RETRIES_EXCEEDED: - return Flux.error(new IOException()); - - case DR_TEST_SCENARIO_NON_RETRYABLE_ERROR: - return Flux.error(new Exception()); - - case DR_TEST_SCENARIO_ERROR_GETTER_MIDDLE: - /* - * We return a retryable error here so we have to invoke the getter, which will throw an error in - * this case. - */ - return (this.tryNumber == 1) - ? Flux.error(new IOException()) - : Flux.error(new IllegalArgumentException("Retried after getter error.")); - - case DR_TEST_SCENARIO_TIMEOUT: - return Flux.just(scenarioData.duplicate()).delayElements(Duration.ofSeconds(61)); - - default: - return Flux.error(new IllegalArgumentException("Invalid test case")); - } - } - - public HttpPipelinePolicy asPolicy() { - return (context, next) -> { - tryNumber++; - HttpHeader rangeHeader = context.getHttpRequest().getHeaders().get("x-ms-range"); - long offset = 0L; - Long count = null; - if (rangeHeader != null) { - String[] ranges = rangeHeader.getValue().replace("bytes=", "").split("-"); - offset = Long.parseLong(ranges[0]); - if (ranges.length > 1) { - count = Long.parseLong(ranges[1]) - offset + 1; - } - } - long finalOffset = offset; - Long finalCount = count; - - MockHttpResponse response = new MockHttpResponse(null, 200) { - @Override - public Flux getBody() { - return getDownloadStream(finalOffset, finalCount); - } - }; - Long contentUpperBound = finalCount == null ? scenarioData.remaining() - 1 : finalOffset + finalCount - 1; - response.getHeaders() - .set(HttpHeaderName.CONTENT_RANGE, - String.format("%d-%d/%d", finalOffset, contentUpperBound, scenarioData.remaining())); - - switch (scenario) { - case DR_TEST_SCENARIO_ERROR_GETTER_MIDDLE: - switch (tryNumber) { - case 1: - return Mono.just(response); - - case 2: - /* - This validates that we don't retry in the getter even if it's a retryable error from the - service. - */ - throw new BlobStorageException("Message", new MockHttpResponse(null, 500), null); - - default: - throw new IllegalArgumentException("Retried after error in getter"); - } - case DR_TEST_SCENARIO_NO_MULTIPLE_SUBSCRIPTION: - // Construct a new flux each time to mimic getting a new download stream. - DownloadResponseMockFlux nextFlux - = new DownloadResponseMockFlux(scenario, tryNumber, scenarioData, options); - MockHttpResponse newResponse = new MockHttpResponse(null, 200) { - @Override - public Flux getBody() { - return nextFlux.getDownloadStream(finalOffset, finalCount); - } - }; - return Mono.just(newResponse); - - default: - return Mono.just(response); - } - }; - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseTests.java deleted file mode 100644 index d44cbd49babd..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/DownloadResponseTests.java +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.HttpHeader; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.BlobContainerAsyncClient; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.BlobServiceAsyncClient; -import com.azure.storage.blob.BlobServiceClient; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.BlobDownloadAsyncResponse; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.DownloadRetryOptions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.Exceptions; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.util.concurrent.TimeoutException; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class DownloadResponseTests extends BlobTestBase { - private BlockBlobClient bu; - - @BeforeEach - public void setup() { - bu = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bu.upload(DATA.getDefaultInputStream(), DATA.getDefaultText().length()); - } - - /* - This shouldn't really be different from anything else we're doing in the other tests. Just a sanity check against - a real use case. - */ - @Test - public void networkCall() { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - bu.downloadStream(outputStream); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), outputStream.toByteArray()); - } - - @Test - public void networkCallNoETagReturned() { - HttpPipelinePolicy removeETagPolicy = (context, next) -> next.process().flatMap(response -> { - HttpHeader eTagHeader = response.getHeaders().get(HttpHeaderName.ETAG); - if (eTagHeader == null) { - return Mono.just(response); - } - HttpHeaders headers = response.getHeaders(); - headers.remove(HttpHeaderName.ETAG); - return Mono.just(getStubDownloadResponse(response, response.getStatusCode(), response.getBody(), headers)); - }); - BlobServiceClient bsc = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), - primaryBlobServiceClient.getAccountUrl(), removeETagPolicy).buildClient(); - BlobContainerClient cc = bsc.getBlobContainerClient(containerName); - BlockBlobClient blockBlobClient = cc.getBlobClient(bu.getBlobName()).getBlockBlobClient(); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - blockBlobClient.downloadStream(outputStream); - TestUtils.assertArraysEqual(DATA.getDefaultBytes(), outputStream.toByteArray()); - } - - @ParameterizedTest - @MethodSource("successfulSupplier") - public void successful(int scenario, int tryNumber, boolean setCount) { - DownloadResponseMockFlux flux = new DownloadResponseMockFlux(scenario, this); - - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - BlobServiceAsyncClient bsc = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), - primaryBlobServiceClient.getAccountUrl(), flux.asPolicy()).buildAsyncClient(); - BlobContainerAsyncClient cc = bsc.getBlobContainerAsyncClient(containerName); - BlockBlobAsyncClient blockBlobAsyncClient = cc.getBlobAsyncClient(bu.getBlobName()).getBlockBlobAsyncClient(); - BlobRange range = setCount ? new BlobRange(0L, (long) flux.getScenarioData().remaining()) : new BlobRange(0); - - StepVerifier.create(blockBlobAsyncClient.downloadStreamWithResponse(range, options, null, false)) - .assertNext(response -> { - TestUtils.assertArraysEqual(FluxUtil.collectBytesInByteBufferStream(response.getValue()).block(), - flux.getScenarioData().array()); - assertEquals(tryNumber, flux.getTryNumber()); - }) - .verifyComplete(); - } - - private static Stream successfulSupplier() { - return Stream.of(Arguments.of(DownloadResponseMockFlux.DR_TEST_SCENARIO_SUCCESSFUL_ONE_CHUNK, 1, true), - Arguments.of(DownloadResponseMockFlux.DR_TEST_SCENARIO_SUCCESSFUL_MULTI_CHUNK, 1, true), - Arguments.of(DownloadResponseMockFlux.DR_TEST_SCENARIO_SUCCESSFUL_STREAM_FAILURES, 4, true), - Arguments.of(DownloadResponseMockFlux.DR_TEST_SCENARIO_NO_MULTIPLE_SUBSCRIPTION, 4, true), - // Range download - Arguments.of(DownloadResponseMockFlux.DR_TEST_SCENARIO_ERROR_AFTER_ALL_DATA, 1, true), - // Non-range download - Arguments.of(DownloadResponseMockFlux.DR_TEST_SCENARIO_ERROR_AFTER_ALL_DATA, 1, false)); - } - - @ParameterizedTest - @MethodSource("failureSupplier") - public void failure(int scenario, Class exceptionType, int tryNumber) { - DownloadResponseMockFlux flux = new DownloadResponseMockFlux(scenario, this); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); - - BlobServiceAsyncClient bsc = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), - primaryBlobServiceClient.getAccountUrl(), flux.asPolicy()).buildAsyncClient(); - BlobContainerAsyncClient cc = bsc.getBlobContainerAsyncClient(containerName); - BlockBlobAsyncClient blockBlobAsyncClient = cc.getBlobAsyncClient(bu.getBlobName()).getBlockBlobAsyncClient(); - - BlobDownloadAsyncResponse response - = blockBlobAsyncClient.downloadStreamWithResponse(null, options, null, false).block(); - assertNotNull(response); - - StepVerifier.create(response.getValue()).verifyErrorSatisfies(e -> { - Throwable cause = Exceptions.unwrap(e); - assertInstanceOf(exceptionType, cause); - assertEquals(tryNumber, flux.getTryNumber()); - }); - } - - private static Stream failureSupplier() { - return Stream.of( - Arguments.of(DownloadResponseMockFlux.DR_TEST_SCENARIO_MAX_RETRIES_EXCEEDED, IOException.class, 6), - Arguments.of(DownloadResponseMockFlux.DR_TEST_SCENARIO_NON_RETRYABLE_ERROR, Exception.class, 1), - Arguments.of(DownloadResponseMockFlux.DR_TEST_SCENARIO_ERROR_GETTER_MIDDLE, BlobStorageException.class, 2)); - } - - @ParameterizedTest - // We test retry count elsewhere. Just using small numbers to speed up the test. - @CsvSource(value = { "0,1" }) - public void timeout(int retryCount) { - DownloadResponseMockFlux flux - = new DownloadResponseMockFlux(DownloadResponseMockFlux.DR_TEST_SCENARIO_TIMEOUT, this); - DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(retryCount); - - BlobServiceAsyncClient bsc = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount().getCredential(), - primaryBlobServiceClient.getAccountUrl(), flux.asPolicy()).buildAsyncClient(); - BlobContainerAsyncClient cc = bsc.getBlobContainerAsyncClient(containerName); - BlockBlobAsyncClient blockBlobAsyncClient = cc.getBlobAsyncClient(bu.getBlobName()).getBlockBlobAsyncClient(); - - Flux bufferMono = blockBlobAsyncClient.downloadStreamWithResponse(null, options, null, false) - .flatMapMany(r -> r.getValue()); - - StepVerifier.create(bufferMono.timeout(Duration.ofSeconds(1))) - .expectSubscription() - .verifyErrorSatisfies(it -> assertInstanceOf(TimeoutException.class, Exceptions.unwrap(it))); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTests.java deleted file mode 100644 index 29449f6b65be..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTests.java +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.util.Context; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerEncoding; -import com.azure.storage.blob.BlobContainerAsyncClient; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.BlobUrlParts; -import com.azure.storage.blob.FakeCredentialInTests; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.PageList; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.Utility; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.SasImplUtils; -import com.azure.storage.common.sas.CommonSasQueryParameters; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Flux; -import reactor.test.StepVerifier; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class HelperTests extends BlobTestBase { - /* - This test is to validate the workaround for the autorest bug that forgets to set the request property on the - response. - */ - - @Test - public void requestProperty() { - assertNotNull(cc.deleteWithResponse(null, null, null).getRequest()); - } - - @ParameterizedTest - @MethodSource("blobRangeSupplier") - public void blobRange(int offset, Long count, String result) { - assertEquals(new BlobRange(offset, count).toHeaderValue(), result); - } - - private static Stream blobRangeSupplier() { - return Stream.of(Arguments.of(0, null, null), Arguments.of(0, 5L, "bytes=0-4"), - Arguments.of(5, 10L, "bytes=5-14")); - } - - @ParameterizedTest - @MethodSource("blobRangeIASupplier") - public void blobRangeIA(int offset, Long count) { - assertThrows(IllegalArgumentException.class, () -> new BlobRange(offset, count)); - } - - private static Stream blobRangeIASupplier() { - return Stream.of(Arguments.of(-1, 5L), Arguments.of(0, -1L)); - } - - @ParameterizedTest - @CsvSource( - value = { - "blob,blob", - "path/to]a blob,path/to]a blob", - "path%2Fto%5Da%20blob,path/to]a blob", - "斑點,斑點", - "%E6%96%91%E9%BB%9E,斑點" }) - public void urlParser(String originalBlobName, String finalBlobName) throws MalformedURLException { - BlobUrlParts parts = BlobUrlParts.parse(new URL( - "http://host/container/" + originalBlobName + "?snapshot=snapshot&sv=" + Constants.SAS_SERVICE_VERSION - + "&sr=c&sp=r&sig=" + FakeCredentialInTests.FAKE_SIGNATURE_PLACEHOLDER)); - - assertEquals("http", parts.getScheme()); - assertEquals("host", parts.getHost()); - assertEquals("container", parts.getBlobContainerName()); - assertEquals(finalBlobName, parts.getBlobName()); - assertEquals("snapshot", parts.getSnapshot()); - assertEquals("r", parts.getCommonSasQueryParameters().getPermissions()); - assertEquals(Constants.SAS_SERVICE_VERSION, parts.getCommonSasQueryParameters().getVersion()); - assertEquals("c", parts.getCommonSasQueryParameters().getResource()); - assertEquals(Utility.urlDecode("sD3fPKLnFKZUjnSV4qA%2FXoJOqsmDfNfxWcZ7kPtLc0I%3D"), - parts.getCommonSasQueryParameters().getSignature()); - } - - @Test - public void blobURLParts() { - BlobUrlParts parts = new BlobUrlParts(); - parts.setScheme("http") - .setHost("host") - .setContainerName("container") - .setBlobName("blob") - .setSnapshot("snapshot"); - OffsetDateTime expiryTime = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - BlobSasPermission p = new BlobSasPermission().setReadPermission(true); - BlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiryTime, p); - - BlobSasImplUtil implUtil - = new BlobSasImplUtil(sasValues, "containerName", "blobName", "snapshot", null, "encryptionScope"); - String sas = implUtil.generateSas(ENVIRONMENT.getPrimaryAccount().getCredential(), Context.NONE); - - parts.setCommonSasQueryParameters(new CommonSasQueryParameters(SasImplUtils.parseQueryString(sas), true)); - - String[] splitParts = parts.toUrl().toString().split("\\?"); - - // Ensure that there is only one question mark even when sas and snapshot are present - assertEquals(splitParts.length, 2); - assertEquals(splitParts[0], "http://host/container/blob"); - assertTrue(splitParts[1].contains("snapshot=snapshot")); - assertTrue(splitParts[1].contains("sp=r")); - assertTrue(splitParts[1].contains("sig=")); - assertTrue(splitParts[1].contains("ses=encryptionScope")); - assertEquals(splitParts[1].split("&").length, 7); // snapshot & sv & sr & sp & sig & ses - } - - @Test - public void blobURLPartsImplicitRoot() { - BlobUrlParts bup = new BlobUrlParts().setScheme("http").setHost("host").setBlobName("blob"); - - BlobUrlParts implParts = BlobUrlParts.parse(bup.toUrl()); - - assertEquals(implParts.getBlobContainerName(), BlobContainerAsyncClient.ROOT_CONTAINER_NAME); - } - - @Test - public void utilityConvertStreamToBufferReplayable() { - byte[] data = getRandomByteArray(1024); - - Flux flux = Utility.convertStreamToByteBuffer(new ByteArrayInputStream(data), 1024, 1024, true); - - StepVerifier.create(flux) - .assertNext(buffer -> assertEquals(buffer.compareTo(ByteBuffer.wrap(data)), 0)) - .verifyComplete(); - // subscribe multiple times and ensure data is same each time - StepVerifier.create(flux) - .assertNext(buffer -> assertEquals(buffer.compareTo(ByteBuffer.wrap(data)), 0)) - .verifyComplete(); - } - - /* - This test covers the switch from using available() to using read() to check that a stream is done when converting - from a stream to a flux. We previously used to assert that, when we had read length bytes from the stream that - available() == 0, but available only returns an estimate and is not reliable. Now we assert that read() == -1 - */ - @Test - public void utilityConvertStreamToBufferAvailable() { - byte[] data = getRandomByteArray(10); - - Flux flux = Utility.convertStreamToByteBuffer(new TestBAIS(data), 10, 10, true); - - //then: "When the stream is the right length but available always returns > 0, do not throw" - StepVerifier.create(flux) - .assertNext(buffer -> assertEquals(buffer.compareTo(ByteBuffer.wrap(data)), 0)) - .verifyComplete(); - // subscribe multiple times and ensure data is same each time - StepVerifier.create(flux) - .assertNext(buffer -> assertEquals(buffer.compareTo(ByteBuffer.wrap(data)), 0)) - .verifyComplete(); - - //when: "When the stream is actually longer than the length, throw" - flux = Utility.convertStreamToByteBuffer(new TestBAIS(data), 9, 10, true); - - StepVerifier.create(flux).verifyError(IllegalStateException.class); - } - - static class TestBAIS extends ByteArrayInputStream { - - TestBAIS(byte[] data) { - super(data); - } - - @Override - public synchronized int available() { - return 10; - } - } - - @Test - public void pageListCustomDeserializer() throws IOException { - String responseXml = " \n" + " \n" + " \n" - + " 0 \n" + " 511 \n" + " \n" + " \n" - + " 512 \n" + " 1023 \n" + " \n" - + " \n" + " 1024 \n" + " 2047 \n" - + " \n" + ""; - - PageList pageList = JacksonAdapter.createDefaultSerializerAdapter() - .deserialize(responseXml, PageList.class, SerializerEncoding.XML); - - assertEquals(2, pageList.getPageRange().size()); - assertEquals(1, pageList.getClearRange().size()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HttpFaultInjectingTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HttpFaultInjectingTests.java deleted file mode 100644 index 565a9b7e44e2..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HttpFaultInjectingTests.java +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpClientProvider; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.netty.NettyAsyncHttpClientProvider; -import com.azure.core.http.okhttp.OkHttpAsyncClientProvider; -import com.azure.core.test.TestMode; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.HttpClientOptions; -import com.azure.core.util.SharedExecutorService; -import com.azure.core.util.UrlBuilder; -import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobClientBuilder; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.BlobServiceClientBuilder; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.options.BlobDownloadToFileOptions; -import com.azure.storage.common.ParallelTransferOptions; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.policy.RequestRetryOptions; -import com.azure.storage.common.policy.RetryPolicyType; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIf; -import reactor.core.publisher.Mono; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.OpenOption; -import java.nio.file.StandardOpenOption; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -import static com.azure.storage.blob.BlobTestBase.ENVIRONMENT; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Set of tests that use HTTP fault injecting to simulate scenarios where the network has random errors. - */ -@EnabledIf("shouldRun") -public class HttpFaultInjectingTests { - private static final ClientLogger LOGGER = new ClientLogger(HttpFaultInjectingTests.class); - private static final HttpHeaderName UPSTREAM_URI_HEADER = HttpHeaderName.fromString("X-Upstream-Base-Uri"); - private static final HttpHeaderName HTTP_FAULT_INJECTOR_RESPONSE_HEADER - = HttpHeaderName.fromString("x-ms-faultinjector-response-option"); - - private BlobContainerClient containerClient; - - @BeforeEach - public void setup() { - String testName - = ("httpFaultInjectingTests" + CoreUtils.randomUuid().toString().replace("-", "")).toLowerCase(); - containerClient = new BlobServiceClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .httpClient(BlobTestBase.getHttpClient(() -> { - throw new RuntimeException("Test should not run during playback."); - })) - .buildClient() - .createBlobContainer(testName); - } - - @AfterEach - public void teardown() { - if (containerClient != null) { - containerClient.delete(); - } - } - - /** - * Tests downloading to file with fault injection. - *

- * This test will upload a single blob of about 9MB and then download it in parallel 500 times. Each download will - * have its file contents compared to the original blob data. The test only cares about files that were properly - * downloaded, if a download fails with a network error it will be ignored. A requirement of 90% of files being - * successfully downloaded is also a requirement to prevent a case where most files failed to download and passing, - * hiding a true issue. - */ - @Test - public void downloadToFileWithFaultInjection() throws IOException, InterruptedException { - byte[] realFileBytes = new byte[9 * Constants.MB - 1]; - ThreadLocalRandom.current().nextBytes(realFileBytes); - - containerClient.getBlobClient(containerClient.getBlobContainerName()) - .upload(BinaryData.fromBytes(realFileBytes), true); - - BlobClient downloadClient = new BlobClientBuilder().endpoint(ENVIRONMENT.getPrimaryAccount().getBlobEndpoint()) - .containerName(containerClient.getBlobContainerName()) - .blobName(containerClient.getBlobContainerName()) - .credential(ENVIRONMENT.getPrimaryAccount().getCredential()) - .httpClient(new HttpFaultInjectingHttpClient(getFaultInjectingWrappedHttpClient())) - .retryOptions(new RequestRetryOptions(RetryPolicyType.FIXED, 4, null, 10L, 10L, null)) - .buildClient(); - - List files = new ArrayList<>(500); - for (int i = 0; i < 500; i++) { - File file = File.createTempFile(CoreUtils.randomUuid().toString() + i, ".txt"); - file.deleteOnExit(); - files.add(file); - } - AtomicInteger successCount = new AtomicInteger(); - - Set overwriteOptions - = new HashSet<>(Arrays.asList(StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, // If the file already exists and it is opened for WRITE access, then its length is truncated to 0. - StandardOpenOption.READ, StandardOpenOption.WRITE)); - - CountDownLatch countDownLatch = new CountDownLatch(500); - SharedExecutorService.getInstance().invokeAll(files.stream().map(it -> (Callable) () -> { - try { - downloadClient.downloadToFileWithResponse( - new BlobDownloadToFileOptions(it.getAbsolutePath()).setOpenOptions(overwriteOptions) - .setParallelTransferOptions(new ParallelTransferOptions().setMaxConcurrency(2)), - null, Context.NONE); - byte[] actualFileBytes = Files.readAllBytes(it.toPath()); - TestUtils.assertArraysEqual(realFileBytes, actualFileBytes); - LOGGER.atVerbose() - .addKeyValue("successCount", successCount.incrementAndGet()) - .log("Download completed successfully."); - Files.deleteIfExists(it.toPath()); - } catch (Exception ex) { - // Don't let network exceptions fail the download - LOGGER.atWarning() - .addKeyValue("downloadFile", it.getAbsolutePath()) - .log("Failed to complete download.", ex); - } finally { - countDownLatch.countDown(); - } - - return null; - }).collect(Collectors.toList())); - - countDownLatch.await(10, TimeUnit.MINUTES); - - assertTrue(successCount.get() >= 450); - // cleanup - files.forEach(it -> { - try { - Files.deleteIfExists(it.toPath()); - } catch (IOException e) { - LOGGER.atWarning().addKeyValue("file", it.getAbsolutePath()).log("Failed to delete file.", e); - } - }); - } - - @SuppressWarnings("unchecked") - private HttpClient getFaultInjectingWrappedHttpClient() { - switch (ENVIRONMENT.getHttpClientType()) { - case NETTY: - return HttpClient.createDefault(new HttpClientOptions().readTimeout(Duration.ofSeconds(2)) - .responseTimeout(Duration.ofSeconds(2)) - .setHttpClientProvider(NettyAsyncHttpClientProvider.class)); - - case OK_HTTP: - return HttpClient.createDefault(new HttpClientOptions().readTimeout(Duration.ofSeconds(2)) - .responseTimeout(Duration.ofSeconds(2)) - .setHttpClientProvider(OkHttpAsyncClientProvider.class)); - - case VERTX: - return HttpClient.createDefault(new HttpClientOptions().readTimeout(Duration.ofSeconds(2)) - .responseTimeout(Duration.ofSeconds(2)) - .setHttpClientProvider(getVertxClientProviderReflectivelyUntilNameChangeReleases())); - - case JDK_HTTP: - try { - return HttpClient.createDefault(new HttpClientOptions().readTimeout(Duration.ofSeconds(2)) - .responseTimeout(Duration.ofSeconds(2)) - .setHttpClientProvider((Class) Class - .forName("com.azure.core.http.jdk.httpclient.JdkHttpClientProvider"))); - } catch (ClassNotFoundException e) { - throw new IllegalStateException(e); - } - - default: - throw new IllegalArgumentException("Unknown http client type: " + ENVIRONMENT.getHttpClientType()); - } - } - - @SuppressWarnings("unchecked") - private static Class getVertxClientProviderReflectivelyUntilNameChangeReleases() { - Class clazz; - try { - clazz = Class.forName("com.azure.core.http.vertx.VertxHttpClientProvider"); - } catch (ClassNotFoundException ex) { - try { - clazz = Class.forName("com.azure.core.http.vertx.VertxAsyncHttpClientProvider"); - } catch (ClassNotFoundException ex2) { - ex2.addSuppressed(ex); - throw new RuntimeException(ex2); - } - } - - return (Class) clazz; - } - - // For now a local implementation is here in azure-storage-blob until this is released in azure-core-test. - // Since this is a local definition with a clear set of configurations everything is simplified. - private static final class HttpFaultInjectingHttpClient implements HttpClient { - private final HttpClient wrappedHttpClient; - - HttpFaultInjectingHttpClient(HttpClient wrappedHttpClient) { - this.wrappedHttpClient = wrappedHttpClient; - } - - @Override - public Mono send(HttpRequest request) { - return send(request, Context.NONE); - } - - @Override - public Mono send(HttpRequest request, Context context) { - URL originalUrl = request.getUrl(); - request.setHeader(UPSTREAM_URI_HEADER, originalUrl.toString()).setUrl(rewriteUrl(originalUrl)); - String faultType = faultInjectorHandling(); - request.setHeader(HTTP_FAULT_INJECTOR_RESPONSE_HEADER, faultType); - - return wrappedHttpClient.send(request, context).map(response -> { - HttpRequest request1 = response.getRequest(); - request1.getHeaders().remove(UPSTREAM_URI_HEADER); - request1.setUrl(originalUrl); - - return response; - }); - } - - @Override - public HttpResponse sendSync(HttpRequest request, Context context) { - URL originalUrl = request.getUrl(); - request.setHeader(UPSTREAM_URI_HEADER, originalUrl.toString()).setUrl(rewriteUrl(originalUrl)); - String faultType = faultInjectorHandling(); - request.setHeader(HTTP_FAULT_INJECTOR_RESPONSE_HEADER, faultType); - - HttpResponse response = wrappedHttpClient.sendSync(request, context); - response.getRequest().setUrl(originalUrl); - response.getRequest().getHeaders().remove(UPSTREAM_URI_HEADER); - - return response; - } - - private static URL rewriteUrl(URL originalUrl) { - try { - return UrlBuilder.parse(originalUrl).setScheme("http").setHost("localhost").setPort(7777).toUrl(); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - private static String faultInjectorHandling() { - // f: Full response - // p: Partial Response (full headers, 50% of body), then wait indefinitely - // pc: Partial Response (full headers, 50% of body), then close (TCP FIN) - // pa: Partial Response (full headers, 50% of body), then abort (TCP RST) - // pn: Partial Response (full headers, 50% of body), then finish normally - // n: No response, then wait indefinitely - // nc: No response, then close (TCP FIN) - // na: No response, then abort (TCP RST) - double random = ThreadLocalRandom.current().nextDouble(); - int choice = (int) (random * 100); - - if (choice >= 25) { - // 75% of requests complete without error. - return "f"; - } else if (choice >= 1) { - if (random <= 0.34D) { - return "n"; - } else if (random <= 0.67D) { - return "nc"; - } else { - return "na"; - } - } else { - if (random <= 0.25D) { - return "p"; - } else if (random <= 0.50D) { - return "pc"; - } else if (random <= 0.75D) { - return "pa"; - } else { - return "pn"; - } - } - } - } - - private static boolean shouldRun() { - String osName = System.getProperty("os.name").toLowerCase(Locale.ROOT); - - // macOS has known issues running HTTP fault injector, change this once - // https://github.com/Azure/azure-sdk-tools/pull/6216 is resolved - return ENVIRONMENT.getTestMode() == TestMode.LIVE && !osName.contains("mac os") && !osName.contains("darwin"); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/LeaseApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/LeaseApiTests.java deleted file mode 100644 index 9619b5632292..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/LeaseApiTests.java +++ /dev/null @@ -1,799 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.rest.Response; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.BlobContainerProperties; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.options.BlobAcquireLeaseOptions; -import com.azure.storage.blob.options.BlobBreakLeaseOptions; -import com.azure.storage.blob.options.BlobChangeLeaseOptions; -import com.azure.storage.blob.options.BlobReleaseLeaseOptions; -import com.azure.storage.blob.options.BlobRenewLeaseOptions; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; - -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class LeaseApiTests extends BlobTestBase { - private BlobClientBase createBlobClient() { - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - bc.upload(DATA.getDefaultInputStream(), DATA.getDefaultDataSize()); - return bc; - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseSupplier") - public void acquireBlobLease(String proposedID, int leaseTime, LeaseStateType leaseState, - LeaseDurationType leaseDuration) { - BlobClientBase bc = createBlobClient(); - BlobLeaseClient leaseClient = createLeaseClient(bc, proposedID); - - if (proposedID != null) { - assertEquals(leaseClient.getLeaseId(), proposedID); - } - - String leaseId = leaseClient.acquireLease(leaseTime); - - assertNotNull(leaseId); - assertEquals(leaseClient.getLeaseId(), leaseId); - - Response response = bc.getPropertiesWithResponse(null, null, null); - BlobProperties properties = response.getValue(); - HttpHeaders headers = response.getHeaders(); - - assertEquals(leaseState, properties.getLeaseState()); - assertEquals(leaseDuration, properties.getLeaseDuration()); - assertTrue(validateBasicHeaders(headers)); - } - - private static Stream acquireBlobLeaseSupplier() { - return Stream.of(Arguments.of(null, -1, LeaseStateType.LEASED, LeaseDurationType.INFINITE), - Arguments.of(null, 25, LeaseStateType.LEASED, LeaseDurationType.FIXED), - Arguments.of(CoreUtils.randomUuid().toString(), -1, LeaseStateType.LEASED, LeaseDurationType.INFINITE)); - } - - @Test - public void acquireBlobLeaseMin() { - assertResponseStatusCode( - createLeaseClient(createBlobClient()).acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1), null, null), - 201); - } - - @ParameterizedTest - @ValueSource(ints = { -10, 10, 70 }) - public void acquireBlobLeaseDurationFail(int duration) { - BlobLeaseClient leaseClient = createLeaseClient(createBlobClient()); - assertThrows(BlobStorageException.class, () -> leaseClient.acquireLease(duration)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void acquireBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobClientBase bc = createBlobClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertResponseStatusCode(createLeaseClient(bc) - .acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1).setRequestConditions(mac), null, null), 201); - } - - private static Stream acquireBlobLeaseDurationFailSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), Arguments.of(OLD_DATE, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null), Arguments.of(null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null), - Arguments.of(null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void acquireBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - BlobClientBase bc = createBlobClient(); - noneMatch = setupBlobMatchCondition(bc, noneMatch); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc) - .acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1).setRequestConditions(mac), null, null)); - } - - private static Stream acquireBlobLeaseACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null), Arguments.of(null, OLD_DATE, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null), Arguments.of(null, null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void acquireBlobLeaseError() { - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc).acquireLease(20)); - } - - @Test - public void renewBlobLease() { - BlobClientBase bc = createBlobClient(); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobLeaseClient leaseClient = createLeaseClient(bc, leaseID); - - // If running in live mode wait for the lease to expire to ensure we are actually renewing it - sleepIfRunningAgainstService(16000); - Response renewLeaseResponse - = leaseClient.renewLeaseWithResponse(new BlobRenewLeaseOptions(), null, null); - - assertEquals(bc.getProperties().getLeaseState(), LeaseStateType.LEASED); - validateBasicHeaders(renewLeaseResponse.getHeaders()); - assertNotNull(renewLeaseResponse.getValue()); - assertEquals(renewLeaseResponse.getValue(), leaseClient.getLeaseId()); - } - - @Test - public void renewBlobLeaseSimple() { - BlobClientBase bc = createBlobClient(); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobLeaseClient leaseClient = createLeaseClient(bc, leaseID); - - // If running in live mode wait for the lease to expire to ensure we are actually renewing it - sleepIfRunningAgainstService(16000); - leaseClient.renewLease(); - - assertEquals(bc.getProperties().getLeaseState(), LeaseStateType.LEASED); - } - - @Test - public void renewBlobLeaseMin() { - BlobClientBase bc = createBlobClient(); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - - assertResponseStatusCode( - createLeaseClient(bc, leaseID).renewLeaseWithResponse(new BlobRenewLeaseOptions(), null, null), 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void renewBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobClientBase bc = createBlobClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertResponseStatusCode(createLeaseClient(bc, leaseID) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac), null, null), 200); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void renewBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobClientBase bc = createBlobClient(); - noneMatch = setupBlobMatchCondition(bc, noneMatch); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc, leaseID) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac), null, null)); - } - - @Test - public void renewBlobLeaseError() { - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc, "id").renewLease()); - } - - @Test - public void releaseBlobLease() { - BlobClientBase bc = createBlobClient(); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - HttpHeaders headers - = createLeaseClient(bc, leaseID).releaseLeaseWithResponse(new BlobReleaseLeaseOptions(), null, null) - .getHeaders(); - - assertEquals(bc.getProperties().getLeaseState(), LeaseStateType.AVAILABLE); - assertTrue(validateBasicHeaders(headers)); - } - - @Test - public void releaseBlobLeaseSimple() { - BlobClientBase bc = createBlobClient(); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - createLeaseClient(bc, leaseID).releaseLease(); - - assertEquals(bc.getProperties().getLeaseState(), LeaseStateType.AVAILABLE); - } - - @Test - public void releaseBlobLeaseMin() { - BlobClientBase bc = createBlobClient(); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - assertResponseStatusCode( - createLeaseClient(bc, leaseID).releaseLeaseWithResponse(new BlobReleaseLeaseOptions(), null, null), 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void releaseBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobClientBase bc = createBlobClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertResponseStatusCode(createLeaseClient(bc, leaseID) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac), null, null), 200); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void releaseBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - BlobClientBase bc = createBlobClient(); - noneMatch = setupBlobMatchCondition(bc, noneMatch); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc, leaseID) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac), null, null)); - } - - @Test - public void releaseBlobLeaseError() { - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc, "id").releaseLease()); - } - - @ParameterizedTest - @MethodSource("breakBlobLeaseSupplier") - public void breakBlobLease(int leaseTime, Integer breakPeriod, int remainingTime) { - BlobClientBase bc = createBlobClient(); - BlobLeaseClient leaseClient = createLeaseClient(bc, testResourceNamer.randomUuid()); - leaseClient.acquireLease(leaseTime); - Response breakLeaseResponse = leaseClient.breakLeaseWithResponse( - new BlobBreakLeaseOptions().setBreakPeriod(breakPeriod == null ? null : Duration.ofSeconds(breakPeriod)), - null, null); - LeaseStateType leaseState = bc.getProperties().getLeaseState(); - - assertTrue(leaseState == LeaseStateType.BROKEN || leaseState == LeaseStateType.BREAKING); - assertTrue(breakLeaseResponse.getValue() <= remainingTime); - assertTrue(validateBasicHeaders(breakLeaseResponse.getHeaders())); - } - - @Test - public void breakBlobLeaseSimple() { - BlobClientBase bc = createBlobClient(); - BlobLeaseClient leaseClient = createLeaseClient(bc, testResourceNamer.randomUuid()); - leaseClient.acquireLease(-1); - leaseClient.breakLease(); - LeaseStateType leaseState = bc.getProperties().getLeaseState(); - - assertTrue(leaseState == LeaseStateType.BROKEN || leaseState == LeaseStateType.BREAKING); - } - - private static Stream breakBlobLeaseSupplier() { - return Stream.of(Arguments.of(-1, null, 0), Arguments.of(-1, 20, 25), Arguments.of(20, 15, 16)); - } - - @Test - public void breakBlobLeaseMin() { - BlobClientBase bc = createBlobClient(); - setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - - assertResponseStatusCode(createLeaseClient(bc).breakLeaseWithResponse(new BlobBreakLeaseOptions(), null, null), - 202); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void breakBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobClientBase bc = createBlobClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - setupBlobLeaseCondition(bc, RECEIVED_ETAG); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertResponseStatusCode(createLeaseClient(bc) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac), null, null), 202); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void breakBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobClientBase bc = createBlobClient(); - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac), null, null)); - } - - @Test - public void breakBlobLeaseError() { - BlobClientBase bc = createBlobClient(); - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc).breakLease()); - } - - @Test - public void changeBlobLease() { - BlobClientBase bc = createBlobClient(); - BlobLeaseClient leaseClient = createLeaseClient(bc, testResourceNamer.randomUuid()); - leaseClient.acquireLease(15); - - String newLeaseId = testResourceNamer.randomUuid(); - Response changeLeaseResponse - = leaseClient.changeLeaseWithResponse(new BlobChangeLeaseOptions(newLeaseId), null, null); - - assertEquals(changeLeaseResponse.getValue(), newLeaseId); - assertEquals(changeLeaseResponse.getValue(), leaseClient.getLeaseId()); - - BlobLeaseClient leaseClient2 = createLeaseClient(bc, changeLeaseResponse.getValue()); - - assertResponseStatusCode(leaseClient2.releaseLeaseWithResponse(new BlobReleaseLeaseOptions(), null, null), 200); - assertTrue(validateBasicHeaders(changeLeaseResponse.getHeaders())); - } - - @Test - public void changeBlobLeaseSimple() { - BlobClientBase bc = createBlobClient(); - - String oldLease = testResourceNamer.randomUuid(); - String newLease = testResourceNamer.randomUuid(); - - BlobLeaseClient leaseClient = createLeaseClient(bc, oldLease); - leaseClient.acquireLease(15); - - leaseClient.changeLease(newLease); - - assertEquals(newLease, leaseClient.getLeaseId()); - } - - @Test - public void changeBlobLeaseMin() { - BlobClientBase bc = createBlobClient(); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - assertResponseStatusCode(createLeaseClient(bc, leaseID) - .changeLeaseWithResponse(new BlobChangeLeaseOptions(testResourceNamer.randomUuid()), null, null), 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void changeBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobClientBase bc = createBlobClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertResponseStatusCode(createLeaseClient(bc, leaseID).changeLeaseWithResponse( - new BlobChangeLeaseOptions(testResourceNamer.randomUuid()).setRequestConditions(mac), null, null), 200); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void changeBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - BlobClientBase bc = createBlobClient(); - noneMatch = setupBlobMatchCondition(bc, noneMatch); - String leaseID = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc, leaseID).changeLeaseWithResponse( - new BlobChangeLeaseOptions(testResourceNamer.randomUuid()).setRequestConditions(mac), null, null)); - } - - @Test - public void changeBlobLeaseError() { - BlockBlobClient bc = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - assertThrows(BlobStorageException.class, () -> createLeaseClient(bc, "id").changeLease("id")); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseSupplier") - public void acquireContainerLease(String proposedID, int leaseTime, LeaseStateType leaseState, - LeaseDurationType leaseDuration) { - BlobLeaseClient leaseClient = createLeaseClient(cc, proposedID); - - Response leaseResponse - = leaseClient.acquireLeaseWithResponse(new BlobAcquireLeaseOptions(leaseTime), null, null); - - assertEquals(leaseResponse.getValue(), leaseClient.getLeaseId()); - - BlobContainerProperties properties = cc.getProperties(); - - assertNotNull(leaseResponse.getValue()); - assertTrue(validateBasicHeaders(leaseResponse.getHeaders())); - assertEquals(properties.getLeaseState(), leaseState); - assertEquals(properties.getLeaseDuration(), leaseDuration); - } - - private static Stream acquireContainerLeaseSupplier() { - return Stream.of(Arguments.of(null, -1, LeaseStateType.LEASED, LeaseDurationType.INFINITE), - Arguments.of(null, 25, LeaseStateType.LEASED, LeaseDurationType.FIXED), - Arguments.of(CoreUtils.randomUuid().toString(), -1, LeaseStateType.LEASED, LeaseDurationType.INFINITE)); - } - - @Test - public void acquireContainerLeaseMin() { - assertResponseStatusCode( - createLeaseClient(cc).acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1), null, null), 201); - } - - @ParameterizedTest - @ValueSource(ints = { -10, 10, 70 }) - public void acquireContainerLeaseDurationFail(int duration) { - BlobLeaseClient leaseClient = createLeaseClient(cc); - assertThrows(BlobStorageException.class, () -> leaseClient.acquireLease(duration)); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACSupplier") - public void acquireContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch); - - assertResponseStatusCode(createLeaseClient(cc) - .acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1).setRequestConditions(mac), null, null), 201); - } - - private static Stream acquireContainerLeaseACSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of(OLD_DATE, null, null, null), - Arguments.of(null, NEW_DATE, null, null), Arguments.of(null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, GARBAGE_ETAG)); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void acquireContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc) - .acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1).setRequestConditions(mac), null, null)); - } - - private static Stream acquireContainerLeaseACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null), Arguments.of(null, OLD_DATE)); - } - - @Test - public void acquireContainerLeaseError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc).acquireLease(50)); - } - - @Test - public void renewContainerLease() { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseClient leaseClient = createLeaseClient(cc, leaseID); - - // If running in live mode wait for the lease to expire to ensure we are actually renewing it - sleepIfRunningAgainstService(16000); - Response renewLeaseResponse - = leaseClient.renewLeaseWithResponse(new BlobRenewLeaseOptions(), null, null); - - assertEquals(renewLeaseResponse.getValue(), leaseClient.getLeaseId()); - assertEquals(cc.getProperties().getLeaseState(), LeaseStateType.LEASED); - assertTrue(validateBasicHeaders(renewLeaseResponse.getHeaders())); - } - - @Test - public void renewContainerLeaseMin() { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - assertResponseStatusCode( - createLeaseClient(cc, leaseID).renewLeaseWithResponse(new BlobRenewLeaseOptions(), null, null), 200); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACSupplier") - public void renewContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified) { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertResponseStatusCode(createLeaseClient(cc, leaseID) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac), null, null), 200); - } - - private static Stream renewContainerLeaseACSupplier() { - return Stream.of(Arguments.of(OLD_DATE, null), Arguments.of(null, NEW_DATE)); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void renewContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc, leaseID) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac), null, null)); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACIllegalSupplier") - public void renewContainerLeaseACIllegal(String match, String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc, RECEIVED_ETAG) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac), null, null)); - } - - private static Stream renewContainerLeaseACIllegalSupplier() { - return Stream.of(Arguments.of(RECEIVED_ETAG, null), Arguments.of(null, GARBAGE_ETAG)); - } - - @Test - public void renewContainerLeaseError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc, "id").renewLease()); - } - - @Test - public void releaseContainerLease() { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - Response releaseLeaseResponse - = createLeaseClient(cc, leaseID).releaseLeaseWithResponse(new BlobReleaseLeaseOptions(), null, null); - - assertEquals(cc.getProperties().getLeaseState(), LeaseStateType.AVAILABLE); - assertTrue(validateBasicHeaders(releaseLeaseResponse.getHeaders())); - } - - @Test - public void releaseContainerLeaseMin() { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - - assertResponseStatusCode( - createLeaseClient(cc, leaseID).releaseLeaseWithResponse(new BlobReleaseLeaseOptions(), null, null), 200); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACSupplier") - public void releaseContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified) { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertResponseStatusCode(createLeaseClient(cc, leaseID) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac), null, null), 200); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void releaseContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc, leaseID) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac), null, null)); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACIllegalSupplier") - public void releaseContainerLeaseACIllegal(String match, String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc, RECEIVED_LEASE_ID) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac), null, null)); - } - - @Test - public void releaseContainerLeaseError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc, "id").releaseLease()); - } - - @ParameterizedTest - @MethodSource("breakBlobLeaseSupplier") - public void breakContainerLease(int leaseTime, Integer breakPeriod, int remainingTime) { - BlobLeaseClient leaseClient = createLeaseClient(cc, testResourceNamer.randomUuid()); - leaseClient.acquireLease(leaseTime); - - Response breakLeaseResponse = leaseClient.breakLeaseWithResponse( - new BlobBreakLeaseOptions().setBreakPeriod(breakPeriod == null ? null : Duration.ofSeconds(breakPeriod)), - null, null); - LeaseStateType state = cc.getProperties().getLeaseState(); - - assertTrue(state == LeaseStateType.BROKEN || state == LeaseStateType.BREAKING); - assertTrue(breakLeaseResponse.getValue() <= remainingTime); - assertTrue(validateBasicHeaders(breakLeaseResponse.getHeaders())); - if (breakPeriod != null) { - // If running in live mode wait for the lease to break so we can delete the container after the test completes - sleepIfRunningAgainstService(breakPeriod * 1000); - } - } - - @Test - public void breakContainerLeaseMin() { - setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - assertResponseStatusCode(createLeaseClient(cc).breakLeaseWithResponse(new BlobBreakLeaseOptions(), null, null), - 202); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACSupplier") - public void breakContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified) { - setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertResponseStatusCode(createLeaseClient(cc) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac), null, null), 202); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void breakContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac), null, null)); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACIllegalSupplier") - public void breakContainerLeaseACIllegal(String match, String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac), null, null)); - } - - @Test - public void breakContainerLeaseError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc).breakLease()); - } - - @Test - public void changeContainerLease() { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseClient leaseClient = createLeaseClient(cc, leaseID); - - assertEquals(leaseClient.getLeaseId(), leaseID); - Response changeLeaseResponse = leaseClient - .changeLeaseWithResponse(new BlobChangeLeaseOptions(testResourceNamer.randomUuid()), null, null); - - assertTrue(validateBasicHeaders(changeLeaseResponse.getHeaders())); - String newLeaseId = changeLeaseResponse.getValue(); - assertEquals(newLeaseId, leaseClient.getLeaseId()); - assertNotEquals(newLeaseId, leaseID); - - assertResponseStatusCode( - createLeaseClient(cc, newLeaseId).releaseLeaseWithResponse(new BlobReleaseLeaseOptions(), null, null), 200); - } - - @Test - public void changeContainerLeaseMin() { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - - assertResponseStatusCode(createLeaseClient(cc, leaseID) - .changeLeaseWithResponse(new BlobChangeLeaseOptions(testResourceNamer.randomUuid()), null, null), 200); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACSupplier") - public void changeContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified) { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertResponseStatusCode(createLeaseClient(cc, leaseID).changeLeaseWithResponse( - new BlobChangeLeaseOptions(testResourceNamer.randomUuid()).setRequestConditions(mac), null, null), 200); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void changeContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - String leaseID = setupContainerLeaseCondition(cc, RECEIVED_LEASE_ID); - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc, leaseID).changeLeaseWithResponse( - new BlobChangeLeaseOptions(testResourceNamer.randomUuid()).setRequestConditions(mac), null, null)); - - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACIllegalSupplier") - public void changeContainerLeaseACIllegal(String match, String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc, RECEIVED_LEASE_ID).changeLeaseWithResponse( - new BlobChangeLeaseOptions(GARBAGE_LEASE_ID).setRequestConditions(mac), null, null)); - } - - @Test - public void changeContainerLeaseError() { - cc = primaryBlobServiceClient.getBlobContainerClient(generateContainerName()); - assertThrows(BlobStorageException.class, () -> createLeaseClient(cc, "id").changeLease("id")); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/LeaseAsyncApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/LeaseAsyncApiTests.java deleted file mode 100644 index ab2f65af5b6e..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/LeaseAsyncApiTests.java +++ /dev/null @@ -1,878 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.rest.Response; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.BlobLeaseRequestConditions; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.LeaseDurationType; -import com.azure.storage.blob.models.LeaseStateType; -import com.azure.storage.blob.options.BlobAcquireLeaseOptions; -import com.azure.storage.blob.options.BlobBreakLeaseOptions; -import com.azure.storage.blob.options.BlobChangeLeaseOptions; -import com.azure.storage.blob.options.BlobReleaseLeaseOptions; -import com.azure.storage.blob.options.BlobRenewLeaseOptions; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.function.Tuple2; - -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class LeaseAsyncApiTests extends BlobTestBase { - - private BlobAsyncClientBase createBlobAsyncClient() { - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - bc.upload(DATA.getDefaultFlux(), DATA.getDefaultDataSize()).block(); - return bc; - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseSupplier") - public void acquireBlobLease(String proposedID, int leaseTime, LeaseStateType leaseState, - LeaseDurationType leaseDuration) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(bc, proposedID); - - if (proposedID != null) { - assertEquals(leaseClient.getLeaseId(), proposedID); - } - - StepVerifier.create(leaseClient.acquireLease(leaseTime)).assertNext(r -> { - assertNotNull(r); - assertEquals(leaseClient.getLeaseId(), r); - }).verifyComplete(); - - StepVerifier.create(bc.getPropertiesWithResponse(null)).assertNext(r -> { - BlobProperties properties = r.getValue(); - HttpHeaders headers = r.getHeaders(); - - assertEquals(leaseState, properties.getLeaseState()); - assertEquals(leaseDuration, properties.getLeaseDuration()); - assertTrue(validateBasicHeaders(headers)); - }).verifyComplete(); - } - - private static Stream acquireBlobLeaseSupplier() { - return Stream.of(Arguments.of(null, -1, LeaseStateType.LEASED, LeaseDurationType.INFINITE), - Arguments.of(null, 25, LeaseStateType.LEASED, LeaseDurationType.FIXED), - Arguments.of(CoreUtils.randomUuid().toString(), -1, LeaseStateType.LEASED, LeaseDurationType.INFINITE)); - } - - @Test - public void acquireBlobLeaseMin() { - assertAsyncResponseStatusCode( - createLeaseAsyncClient(createBlobAsyncClient()).acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1)), - 201); - } - - @ParameterizedTest - @ValueSource(ints = { -10, 10, 70 }) - public void acquireBlobLeaseDurationFail(int duration) { - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(createBlobAsyncClient()); - StepVerifier.create(leaseClient.acquireLease(duration)).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void acquireBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t).then(setupBlobMatchCondition(bc, match)).flatMap(condition -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(convertNull(condition)) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc) - .acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1).setRequestConditions(mac)); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - private static Stream acquireBlobLeaseDurationFailSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), Arguments.of(OLD_DATE, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null), Arguments.of(null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null), - Arguments.of(null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void acquireBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono> response = setupBlobMatchCondition(bc, noneMatch).flatMap(condition -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(convertNull(condition)) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc) - .acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1).setRequestConditions(mac)); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream acquireBlobLeaseACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null), Arguments.of(null, OLD_DATE, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null), Arguments.of(null, null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void acquireBlobLeaseError() { - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - StepVerifier.create(createLeaseAsyncClient(bc).acquireLease(20)).verifyError(BlobStorageException.class); - } - - @Test - public void renewBlobLease() { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono, BlobLeaseAsyncClient>> response - = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID).flatMap(r -> { - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(bc, r); - sleepIfRunningAgainstService(16000); - return Mono.zip(leaseClient.renewLeaseWithResponse(new BlobRenewLeaseOptions()), - Mono.just(leaseClient)); - }); - - StepVerifier.create(response).assertNext(r -> { - validateBasicHeaders(r.getT1().getHeaders()); - assertNotNull(r.getT1().getValue()); - assertEquals(r.getT2().getLeaseId(), r.getT1().getValue()); - }).verifyComplete(); - - StepVerifier.create(bc.getProperties()) - .assertNext(r -> assertEquals(LeaseStateType.LEASED, r.getLeaseState())) - .verifyComplete(); - } - - @Test - public void renewBlobLeaseMin() { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono> response = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(bc, r).renewLeaseWithResponse(new BlobRenewLeaseOptions())); - - assertAsyncResponseStatusCode(response, 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void renewBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc, conditions.get(0)) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac)); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void renewBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc, conditions.get(0)) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac)); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void renewBlobLeaseError() { - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - StepVerifier.create(createLeaseAsyncClient(bc, "id").renewLease()).verifyError(BlobStorageException.class); - } - - @Test - public void releaseBlobLease() { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono> response = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(bc, r).releaseLeaseWithResponse(new BlobReleaseLeaseOptions())); - - StepVerifier.create(response) - .assertNext(r -> assertTrue(validateBasicHeaders(r.getHeaders()))) - .verifyComplete(); - - StepVerifier.create(bc.getProperties()) - .assertNext(r -> assertEquals(LeaseStateType.AVAILABLE, r.getLeaseState())) - .verifyComplete(); - } - - @Test - public void releaseBlobLeaseMin() { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono> response = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(bc, r).releaseLeaseWithResponse(new BlobReleaseLeaseOptions())); - - assertAsyncResponseStatusCode(response, 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void releaseBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc, conditions.get(0)) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac)); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void releaseBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc, conditions.get(0)) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac)); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void releaseBlobLeaseError() { - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - StepVerifier.create(createLeaseAsyncClient(bc, "id").releaseLease()).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("breakBlobLeaseSupplier") - public void breakBlobLease(int leaseTime, Integer breakPeriod, int remainingTime) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(bc, testResourceNamer.randomUuid()); - - StepVerifier - .create( - leaseClient.acquireLease(leaseTime) - .then(leaseClient.breakLeaseWithResponse(new BlobBreakLeaseOptions() - .setBreakPeriod(breakPeriod == null ? null : Duration.ofSeconds(breakPeriod))))) - .assertNext(r -> { - assertTrue(r.getValue() <= remainingTime); - assertTrue(validateBasicHeaders(r.getHeaders())); - }) - .verifyComplete(); - - StepVerifier.create(bc.getProperties()) - .assertNext(r -> assertTrue( - r.getLeaseState() == LeaseStateType.BROKEN || r.getLeaseState() == LeaseStateType.BREAKING)) - .verifyComplete(); - } - - private static Stream breakBlobLeaseSupplier() { - return Stream.of(Arguments.of(-1, null, 0), Arguments.of(-1, 20, 25), Arguments.of(20, 15, 16)); - } - - @Test - public void breakBlobLeaseMin() { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - assertAsyncResponseStatusCode(setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID) - .then(createLeaseAsyncClient(bc).breakLeaseWithResponse(new BlobBreakLeaseOptions())), 202); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void breakBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, RECEIVED_ETAG), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac)); - }); - - assertAsyncResponseStatusCode(response, 202); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void breakBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac)); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void breakBlobLeaseError() { - BlobAsyncClientBase bc = createBlobAsyncClient(); - StepVerifier.create(createLeaseAsyncClient(bc).breakLease()).verifyError(BlobStorageException.class); - } - - @Test - public void changeBlobLease() { - BlobAsyncClientBase bc = createBlobAsyncClient(); - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(bc, testResourceNamer.randomUuid()); - String newLeaseId = testResourceNamer.randomUuid(); - - Mono client = leaseClient.acquireLease(15) - .then(leaseClient.changeLeaseWithResponse(new BlobChangeLeaseOptions(newLeaseId))) - .flatMap(r -> { - assertEquals(r.getValue(), newLeaseId); - assertEquals(r.getValue(), leaseClient.getLeaseId()); - assertTrue(validateBasicHeaders(r.getHeaders())); - return Mono.just(createLeaseAsyncClient(bc, r.getValue())); - }); - - assertAsyncResponseStatusCode(client.flatMap(r -> r.releaseLeaseWithResponse(new BlobReleaseLeaseOptions())), - 200); - } - - @Test - public void changeBlobLeaseMin() { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono> response - = setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID).flatMap(r -> createLeaseAsyncClient(bc, r) - .changeLeaseWithResponse(new BlobChangeLeaseOptions(testResourceNamer.randomUuid()))); - - assertAsyncResponseStatusCode(response, 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("acquireBlobLeaseDurationFailSupplier") - public void changeBlobLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc, conditions.get(0)).changeLeaseWithResponse( - new BlobChangeLeaseOptions(testResourceNamer.randomUuid()).setRequestConditions(mac)); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("acquireBlobLeaseACFailSupplier") - public void changeBlobLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - BlobAsyncClientBase bc = createBlobAsyncClient(); - - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, RECEIVED_LEASE_ID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setTagsConditions(tags); - - return createLeaseAsyncClient(bc, conditions.get(0)).changeLeaseWithResponse( - new BlobChangeLeaseOptions(testResourceNamer.randomUuid()).setRequestConditions(mac)); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void changeBlobLeaseError() { - BlockBlobAsyncClient bc = ccAsync.getBlobAsyncClient(generateBlobName()).getBlockBlobAsyncClient(); - StepVerifier.create(createLeaseAsyncClient(bc, "id").changeLease("id")).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseSupplier") - public void acquireContainerLease(String proposedID, int leaseTime, LeaseStateType leaseState, - LeaseDurationType leaseDuration) { - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(ccAsync, proposedID); - - StepVerifier.create(leaseClient.acquireLeaseWithResponse(new BlobAcquireLeaseOptions(leaseTime))) - .assertNext(r -> { - assertEquals(leaseClient.getLeaseId(), r.getValue()); - assertNotNull(r.getValue()); - assertTrue(validateBasicHeaders(r.getHeaders())); - }) - .verifyComplete(); - - StepVerifier.create(ccAsync.getProperties()).assertNext(r -> { - assertEquals(r.getLeaseState(), leaseState); - assertEquals(r.getLeaseDuration(), leaseDuration); - }).verifyComplete(); - } - - private static Stream acquireContainerLeaseSupplier() { - return Stream.of(Arguments.of(null, -1, LeaseStateType.LEASED, LeaseDurationType.INFINITE), - Arguments.of(null, 25, LeaseStateType.LEASED, LeaseDurationType.FIXED), - Arguments.of(CoreUtils.randomUuid().toString(), -1, LeaseStateType.LEASED, LeaseDurationType.INFINITE)); - } - - @Test - public void acquireContainerLeaseMin() { - assertAsyncResponseStatusCode( - createLeaseAsyncClient(ccAsync).acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1)), 201); - } - - @ParameterizedTest - @ValueSource(ints = { -10, 10, 70 }) - public void acquireContainerLeaseDurationFail(int duration) { - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(ccAsync); - StepVerifier.create(leaseClient.acquireLease(duration)).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACSupplier") - public void acquireContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch); - - assertAsyncResponseStatusCode(createLeaseAsyncClient(ccAsync) - .acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1).setRequestConditions(mac)), 201); - } - - private static Stream acquireContainerLeaseACSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of(OLD_DATE, null, null, null), - Arguments.of(null, NEW_DATE, null, null), Arguments.of(null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, GARBAGE_ETAG)); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void acquireContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - StepVerifier - .create(createLeaseAsyncClient(ccAsync) - .acquireLeaseWithResponse(new BlobAcquireLeaseOptions(-1).setRequestConditions(mac))) - .verifyError(BlobStorageException.class); - } - - private static Stream acquireContainerLeaseACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null), Arguments.of(null, OLD_DATE)); - } - - @Test - public void acquireContainerLeaseError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(createLeaseAsyncClient(ccAsync).acquireLease(50)).verifyError(BlobStorageException.class); - } - - @Test - public void renewContainerLease() { - Mono, BlobLeaseAsyncClient>> response - = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID).flatMap(leaseID -> { - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(ccAsync, leaseID); - // If running in live mode wait for the lease to expire to ensure we are actually renewing it - sleepIfRunningAgainstService(16000); - return Mono.zip(leaseClient.renewLeaseWithResponse(new BlobRenewLeaseOptions()), - Mono.just(leaseClient)); - }); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(r.getT2().getLeaseId(), r.getT1().getValue()); - assertTrue(validateBasicHeaders(r.getT1().getHeaders())); - }).verifyComplete(); - - StepVerifier.create(ccAsync.getProperties()) - .assertNext(r -> assertEquals(LeaseStateType.LEASED, r.getLeaseState())) - .verifyComplete(); - } - - @Test - public void renewContainerLeaseMin() { - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r).renewLeaseWithResponse(new BlobRenewLeaseOptions())); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACSupplier") - public void renewContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac))); - - assertAsyncResponseStatusCode(response, 200); - } - - private static Stream renewContainerLeaseACSupplier() { - return Stream.of(Arguments.of(OLD_DATE, null), Arguments.of(null, NEW_DATE)); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void renewContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac))); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACIllegalSupplier") - public void renewContainerLeaseACIllegal(String match, String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - StepVerifier - .create(createLeaseAsyncClient(ccAsync, RECEIVED_ETAG) - .renewLeaseWithResponse(new BlobRenewLeaseOptions().setRequestConditions(mac))) - .verifyError(BlobStorageException.class); - } - - private static Stream renewContainerLeaseACIllegalSupplier() { - return Stream.of(Arguments.of(RECEIVED_ETAG, null), Arguments.of(null, GARBAGE_ETAG)); - } - - @Test - public void renewContainerLeaseError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(createLeaseAsyncClient(ccAsync, "id").renewLease()).verifyError(BlobStorageException.class); - } - - @Test - public void releaseContainerLease() { - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r).releaseLeaseWithResponse(new BlobReleaseLeaseOptions())); - - StepVerifier.create(response) - .assertNext(r -> assertTrue(validateBasicHeaders(r.getHeaders()))) - .verifyComplete(); - - StepVerifier.create(ccAsync.getProperties()) - .assertNext(r -> assertEquals(LeaseStateType.AVAILABLE, r.getLeaseState())) - .verifyComplete(); - } - - @Test - public void releaseContainerLeaseMin() { - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r).releaseLeaseWithResponse(new BlobReleaseLeaseOptions())); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACSupplier") - public void releaseContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac))); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void releaseContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac))); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACIllegalSupplier") - public void releaseContainerLeaseACIllegal(String match, String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - StepVerifier - .create(createLeaseAsyncClient(ccAsync, RECEIVED_LEASE_ID) - .releaseLeaseWithResponse(new BlobReleaseLeaseOptions().setRequestConditions(mac))) - .verifyError(BlobStorageException.class); - } - - @Test - public void releaseContainerLeaseError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(createLeaseAsyncClient(ccAsync, "id").releaseLease()) - .verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("breakBlobLeaseSupplier") - public void breakContainerLease(int leaseTime, Integer breakPeriod, int remainingTime) { - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(ccAsync, testResourceNamer.randomUuid()); - - StepVerifier - .create( - leaseClient.acquireLease(leaseTime) - .then(leaseClient.breakLeaseWithResponse(new BlobBreakLeaseOptions() - .setBreakPeriod(breakPeriod == null ? null : Duration.ofSeconds(breakPeriod))))) - .assertNext(r -> { - assertTrue(r.getValue() <= remainingTime); - assertTrue(validateBasicHeaders(r.getHeaders())); - }) - .verifyComplete(); - - StepVerifier.create(ccAsync.getProperties()) - .assertNext(r -> assertTrue( - r.getLeaseState() == LeaseStateType.BROKEN || r.getLeaseState() == LeaseStateType.BREAKING)) - .verifyComplete(); - - if (breakPeriod != null) { - // If running in live mode wait for the lease to break so we can delete the container after the test completes - sleepIfRunningAgainstService(breakPeriod * 1000); - } - } - - @Test - public void breakContainerLeaseMin() { - assertAsyncResponseStatusCode(setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .then(createLeaseAsyncClient(ccAsync).breakLeaseWithResponse(new BlobBreakLeaseOptions())), 202); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACSupplier") - public void breakContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - assertAsyncResponseStatusCode( - setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID).then(createLeaseAsyncClient(ccAsync) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac))), - 202); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void breakContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - StepVerifier - .create(setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID).then(createLeaseAsyncClient(ccAsync) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac)))) - .verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACIllegalSupplier") - public void breakContainerLeaseACIllegal(String match, String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - StepVerifier - .create(createLeaseAsyncClient(ccAsync) - .breakLeaseWithResponse(new BlobBreakLeaseOptions().setRequestConditions(mac))) - .verifyError(BlobStorageException.class); - } - - @Test - public void breakContainerLeaseError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(createLeaseAsyncClient(ccAsync).breakLease()).verifyError(BlobStorageException.class); - } - - @Test - public void changeContainerLease() { - Mono client - = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID).flatMap(leaseID -> { - BlobLeaseAsyncClient leaseClient = createLeaseAsyncClient(ccAsync, leaseID); - assertEquals(leaseClient.getLeaseId(), leaseID); - return Mono.zip( - leaseClient.changeLeaseWithResponse(new BlobChangeLeaseOptions(testResourceNamer.randomUuid())), - Mono.just(leaseClient), Mono.just(leaseID)); - }).flatMap(tuple -> { - assertTrue(validateBasicHeaders(tuple.getT1().getHeaders())); - String newLeaseId = tuple.getT1().getValue(); - assertEquals(newLeaseId, tuple.getT2().getLeaseId()); - assertNotEquals(newLeaseId, tuple.getT3()); - return Mono.just(createLeaseAsyncClient(ccAsync, newLeaseId)); - }); - - assertAsyncResponseStatusCode(client.flatMap(r -> r.releaseLeaseWithResponse(new BlobReleaseLeaseOptions())), - 200); - } - - @Test - public void changeContainerLeaseMin() { - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r) - .changeLeaseWithResponse(new BlobChangeLeaseOptions(testResourceNamer.randomUuid()))); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACSupplier") - public void changeContainerLeaseAC(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r).changeLeaseWithResponse( - new BlobChangeLeaseOptions(testResourceNamer.randomUuid()).setRequestConditions(mac))); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("acquireContainerLeaseACFailSupplier") - public void changeContainerLeaseACFail(OffsetDateTime modified, OffsetDateTime unmodified) { - BlobLeaseRequestConditions mac - = new BlobLeaseRequestConditions().setIfModifiedSince(modified).setIfUnmodifiedSince(unmodified); - - Mono> response = setupContainerLeaseConditionAsync(ccAsync, RECEIVED_LEASE_ID) - .flatMap(r -> createLeaseAsyncClient(ccAsync, r).changeLeaseWithResponse( - new BlobChangeLeaseOptions(testResourceNamer.randomUuid()).setRequestConditions(mac))); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("renewContainerLeaseACIllegalSupplier") - public void changeContainerLeaseACIllegal(String match, String noneMatch) { - BlobLeaseRequestConditions mac = new BlobLeaseRequestConditions().setIfMatch(match).setIfNoneMatch(noneMatch); - - StepVerifier - .create(createLeaseAsyncClient(ccAsync, RECEIVED_LEASE_ID) - .changeLeaseWithResponse(new BlobChangeLeaseOptions(GARBAGE_LEASE_ID).setRequestConditions(mac))) - .verifyError(BlobStorageException.class); - } - - @Test - public void changeContainerLeaseError() { - ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(generateContainerName()); - StepVerifier.create(createLeaseAsyncClient(ccAsync, "id").changeLease("id")) - .verifyError(BlobStorageException.class); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobApiTests.java deleted file mode 100644 index 4d04801c5e30..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobApiTests.java +++ /dev/null @@ -1,1719 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpRange; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.Response; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.CoreUtils; -import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobContainerClient; -import com.azure.storage.blob.BlobServiceClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.ClearRange; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.PageBlobCopyIncrementalRequestConditions; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.models.PageBlobRequestConditions; -import com.azure.storage.blob.models.PageList; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.models.PageRangeItem; -import com.azure.storage.blob.models.SequenceNumberActionType; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.ListPageRangesDiffOptions; -import com.azure.storage.blob.options.ListPageRangesOptions; -import com.azure.storage.blob.options.PageBlobCopyIncrementalOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.sas.BlobContainerSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import com.azure.storage.common.test.shared.policy.TransientFailureInjectingHttpPipelinePolicy; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class PageBlobApiTests extends BlobTestBase { - private PageBlobClient bc; - private String blobName; - - @BeforeEach - public void setup() { - blobName = generateBlobName(); - bc = cc.getBlobClient(blobName).getPageBlobClient(); - bc.create(PageBlobClient.PAGE_BYTES); - } - - @Test - public void createAllNull() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - - Response response - = bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertNull(response.getValue().getContentMd5()); - assertTrue(response.getValue().isServerEncrypted()); - } - - @Test - public void createMin() { - assertResponseStatusCode(bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, null, null, null, null), - 201); - } - - @Test - public void createSequenceNumber() { - bc.createWithResponse(PageBlobClient.PAGE_BYTES, 2L, null, null, null, null, null); - assertEquals(bc.getProperties().getBlobSequenceNumber(), 2); - } - - @ParameterizedTest - @MethodSource("createHeadersSupplier") - public void createHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, headers, null, null, null, null); - - Response response = bc.getPropertiesWithResponse(null, null, null); - - // If the value isn't set the service will automatically set it - contentType = (contentType == null) ? "application/octet-stream" : contentType; - assertTrue(validateBlobProperties(response, cacheControl, contentDisposition, contentEncoding, contentLanguage, - contentMD5, contentType)); - } - - private static Stream createHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of("control", "disposition", "encoding", "language", - Base64.getEncoder().encode(MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes())), "type")); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, metadata, null, null, null); - Response response = bc.getPropertiesWithResponse(null, null, null); - - assertResponseStatusCode(response, 200); - assertEquals(response.getValue().getMetadata(), metadata); - } - - private static Stream createMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createTagsSupplier") - public void createTags(String key1, String value1, String key2, String value2) { - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - bc.createWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setTags(tags), null, null); - - Response> response = bc.getTagsWithResponse(new BlobGetTagsOptions(), null, null); - - assertResponseStatusCode(response, 200); - assertEquals(response.getValue(), tags); - } - - private static Stream createTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void createAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(setupBlobMatchCondition(bc, match)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, null, bac, null, null), - 201); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void createACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, null, bac, null, null)); - } - - @Test - public void createError() { - assertThrows(BlobStorageException.class, () -> bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, - null, new BlobRequestConditions().setLeaseId("id"), null, null)); - } - - @Test - public void createIfNotExistsAllNull() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - - Response response - = bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES), null, null); - - assertResponseStatusCode(response, 201); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertNull(response.getValue().getContentMd5()); - assertTrue(response.getValue().isServerEncrypted()); - } - - @Test - public void createIfNotExistsSimple() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - - bc.createIfNotExists(PageBlobClient.PAGE_BYTES); - assertTrue(bc.exists()); - } - - @Test - public void createIfNotExistsBlobThatAlreadyExists() { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getPageBlobClient(); - PageBlobCreateOptions options = new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES); - Response initialResponse = bc.createIfNotExistsWithResponse(options, null, null); - - Response secondResponse = bc.createIfNotExistsWithResponse(options, null, null); - - assertResponseStatusCode(initialResponse, 201); - assertResponseStatusCode(secondResponse, 409); - } - - @Test - public void createIfNotExistsMin() { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getPageBlobClient(); - - assertResponseStatusCode( - bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES), null, null), 201); - } - - @Test - public void createIfNotExistsSequenceNumber() { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getPageBlobClient(); - - bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setSequenceNumber(2L), - null, null); - - assertEquals(bc.getProperties().getBlobSequenceNumber(), 2); - } - - @ParameterizedTest - @MethodSource("createIfNotExistsHeadersSupplier") - public void createIfNotExistsHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getPageBlobClient(); - - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setHeaders(headers), null, - null); - - Response response = bc.getPropertiesWithResponse(null, null, null); - - // If the value isn't set the service will automatically set it - contentType = (contentType == null) ? "application/octet-stream" : contentType; - - assertTrue(validateBlobProperties(response, cacheControl, contentDisposition, contentEncoding, contentLanguage, - contentMD5, contentType)); - } - - private static Stream createIfNotExistsHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), Arguments.of("control", "disposition", - "encoding", "language", MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()), "type")); - } - - @ParameterizedTest - @MethodSource("createIfNotExistsMetadataSupplier") - public void createIfNotExistsMetadata(String key1, String value1, String key2, String value2) { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getPageBlobClient(); - - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setMetadata(metadata), - null, null); - Response response = bc.getPropertiesWithResponse(null, null, null); - - assertResponseStatusCode(response, 200); - assertEquals(response.getValue().getMetadata(), metadata); - } - - private static Stream createIfNotExistsMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createIfNotExistsTagsSupplier") - public void createIfNotExistsTags(String key1, String value1, String key2, String value2) { - String blobName = cc.getBlobClient(generateBlobName()).getBlobName(); - bc = cc.getBlobClient(blobName).getPageBlobClient(); - - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setTags(tags), null, - null); - - Response> response = bc.getTagsWithResponse(new BlobGetTagsOptions(), null, null); - - assertResponseStatusCode(response, 200); - assertEquals(response.getValue(), tags); - } - - private static Stream createIfNotExistsTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @Test - public void uploadPage() { - Response response - = bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertNotNull(response.getHeaders().getValue(X_MS_CONTENT_CRC64)); - assertEquals(response.getValue().getBlobSequenceNumber(), 0); - assertTrue(response.getValue().isServerEncrypted()); - } - - @Test - public void uploadPageMin() { - assertResponseStatusCode( - bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, null, null, null), - 201); - } - - @ParameterizedTest - @MethodSource("uploadPageIASupplier") - public void uploadPageIA(Integer dataSize, Throwable exceptionType) { - ByteArrayInputStream data = (dataSize == null) ? null : new ByteArrayInputStream(getRandomByteArray(dataSize)); - assertThrows(exceptionType.getClass(), - () -> bc.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1), data)); - } - - private static Stream uploadPageIASupplier() { - return Stream.of(Arguments.of(null, new NullPointerException()), - Arguments.of(PageBlobClient.PAGE_BYTES, new UnexpectedLengthException(null, 0L, 0L /* dummy values */)), - Arguments.of(PageBlobClient.PAGE_BYTES * 3, - new UnexpectedLengthException(null, 0L, 0L /* dummy values */))); - } - - @Test - public void uploadPageTransactionalMD5() throws NoSuchAlgorithmException { - byte[] data = getRandomByteArray(PageBlobClient.PAGE_BYTES); - byte[] md5 = MessageDigest.getInstance("MD5").digest(data); - - assertResponseStatusCode( - bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(data), md5, null, null, null), - 201); - } - - @Test - public void uploadPageTransactionalMD5Fail() { - BlobStorageException e = assertThrows(BlobStorageException.class, - () -> bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), - MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null, null, null)); - assertEquals(BlobErrorCode.MD5MISMATCH, e.getErrorCode()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("uploadPageACSupplier") - public void uploadPageAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(setupBlobMatchCondition(bc, match)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - assertResponseStatusCode( - bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, pac, null, null), - 201); - } - - private static Stream uploadPageACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null, null, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null, null, null, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null, null, null, null), - Arguments.of(null, null, null, null, null, 5L, null, null, null), - Arguments.of(null, null, null, null, null, null, 3L, null, null), - Arguments.of(null, null, null, null, null, null, null, 0L, null), - Arguments.of(null, null, null, null, null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("uploadPageACFailSupplier") - public void uploadPageACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, String tags) { - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, pac, null, null)); - } - - private static Stream uploadPageACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null, null, null, null, null), - Arguments.of(null, OLD_DATE, null, null, null, null, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null, null, null, null, null), - Arguments.of(null, null, null, RECEIVED_ETAG, null, null, null, null, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID, null, null, null, null), - Arguments.of(null, null, null, null, null, -1L, null, null, null), - Arguments.of(null, null, null, null, null, null, -1L, null, null), - Arguments.of(null, null, null, null, null, null, null, 100L, null), - Arguments.of(null, null, null, null, null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void uploadPageError() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - - assertThrows(BlobStorageException.class, - () -> bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, - new PageBlobRequestConditions().setLeaseId("id"), null, null)); - } - - @Test - public void uploadPageRetryOnTransientFailure() { - PageBlobClient clientWithFailure = getBlobClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - bc.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getPageBlobClient(); - - byte[] data = getRandomByteArray(PageBlobClient.PAGE_BYTES); - clientWithFailure.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(data)); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - bc.downloadStream(os); - TestUtils.assertArraysEqual(os.toByteArray(), data); - } - - @Test - public void uploadPageFromURLMin() { - PageBlobClient destURL = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - destURL.create(PageBlobClient.PAGE_BYTES); - destURL.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - - String sas = destURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - Response response = bc.uploadPagesFromUrlWithResponse(pageRange, destURL.getBlobUrl() + "?" + sas, - null, null, null, null, null, null); - - assertResponseStatusCode(response, 201); - assertTrue(validateBasicHeaders(response.getHeaders())); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void uploadPageFromURLSourceErrorAndStatusCode() { - PageBlobClient destBlob = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - - destBlob.createIfNotExists(Constants.KB); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - - BlobStorageException e = assertThrows(BlobStorageException.class, () -> destBlob.uploadPagesFromUrl(pageRange, bc.getBlobUrl(), null)); - - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }*/ - - @Test - public void uploadPageFromURLRange() { - byte[] data = getRandomByteArray(PageBlobClient.PAGE_BYTES * 4); - - PageBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - sourceURL.create(PageBlobClient.PAGE_BYTES * 4); - sourceURL.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 4 - 1), - new ByteArrayInputStream(data)); - - PageBlobClient destURL = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - destURL.create(PageBlobClient.PAGE_BYTES * 2); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - destURL.uploadPagesFromUrl(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1), - sourceURL.getBlobUrl() + "?" + sas, PageBlobClient.PAGE_BYTES * 2L); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - destURL.downloadStream(outputStream); - TestUtils.assertArraysEqual(data, PageBlobClient.PAGE_BYTES * 2, outputStream.toByteArray(), 0, - PageBlobClient.PAGE_BYTES * 2); - } - - @Test - public void uploadPageFromURLIA() { - assertThrows(IllegalArgumentException.class, - () -> bc.uploadPagesFromUrl(null, bc.getBlobUrl(), (long) PageBlobClient.PAGE_BYTES)); - } - - @Test - public void uploadPageFromURLMD5() { - PageBlobClient destURL = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - destURL.create(PageBlobClient.PAGE_BYTES); - byte[] data = getRandomByteArray(PageBlobClient.PAGE_BYTES); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - bc.uploadPages(pageRange, new ByteArrayInputStream(data)); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertDoesNotThrow(() -> destURL.uploadPagesFromUrlWithResponse(pageRange, bc.getBlobUrl() + "?" + sas, null, - MessageDigest.getInstance("MD5").digest(data), null, null, null, null)); - } - - @Test - public void uploadPageFromURLMD5Fail() { - PageBlobClient destURL = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - destURL.create(PageBlobClient.PAGE_BYTES); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - bc.uploadPages(pageRange, new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertThrows(BlobStorageException.class, - () -> destURL.uploadPagesFromUrlWithResponse(pageRange, bc.getBlobUrl() + "?" + sas, null, - MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null, null, null, null)); - - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("uploadPageACSupplier") - public void uploadPageFromURLDestinationAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, - String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - PageBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - sourceURL.create(PageBlobClient.PAGE_BYTES); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - sourceURL.uploadPages(pageRange, new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(setupBlobMatchCondition(bc, match)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertResponseStatusCode(bc.uploadPagesFromUrlWithResponse(pageRange, sourceURL.getBlobUrl() + "?" + sas, null, - null, pac, null, null, null), 201); - } - - @ParameterizedTest - @MethodSource("uploadPageACFailSupplier") - public void uploadPageFromURLDestinationACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, - String tags) { - PageBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - sourceURL.create(PageBlobClient.PAGE_BYTES); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - sourceURL.uploadPages(pageRange, new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - - noneMatch = setupBlobMatchCondition(bc, noneMatch); - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertThrows(BlobStorageException.class, () -> bc.uploadPagesFromUrlWithResponse(pageRange, - sourceURL.getBlobUrl() + "?" + sas, null, null, pac, null, null, null)); - } - - @ParameterizedTest - @MethodSource("uploadPageFromURLSourceACSupplier") - public void uploadPageFromURLSourceAC(OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch) { - PageBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - sourceURL.create(PageBlobClient.PAGE_BYTES); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - sourceURL.uploadPages(pageRange, new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - - sourceIfMatch = setupBlobMatchCondition(sourceURL, sourceIfMatch); - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(sourceIfMatch) - .setIfNoneMatch(sourceIfNoneMatch); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertResponseStatusCode(bc.uploadPagesFromUrlWithResponse(pageRange, sourceURL.getBlobUrl() + "?" + sas, null, - null, null, smac, null, null), 201); - } - - private static Stream uploadPageFromURLSourceACSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of(OLD_DATE, null, null, null), - Arguments.of(null, NEW_DATE, null, null), Arguments.of(null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, GARBAGE_ETAG)); - } - - @ParameterizedTest - @MethodSource("uploadPageFromURLSourceACFailSupplier") - public void uploadPageFromURLSourceACFail(OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch) { - PageBlobClient sourceURL = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - sourceURL.create(PageBlobClient.PAGE_BYTES); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - sourceURL.uploadPages(pageRange, new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(sourceIfMatch) - .setIfNoneMatch(setupBlobMatchCondition(sourceURL, sourceIfNoneMatch)); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertThrows(BlobStorageException.class, () -> bc.uploadPagesFromUrlWithResponse(pageRange, - sourceURL.getBlobUrl() + "?" + sas, null, null, null, smac, null, null)); - } - - private static Stream uploadPageFromURLSourceACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null), Arguments.of(null, OLD_DATE, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null), Arguments.of(null, null, null, RECEIVED_ETAG)); - } - - @SuppressWarnings("deprecation") - @Test - public void clearPage() { - bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, null, null, null); - - Response response = bc.clearPagesWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), null, null, null); - - assertEquals(0, bc.getPageRanges(new BlobRange(0)).getPageRange().size()); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertNull(response.getValue().getContentMd5()); - assertEquals(0, response.getValue().getBlobSequenceNumber()); - } - - @Test - public void clearPageMin() { - assertNotNull(bc.clearPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1))); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("uploadPageACSupplier") - public void clearPagesAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, String tags) { - bc.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - assertResponseStatusCode(bc.clearPagesWithResponse( - new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), pac, null, null), 201); - } - - @ParameterizedTest - @MethodSource("uploadPageACFailSupplier") - public void clearPagesACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, String tags) { - bc.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - noneMatch = setupBlobMatchCondition(bc, noneMatch); - setupBlobLeaseCondition(bc, leaseID); - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.clearPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), pac, - null, null)); - } - - @Test - public void clearPageError() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - - assertThrows(BlobStorageException.class, - () -> bc.clearPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1))); - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRanges() { - bc.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - Response response - = bc.getPageRangesWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), null, null, null); - - assertResponseStatusCode(response, 200); - assertEquals(1, response.getValue().getPageRange().size()); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertEquals("512", response.getHeaders().getValue(X_MS_BLOB_CONTENT_LENGTH)); - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRangesMin() { - assertDoesNotThrow(() -> bc.getPageRanges(null)); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void getPageRangesAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertDoesNotThrow( - () -> bc.getPageRangesWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), bac, null, null)); - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void getPageRangesACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.getPageRangesWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), bac, null, null)); - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRangesError() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - assertThrows(BlobStorageException.class, () -> bc.getPageRanges(null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPageRanges() { - bc.create(4 * Constants.KB, true); - ByteArrayInputStream data = new ByteArrayInputStream(getRandomByteArray(4 * Constants.KB)); - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data); - bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1)); - bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1)); - - Iterator iterable = bc.listPageRanges(new BlobRange(0, (long) 4 * Constants.KB)).iterator(); - PageRangeItem item = iterable.next(); - - assertEquals(item.getRange(), new HttpRange(0, (long) Constants.KB)); - assertFalse(item.isClear()); - - item = iterable.next(); - - assertEquals(item.getRange(), new HttpRange(2 * Constants.KB, (long) Constants.KB)); - assertFalse(item.isClear()); - - assertFalse(iterable.hasNext()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesRangesPageSize() { - bc.create(4 * Constants.KB, true); - ByteArrayInputStream data = new ByteArrayInputStream(getRandomByteArray(4 * Constants.KB)); - data.mark(Integer.MAX_VALUE); - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data); - bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1)); - bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1)); - - // when: "max results on options" - Iterator> iterator - = bc.listPageRanges(new ListPageRangesOptions(new BlobRange(0, 4L * Constants.KB)).setMaxResultsPerPage(1), - null, null).iterableByPage().iterator(); - PagedResponse page = iterator.next(); - - assertEquals(page.getValue().size(), 1); - - page = iterator.next(); - - assertEquals(page.getValue().size(), 1); - assertFalse(iterator.hasNext()); - - // when: "max results on iterableByPage" - iterator = bc.listPageRanges(new ListPageRangesOptions(new BlobRange(0, 4L * Constants.KB)), null, null) - .iterableByPage(1) - .iterator(); - page = iterator.next(); - - assertEquals(page.getValue().size(), 1); - - page = iterator.next(); - - assertEquals(page.getValue().size(), 1); - assertFalse(iterator.hasNext()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesContinuationToken() { - bc.create(4 * Constants.KB, true); - ByteArrayInputStream data = new ByteArrayInputStream(getRandomByteArray(4 * Constants.KB)); - data.mark(Integer.MAX_VALUE); - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data); - bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1)); - bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1)); - - Iterator> iterator - = bc.listPageRanges(new ListPageRangesOptions(new BlobRange(0, 4L * Constants.KB)).setMaxResultsPerPage(1), - null, null).iterableByPage().iterator(); - String token = iterator.next().getContinuationToken(); - - iterator = bc.listPageRanges(new ListPageRangesOptions(new BlobRange(0, 4L * Constants.KB)), null, null) - .iterableByPage(token) - .iterator(); - PagedResponse page = iterator.next(); - - assertEquals(page.getValue().size(), 1); - assertFalse(iterator.hasNext()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesRange() { - bc.create(4 * Constants.KB, true); - ByteArrayInputStream data = new ByteArrayInputStream(getRandomByteArray(4 * Constants.KB)); - data.mark(Integer.MAX_VALUE); - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data); - bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1)); - bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1)); - - Iterator iterator - = bc.listPageRanges(new ListPageRangesOptions(new BlobRange(2 * Constants.KB + 1, 2L * Constants.KB)), null, - null).iterator(); - - int size = 0; - while (iterator.hasNext()) { - size++; - iterator.next(); - } - assertEquals(size, 1); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void listPagesRangesAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertDoesNotThrow(() -> bc.listPageRanges( - new ListPageRangesOptions(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES)).setRequestConditions(bac), - null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void listPageRangesACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.listPageRanges( - new ListPageRangesOptions(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES)).setRequestConditions(bac), - null, null).stream().count()); - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("getPageRangesDiffSupplier") - public void getPageRangesDiff(List rangesToUpdate, List rangesToClear, - List expectedPageRanges, List expectedClearRanges) { - bc.create(4 * Constants.MB, true); - - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.MB - 1), - new ByteArrayInputStream(getRandomByteArray(4 * Constants.MB))); - - String snapId = bc.createSnapshot().getSnapshotId(); - - rangesToUpdate.forEach(it -> bc.uploadPages(it, - new ByteArrayInputStream(getRandomByteArray((int) (it.getEnd() - it.getStart()) + 1)))); - - rangesToClear.forEach(it -> bc.clearPages(it)); - - Response response - = bc.getPageRangesDiffWithResponse(new BlobRange(0, 4L * Constants.MB), snapId, null, null, null); - - assertTrue(validateBasicHeaders(response.getHeaders())); - assertEquals(expectedPageRanges.size(), response.getValue().getPageRange().size()); - assertEquals(expectedClearRanges.size(), response.getValue().getClearRange().size()); - - for (int i = 0; i < expectedPageRanges.size(); i++) { - PageRange actualRange = response.getValue().getPageRange().get(i); - PageRange expectedRange = expectedPageRanges.get(i); - assertEquals(expectedRange.getStart(), actualRange.getStart()); - assertEquals(expectedRange.getEnd(), actualRange.getEnd()); - } - - for (int i = 0; i < expectedClearRanges.size(); i++) { - ClearRange actualRange = response.getValue().getClearRange().get(i); - ClearRange expectedRange = expectedClearRanges.get(i); - assertEquals(expectedRange.getStart(), actualRange.getStart()); - assertEquals(expectedRange.getEnd(), actualRange.getEnd()); - } - - assertEquals(Integer.parseInt(response.getHeaders().getValue(X_MS_BLOB_CONTENT_LENGTH)), 4 * Constants.MB); - } - - private static Stream getPageRangesDiffSupplier() { - return Stream.of(Arguments.of(createPageRanges(), createPageRanges(), createPageRanges(), createClearRanges()), - Arguments.of(createPageRanges(0, 511), createPageRanges(), createPageRanges(0, 511), createClearRanges()), - Arguments.of(createPageRanges(), createPageRanges(0, 511), createPageRanges(), createClearRanges(0, 511)), - Arguments.of(createPageRanges(0, 511), createPageRanges(512, 1023), createPageRanges(0, 511), - createClearRanges(512, 1023)), - Arguments.of(createPageRanges(0, 511, 1024, 1535), createPageRanges(512, 1023, 1536, 2047), - createPageRanges(0, 511, 1024, 1535), createClearRanges(512, 1023, 1536, 2047))); - } - - private static List createPageRanges(long... offsets) { - List pageRanges = new ArrayList<>(); - - if (CoreUtils.isNullOrEmpty(Collections.singleton(offsets))) { - return pageRanges; - } - - for (int i = 0; i < offsets.length / 2; i++) { - pageRanges.add(new PageRange().setStart(offsets[i * 2]).setEnd(offsets[i * 2 + 1])); - } - return pageRanges; - } - - static List createClearRanges(long... offsets) { - List clearRanges = new ArrayList<>(); - - if (CoreUtils.isNullOrEmpty(Collections.singleton(offsets))) { - return clearRanges; - } - - for (int i = 0; i < offsets.length / 2; i++) { - clearRanges.add(new ClearRange().setStart(offsets[i * 2]).setEnd(offsets[i * 2 + 1])); - } - - return clearRanges; - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRangesDiffMin() { - String snapId = bc.createSnapshot().getSnapshotId(); - assertDoesNotThrow(() -> bc.getPageRangesDiff(null, snapId).getPageRange()); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void getPageRangesDiffAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - String snapId = bc.createSnapshot().getSnapshotId(); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(setupBlobMatchCondition(bc, match)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertDoesNotThrow(() -> bc.getPageRangesDiffWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), - snapId, bac, null, null)); - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void getPageRangesDiffACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - String snapId = bc.createSnapshot().getSnapshotId(); - - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.getPageRangesDiffWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), snapId, bac, - null, null)); - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRangesDiffError() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - assertThrows(BlobStorageException.class, () -> bc.getPageRangesDiff(null, "snapshot")); - } - - /* Uncomment any managed disk lines if a managed disk account is available to be tested. They are difficult to - acquire so we do not run them in the nightly live run tests. */ - @Disabled("Requires a managed disk account") - @Test - public void getPageRangesDiffPrevSnapshotUrl() { - BlobServiceClient managedDiskServiceClient = getServiceClient(ENVIRONMENT.getManagedDiskAccount()); - BlobContainerClient managedDiskContainer - = managedDiskServiceClient.getBlobContainerClient(generateContainerName()); - managedDiskContainer.create(); - PageBlobClient managedDiskBlob = managedDiskContainer.getBlobClient(generateBlobName()).getPageBlobClient(); - managedDiskBlob.create(PageBlobClient.PAGE_BYTES * 2); - - managedDiskBlob.uploadPages( - new PageRange().setStart(PageBlobClient.PAGE_BYTES).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - - String snapUrl = managedDiskBlob.createSnapshot().getBlobUrl(); - - managedDiskBlob.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - - managedDiskBlob - .clearPages(new PageRange().setStart(PageBlobClient.PAGE_BYTES).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1)); - - Response response = managedDiskBlob.getManagedDiskPageRangesDiffWithResponse( - new BlobRange(0, PageBlobClient.PAGE_BYTES * 2L), snapUrl, null, null, null); - - assertEquals(1, response.getValue().getPageRange().size()); - assertEquals(0, response.getValue().getPageRange().get(0).getStart()); - assertEquals(PageBlobClient.PAGE_BYTES - 1, response.getValue().getPageRange().get(0).getEnd()); - assertEquals(1, response.getValue().getClearRange().size()); - assertEquals(PageBlobClient.PAGE_BYTES, response.getValue().getClearRange().get(0).getStart()); - assertEquals(PageBlobClient.PAGE_BYTES * 2 - 1, response.getValue().getClearRange().get(0).getEnd()); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertEquals(PageBlobClient.PAGE_BYTES * 2, - Integer.parseInt(response.getHeaders().getValue(X_MS_BLOB_CONTENT_LENGTH))); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesRangesDiff() { - bc.create(4 * Constants.KB, true); - ByteArrayInputStream data = new ByteArrayInputStream(getRandomByteArray(4 * Constants.KB)); - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data); - String snapshot = bc.createSnapshot().getSnapshotId(); - data = new ByteArrayInputStream(getRandomByteArray(Constants.KB)); - data.mark(Integer.MAX_VALUE); - bc.uploadPages(new PageRange().setStart(0).setEnd(Constants.KB - 1), data); - data.reset(); - bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1)); - bc.uploadPages(new PageRange().setStart(2 * Constants.KB).setEnd(3 * Constants.KB - 1), data); - bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1)); - - Iterator iterable - = bc.listPageRangesDiff(new BlobRange(0, 4L * Constants.KB), snapshot).iterator(); - PageRangeItem item = iterable.next(); - - assertEquals(item.getRange(), new HttpRange(0L, (long) Constants.KB)); - assertFalse(item.isClear()); - - item = iterable.next(); - - assertEquals(item.getRange(), new HttpRange(2 * Constants.KB, (long) Constants.KB)); - assertFalse(item.isClear()); - - item = iterable.next(); - - assertEquals(item.getRange(), new HttpRange(Constants.KB, (long) Constants.KB)); - assertTrue(item.isClear()); - - item = iterable.next(); - - assertEquals(item.getRange(), new HttpRange(3 * Constants.KB, (long) Constants.KB)); - assertTrue(item.isClear()); - - assertFalse(iterable.hasNext()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesRangesDiffPageSize() { - bc.create(4 * Constants.KB, true); - ByteArrayInputStream data = new ByteArrayInputStream(getRandomByteArray(4 * Constants.KB)); - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data); - String snapshot = bc.createSnapshot().getSnapshotId(); - data = new ByteArrayInputStream(getRandomByteArray(Constants.KB)); - data.mark(Integer.MAX_VALUE); - bc.uploadPages(new PageRange().setStart(0).setEnd(Constants.KB - 1), data); - data.reset(); - bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1)); - bc.uploadPages(new PageRange().setStart(2 * Constants.KB).setEnd(3 * Constants.KB - 1), data); - bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1)); - - // when: "max results on options" - Iterator> iterator = bc.listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(0, 4L * Constants.KB), snapshot).setMaxResultsPerPage(2), null, - null).iterableByPage().iterator(); - PagedResponse page = iterator.next(); - - assertEquals(page.getValue().size(), 2); - page = iterator.next(); - - assertEquals(page.getValue().size(), 2); - assertFalse(iterator.hasNext()); - - // when: "max results on iterableByPage" - iterator = bc.listPageRangesDiff(new ListPageRangesDiffOptions(new BlobRange(0, 4L * Constants.KB), snapshot), - null, null).iterableByPage(2).iterator(); - page = iterator.next(); - - assertEquals(page.getValue().size(), 2); - - page = iterator.next(); - - assertEquals(page.getValue().size(), 2); - assertFalse(iterator.hasNext()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesDiffContinuationToken() { - bc.create(4 * Constants.KB, true); - ByteArrayInputStream data = new ByteArrayInputStream(getRandomByteArray(4 * Constants.KB)); - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data); - String snapshot = bc.createSnapshot().getSnapshotId(); - data = new ByteArrayInputStream(getRandomByteArray(Constants.KB)); - data.mark(Integer.MAX_VALUE); - bc.uploadPages(new PageRange().setStart(0).setEnd(Constants.KB - 1), data); - data.reset(); - bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1)); - bc.uploadPages(new PageRange().setStart(2 * Constants.KB).setEnd(3 * Constants.KB - 1), data); - bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1)); - - Iterator> iterator = bc.listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(0, 4L * Constants.KB), snapshot).setMaxResultsPerPage(2), null, - null).iterableByPage().iterator(); - String token = iterator.next().getContinuationToken(); - - iterator = bc.listPageRangesDiff(new ListPageRangesDiffOptions(new BlobRange(0, 4L * Constants.KB), snapshot), - null, null).iterableByPage(token).iterator(); - PagedResponse page = iterator.next(); - - assertEquals(page.getValue().size(), 2); - assertFalse(iterator.hasNext()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesDiffRange() { - bc.create(4 * Constants.KB, true); - ByteArrayInputStream data = new ByteArrayInputStream(getRandomByteArray(4 * Constants.KB)); - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data); - String snapshot = bc.createSnapshot().getSnapshotId(); - data = new ByteArrayInputStream(getRandomByteArray(Constants.KB)); - data.mark(Integer.MAX_VALUE); - bc.uploadPages(new PageRange().setStart(0).setEnd(Constants.KB - 1), data); - data.reset(); - bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1)); - bc.uploadPages(new PageRange().setStart(2 * Constants.KB).setEnd(3 * Constants.KB - 1), data); - bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1)); - - Iterator iterator = bc.listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(2 * Constants.KB + 1, 2L * Constants.KB), snapshot), null, null) - .iterator(); - - int size = 0; - while (iterator.hasNext()) { - iterator.next(); - size++; - } - assertEquals(size, 2); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void listPageRangesDiffAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - bc.create(4 * Constants.KB, true); - ByteArrayInputStream data = new ByteArrayInputStream(getRandomByteArray(4 * Constants.KB)); - bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data); - String snapshot = bc.createSnapshot().getSnapshotId(); - - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - match = setupBlobMatchCondition(bc, match); - leaseID = setupBlobLeaseCondition(bc, leaseID); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertDoesNotThrow( - () -> bc - .listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), snapshot) - .setRequestConditions(bac), - null, null) - .stream() - .count()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void listPageRangesDiffACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - String snapshot = bc.createSnapshot().getSnapshotId(); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc - .listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), snapshot) - .setRequestConditions(bac), - null, null) - .stream() - .count()); - } - - @ParameterizedTest - @MethodSource("pageRangeIASupplier") - public void pageRangeIA(int start, int end) { - PageRange range = new PageRange().setStart(start).setEnd(end); - assertThrows(IllegalArgumentException.class, () -> bc.clearPages(range)); - } - - private static Stream pageRangeIASupplier() { - return Stream.of(Arguments.of(1, 1), Arguments.of(-PageBlobClient.PAGE_BYTES, PageBlobClient.PAGE_BYTES - 1), - Arguments.of(0, 0), Arguments.of(1, PageBlobClient.PAGE_BYTES - 1), - Arguments.of(0, PageBlobClient.PAGE_BYTES), - Arguments.of(PageBlobClient.PAGE_BYTES * 2, PageBlobClient.PAGE_BYTES - 1)); - } - - @Test - public void resize() { - Response response = bc.resizeWithResponse(PageBlobClient.PAGE_BYTES * 2, null, null, null); - - assertEquals(PageBlobClient.PAGE_BYTES * 2, bc.getProperties().getBlobSize()); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertNotNull(response.getValue().getBlobSequenceNumber()); - } - - @Test - public void resizeSimple() { - bc.resize(PageBlobClient.PAGE_BYTES * 2); - assertEquals(PageBlobClient.PAGE_BYTES * 2, bc.getProperties().getBlobSize()); - } - - @Test - public void resizeMin() { - assertResponseStatusCode(bc.resizeWithResponse(PageBlobClient.PAGE_BYTES, null, null, null), 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void resizeAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(setupBlobMatchCondition(bc, match)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode(bc.resizeWithResponse(PageBlobClient.PAGE_BYTES * 2, bac, null, null), 200); - - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void resizeACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.resizeWithResponse(PageBlobClient.PAGE_BYTES * 2, bac, null, null)); - } - - @Test - public void resizeError() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - assertThrows(BlobStorageException.class, () -> bc.resize(0)); - } - - @ParameterizedTest - @MethodSource("sequenceNumberSupplier") - public void sequenceNumber(SequenceNumberActionType action, Long number, Long result) { - Response response = bc.updateSequenceNumberWithResponse(action, number, null, null, null); - - assertEquals(result, bc.getProperties().getBlobSequenceNumber()); - assertTrue(validateBasicHeaders(response.getHeaders())); - assertEquals(response.getValue().getBlobSequenceNumber(), result); - } - - @ParameterizedTest - @MethodSource("sequenceNumberSupplier") - public void sequenceNumberSimple(SequenceNumberActionType action, Long number, Long result) { - bc.updateSequenceNumber(action, number); - - assertEquals(result, bc.getProperties().getBlobSequenceNumber()); - } - - private static Stream sequenceNumberSupplier() { - return Stream.of(Arguments.of(SequenceNumberActionType.UPDATE, 5L, 5L), - Arguments.of(SequenceNumberActionType.INCREMENT, null, 1L), - Arguments.of(SequenceNumberActionType.MAX, 2L, 2L)); - } - - @Test - public void sequenceNumberMin() { - assertResponseStatusCode( - bc.updateSequenceNumberWithResponse(SequenceNumberActionType.INCREMENT, null, null, null, null), 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void sequenceNumberAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - bc.setTags(t); - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(setupBlobMatchCondition(bc, match)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertResponseStatusCode( - bc.updateSequenceNumberWithResponse(SequenceNumberActionType.UPDATE, 1L, bac, null, null), 200); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void sequenceNumberACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(setupBlobLeaseCondition(bc, leaseID)) - .setIfMatch(match) - .setIfNoneMatch(setupBlobMatchCondition(bc, noneMatch)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, - () -> bc.updateSequenceNumberWithResponse(SequenceNumberActionType.UPDATE, 1L, bac, null, null)); - } - - @Test - public void sequenceNumberError() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - assertThrows(BlobStorageException.class, () -> bc.updateSequenceNumber(SequenceNumberActionType.UPDATE, 0L)); - } - - @Test - public void startIncrementalCopy() { - PageBlobClient bc2 = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - String snapId = bc.createSnapshot().getSnapshotId(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - Response copyResponse - = bc2.copyIncrementalWithResponse(bc.getBlobUrl() + "?" + sas, snapId, null, null, null); - - CopyStatusType status = copyResponse.getValue(); - OffsetDateTime start = testResourceNamer.now(); - while (status != CopyStatusType.SUCCESS) { - status = bc2.getProperties().getCopyStatus(); - OffsetDateTime currentTime = testResourceNamer.now(); - if (status == CopyStatusType.FAILED || currentTime.minusMinutes(1) == start) { - throw new RuntimeException("Copy failed or took too long"); - } - sleepIfRunningAgainstService(1000); - } - - BlobProperties properties = bc2.getProperties(); - assertTrue(properties.isIncrementalCopy()); - assertNotNull(properties.getCopyDestinationSnapshot()); - validateBasicHeaders(copyResponse.getHeaders()); - assertNotNull(copyResponse.getHeaders().getValue(X_MS_COPY_ID)); - assertNotNull(copyResponse.getValue()); - } - - @Test - public void startIncrementalCopyMin() { - PageBlobClient bc2 = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - String snapshot = bc.createSnapshot().getSnapshotId(); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - assertResponseStatusCode( - bc2.copyIncrementalWithResponse(bc.getBlobUrl() + "?" + sas, snapshot, null, null, null), 202); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("startIncrementalCopyACSupplier") - public void startIncrementalCopyAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - PageBlobClient bu2 = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - String snapshot = bc.createSnapshot().getSnapshotId(); - - sleepIfRunningAgainstService(10 * 1000); - - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - - Response copyResponse - = bu2.copyIncrementalWithResponse(bc.getBlobUrl() + "?" + sas, snapshot, null, null, null); - - CopyStatusType status = copyResponse.getValue(); - OffsetDateTime start = testResourceNamer.now(); - while (status != CopyStatusType.SUCCESS) { - status = bu2.getProperties().getCopyStatus(); - OffsetDateTime currentTime = testResourceNamer.now(); - if (status == CopyStatusType.FAILED || currentTime.minusMinutes(1) == start) { - throw new RuntimeException("Copy failed or took too long"); - } - sleepIfRunningAgainstService(1000); - } - Map t = new HashMap<>(); - t.put("foo", "bar"); - bu2.setTags(t); - - snapshot = bc.createSnapshot().getSnapshotId(); - match = setupBlobMatchCondition(bu2, match); - PageBlobCopyIncrementalRequestConditions mac - = new PageBlobCopyIncrementalRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertResponseStatusCode(bu2.copyIncrementalWithResponse( - new PageBlobCopyIncrementalOptions(bc.getBlobUrl() + "?" + sas, snapshot).setRequestConditions(mac), null, - null), 202); - } - - private static Stream startIncrementalCopyACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), Arguments.of(OLD_DATE, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null), Arguments.of(null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null), - Arguments.of(null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("startIncrementalCopyACFailSupplier") - public void startIncrementalCopyACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - - PageBlobClient bu2 = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - String snapshot = bc.createSnapshot().getSnapshotId(); - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobContainerSasPermission().setReadPermission(true))); - bu2.copyIncremental(bc.getBlobUrl() + "?" + sas, snapshot); - String finalSnapshot = bc.createSnapshot().getSnapshotId(); - noneMatch = setupBlobMatchCondition(bu2, noneMatch); - PageBlobCopyIncrementalRequestConditions mac - = new PageBlobCopyIncrementalRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - - assertThrows(BlobStorageException.class, () -> bu2.copyIncrementalWithResponse( - new PageBlobCopyIncrementalOptions(bc.getBlobUrl() + "?" + sas, finalSnapshot).setRequestConditions(mac), - null, null)); - } - - private static Stream startIncrementalCopyACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null), Arguments.of(null, OLD_DATE, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null), Arguments.of(null, null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void startIncrementalCopyError() { - bc = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - assertThrows(BlobStorageException.class, () -> bc.copyIncremental("https://www.error.com", "snapshot")); - } - - @Test - public void getContainerName() { - assertEquals(containerName, bc.getContainerName()); - } - - @Test - public void getPageBlobName() { - assertEquals(blobName, bc.getBlobName()); - } - - @ParameterizedTest - @MethodSource("getBlobNameAndBuildClientSupplier") - public void getBlobNameAndBuildClient(String originalBlobName, String finalBlobName) { - BlobClient client = cc.getBlobClient(originalBlobName); - PageBlobClient blockClient = cc.getBlobClient(client.getBlobName()).getPageBlobClient(); - assertEquals(blockClient.getBlobName(), finalBlobName); - } - - private static Stream getBlobNameAndBuildClientSupplier() { - return Stream.of(Arguments.of("blobName", "blobName"), Arguments.of("dir1/a%20b.txt", "dir1/a%20b.txt"), - Arguments.of("path/to]a blob", "path/to]a blob"), - Arguments.of("path%2Fto%5Da%20blob", "path%2Fto%5Da%20blob"), Arguments.of("斑點", "斑點"), - Arguments.of("%E6%96%91%E9%BB%9E", "%E6%96%91%E9%BB%9E"), Arguments.of("斑點", "斑點")); - } - - @Test - public void createOverwriteFalse() { - assertThrows(BlobStorageException.class, () -> bc.create(512)); - } - - @Test - public void createOverwriteTrue() { - assertDoesNotThrow(() -> bc.create(512, true)); - } - - @Test - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - public void perCallPolicy() { - PageBlobClient specialBlob - = getSpecializedBuilder(bc.getBlobUrl()).addPolicy(getPerCallVersionPolicy()).buildPageBlobClient(); - - Response response = specialBlob.getPropertiesWithResponse(null, null, null); - - assertEquals(response.getHeaders().getValue(X_MS_VERSION), "2017-11-09"); - } - - @Test - public void defaultAudience() { - PageBlobClient aadBlob - = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()).audience(null).buildPageBlobClient(); - - assertTrue(aadBlob.exists()); - } - - @Test - public void storageAccountAudience() { - PageBlobClient aadBlob = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(cc.getAccountName())) - .buildPageBlobClient(); - - assertTrue(aadBlob.exists()); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - PageBlobClient aadBlob = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildPageBlobClient(); - - assertNotNull(aadBlob.getProperties()); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", cc.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - PageBlobClient aadBlob - = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()).audience(audience).buildPageBlobClient(); - - assertTrue(aadBlob.exists()); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobAsyncApiTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobAsyncApiTests.java deleted file mode 100644 index 5886a7985925..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/PageBlobAsyncApiTests.java +++ /dev/null @@ -1,1804 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpRange; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.Response; -import com.azure.core.test.TestMode; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.FluxUtil; -import com.azure.storage.blob.BlobAsyncClient; -import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.BlobAudience; -import com.azure.storage.blob.models.BlobErrorCode; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobProperties; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.BlobStorageException; -import com.azure.storage.blob.models.ClearRange; -import com.azure.storage.blob.models.CopyStatusType; -import com.azure.storage.blob.models.PageBlobCopyIncrementalRequestConditions; -import com.azure.storage.blob.models.PageBlobItem; -import com.azure.storage.blob.models.PageBlobRequestConditions; -import com.azure.storage.blob.models.PageList; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.blob.models.PageRangeItem; -import com.azure.storage.blob.models.SequenceNumberActionType; -import com.azure.storage.blob.options.BlobGetTagsOptions; -import com.azure.storage.blob.options.ListPageRangesDiffOptions; -import com.azure.storage.blob.options.ListPageRangesOptions; -import com.azure.storage.blob.options.PageBlobCopyIncrementalOptions; -import com.azure.storage.blob.options.PageBlobCreateOptions; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.test.shared.extensions.LiveOnly; -import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; -import com.azure.storage.common.test.shared.policy.TransientFailureInjectingHttpPipelinePolicy; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.function.Tuple2; - -import java.nio.ByteBuffer; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class PageBlobAsyncApiTests extends BlobTestBase { - - private PageBlobAsyncClient bc; - private String blobName; - - @BeforeEach - public void setup() { - blobName = generateBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getPageBlobAsyncClient(); - bc.create(PageBlobClient.PAGE_BYTES).block(); - } - - @Test - public void createAllNull() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - - StepVerifier.create(bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, null, null)).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(validateBasicHeaders(r.getHeaders())); - assertNull(r.getValue().getContentMd5()); - assertTrue(r.getValue().isServerEncrypted()); - }).verifyComplete(); - } - - @Test - public void createMin() { - assertAsyncResponseStatusCode(bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, null, null), 201); - } - - @Test - public void createSequenceNumber() { - StepVerifier - .create(bc.createWithResponse(PageBlobClient.PAGE_BYTES, 2L, null, null, null).then(bc.getProperties())) - .assertNext(r -> assertEquals(2, r.getBlobSequenceNumber())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("createHeadersSupplier") - public void createHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - contentType = (contentType == null) ? "application/octet-stream" : contentType; - String finalContentType = contentType; - - StepVerifier - .create(bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, headers, null, null) - .then(bc.getPropertiesWithResponse(null))) - .assertNext(r -> assertTrue(validateBlobProperties(r, cacheControl, contentDisposition, contentEncoding, - contentLanguage, contentMD5, finalContentType))) - .verifyComplete(); - } - - private static Stream createHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), - Arguments.of("control", "disposition", "encoding", "language", - Base64.getEncoder().encode(MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes())), "type")); - } - - @ParameterizedTest - @MethodSource("createMetadataSupplier") - public void createMetadata(String key1, String value1, String key2, String value2) { - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - StepVerifier.create(bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, metadata, null) - .then(bc.getPropertiesWithResponse(null))).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(metadata, r.getValue().getMetadata()); - }).verifyComplete(); - } - - private static Stream createMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createTagsSupplier") - public void createTags(String key1, String value1, String key2, String value2) { - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - StepVerifier.create(bc.createWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setTags(tags)) - .then(bc.getTagsWithResponse(new BlobGetTagsOptions()))).assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(tags, r.getValue()); - }).verifyComplete(); - } - - private static Stream createTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void createAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - return bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, null, bac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void createACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response = setupBlobMatchCondition(bc, noneMatch).flatMap(condition -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(convertNull(condition)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, null, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void createError() { - StepVerifier.create(bc.createWithResponse(PageBlobClient.PAGE_BYTES, null, null, null, - new BlobRequestConditions().setLeaseId("id"))).verifyError(BlobStorageException.class); - } - - @Test - public void createIfNotExistsAllNull() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - - StepVerifier.create(bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES))) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(validateBasicHeaders(r.getHeaders())); - assertNull(r.getValue().getContentMd5()); - assertTrue(r.getValue().isServerEncrypted()); - }) - .verifyComplete(); - } - - @Test - public void createIfNotExistsBlobThatAlreadyExists() { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getPageBlobAsyncClient(); - PageBlobCreateOptions options = new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES); - - assertAsyncResponseStatusCode(bc.createIfNotExistsWithResponse(options), 201); - assertAsyncResponseStatusCode(bc.createIfNotExistsWithResponse(options), 409); - } - - @Test - public void createIfNotExistsMin() { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getPageBlobAsyncClient(); - - assertAsyncResponseStatusCode( - bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES)), 201); - } - - @Test - public void createIfNotExistsSequenceNumber() { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getPageBlobAsyncClient(); - - StepVerifier.create( - bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setSequenceNumber(2L)) - .then(bc.getProperties())) - .assertNext(r -> assertEquals(2, r.getBlobSequenceNumber())) - .verifyComplete(); - } - - @ParameterizedTest - @MethodSource("createIfNotExistsHeadersSupplier") - public void createIfNotExistsHeaders(String cacheControl, String contentDisposition, String contentEncoding, - String contentLanguage, byte[] contentMD5, String contentType) { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getPageBlobAsyncClient(); - - BlobHttpHeaders headers = new BlobHttpHeaders().setCacheControl(cacheControl) - .setContentDisposition(contentDisposition) - .setContentEncoding(contentEncoding) - .setContentLanguage(contentLanguage) - .setContentMd5(contentMD5) - .setContentType(contentType); - - contentType = (contentType == null) ? "application/octet-stream" : contentType; - String finalContentType = contentType; - - StepVerifier - .create(bc - .createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setHeaders(headers)) - .then(bc.getPropertiesWithResponse(null))) - .assertNext(r -> assertTrue(validateBlobProperties(r, cacheControl, contentDisposition, contentEncoding, - contentLanguage, contentMD5, finalContentType))) - .verifyComplete(); - } - - private static Stream createIfNotExistsHeadersSupplier() throws NoSuchAlgorithmException { - return Stream.of(Arguments.of(null, null, null, null, null, null), Arguments.of("control", "disposition", - "encoding", "language", MessageDigest.getInstance("MD5").digest(DATA.getDefaultBytes()), "type")); - } - - @ParameterizedTest - @MethodSource("createIfNotExistsMetadataSupplier") - public void createIfNotExistsMetadata(String key1, String value1, String key2, String value2) { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getPageBlobAsyncClient(); - - Map metadata = new HashMap<>(); - if (key1 != null) { - metadata.put(key1, value1); - } - if (key2 != null) { - metadata.put(key2, value2); - } - - StepVerifier.create( - bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setMetadata(metadata)) - .then(bc.getPropertiesWithResponse(null))) - .assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(metadata, r.getValue().getMetadata()); - }) - .verifyComplete(); - } - - private static Stream createIfNotExistsMetadataSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz")); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("createIfNotExistsTagsSupplier") - public void createIfNotExistsTags(String key1, String value1, String key2, String value2) { - String blobName = ccAsync.getBlobAsyncClient(generateBlobName()).getBlobName(); - bc = ccAsync.getBlobAsyncClient(blobName).getPageBlobAsyncClient(); - - Map tags = new HashMap<>(); - if (key1 != null) { - tags.put(key1, value1); - } - if (key2 != null) { - tags.put(key2, value2); - } - - StepVerifier - .create(bc.createIfNotExistsWithResponse(new PageBlobCreateOptions(PageBlobClient.PAGE_BYTES).setTags(tags)) - .then(bc.getTagsWithResponse(new BlobGetTagsOptions()))) - .assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(tags, r.getValue()); - }) - .verifyComplete(); - } - - private static Stream createIfNotExistsTagsSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of("foo", "bar", "fizz", "buzz"), - Arguments.of(" +-./:=_ +-./:=_", " +-./:=_", null, null)); - } - - @Test - public void uploadPage() { - StepVerifier - .create(bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, null)) - .assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(validateBasicHeaders(r.getHeaders())); - assertNotNull(r.getHeaders().getValue(X_MS_CONTENT_CRC64)); - assertEquals(0, r.getValue().getBlobSequenceNumber()); - assertTrue(r.getValue().isServerEncrypted()); - }) - .verifyComplete(); - } - - @Test - public void uploadPageMin() { - assertAsyncResponseStatusCode( - bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, null), - 201); - } - - @ParameterizedTest - @MethodSource("uploadPageIASupplier") - public void uploadPageIA(Integer dataSize, Throwable exceptionType) { - Flux data - = (dataSize == null) ? null : Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))); - - StepVerifier.create(bc.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1), data)) - .verifyError(exceptionType.getClass()); - } - - private static Stream uploadPageIASupplier() { - return Stream.of(Arguments.of(null, new NullPointerException()), - Arguments.of(PageBlobClient.PAGE_BYTES, new UnexpectedLengthException(null, 0L, 0L /* dummy values */)), - Arguments.of(PageBlobClient.PAGE_BYTES * 3, - new UnexpectedLengthException(null, 0L, 0L /* dummy values */))); - } - - @Test - public void uploadPageTransactionalMD5() throws NoSuchAlgorithmException { - byte[] data = getRandomByteArray(PageBlobClient.PAGE_BYTES); - byte[] md5 = MessageDigest.getInstance("MD5").digest(data); - - assertAsyncResponseStatusCode( - bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(data)), md5, null), - 201); - } - - @Test - public void uploadPageTransactionalMD5Fail() throws NoSuchAlgorithmException { - - StepVerifier - .create(bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), - MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null)) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertEquals(BlobErrorCode.MD5MISMATCH, e.getErrorCode()); - }); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("uploadPageACSupplier") - public void uploadPageAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - return bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, pac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - private static Stream uploadPageACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null, null, null, null, null), - Arguments.of(OLD_DATE, null, null, null, null, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null, null, null, null, null), - Arguments.of(null, null, RECEIVED_ETAG, null, null, null, null, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null, null, null, null, null), - Arguments.of(null, null, null, null, RECEIVED_LEASE_ID, null, null, null, null), - Arguments.of(null, null, null, null, null, 5L, null, null, null), - Arguments.of(null, null, null, null, null, null, 3L, null, null), - Arguments.of(null, null, null, null, null, null, null, 0L, null), - Arguments.of(null, null, null, null, null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("uploadPageACFailSupplier") - public void uploadPageACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - return bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, pac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream uploadPageACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null, null, null, null, null), - Arguments.of(null, OLD_DATE, null, null, null, null, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null, null, null, null, null), - Arguments.of(null, null, null, RECEIVED_ETAG, null, null, null, null, null), - Arguments.of(null, null, null, null, GARBAGE_LEASE_ID, null, null, null, null), - Arguments.of(null, null, null, null, null, -1L, null, null, null), - Arguments.of(null, null, null, null, null, null, -1L, null, null), - Arguments.of(null, null, null, null, null, null, null, 100L, null), - Arguments.of(null, null, null, null, null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void uploadPageError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - - StepVerifier - .create(bc.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, - new PageBlobRequestConditions().setLeaseId("id"))) - .verifyError(BlobStorageException.class); - } - - @Test - public void uploadPageRetryOnTransientFailure() { - PageBlobAsyncClient clientWithFailure = getBlobAsyncClient(ENVIRONMENT.getPrimaryAccount().getCredential(), - bc.getBlobUrl(), new TransientFailureInjectingHttpPipelinePolicy()).getPageBlobAsyncClient(); - - byte[] data = getRandomByteArray(PageBlobClient.PAGE_BYTES); - - StepVerifier - .create(clientWithFailure - .uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(data))) - .then(FluxUtil.collectBytesInByteBufferStream(bc.downloadStream()))) - .assertNext(r -> TestUtils.assertArraysEqual(r, data)) - .verifyComplete(); - } - - @Test - public void uploadPageFromURLMin() { - PageBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - String sas = destURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - - Mono> response = destURL.create(PageBlobClient.PAGE_BYTES) - .then(destURL.uploadPages(pageRange, - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))))) - .then( - bc.uploadPagesFromUrlWithResponse(pageRange, destURL.getBlobUrl() + "?" + sas, null, null, null, null)); - - StepVerifier.create(response).assertNext(r -> { - assertResponseStatusCode(r, 201); - assertTrue(validateBasicHeaders(r.getHeaders())); - }).verifyComplete(); - } - - /*@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @Test - public void uploadPageFromURLSourceErrorAndStatusCode() { - PageBlobAsyncClient destBlob = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - - StepVerifier.create(destBlob.createIfNotExists(Constants.KB).then(destBlob.uploadPagesFromUrl(pageRange, bc.getBlobUrl(), null))) - .verifyErrorSatisfies(r -> { - BlobStorageException e = assertInstanceOf(BlobStorageException.class, r); - assertTrue(e.getStatusCode() == 409); - assertTrue(e.getServiceMessage().contains("PublicAccessNotPermitted")); - assertTrue(e.getServiceMessage().contains("Public access is not permitted on this storage account.")); - }); - }*/ - - @Test - public void uploadPageFromURLRange() { - byte[] data = getRandomByteArray(PageBlobClient.PAGE_BYTES * 4); - - PageBlobAsyncClient sourceURL = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - PageBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - - String sas = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono response = sourceURL.create(PageBlobClient.PAGE_BYTES * 4) - .then(sourceURL.uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 4 - 1), - Flux.just(ByteBuffer.wrap(data)))) - .then(destURL.create(PageBlobClient.PAGE_BYTES * 2)) - .then(destURL.uploadPagesFromUrl(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1), - sourceURL.getBlobUrl() + "?" + sas, PageBlobClient.PAGE_BYTES * 2L)) - .then(FluxUtil.collectBytesInByteBufferStream(destURL.downloadStream())); - - StepVerifier.create(response) - .assertNext(r -> TestUtils.assertArraysEqual(data, PageBlobClient.PAGE_BYTES * 2, r, 0, - PageBlobClient.PAGE_BYTES * 2)) - .verifyComplete(); - } - - @Test - public void uploadPageFromURLIA() { - StepVerifier.create(bc.uploadPagesFromUrl(null, bc.getBlobUrl(), (long) PageBlobClient.PAGE_BYTES)) - .verifyError(IllegalArgumentException.class); - } - - @Test - public void uploadPageFromURLMD5() throws NoSuchAlgorithmException { - PageBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - byte[] data = getRandomByteArray(PageBlobClient.PAGE_BYTES); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono> response = destURL.create(PageBlobClient.PAGE_BYTES) - .then(bc.uploadPages(pageRange, Flux.just(ByteBuffer.wrap(data)))) - .then(destURL.uploadPagesFromUrlWithResponse(pageRange, bc.getBlobUrl() + "?" + sas, null, - MessageDigest.getInstance("MD5").digest(data), null, null)); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @Test - public void uploadPageFromURLMD5Fail() throws NoSuchAlgorithmException { - PageBlobAsyncClient destURL = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono> response = destURL.create(PageBlobClient.PAGE_BYTES) - .then(bc.uploadPages(pageRange, Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))))) - .then(destURL.uploadPagesFromUrlWithResponse(pageRange, bc.getBlobUrl() + "?" + sas, null, - MessageDigest.getInstance("MD5").digest("garbage".getBytes()), null, null)); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("uploadPageACSupplier") - public void uploadPageFromURLDestinationAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, - String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - PageBlobAsyncClient sourceURL = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - - Mono> response = bc.setTags(t) - .then(sourceURL.create(PageBlobClient.PAGE_BYTES)) - .then(sourceURL.uploadPages(pageRange, - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))))) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - String sas - = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - return bc.uploadPagesFromUrlWithResponse(pageRange, sourceURL.getBlobUrl() + "?" + sas, null, null, pac, - null); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - @ParameterizedTest - @MethodSource("uploadPageACFailSupplier") - public void uploadPageFromURLDestinationACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, - String tags) { - PageBlobAsyncClient sourceURL = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - - Mono> response = sourceURL.create(PageBlobClient.PAGE_BYTES) - .then(sourceURL.uploadPages(pageRange, - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))))) - .then(setupBlobMatchCondition(bc, noneMatch)) - .flatMap(condition -> { - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(leaseID) - .setIfMatch(match) - .setIfNoneMatch(convertNull(condition)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - String sas - = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - return bc.uploadPagesFromUrlWithResponse(pageRange, sourceURL.getBlobUrl() + "?" + sas, null, null, pac, - null); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("uploadPageFromURLSourceACSupplier") - public void uploadPageFromURLSourceAC(OffsetDateTime sourceIfModifiedSince, OffsetDateTime sourceIfUnmodifiedSince, - String sourceIfMatch, String sourceIfNoneMatch) { - PageBlobAsyncClient sourceURL = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - - Mono> response = sourceURL.create(PageBlobClient.PAGE_BYTES) - .then(sourceURL.uploadPages(pageRange, - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))))) - .then(setupBlobMatchCondition(sourceURL, sourceIfMatch)) - .flatMap(condition -> { - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(convertNull(condition)) - .setIfNoneMatch(sourceIfNoneMatch); - String sas - = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - return bc.uploadPagesFromUrlWithResponse(pageRange, sourceURL.getBlobUrl() + "?" + sas, null, null, - null, smac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - private static Stream uploadPageFromURLSourceACSupplier() { - return Stream.of(Arguments.of(null, null, null, null), Arguments.of(OLD_DATE, null, null, null), - Arguments.of(null, NEW_DATE, null, null), Arguments.of(null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, GARBAGE_ETAG)); - } - - @ParameterizedTest - @MethodSource("uploadPageFromURLSourceACFailSupplier") - public void uploadPageFromURLSourceACFail(OffsetDateTime sourceIfModifiedSince, - OffsetDateTime sourceIfUnmodifiedSince, String sourceIfMatch, String sourceIfNoneMatch) { - PageBlobAsyncClient sourceURL = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - PageRange pageRange = new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1); - - Mono> response = sourceURL.create(PageBlobClient.PAGE_BYTES) - .then(sourceURL.uploadPages(pageRange, - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))))) - .then(setupBlobMatchCondition(sourceURL, sourceIfNoneMatch)) - .flatMap(condition -> { - BlobRequestConditions smac = new BlobRequestConditions().setIfModifiedSince(sourceIfModifiedSince) - .setIfUnmodifiedSince(sourceIfUnmodifiedSince) - .setIfMatch(sourceIfMatch) - .setIfNoneMatch(convertNull(condition)); - String sas - = sourceURL.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - return bc.uploadPagesFromUrlWithResponse(pageRange, sourceURL.getBlobUrl() + "?" + sas, null, null, - null, smac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream uploadPageFromURLSourceACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null), Arguments.of(null, OLD_DATE, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null), Arguments.of(null, null, null, RECEIVED_ETAG)); - } - - @SuppressWarnings("deprecation") - @Test - public void clearPage() { - StepVerifier - .create(bc - .uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES))), null, null) - .then( - bc.clearPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), null))) - .assertNext(r -> { - assertTrue(validateBasicHeaders(r.getHeaders())); - assertNull(r.getValue().getContentMd5()); - assertEquals(0, r.getValue().getBlobSequenceNumber()); - }) - .verifyComplete(); - - StepVerifier.create(bc.getPageRanges(new BlobRange(0))) - .assertNext(r -> assertEquals(0, r.getPageRange().size())) - .verifyComplete(); - } - - @Test - public void clearPageMin() { - StepVerifier.create(bc.clearPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1))) - .expectNextCount(1) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("uploadPageACSupplier") - public void clearPagesAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc - .uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES)))) - .then(bc.setTags(t)) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - return bc.clearPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - pac); - }); - - assertAsyncResponseStatusCode(response, 201); - } - - @ParameterizedTest - @MethodSource("uploadPageACFailSupplier") - public void clearPagesACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, Long sequenceNumberLT, Long sequenceNumberLTE, Long sequenceNumberEqual, String tags) { - Mono> response = bc - .uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES)))) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - PageBlobRequestConditions pac = new PageBlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfSequenceNumberLessThan(sequenceNumberLT) - .setIfSequenceNumberLessThanOrEqualTo(sequenceNumberLTE) - .setIfSequenceNumberEqualTo(sequenceNumberEqual) - .setTagsConditions(tags); - - return bc.clearPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - pac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void clearPageError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - - StepVerifier.create(bc.clearPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1))) - .verifyError(BlobStorageException.class); - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRanges() { - StepVerifier - .create(bc - .uploadPages(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(PageBlobClient.PAGE_BYTES)))) - .then(bc.getPageRangesWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), null))) - .assertNext(r -> { - assertResponseStatusCode(r, 200); - assertEquals(1, r.getValue().getPageRange().size()); - assertTrue(validateBasicHeaders(r.getHeaders())); - assertEquals("512", r.getHeaders().getValue(X_MS_BLOB_CONTENT_LENGTH)); - }) - .verifyComplete(); - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRangesMin() { - StepVerifier.create(bc.getPageRanges(null)).expectNextCount(1).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void getPageRangesAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.getPageRangesWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), bac); - }); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void getPageRangesACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.getPageRangesWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRangesError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - StepVerifier.create(bc.getPageRanges(null)).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPageRanges() { - Flux data = Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.KB))); - - Flux response = bc.create(4 * Constants.KB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data)) - .then(bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1))) - .then(bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1))) - .thenMany(bc.listPageRanges(new BlobRange(0, (long) 4 * Constants.KB))); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(r.getRange(), new HttpRange(0, (long) Constants.KB)); - assertFalse(r.isClear()); - }).assertNext(r -> { - assertEquals(r.getRange(), new HttpRange(2 * Constants.KB, (long) Constants.KB)); - assertFalse(r.isClear()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesRangesPageSize() { - Flux data = Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.KB))); - - Flux> response = bc.create(4 * Constants.KB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data)) - .then(bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1))) - .then(bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1))) - .thenMany(bc - .listPageRanges(new ListPageRangesOptions(new BlobRange(0, 4L * Constants.KB)).setMaxResultsPerPage(1)) - .byPage()); - - // when: "max results on options" - StepVerifier.create(response) - .assertNext(r -> assertEquals(1, r.getValue().size())) - .assertNext(r -> assertEquals(1, r.getValue().size())) - .verifyComplete(); - - // when: "max results on iterableByPage" - StepVerifier.create(bc.listPageRanges(new ListPageRangesOptions(new BlobRange(0, 4L * Constants.KB))).byPage(1)) - .assertNext(r -> assertEquals(1, r.getValue().size())) - .assertNext(r -> assertEquals(1, r.getValue().size())) - .verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesContinuationToken() { - Flux data = Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.KB))); - - Flux> response = bc.create(4 * Constants.KB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data)) - .then(bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1))) - .then(bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1))) - .thenMany(bc - .listPageRanges(new ListPageRangesOptions(new BlobRange(0, 4L * Constants.KB)).setMaxResultsPerPage(1)) - .byPage()) - .flatMap(r -> bc.listPageRanges(new ListPageRangesOptions(new BlobRange(0, 4L * Constants.KB))) - .byPage(r.getContinuationToken())); - - StepVerifier.create(response).assertNext(r -> assertEquals(1, r.getValue().size())).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesRange() { - Flux data = Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.KB))); - - Flux response = bc.create(4 * Constants.KB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data)) - .then(bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1))) - .then(bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1))) - .thenMany( - bc.listPageRanges(new ListPageRangesOptions(new BlobRange(2 * Constants.KB + 1, 2L * Constants.KB)))); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void listPagesRangesAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Flux response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMapMany(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.listPageRanges(new ListPageRangesOptions(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES)) - .setRequestConditions(bac)); - }); - - StepVerifier.create(response).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void listPageRangesACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc - .listPageRanges(new ListPageRangesOptions(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES)) - .setRequestConditions(bac)) - .count(); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("getPageRangesDiffSupplier") - public void getPageRangesDiff(List rangesToUpdate, List rangesToClear, - List expectedPageRanges, List expectedClearRanges) { - Mono> response = bc.create(4 * Constants.MB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.MB - 1), - Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.MB))))) - .then(bc.createSnapshot()) - .flatMap(snapId -> { - Flux upload = Flux.fromIterable(rangesToUpdate) - .flatMap(it -> bc.uploadPages(it, - Flux.just(ByteBuffer.wrap(getRandomByteArray((int) (it.getEnd() - it.getStart()) + 1))))); - Flux clear = Flux.fromIterable(rangesToClear).flatMap(it -> bc.clearPages(it)); - return upload.thenMany(clear) - .then(bc.getPageRangesDiffWithResponse(new BlobRange(0, 4L * Constants.MB), snapId.getSnapshotId(), - null)); - }); - - StepVerifier.create(response).assertNext(r -> { - assertTrue(validateBasicHeaders(r.getHeaders())); - assertEquals(expectedPageRanges.size(), r.getValue().getPageRange().size()); - assertEquals(expectedClearRanges.size(), r.getValue().getClearRange().size()); - - for (int i = 0; i < expectedPageRanges.size(); i++) { - PageRange actualRange = r.getValue().getPageRange().get(i); - PageRange expectedRange = expectedPageRanges.get(i); - assertEquals(expectedRange.getStart(), actualRange.getStart()); - assertEquals(expectedRange.getEnd(), actualRange.getEnd()); - } - - for (int i = 0; i < expectedClearRanges.size(); i++) { - ClearRange actualRange = r.getValue().getClearRange().get(i); - ClearRange expectedRange = expectedClearRanges.get(i); - assertEquals(expectedRange.getStart(), actualRange.getStart()); - assertEquals(expectedRange.getEnd(), actualRange.getEnd()); - } - - assertEquals(4 * Constants.MB, Integer.parseInt(r.getHeaders().getValue(X_MS_BLOB_CONTENT_LENGTH))); - }).verifyComplete(); - } - - private static Stream getPageRangesDiffSupplier() { - return Stream.of(Arguments.of(createPageRanges(), createPageRanges(), createPageRanges(), createClearRanges()), - Arguments.of(createPageRanges(0, 511), createPageRanges(), createPageRanges(0, 511), createClearRanges()), - Arguments.of(createPageRanges(), createPageRanges(0, 511), createPageRanges(), createClearRanges(0, 511)), - Arguments.of(createPageRanges(0, 511), createPageRanges(512, 1023), createPageRanges(0, 511), - createClearRanges(512, 1023)), - Arguments.of(createPageRanges(0, 511, 1024, 1535), createPageRanges(512, 1023, 1536, 2047), - createPageRanges(0, 511, 1024, 1535), createClearRanges(512, 1023, 1536, 2047))); - } - - private static List createPageRanges(long... offsets) { - List pageRanges = new ArrayList<>(); - - if (CoreUtils.isNullOrEmpty(Collections.singleton(offsets))) { - return pageRanges; - } - - for (int i = 0; i < offsets.length / 2; i++) { - pageRanges.add(new PageRange().setStart(offsets[i * 2]).setEnd(offsets[i * 2 + 1])); - } - return pageRanges; - } - - static List createClearRanges(long... offsets) { - List clearRanges = new ArrayList<>(); - - if (CoreUtils.isNullOrEmpty(Collections.singleton(offsets))) { - return clearRanges; - } - - for (int i = 0; i < offsets.length / 2; i++) { - clearRanges.add(new ClearRange().setStart(offsets[i * 2]).setEnd(offsets[i * 2 + 1])); - } - - return clearRanges; - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRangesDiffMin() { - Mono response = bc.createSnapshot().flatMap(r -> bc.getPageRangesDiff(null, r.getSnapshotId())); - - StepVerifier.create(response).assertNext(r -> assertDoesNotThrow(r::getPageRange)).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void getPageRangesDiffAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(bc.createSnapshot()) - .flatMap( - snapId -> Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.getPageRangesDiffWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), - snapId.getSnapshotId(), bac); - })); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @SuppressWarnings("deprecation") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void getPageRangesDiffACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - - Mono> response = bc.createSnapshot() - .flatMap( - snapId -> Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.getPageRangesDiffWithResponse(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), - snapId.getSnapshotId(), bac); - })); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @SuppressWarnings("deprecation") - @Test - public void getPageRangesDiffError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - StepVerifier.create(bc.getPageRangesDiff(null, "snapshot")).verifyError(BlobStorageException.class); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesRangesDiff() { - Flux data = Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.KB))); - Flux data2 = Flux.just(ByteBuffer.wrap(getRandomByteArray(Constants.KB))); - - Flux response = bc.create(4 * Constants.KB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data)) - .then(bc.createSnapshot()) - .flatMapMany(r -> bc.uploadPages(new PageRange().setStart(0).setEnd(Constants.KB - 1), data2) - .then(bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1))) - .then(bc.uploadPages(new PageRange().setStart(2 * Constants.KB).setEnd(3 * Constants.KB - 1), data2)) - .then(bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1))) - .thenMany(bc.listPageRangesDiff(new BlobRange(0, 4L * Constants.KB), r.getSnapshotId()))); - - StepVerifier.create(response).assertNext(r -> { - assertEquals(r.getRange(), new HttpRange(0L, (long) Constants.KB)); - assertFalse(r.isClear()); - }).assertNext(r -> { - assertEquals(r.getRange(), new HttpRange(2 * Constants.KB, (long) Constants.KB)); - assertFalse(r.isClear()); - }).assertNext(r -> { - assertEquals(r.getRange(), new HttpRange(Constants.KB, (long) Constants.KB)); - assertTrue(r.isClear()); - }).assertNext(r -> { - assertEquals(r.getRange(), new HttpRange(3 * Constants.KB, (long) Constants.KB)); - assertTrue(r.isClear()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesRangesDiffPageSize() { - Flux data = Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.KB))); - Flux data2 = Flux.just(ByteBuffer.wrap(getRandomByteArray(Constants.KB))); - - Flux, PagedResponse>> response = bc - .create(4 * Constants.KB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data)) - .then(bc.createSnapshot()) - .flatMapMany(r -> bc.uploadPages(new PageRange().setStart(0).setEnd(Constants.KB - 1), data2) - .then(bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1))) - .then(bc.uploadPages(new PageRange().setStart(2 * Constants.KB).setEnd(3 * Constants.KB - 1), data2)) - .then(bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1))) - .thenMany(Flux.zip( - bc.listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(0, 4L * Constants.KB), r.getSnapshotId()) - .setMaxResultsPerPage(2)) - .byPage(), - bc.listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(0, 4L * Constants.KB), r.getSnapshotId())) - .byPage(2)))); - - // when: "max results on options and on iterableByPage" - StepVerifier.create(response).assertNext(r -> { - assertEquals(2, r.getT1().getValue().size()); - assertEquals(2, r.getT2().getValue().size()); - }).assertNext(r -> { - assertEquals(2, r.getT1().getValue().size()); - assertEquals(2, r.getT2().getValue().size()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesDiffContinuationToken() { - Flux data = Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.KB))); - Flux data2 = Flux.just(ByteBuffer.wrap(getRandomByteArray(Constants.KB))); - - Flux> response - = bc.create(4 * Constants.KB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data)) - .then(bc.createSnapshot()) - .flatMapMany( - r -> bc.uploadPages(new PageRange().setStart(0).setEnd(Constants.KB - 1), data2) - .then(bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1))) - .then(bc.uploadPages(new PageRange().setStart(2 * Constants.KB).setEnd(3 * Constants.KB - 1), - data2)) - .then(bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1))) - .thenMany( - Flux.zip( - bc.listPageRangesDiff(new ListPageRangesDiffOptions(new BlobRange(0, 4L * Constants.KB), - r.getSnapshotId()).setMaxResultsPerPage(2)).byPage(), - Flux.just(r.getSnapshotId())))) - .flatMap(tuple -> bc - .listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(0, 4L * Constants.KB), tuple.getT2())) - .byPage(tuple.getT1().getContinuationToken())); - - StepVerifier.create(response).assertNext(r -> assertEquals(2, r.getValue().size())).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @Test - public void listPagesDiffRange() { - Flux data = Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.KB))); - Flux data2 = Flux.just(ByteBuffer.wrap(getRandomByteArray(Constants.KB))); - - Flux response = bc.create(4 * Constants.KB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data)) - .then(bc.createSnapshot()) - .flatMapMany(r -> bc.uploadPages(new PageRange().setStart(0).setEnd(Constants.KB - 1), data2) - .then(bc.clearPages(new PageRange().setStart(Constants.KB).setEnd(2 * Constants.KB - 1))) - .then(bc.uploadPages(new PageRange().setStart(2 * Constants.KB).setEnd(3 * Constants.KB - 1), data2)) - .then(bc.clearPages(new PageRange().setStart(3 * Constants.KB).setEnd(4 * Constants.KB - 1))) - .thenMany(bc.listPageRangesDiff(new ListPageRangesDiffOptions( - new BlobRange(2 * Constants.KB + 1, 2L * Constants.KB), r.getSnapshotId())))); - - StepVerifier.create(response).expectNextCount(2).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void listPageRangesDiffAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Flux data = Flux.just(ByteBuffer.wrap(getRandomByteArray(4 * Constants.KB))); - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Flux response = bc.create(4 * Constants.KB, true) - .then(bc.uploadPages(new PageRange().setStart(0).setEnd(4 * Constants.KB - 1), data)) - .then(bc.createSnapshot()) - .flatMapMany(snapId -> bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - return bc - .listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), - snapId.getSnapshotId()).setRequestConditions(bac)) - .count(); - })); - - StepVerifier.create(response).expectNextCount(1).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2021-06-08") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void listPageRangesDiffACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String leaseID, String tags) { - Mono response = bc.createSnapshot() - .flatMap( - snapId -> Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc - .listPageRangesDiff( - new ListPageRangesDiffOptions(new BlobRange(0, (long) PageBlobClient.PAGE_BYTES), - snapId.getSnapshotId()).setRequestConditions(bac)) - .count(); - })); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("pageRangeIASupplier") - public void pageRangeIA(int start, int end) { - PageRange range = new PageRange().setStart(start).setEnd(end); - StepVerifier.create(bc.clearPages(range)).verifyError(IllegalArgumentException.class); - } - - private static Stream pageRangeIASupplier() { - return Stream.of(Arguments.of(1, 1), Arguments.of(-PageBlobClient.PAGE_BYTES, PageBlobClient.PAGE_BYTES - 1), - Arguments.of(0, 0), Arguments.of(1, PageBlobClient.PAGE_BYTES - 1), - Arguments.of(0, PageBlobClient.PAGE_BYTES), - Arguments.of(PageBlobClient.PAGE_BYTES * 2, PageBlobClient.PAGE_BYTES - 1)); - } - - @Test - public void resize() { - StepVerifier.create(bc.resizeWithResponse(PageBlobClient.PAGE_BYTES * 2, null)).assertNext(r -> { - assertTrue(validateBasicHeaders(r.getHeaders())); - assertNotNull(r.getValue().getBlobSequenceNumber()); - }).verifyComplete(); - - StepVerifier.create(bc.getProperties()) - .assertNext(r -> assertEquals(PageBlobClient.PAGE_BYTES * 2, r.getBlobSize())) - .verifyComplete(); - } - - @Test - public void resizeMin() { - assertAsyncResponseStatusCode(bc.resizeWithResponse(PageBlobClient.PAGE_BYTES, null), 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void resizeAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.resizeWithResponse(PageBlobClient.PAGE_BYTES * 2, bac); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void resizeACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.resizeWithResponse(PageBlobClient.PAGE_BYTES * 2, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void resizeError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - StepVerifier.create(bc.resize(0)).verifyError(BlobStorageException.class); - } - - @ParameterizedTest - @MethodSource("sequenceNumberSupplier") - public void sequenceNumber(SequenceNumberActionType action, Long number, Long result) { - StepVerifier.create(bc.updateSequenceNumberWithResponse(action, number, null)).assertNext(r -> { - assertTrue(validateBasicHeaders(r.getHeaders())); - assertEquals(result, r.getValue().getBlobSequenceNumber()); - }).verifyComplete(); - - StepVerifier.create(bc.getProperties()) - .assertNext(r -> assertEquals(result, r.getBlobSequenceNumber())) - .verifyComplete(); - } - - private static Stream sequenceNumberSupplier() { - return Stream.of(Arguments.of(SequenceNumberActionType.UPDATE, 5L, 5L), - Arguments.of(SequenceNumberActionType.INCREMENT, null, 1L), - Arguments.of(SequenceNumberActionType.MAX, 2L, 2L)); - } - - @Test - public void sequenceNumberMin() { - assertAsyncResponseStatusCode( - bc.updateSequenceNumberWithResponse(SequenceNumberActionType.INCREMENT, null, null), 200); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsSupplier") - public void sequenceNumberAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Map t = new HashMap<>(); - t.put("foo", "bar"); - - Mono> response = bc.setTags(t) - .then(Mono.zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, match), - BlobTestBase::convertNulls)) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(conditions.get(1)) - .setIfNoneMatch(noneMatch) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.updateSequenceNumberWithResponse(SequenceNumberActionType.UPDATE, 1L, bac); - }); - - assertAsyncResponseStatusCode(response, 200); - } - - @ParameterizedTest - @MethodSource("com.azure.storage.blob.BlobTestBase#allConditionsFailSupplier") - public void sequenceNumberACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, String noneMatch, - String leaseID, String tags) { - Mono> response - = Mono - .zip(setupBlobLeaseCondition(bc, leaseID), setupBlobMatchCondition(bc, noneMatch), - BlobTestBase::convertNulls) - .flatMap(conditions -> { - BlobRequestConditions bac = new BlobRequestConditions().setLeaseId(conditions.get(0)) - .setIfMatch(match) - .setIfNoneMatch(conditions.get(1)) - .setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setTagsConditions(tags); - - return bc.updateSequenceNumberWithResponse(SequenceNumberActionType.UPDATE, 1L, bac); - }); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - @Test - public void sequenceNumberError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - StepVerifier.create(bc.updateSequenceNumber(SequenceNumberActionType.UPDATE, 0L)) - .verifyError(BlobStorageException.class); - } - - @Test - public void startIncrementalCopy() { - PageBlobAsyncClient bc2 = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - long ms = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 1L; - - Mono response = bc.createSnapshot() - .flatMap( - snapId -> bc2.copyIncrementalWithResponse(bc.getBlobUrl() + "?" + sas, snapId.getSnapshotId(), null)) - .flatMap(copyResponse -> { - validateBasicHeaders(copyResponse.getHeaders()); - assertNotNull(copyResponse.getHeaders().getValue(X_MS_COPY_ID)); - assertNotNull(copyResponse.getValue()); - - Mono statusMono = Mono.just(copyResponse.getValue()); - OffsetDateTime start = testResourceNamer.now(); - - return statusMono.expand(status -> { - if (status == CopyStatusType.SUCCESS) { - return Mono.empty(); - } else { - return bc2.getProperties() - .map(BlobProperties::getCopyStatus) - .delaySubscription(Duration.ofSeconds(ms)) - .doOnNext(currentStatus -> { - OffsetDateTime currentTime = testResourceNamer.now(); - if (currentStatus == CopyStatusType.FAILED - || currentTime.minusMinutes(1).isAfter(start)) { - throw new RuntimeException("Copy failed or took too long"); - } - }); - } - }).last(); - }) - .flatMap(status -> bc2.getProperties()); - - StepVerifier.create(response).assertNext(r -> { - assertTrue(r.isIncrementalCopy()); - assertNotNull(r.getCopyDestinationSnapshot()); - }).verifyComplete(); - } - - @Test - public void startIncrementalCopyMin() { - PageBlobAsyncClient bc2 = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono> response = bc.createSnapshot() - .flatMap(r -> bc2.copyIncrementalWithResponse(bc.getBlobUrl() + "?" + sas, r.getSnapshotId(), null)); - - assertAsyncResponseStatusCode(response, 202); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2019-12-12") - @ParameterizedTest - @MethodSource("startIncrementalCopyACSupplier") - public void startIncrementalCopyAC(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - PageBlobAsyncClient bc2 = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Map t = new HashMap<>(); - t.put("foo", "bar"); - - long ms = ENVIRONMENT.getTestMode() == TestMode.PLAYBACK ? 0L : 1L; - - Mono> response = bc.createSnapshot() - .flatMap( - snapId -> bc2.copyIncrementalWithResponse(bc.getBlobUrl() + "?" + sas, snapId.getSnapshotId(), null)) - .flatMap(copyResponse -> { - Mono statusMono = Mono.just(copyResponse.getValue()); - OffsetDateTime start = testResourceNamer.now(); - - return statusMono.expand(status -> { - if (status == CopyStatusType.SUCCESS) { - return Mono.empty(); - } else { - return bc2.getProperties() - .map(BlobProperties::getCopyStatus) - .delaySubscription(Duration.ofSeconds(ms)) - .doOnNext(currentStatus -> { - OffsetDateTime currentTime = testResourceNamer.now(); - if (currentStatus == CopyStatusType.FAILED - || currentTime.minusMinutes(1).isAfter(start)) { - throw new RuntimeException("Copy failed or took too long"); - } - }); - } - }).last(); - }) - .flatMap(status -> bc2.setTags(t)) - .then(bc.createSnapshot()) - .flatMap(snapId -> setupBlobMatchCondition(bc2, match).flatMap(condition -> { - PageBlobCopyIncrementalRequestConditions mac - = new PageBlobCopyIncrementalRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(convertNull(condition)) - .setIfNoneMatch(noneMatch) - .setTagsConditions(tags); - return bc2.copyIncrementalWithResponse( - new PageBlobCopyIncrementalOptions(bc.getBlobUrl() + "?" + sas, snapId.getSnapshotId()) - .setRequestConditions(mac)); - })); - assertAsyncResponseStatusCode(response, 202); - } - - private static Stream startIncrementalCopyACSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), Arguments.of(OLD_DATE, null, null, null, null), - Arguments.of(null, NEW_DATE, null, null, null), Arguments.of(null, null, RECEIVED_ETAG, null, null), - Arguments.of(null, null, null, GARBAGE_ETAG, null), - Arguments.of(null, null, null, null, "\"foo\" = 'bar'")); - } - - @ParameterizedTest - @MethodSource("startIncrementalCopyACFailSupplier") - public void startIncrementalCopyACFail(OffsetDateTime modified, OffsetDateTime unmodified, String match, - String noneMatch, String tags) { - PageBlobAsyncClient bc2 = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - String sas = bc.generateSas(new BlobServiceSasSignatureValues(testResourceNamer.now().plusDays(1), - new BlobSasPermission().setTagsPermission(true).setReadPermission(true))); - - Mono> response = bc.createSnapshot() - .flatMap(snapId -> bc2.copyIncremental(bc.getBlobUrl() + "?" + sas, snapId.getSnapshotId()) - .then(bc.createSnapshot()) - .flatMap(finalSnapshot -> setupBlobMatchCondition(bc2, noneMatch).flatMap(condition -> { - PageBlobCopyIncrementalRequestConditions mac - = new PageBlobCopyIncrementalRequestConditions().setIfModifiedSince(modified) - .setIfUnmodifiedSince(unmodified) - .setIfMatch(match) - .setIfNoneMatch(convertNull(condition)) - .setTagsConditions(tags); - - return bc2.copyIncrementalWithResponse( - new PageBlobCopyIncrementalOptions(bc.getBlobUrl() + "?" + sas, finalSnapshot.getSnapshotId()) - .setRequestConditions(mac)); - }))); - - StepVerifier.create(response).verifyError(BlobStorageException.class); - } - - private static Stream startIncrementalCopyACFailSupplier() { - return Stream.of(Arguments.of(NEW_DATE, null, null, null, null), Arguments.of(null, OLD_DATE, null, null, null), - Arguments.of(null, null, GARBAGE_ETAG, null, null), Arguments.of(null, null, null, RECEIVED_ETAG, null), - Arguments.of(null, null, null, null, "\"notfoo\" = 'notbar'")); - } - - @Test - public void startIncrementalCopyError() { - bc = ccAsync.getBlobAsyncClient(generateBlobName()).getPageBlobAsyncClient(); - StepVerifier.create(bc.copyIncremental("https://www.error.com", "snapshot")) - .verifyError(BlobStorageException.class); - } - - @Test - public void getContainerName() { - assertEquals(containerName, bc.getContainerName()); - } - - @Test - public void getPageBlobName() { - assertEquals(blobName, bc.getBlobName()); - } - - @ParameterizedTest - @MethodSource("getBlobNameAndBuildClientSupplier") - public void getBlobNameAndBuildClient(String originalBlobName, String finalBlobName) { - BlobAsyncClient client = ccAsync.getBlobAsyncClient(originalBlobName); - PageBlobAsyncClient blockClient = ccAsync.getBlobAsyncClient(client.getBlobName()).getPageBlobAsyncClient(); - assertEquals(finalBlobName, blockClient.getBlobName()); - } - - private static Stream getBlobNameAndBuildClientSupplier() { - return Stream.of(Arguments.of("blobName", "blobName"), Arguments.of("dir1/a%20b.txt", "dir1/a%20b.txt"), - Arguments.of("path/to]a blob", "path/to]a blob"), - Arguments.of("path%2Fto%5Da%20blob", "path%2Fto%5Da%20blob"), Arguments.of("斑點", "斑點"), - Arguments.of("%E6%96%91%E9%BB%9E", "%E6%96%91%E9%BB%9E"), Arguments.of("斑點", "斑點")); - } - - @Test - public void createOverwriteFalse() { - StepVerifier.create(bc.create(512)).verifyError(BlobStorageException.class); - } - - @Test - public void createOverwriteTrue() { - StepVerifier.create(bc.create(512, true)).expectNextCount(1).verifyComplete(); - } - - @Test - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - public void perCallPolicy() { - PageBlobAsyncClient specialBlob - = getSpecializedBuilder(bc.getBlobUrl()).addPolicy(getPerCallVersionPolicy()).buildPageBlobAsyncClient(); - - StepVerifier.create(specialBlob.getPropertiesWithResponse(null)) - .assertNext(r -> assertEquals("2017-11-09", r.getHeaders().getValue(X_MS_VERSION))) - .verifyComplete(); - } - - @Test - public void defaultAudience() { - PageBlobAsyncClient aadBlob - = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()).audience(null).buildPageBlobAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - - @Test - public void storageAccountAudience() { - PageBlobAsyncClient aadBlob = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience(ccAsync.getAccountName())) - .buildPageBlobAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - - @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2024-08-04") - @LiveOnly - @Test - /* This test tests if the bearer challenge is working properly. A bad audience is passed in, the service returns - the default audience, and the request gets retried with this default audience, making the call function as expected. - */ - public void audienceErrorBearerChallengeRetry() { - PageBlobAsyncClient aadBlob = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()) - .audience(BlobAudience.createBlobServiceAccountAudience("badAudience")) - .buildPageBlobAsyncClient(); - - StepVerifier.create(aadBlob.getProperties()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - @Test - public void audienceFromString() { - String url = String.format("https://%s.blob.core.windows.net/", ccAsync.getAccountName()); - BlobAudience audience = BlobAudience.fromString(url); - - PageBlobAsyncClient aadBlob - = getSpecializedBuilderWithTokenCredential(bc.getBlobUrl()).audience(audience).buildPageBlobAsyncClient(); - - StepVerifier.create(aadBlob.exists()).expectNext(true).verifyComplete(); - } - -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlobReadBehaviorTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlobReadBehaviorTests.java deleted file mode 100644 index 5ccc9dfc1ea4..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlobReadBehaviorTests.java +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.core.http.HttpHeaders; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.BinaryData; -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.BlobDownloadAsyncResponse; -import com.azure.storage.blob.models.BlobDownloadHeaders; -import com.azure.storage.blob.models.BlobDownloadResponse; -import com.azure.storage.blob.models.BlobRange; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.models.PageRange; -import com.azure.storage.common.implementation.Constants; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -public class StorageSeekableByteChannelBlobReadBehaviorTests extends BlobTestBase { - private BlockBlobClient blockBlobClient; - private PageBlobClient pageBlobClient; - private AppendBlobClient appendBlobClient; - - @BeforeEach - public void setup() { - blockBlobClient = cc.getBlobClient(generateBlobName()).getBlockBlobClient(); - pageBlobClient = cc.getBlobClient(generateBlobName()).getPageBlobClient(); - appendBlobClient = cc.getBlobClient(generateBlobName()).getAppendBlobClient(); - } - - @AfterEach - public void cleanup() { - cc.deleteIfExists(); - } - - private BlobDownloadResponse createMockDownloadResponse(String contentRange) { - String contentRangeHeader = "Content-Range"; - Map headers = new HashMap<>(); - headers.put(contentRangeHeader, contentRange); - return new BlobDownloadResponse(new BlobDownloadAsyncResponse(null, 206, new HttpHeaders(headers), null, - new BlobDownloadHeaders().setContentRange(contentRange))); - } - - @ParameterizedTest - @MethodSource("readCallsToClientCorrectlySupplier") - public void readCallsToClientCorrectly(long offset, int bufferSize, BlobRequestConditions conditions) - throws IOException { - BlobClientBase client = Mockito.mock(BlobClientBase.class); - ArgumentCaptor blobRangeCaptor = ArgumentCaptor.forClass(BlobRange.class); - Mockito.when(client.downloadStreamWithResponse(any(), any(), any(), any(), anyBoolean(), any(), any())) - .thenReturn( - createMockDownloadResponse("bytes " + offset + "-" + (offset + bufferSize - 1) + "/" + Constants.MB)); - - StorageSeekableByteChannelBlobReadBehavior behavior = new StorageSeekableByteChannelBlobReadBehavior(client, - ByteBuffer.allocate(0), -1, Constants.MB, conditions); - - // when: "ReadBehavior.read() called" - behavior.read(ByteBuffer.allocate(bufferSize), offset); - - // then: "Expected ShareFileClient download parameters given" - verify(client, times(1)).downloadStreamWithResponse(any(), blobRangeCaptor.capture(), any(), eq(conditions), - eq(false), any(), any()); - - BlobRange range = blobRangeCaptor.getValue(); - assertEquals(offset, range.getOffset()); - assertEquals(bufferSize, range.getCount()); - } - - private static Stream readCallsToClientCorrectlySupplier() { - return Stream.of(Arguments.of(0, Constants.KB, null), Arguments.of(50, Constants.KB, null), - Arguments.of(0, 2000, null), Arguments.of(0, Constants.KB, new BlobRequestConditions())); - } - - @ParameterizedTest - @MethodSource("readUsesCacheCorrectlySupplier") - void readUsesCacheCorrectly(long offset, int bufferSize, int cacheSize) throws Exception { - // given: "Behavior with a starting cached response" - BlobClientBase client = Mockito.mock(BlobClientBase.class); - ByteBuffer initialCache = getRandomData(cacheSize); - StorageSeekableByteChannelBlobReadBehavior behavior - = new StorageSeekableByteChannelBlobReadBehavior(client, initialCache, offset, Constants.MB, null); - - // Stubbing downloadStreamWithResponse before any read call - Mockito - .when(client.downloadStreamWithResponse(Mockito.any(), - Mockito.argThat(range -> range.getOffset() == offset && range.getCount().intValue() == bufferSize), - Mockito.any(), Mockito.any(), Mockito.anyBoolean(), Mockito.any(), Mockito.any())) - .thenAnswer(invocation -> { - OutputStream os = invocation.getArgument(0); - BlobRange range = invocation.getArgument(1); - os.write(getRandomData(range.getCount().intValue()).array()); - return createMockDownloadResponse( - "bytes " + offset + "-" + (offset + bufferSize - 1) + "/" + Constants.MB); - }); - // when: "ReadBehavior.read() called at offset of cache" - ByteBuffer buffer = ByteBuffer.allocate(bufferSize); - int read1 = behavior.read(buffer, offset); - - // then: "Cache used" - Mockito.verify(client, Mockito.times(0)) - .downloadStreamWithResponse(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), - Mockito.anyBoolean(), Mockito.any(), Mockito.any()); - assertEquals(Math.min(bufferSize, cacheSize), read1); - byte[] actual = new byte[read1]; - buffer.flip(); - buffer.get(actual); - byte[] expected = new byte[read1]; - initialCache.get(expected); - TestUtils.assertArraysEqual(expected, actual); - - // when: "Read again at same offset" - buffer.clear(); - int read2 = behavior.read(buffer, offset); - - // then: "Client read because cache was cleared after use" - assertEquals(bufferSize, read2); - assertEquals(read2, buffer.position()); - } - - static Stream readUsesCacheCorrectlySupplier() { - return Stream.of(Arguments.of(0L, Constants.KB, Constants.KB), Arguments.of(50L, Constants.KB, Constants.KB), - Arguments.of(0L, 2 * Constants.KB, Constants.KB), Arguments.of(0L, Constants.KB, 2 * Constants.KB)); - } - - @ParameterizedTest - @MethodSource("readGracefulPastEndOfBlobSupplier") - public void readGracefulPastEndOfBlob(String type, long fileSize, int offset, int readSize, int expectedRead) - throws IOException { - byte[] data = getRandomByteArray((int) fileSize); - BlobClientBase client; - - // given: "Selected client type initialized" - switch (type) { - case "block": - blockBlobClient.upload(BinaryData.fromBytes(data)); - client = blockBlobClient; - break; - - case "page": - pageBlobClient.create(fileSize); - pageBlobClient.uploadPages(new PageRange().setStart(0).setEnd(fileSize - 1), - new ByteArrayInputStream(data)); - client = pageBlobClient; - break; - - case "append": - appendBlobClient.create(); - appendBlobClient.appendBlock(new ByteArrayInputStream(data), fileSize); - client = appendBlobClient; - break; - - default: - throw new RuntimeException("Bad test input"); - } - - // and: "behavior to target it" - StorageSeekableByteChannelBlobReadBehavior behavior - = new StorageSeekableByteChannelBlobReadBehavior(client, ByteBuffer.allocate(0), -1, fileSize, null); - - // when: "ReadBehavior.read() called" - ByteBuffer buffer = ByteBuffer.allocate(readSize); - int read = behavior.read(buffer, offset); - - // and: "correct amount read" - assertEquals(expectedRead, read); - assertEquals(Math.max(expectedRead, 0), buffer.position()); - assertEquals(fileSize, behavior.getResourceLength()); - - // and: "if applicable, correct data read" - if (offset < fileSize) { - assertEquals(expectedRead, buffer.position()); - buffer.limit(buffer.position()); - buffer.rewind(); - byte[] validBufferContent = new byte[buffer.limit()]; - buffer.get(validBufferContent); - - TestUtils.assertArraysEqual(data, offset, validBufferContent, 0, validBufferContent.length); - } - } - - private static Stream readGracefulPastEndOfBlobSupplier() { - return Stream.of(Arguments.of("block", Constants.KB, 0, 2 * Constants.KB, Constants.KB), - Arguments.of("block", Constants.KB, 600, Constants.KB, Constants.KB - 600), - Arguments.of("block", Constants.KB, Constants.KB, Constants.KB, -1), - Arguments.of("block", Constants.KB, Constants.KB + 20, Constants.KB, -1), - Arguments.of("page", Constants.KB, 0, 2 * Constants.KB, Constants.KB), - Arguments.of("page", Constants.KB, 600, Constants.KB, Constants.KB - 600), - Arguments.of("page", Constants.KB, Constants.KB, Constants.KB, -1), - Arguments.of("page", Constants.KB, Constants.KB + 20, Constants.KB, -1), - Arguments.of("append", Constants.KB, 0, 2 * Constants.KB, Constants.KB), - Arguments.of("append", Constants.KB, 600, Constants.KB, Constants.KB - 600), - Arguments.of("append", Constants.KB, Constants.KB, Constants.KB, -1), - Arguments.of("append", Constants.KB, Constants.KB + 20, Constants.KB, -1)); - } - - @Test - void readDetectsBlobGrowth() throws IOException { - // Given: data - int halfLength = 512; - byte[] data = getRandomByteArray(2 * halfLength); - - // Blob at half size - String blockId1 = new String(Base64.getEncoder().encode("blockId1".getBytes())); - blockBlobClient.stageBlock(blockId1, BinaryData.fromBytes(Arrays.copyOfRange(data, 0, halfLength))); - blockBlobClient.commitBlockList(Collections.singletonList(blockId1)); - - // behavior to read blob - StorageSeekableByteChannelBlobReadBehavior behavior = new StorageSeekableByteChannelBlobReadBehavior( - blockBlobClient, ByteBuffer.allocate(0), -1, halfLength, null); - ByteBuffer buffer = ByteBuffer.allocate(halfLength); - - // entire blob initially read - int read = behavior.read(buffer, 0); - - // behavior state as expected - assertEquals(halfLength, read); - assertEquals(halfLength, behavior.getResourceLength()); - - // buffer correctly filled - assertEquals(buffer.capacity(), buffer.position()); - TestUtils.assertArraysEqual(data, 0, buffer.array(), 0, halfLength); - - // read at end of blob - buffer.clear(); - read = behavior.read(buffer, halfLength); - - // gracefully signal end of blob - assertEquals(-1, read); - assertEquals(halfLength, behavior.getResourceLength()); - - // buffer unfilled - assertEquals(0, buffer.position()); - - // blob augmented to full size - String blockId2 = new String(Base64.getEncoder().encode("blockId2".getBytes())); - blockBlobClient.stageBlock(blockId2, BinaryData.fromBytes(Arrays.copyOfRange(data, halfLength, data.length))); - blockBlobClient.commitBlockList(Arrays.asList(blockId1, blockId2), true); - - // behavior reads at previous EOF - buffer.clear(); - read = behavior.read(buffer, behavior.getResourceLength()); - - // channel state has updated length - assertEquals(halfLength, read); - assertEquals(2 * halfLength, behavior.getResourceLength()); - - // buffer correctly filled - assertEquals(buffer.capacity(), buffer.position()); - TestUtils.assertArraysEqual(data, halfLength, buffer.array(), 0, data.length - halfLength); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlockBlobWriteBehaviorTests.java b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlockBlobWriteBehaviorTests.java deleted file mode 100644 index 400c009342b2..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/StorageSeekableByteChannelBlockBlobWriteBehaviorTests.java +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.storage.blob.BlobTestBase; -import com.azure.storage.blob.models.AccessTier; -import com.azure.storage.blob.models.BlobHttpHeaders; -import com.azure.storage.blob.models.BlobRequestConditions; -import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions; -import com.azure.storage.blob.options.BlockBlobStageBlockOptions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; - -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.Mockito.times; - -public class StorageSeekableByteChannelBlockBlobWriteBehaviorTests extends BlobTestBase { - - private static Map testStringMap() { - Map map = new HashMap<>(); - map.put("foo", "bar"); - map.put("fizz", "buzz"); - return map; - } - - private StorageSeekableByteChannelBlockBlobWriteBehavior getSimpleBehavior(BlockBlobClient client) { - return new StorageSeekableByteChannelBlockBlobWriteBehavior(client, null, null, null, null, null, - StorageSeekableByteChannelBlockBlobWriteBehavior.WriteMode.OVERWRITE, null); - } - - @ParameterizedTest - @MethodSource("writeBehaviorWriteCallsToClientCorrectlySupplier") - public void writeBehaviorWriteCallsToClientCorrectly(int offset, BlobRequestConditions conditions) - throws IOException { - // Given - BlockBlobClient client = Mockito.mock(BlockBlobClient.class); - // and: "Block blob behavior" - StorageSeekableByteChannelBlockBlobWriteBehavior behavior - = new StorageSeekableByteChannelBlockBlobWriteBehavior(client, null, null, null, null, conditions, - StorageSeekableByteChannelBlockBlobWriteBehavior.WriteMode.OVERWRITE, null); - - // when: "WriteBehavior.write() called" - behavior.write(DATA.getDefaultData(), offset); - - // and: "mockito verification capture" - ArgumentCaptor optionsCaptor - = ArgumentCaptor.forClass(BlockBlobStageBlockOptions.class); - Mockito.verify(client, times(1)).stageBlockWithResponse(optionsCaptor.capture(), isNull(), isNull()); - - // then: "Expected BlockBlobClient upload parameters given" - assertEquals(optionsCaptor.getValue().getLeaseId(), conditions == null ? null : "foo"); - } - - private static Stream writeBehaviorWriteCallsToClientCorrectlySupplier() { - return Stream.of(Arguments.of(0, null), Arguments.of(50, null), - Arguments.of(0, new BlobRequestConditions().setLeaseId("foo"))); - } - - @ParameterizedTest - @MethodSource("writeBehaviorCommitsWithCorrectSettingsSupplier") - public void writeBehaviorCommitsWithCorrectSettings(BlobHttpHeaders headers, Map metadata, - Map tags, AccessTier tier, BlobRequestConditions conditions) throws IOException { - BlockBlobClient client = Mockito.mock(BlockBlobClient.class); - StorageSeekableByteChannelBlockBlobWriteBehavior behavior - = new StorageSeekableByteChannelBlockBlobWriteBehavior(client, headers, metadata, tags, tier, conditions, - StorageSeekableByteChannelBlockBlobWriteBehavior.WriteMode.OVERWRITE, null); - - // Three writes - behavior.write(DATA.getDefaultData(), 0); - behavior.write(DATA.getDefaultData(), 0); - behavior.write(DATA.getDefaultData(), 0); - - // WriteBehavior.commit() called - behavior.commit(0); - - // mockito verification capture - ArgumentCaptor optionsCaptor - = ArgumentCaptor.forClass(BlockBlobCommitBlockListOptions.class); - Mockito.verify(client, times(3)).stageBlockWithResponse(any(), any(), any()); - Mockito.verify(client, times(1)).commitBlockListWithResponse(optionsCaptor.capture(), isNull(), isNull()); - - // Expected commit options - assertEquals(headers, optionsCaptor.getValue().getHeaders()); - assertEquals(metadata, optionsCaptor.getValue().getMetadata()); - assertEquals(tags, optionsCaptor.getValue().getTags()); - assertEquals(tier, optionsCaptor.getValue().getTier()); - assertEquals(conditions, optionsCaptor.getValue().getRequestConditions()); - assertEquals(3, optionsCaptor.getValue().getBase64BlockIds().size()); - } - - private static Stream writeBehaviorCommitsWithCorrectSettingsSupplier() { - return Stream.of(Arguments.of(null, null, null, null, null), - Arguments.of(new BlobHttpHeaders(), null, null, null, null), - Arguments.of(null, testStringMap(), null, null, null), - Arguments.of(null, null, testStringMap(), null, null), Arguments.of(null, null, null, AccessTier.HOT, null), - Arguments.of(null, null, null, null, new BlobRequestConditions())); - } - - @Test - public void writeBehaviorCommitOverwrite() throws IOException { - // Given: "existing blocks" - List blocks = Arrays.asList("1", "2", "3", "4", "5"); - - // Behavior set to overwrite - BlockBlobClient client = Mockito.mock(BlockBlobClient.class); - StorageSeekableByteChannelBlockBlobWriteBehavior behavior - = new StorageSeekableByteChannelBlockBlobWriteBehavior(client, null, null, null, null, null, - StorageSeekableByteChannelBlockBlobWriteBehavior.WriteMode.OVERWRITE, blocks); - - // Three writes - behavior.write(DATA.getDefaultData(), 0); - behavior.write(DATA.getDefaultData(), 0); - behavior.write(DATA.getDefaultData(), 0); - - // WriteBehavior.commit() called - behavior.commit(0); - - // Mockito verification capture - ArgumentCaptor optionsCaptor - = ArgumentCaptor.forClass(BlockBlobCommitBlockListOptions.class); - Mockito.verify(client, times(3)).stageBlockWithResponse(any(), any(), any()); - Mockito.verify(client, times(1)).commitBlockListWithResponse(optionsCaptor.capture(), isNull(), isNull()); - - // Expected three writes and appropriate blocklist - assertEquals(3, optionsCaptor.getValue().getBase64BlockIds().size()); - assertTrue(optionsCaptor.getValue().getBase64BlockIds().stream().noneMatch(blocks::contains)); - } - - @Test - public void writeBehaviorCommitAppend() throws IOException { - // Given: "existing blocks" - List blocks = Arrays.asList("1", "2", "3", "4", "5"); - - // Behavior set to append - BlockBlobClient client = Mockito.mock(BlockBlobClient.class); - StorageSeekableByteChannelBlockBlobWriteBehavior behavior - = new StorageSeekableByteChannelBlockBlobWriteBehavior(client, null, null, null, null, null, - StorageSeekableByteChannelBlockBlobWriteBehavior.WriteMode.APPEND, blocks); - - // Three writes - behavior.write(DATA.getDefaultData(), 0); - behavior.write(DATA.getDefaultData(), 0); - behavior.write(DATA.getDefaultData(), 0); - - // WriteBehavior.commit() called - behavior.commit(0); - - // Mockito verification capture - ArgumentCaptor optionsCaptor - = ArgumentCaptor.forClass(BlockBlobCommitBlockListOptions.class); - Mockito.verify(client, times(3)).stageBlockWithResponse(any(), any(), any()); - Mockito.verify(client, times(1)).commitBlockListWithResponse(optionsCaptor.capture(), isNull(), isNull()); - - // Expected three writes and appropriate blocklist - assertEquals(blocks.size() + 3, optionsCaptor.getValue().getBase64BlockIds().size()); - List capturedBlocks = optionsCaptor.getValue().getBase64BlockIds().subList(0, blocks.size()); - assertEquals(blocks, capturedBlocks); - } - - @Test - public void writeBehaviorCommitPrepend() throws IOException { - // Given: "existing blocks" - List blocks = Arrays.asList("1", "2", "3", "4", "5"); - - // Behavior set to prepend - BlockBlobClient client = Mockito.mock(BlockBlobClient.class); - StorageSeekableByteChannelBlockBlobWriteBehavior behavior - = new StorageSeekableByteChannelBlockBlobWriteBehavior(client, null, null, null, null, null, - StorageSeekableByteChannelBlockBlobWriteBehavior.WriteMode.PREPEND, blocks); - - // Three writes - behavior.write(DATA.getDefaultData(), 0); - behavior.write(DATA.getDefaultData(), 0); - behavior.write(DATA.getDefaultData(), 0); - - // WriteBehavior.commit() called - behavior.commit(0); - - // Mockito verification capture - ArgumentCaptor optionsCaptor - = ArgumentCaptor.forClass(BlockBlobCommitBlockListOptions.class); - Mockito.verify(client, times(3)).stageBlockWithResponse(any(), any(), any()); - Mockito.verify(client, times(1)).commitBlockListWithResponse(optionsCaptor.capture(), isNull(), isNull()); - - // Expected three writes and appropriate blocklist - assertEquals(blocks.size() + 3, optionsCaptor.getValue().getBase64BlockIds().size()); - List capturedBlocks = optionsCaptor.getValue().getBase64BlockIds().subList(3, blocks.size() + 3); - assertEquals(blocks, capturedBlocks); - } - - @Test - public void writeBehaviorSeekUnsupported() { - StorageSeekableByteChannelBlockBlobWriteBehavior behavior - = getSimpleBehavior(Mockito.mock(BlockBlobClient.class)); - - assertThrows(UnsupportedOperationException.class, () -> behavior.assertCanSeek(10)); - } - - @Test - public void writeBehaviorTruncateUnsupported() { - StorageSeekableByteChannelBlockBlobWriteBehavior behavior - = getSimpleBehavior(Mockito.mock(BlockBlobClient.class)); - - assertThrows(UnsupportedOperationException.class, () -> behavior.resize(10)); - } -} diff --git a/sdk/storage/azure-storage-blob/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/sdk/storage/azure-storage-blob/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450f0..000000000000 --- a/sdk/storage/azure-storage-blob/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/sdk/storage/azure-storage-blob/src/test/resources/parquet.parquet b/sdk/storage/azure-storage-blob/src/test/resources/parquet.parquet deleted file mode 100644 index 8eff6678085dbcdd3edbf6ef3199615c1b61ebe3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 80087 zcmeFaNv<@(a%M-Wh#C>#hy@O`1i=yBMKjb61nnUDzV8F5E!5h$1}#G)eQ9QdI4KP@ zzQB9`efcuOGs5E>Z_GW?{*V9t|J48b5C8gq_4v>K_OJi`FZkd8^*!cV$9g)} z)3Kh8^>nPKV?7<~=~z$4dOFtAu^}BB(y<{O8`7~M9UIcIAsrjiu^}BB(y}o6xZd9h=ax2_2gxKd5vN@E^^84F9qG$MGM}e?tBf@t>Iga4DKg(Oin=QZ$#M zxfIQ%Xf8!_DVj^sT#DgR43}cK6vL$$F2!&uhD$MAis4cWmtwgT%cWQ@#d0Z@OR-#v z~wI4;F;DV|I5T#DyXJeT6R6wjr2F2!>x zo=fpuO30;zTuR8Lgj`CFBwR|ur6gQR!lf{~ zhS@a%m0|)a#ROD}38)kkP$?#$QcOUln1D(#0iBCsb`7&@m|er{8fMopyN1~{%&uW} z4YO;QUBm1eX4f#ghS@dDu3>f!vul`L!|WPn*D$+=*)`0rVRj9(YnWZb>>6g*FuR7? zHO#JIb`7&@m|er{8fMopyN1~{%&uW}4YO;QUBm1eX4f#ghS@dDu3>f!vul`L!|WPn z*D$+=*)`0rVRj9(YnWZb>>6g*FuR7?HO#JIb`7&@m|er{8fMopyN1~{%&uW}4YO;Q zUBm1eX4f#ghS@dDu3>f!vul`L!|WPn*D$+=*)`0rVRj9(Ynffk>{@2mGP{=9wal(% zb}h4OnO)25T4vWWyO!Ct%&uj2EwgKxUCZoRX4f*imf5w;u4Q&Dvul}M%j{Za*D|}7 z*|p5BWp*vIYnffk>{@2mGP{=9wal(%b}h4OnO)25T4vWWyO!Ct%&uj2EwgKxUCZoR zX4f*imf5w;u4Q&Dvul}M%j{Za*D|}7*|p5BWp*vIYnffk>{@2mGP{=9wal(%b}h4O znO)25T4vWWyO!Ct%&uj2EwgKxUCZoRX4f*imf5w;u4Q&Dvul}M%j{Za*D|}7*|p5B zWp*vIYnffk>{@2mGP{o1b%jWV|E?0>zG}~>^f%GF}sf0b%jWV|E?0 z>zG}~>^f%GF}sf0b%jWV|E?0>zG}~>^f%GF}sf0bXLdca>zQ58 z?0RO`GrOMI^~|nkc0IG}nO)E9dS=%%yPnzg%&up4J+teXUC-=#X4f;jp4s)xu4i^V zv+J2%&+K|;*E74G+4an>XLdca>zQ58?0RO`GrOMI^~|nkc0IG}nO)E9dS=%%yPnzg z%&up4J+teXUC-=#X4f;jp4s)xu4i^Vv+J2%&+K|;*E74G+4an>XLdca>zQ58?0RO` zGrOMI^~|nkc0IG}nO)E9dS=%%yCJh1GP@zO8#22gvl}wIA+sAYyCJh1GP@zO8#22g zvl}wIA+sAYyCJh1GP@zO8#22gvl}wIA+sAYyCJh1GP@zO8#22gvl}wIA+sAYyCJh1 zGP@zO8#22gvl}wIA+sAYyCJh1GP@zO8#22gvl}wIA+sAYyCJh1GP@zO8#22gvl}wI zA+sAYyCJh1GP@zO8#22gvl}wIA+sAYyCJh1GP@zO8#22gvl}wIA+sAYyCJh1GP@zO z8#22gvl}wIA+sAYyCJh1GP@zO8#22gvl}wIA+sAYyCJh1GP@zO8#22gvl}wIA+sAY zyCJh1GP@zO8#22Qvl}tH5wjaHyAiV+F}o478!@{Pvl}tH5wjaHyAiV+F}o478!@{P zvl}tH5wjaHyAiV+F}o478!@{Pvl}tH5wjaHyAiV+F}o478!@{Pvl}tH5wjaHyAiV+ zF}o478!@{Pvl}tH5wjaHyAiV+F}o478!@{Pvl}tH5wjaHyAiV+F}o478!@{Pvl}tH z5wjaHyAiV+F}o478!@{Pvl}tH5wjaHyAiV+F}o478!@{Pvl}tH5wjaHyAiV+F}o47 z8!@{Pvl}tH5wjaHyAiV+F}o478!@{Pvl}tH5wjaHyAiV+F}o478!@{Pvl}tH5wjaH zyD_sHGrKXf8#B8xvl}zJF|!*pyD_sHGrKXf8#B8xvl}zJF|!*pyD_sHGrKXf8#B8x zvl}zJF|!*pyD_sHGrKXf8#B8xvl}zJF|!*pyD_sHGrKXf8#B8xvl}zJF|!*pyD_sH zGrKXf8#B8xvl}zJF|!*pyD_sHGrKXf8#B8xvl}zJF|!*pyD_sHGrKXf8#B8xvl}zJ zF|!*pyD_sHGrKXf8#B8xvl}zJF|!*pyD_sHGrKXf8#B8xvl}zJF|!*pyD_sHGrKXf z8#B8xvl}zJF|!*pyD_sHGrKXf8#B8xvl}zJF|!*pyD_sHGrKXf8#B8Jvzsux3A39p zy9u+KFuMt}n=rcxvzsux3A39py9u+KFuMt}n=rcxvzsux3A39py9u+KFuMt}n=rcx zvzsux3A39py9u+KFuMt}n=rcxvzsux3A39py9u+KFuMt}n=rcxvzsux3A39py9u+K zFuMt}n=rcxvzsux3A39py9u+KFuMt}n=rcxvzsux3A39py9u+KFuMt}n=rcxvzsux z3A39py9u+KFuMt}n=rcxvzsux3A39py9u+KFuMt}n=rcxvzsux3A39py9u+KFuMt} zn=rcxvzsux3A39py9u+KFuMt}n=rcxvzsux3A2keFsz6DkN^80fB*f@t7HHCeQVHH zuTxhx{o6kW`o7=N)oQ7BUNQUs_y86=ek&GOMf+#`8H={+4)0Z&+TUwmjMrLTwd(rd z_j<36daU>qMb#0U>3jRV?$-Ra+$JHZO-XPtMxU>|K5Wrss=Mg5|F&k& zzE0_f>bo<;SbaOrr=r(eP;QTI57i!gKeM3N&j8GuhO-$51sEezr{SAy~+&Le_7VG&DR~@_x#Eq-KFn&IFuWR zujPD#?=5mQT*L4EA}gwK-;8Q|_j`S=hu>4%s&wjquYH%dU4!rI>+$z`3#RFK-J;f# z>eD^BUUJ*1`J?(S>~q_uPE}gb`CVmjj@A3B-qZP|%bVBD*{F1&`pDm}?w7_X+fsdI zd1>A&UsaRR_s!3c9`$sq^q~4Wx_a*S(x}tzzw_x&Js_Y^sO6^bKl3uphTriQ@xBAN zD{o)5zV!Y)ym_#-mue=uKlhe@;~ETVtBL1*y<1=QsPFgtm48otx#v@_rh>k|>D)f} zPOIu9Uv~FQSz~f_G*lmO?V9WMR`*E!<|NqiscK(-<$aa8?ylWbdD8v#-E$QPy{PZ< zzxTU6zveg3)wz(OU9VONG zG-UNVw_a5RmDk%V)8jm=HKqG|Z52N|66;t_v!EZk8>XC7d{Nk+d5X~ z)`N#Fr}B1F)nyP^_(s>;+G)tA?^b~$zV=ePt$GKwjC8+_#@}rsMtS zT~*h!>bZX3Z`}PH?8;lZzro|(Q0%X&S315f+x@Fkt?r6_O?3_eZ{>4p|K{yD_v>BM zchdbZshOUA9lH4QNZ{6gzvX0uf-nhQ~hC&@JyVHftH2=-1>`UL@H6Fdq_o%1g_Up2Bn+D)9rSlo4Ezn<4s7Bh82@R{m{mU*o zK7Y^7=9^bpNxbyeG8NzasBtELO%)t_InAgKs=w9DLop6c6))A-+UcOnms~YHpRc~| zv7a;b_2k1@j4sXeuIx(X^=qB^>K@ejQTt!^Y0+O&`&kZXpC9Y_q@zu3v^V%Qt$Dh?4 zjDzpd-qHDHT~)X>pOqVFJW*U*RgPv+C-Zz{U)?tLQpZ8kF-uYAk_dnxhx2Y^=jF;(pH@AJ;+hTlo zQ~B$b4S`=j6>xiz-e$q2r)so({!RT}E&Rzd`u<{gem5vk^G5e`vRB}?2JLf6_pi|F zbyn@qZ)%_Bx7@n#Ix#h&@yB$gPoK?~S{L%OFWw?uF`l?{YESOey8P^|%DBHT{iNHc z!~NQ*Ju%zXI=ytNyy)}IvvqFUOZDW$=k0X2E?=%5P3Mz!qe)K-KVS0WeRcNO5xxxc zK3d~oJZG;?OZRVVZ;Wpar#i>&eZIA0+RQ4S=z7l@o!fhBbuPr$-tFde=%4D6>gV$n zhCp|wyeEE|p?Wk%C~9@oK8$v{rvT%>W}x=&+Hm9UUaMo__8{HT^(rb=1jNhur4A$7 zTAe3-f6z47(iL94BOQ;ib$947Q}wZvf9~3fFE#4n@roT=Oz6%@H7B)qeLf6zca*rF zDW8`071^pgH#whG znXU)p^?~Z!p5LIW_EcL%?af>j-8k)+I=Q_xZ&PE0^PxW=KlL4;XUr$H@O(@!<8WvF zrCOeUzFpV!>oBSImdzK=`Wd%a%u^5^H&)V4(bvvL1W zX5~_Mw?}(S?S-jcjqNNLAHKwUko)t%j6zwyU)7W!eV)}S4|x7CVRmrie&5_byf5a9 zfu7aU52T=A&9r}hTZn7f#VN39+8 zAKhLaUmld`PpJNy%)3luJYaczT5f*bmupj}rt`~Y*P6Y$)NQDKMhuoQyvBTi+sD2S z#^(wuwGY&v=3iD0WmjXqO!e!ZX6{$-R6bMvU_R08lS6;fli$~oj%|Ad3U~eI$MB^4 z;}JOdEY;t5UE8(mNfix!|NEJ>Z*Gil3p)R2Fz6zVOX;0>x@wni(+J*kDzEpx^8JGT zXXV#LIb?2Z)ynOWef&@!t;6_+-tTS<08jYZZsc227Q@>jo^r3mcXgD6j5;nt1;Dj?Jcj$Jgma<=sTVs~8z7?1YMW4RU>iRP(#E%9@u_RN3r z2E+5uwCq#u>lO1=YH#x8u(PXD_3->-(7UNI*Hjn3-)*yP_QfhwQG1{5b()?SKP@x$ zPaEPs7z#A%d&rNgDji02IpQ1Jul}dD)#H9ywd};3U;6?9iA}9N)mLBX{z40c`2^Mf zb58YrqJ2KO|Gl!|HaFsD{YLkrTZ?)gJ>p$C-M`m&XyPZt+ZO-(zHS}Yw=8ajS<&yc zp1aHhEk1vcFGtm0#bvZgAL39eK!te%ri9sDJDB_k7QE6yd~Ri%lK;o8%5$Tj+V zy50xZnU=m(Urz1AhPc8u=~8V4^{@Nr&G}5D$}C-xeZ^)_GgS%>z0`RIJoVB6bLZ>r_-T+p3cXLPGDuldziVC?O(?NN58?{gn! zUuaX6<^FqVXM?K7c(bGWSlYD9#&1)NrR(>F)$dfF>gnlqjc7(5oT=J4e%sB(rU#7Q zTer~t-}1h&X#d)g>tjgAXQ|P?as1MhL2q@oD0Jh$&!2i6dX0F-HPQV?7$R*-j0dlP z+vDKyo0)U9c`E<8$KdF%5&bodx6ZCx=N99yj^_u{aJ-0t;d*60TBVP9wo7e0)&Es* z*}I+?A0AYHy4&w3ZEo;F*KhlEobUTmSx?^&yVurVxyna6KaJ_mfEcW5csyBr+0eTU z=gapOv7jed(B2j;@stnkZ$60eH($?^P1kKu9s(7=>&Lz8YHT|I-|<~@RW96KjZe3wL8|;j^_eaRi1=nz*+Bm8XWqGBnGs(hUcW5w zm&IAk*XaJF10rCqM0|qd+i81u^)KF4j>KCZ%z7Aopz@WDciV{RN0}kMN%tdN+OeLG z3jGuF_|4mL7lA5x{QuhFC|djbJk^JL5Nxd$yw83%&0_qWqCZ=SPYko0A^W^)+wE6B z)7RbKhyM9uKA%nN%3-`|GHTy$1Q4EO`c(bU^_u4$Fryh%&*O9Sy@>eKTGh-)k8sQ6 zFkYE?K9A_yoPUTfHQe4~sM#Szu&d#v_IfS8#TVPG^h*6vU!_@V(O6!fy9~=34(y#jbi~btx8o%qahd=M)7ymh^J;&G(Q&z-Z>Vn>P z@3aJ0I;oGZ*MI9XUfrUwC;WFjx~F|T@G{jChgw-7z8 z5b?!$o7_MLhqSh?nx4zYHM)tS`{@A7^nk9r`Q8 zB!AyO6$_%l@VOu8ejE63_6O$M3$?FJ^$g%IS2efC*V1QNzqM)u8o#Zmj}8kos+RFi z3m=}|tEJ=qtu7{$zZfs4?0axGE!G6EzCb)K8iCU7+%aC@_IN(-b$&mUS5!Y1ajNUi zF<+^u{ciP=78m%OKPoRhnrYjjo)7bh_N421cRU7BO&6}8{N5Wg)hXuFWlrtOxK77p##MbcwWqT= z*4<+M6Y%_C+b|sHf7i?7&&99$wHMYOJhj)Q&Hae6v`Tq=Gw1udRN~dpxSJ z^m)JdbjGeif+730@~uBXfHZ^fE{dKTiV*?L5#F}`Uhx_@tg z#SKKb)S-!oyPe)X9kIS-==__$?RxF4D!IR{pW^HD5Al?pc(ZN4^!3n*r@l z&hhBGonH(PFh1e=Z=D~Od@~E3FT#VTxt37{2fd!hdYx{>H(riM8oQO{WSn|7Nm?UUl&L>9JtNcrXpd%lq$s2G#gs zDvb5ro!SEg2Xzx1h@bO%arvFya+NRE_lW~MGcp+DpH z;91A6|IKHfiv08Q^=`*EszOtJ4EfnK?p{>M@daqUG^xh=Nl)$lb?LI$Fn=F=I{s|e zpws<_@e|Lt*X^t?H>;HUi_i5>Hu*|rJpX%(63usx_Oqkx%ABf*#K?n28k@!OFC|~v)>&4RF_UmK&sY5)0_*#x_nx_0wp4WHx47<8t#B(jL zAFmqM)8%M?*#8B6TVG+k^IGz$XaQTkH|jaa*V&{xt9*m_EBUkpLArN{$MzqckA0Tx zsM1}{1+_o>Qekxj@gB##2>{xFs&0>DS^YMChn7OS7 z?hmy`&z?T#j`h#JBi`mV*RD5S-4neYE-bIR7VCeG+lSYV{q!JyVaTVU_M5NP8vPm7 zCsga|Y{2@$LickHwgc@^tu(LKjcxa4>D%M{`SX5WDq{}ywbY*lS=qR;$9hRgyqx*o z75$3wAoI0Mu0{y9Ks=Go@0+jAbs6T%C(Yk-JWKcG+n`z=-)0?lZxpG+{LTJ+!sM%8 z=ihqZMfI8W2u}7`FF8}X9|)shJ#)qW0z>>=%hO^(V^yZ0>+Rda)VId_mR{dw7c5PM z^^Bg*7Z=+!>ryH_w(|SFXMc{{H3s_|h+p(gW-EU2(~5Y=YJ_(V_}8(&?TUry4m>R! zA3c}JX3smSo9B~LT^zxN^{=O=>(4KXXp2F-QsNU;)xD`3l;?QZmZjrzxEAqfI=>su z-CSe+5wqOi`DM#(+>Us`!Q+YhtGeD{KDqPy<)znStTF#PIUa|}S-uwAg7r1Je?jTa zVnuvy;rP;2_Ws*(e!)TI`)=Ngsi{!k7VBXx=3C@v+f}{BcPV$%{m|oeJ{s-a zyHI;qeOa9~%P*cwug?~Pv2UHQ9>C)n9b|z8Zx7E8^!5bng!0~*d^bB5*mZiTkNZnE z=GwXk>lcp4J4e|f#_;{e`Z$K?ZBb6>4|)A;|AiO5f7J0%{dE|fnF9S!evuDZaQF3s z@$IzI`{+%}F0%#JXLISn1IDLj zqw8Cyp~-KYU(fvhMvLyzH{#XYemKnDW#l<$9S~nVMjG$- z9U>0foMOF!?vJV6yBsItRlHu_7~8(+(y*RJ{drRyw?#lvHN0PG+Vd^PmL7!*`SH`| z7;G8buP&hLGiD8d6!@#?{GX<*-y7@sH;->O^X#o3fBhS^PYc#Q{5v8({g5AiEs8$N zFyG?!MqBN!2r&QY`2BLO-g%<<8^zP^>vGFFYE?euH-kG)71YabEV#_Tz^B&z?0PgN#c9<#(fB02u>S=uteUw0eEOk9clPVw==}CuXNZ9#9>?t& zqQjf((gpD$x*h~y@hU~UaG?6%^-_NW=7aCC{H}i)9(%V9+WVKjZ^>JPr!app9B;od zFT)J9QgcB4)4rA0{h+_C9Pxp$V);%6^UIyeFIQCHP+`8Bk$(ZkuVeM>s^j^1JG{?% zJRkNaP-Nw#fa|HVPBl-}MFX(0pirEUzbEHvx9<{MP3zji2kP5B3cEc^2NEgQbjnIj|l! zun)y}uiN@zy`TG|w=DaiyHnMaT^!}qchm=Pn+xnW zBwm(UUv@|Q)N*`c+SBf=+=lor)knVeXTM{-Ww^huuB*ARS59e;uVHpOT^ZKr2X0^b zy|~83YW3~=?|!HEa@(TIR8UjIp3n_E%8*p!dv8?|}VZ{CHbW% z!%XeM`Y`V=K=^g>dz)iF5AoQSWwnfmCxen-eXL7RzWssrirc#{z;4SL@z;U(LlnNk zdR=*{sVCn?-#6W`VE$t1d=T5}I|NYG$@7=And+^@et>Tzewq>s4(D*9zo6@Rm*Tqh zf&HR9UcZXlAx4G$6AST;X$6`G>{n=ceF^bwtaoAmaQ!Ob8@G4ZK9V75rv{#H6zBWR{?}hmR9@%i+PwRT^*g%W zq951pE3rSoQTtg|h<!a}o_Gc{DYjHmfUEiKvx?2!`u6h3RA>iET0pr1f+N*S&-+nGyZ5L?JzDE`ctZp0jp0VBD~m7#`B9Uzy_+}#r{8PPwbNhYmL`3U+~y~ ziKX7({uVkuookF}G2g#A{$l64zgO%RX?T9uRzun9Nvn+8&ul2};s8%qOZ@!ywxvgh z`RvN|cb8c)1lX^((fvu?TFg(0{V>dDZxMaRhE#P7)Lxvyr-K*!E83Cn2bNd5uF$!1 zy#LL2cF@6!^-JE*n4asmb=ZGfa{TnGr(yWe{_HFHkIi+qT5&&um-@5)?S38NjQvA& zKXI$KDR^GY=V^R+7SE7h^{6`D|822PyS%dz`{C(&K3xRod<5#+sXaFKwfk?ri)}>Y zt3d!PxUj#L$5;K3y?3yC#Ix!8>@hZZvtmC5*H2!a-v0K3_q-mC)^sWHg~~s~E7qS8 z(Rn@MZFK*#~qWu<{N8CukZ54&b_Ko6VErRv777X zxBrXBXXSPpw5ix%e;&W{|FEyAe-MvD6!Q1F#J-u}#D4RPUa|j)_se?B1&$Bv zp|7Lwe@cXN3hd92{hM9(J=QBeXPyK5 zVJW^4tb@gf3i|`NKgE99VZwhD!d}1fw*Ba{^~8S6f?m&0;Czq$7WGIxA>NG@C#)A7 zyx%;pa^21y_H(r~9_Z|n`yI~%j65D}_re7o=AQ@0n|teu`?nwHv*hPhKK|U%-;Xu5 z4=?sI{BDrKI>PUK5c-*d6Z<_EUN6U7qYQ=*`+aNbFRpL3dVVsT5ApS^d(fvf=7XND zx7jlE?rn+vjMTp57+$$xZ`H=_V}RY2&w=^N`qBMdpW&)^ovAaY_N+EHK9BKG_fmbF zDP|NJ&vTq5^&jhg*3*mr@!5#iZ~Qby+?e0al-*l3t&fU1I+S=EJ2{>-7e2gFBxK<)dJ+M&aW4)#OP{ln^4bz_S&_8$^IUy$VkdT^C5 zGMHBONNY@F-v2J0Eyul)JMPdF_%_CNA|wWS%W5nHHmzn0(o>E7FO$Nc2Wh(GL3 z$aRh9Wlmm?!QR-m35F8$Bl5j`&ay45N)0>l)_2t}BAy}sPW~ZmGtO8ONBp1e_w8<5 zd4u)4hWeWh?Q=GwebSCzkL$N$J1xflJU+m-v3YJDi~S(!@0NMGAM^(~ z@#_24WFz)_T|Kq`*bTCelW#Fz=lB2`Pz<%PU;Ux)zmF0t(%Ap=NWA1Ku;mB)m;Pft z2eUPdpdO6JiO;S$bcQ*J^1T0aobJlhm>*jnA7ZGFr@Jinv+?-XVf(>RHy-^N`R4F+ z=2l~WC3Xo@{a^tF8@>@=;{5@x*TIDc3a~y*e#|?T!_AB9ZwmaAVzF{IX$w7r9UcS5%e+6W+k)z7 z(hBVp-Oov5h3!Clre*!U(piJP2=Pg3Z}VwzPirw>$Z0&e>!zFL9`TQx>Z_Yl|BcuW zo6g+db?Ju(O0gcs^JR~@1Qy62^=Z2Q{e&Hel4iWw_on1 z_5<-QJOZ?Xx0mKO=T^-oTYuv@y1zTTJ=(cMebf8ZhZTvX!+r%G5C5M3ISrn-z&g_J z{BFbs@c<~|-#niwJi=La|Lu>Z`Y{#4mFBoQvMZdbh{#@dH#B;-&{>5`9YA?U#o6uxEYU1&7hQ-2Qy0D%yk^koC z+U3Uc8;<99b-kcRpKmp@55 zzhnMD*FWNE;iD@bluzT860r>bVZY?S`;}gYg~9>x0kiUWGA*zh66ZUxpC8s0Fhs%n z&P4ai&PRzY`iM8qbUzC37dK;n!sF?B@OY?m73Oa_KhNnkX0Y{%{htBxR}XVh+qS}f z4eFopFwfQPX{qLuuCJK7dn&PiuBhnqu1PV!#(sw`AU>~t8_-;W_mAddSl!9iWkq>8 zmDev0k&_zn=#kpL^Tcc#4?ro?@O-Pp1H!-gLuaV`eY)`Y51wz9`~M+8&`)+z1M}pv zw|a^I`*-;HE{wL)7SBFmzcHWxQ>BN+^ColJ{yp3N_iX#$v+aM+w*Nib{`YMAZ|w2+ zZ2RA{?SId<|2^CO_iX#$v+ckB;P2V?zh~S3o^Ahow*Bwf_P=M_fBnJVv+aM+w*Nib z{`YMA-?Qz1&$j>igTH6n|DJ9Cd$#@W+4jF@+y9-jd0NWTQl6Ibw3KJ0JR{{9DbGlGM#?i%o{{p5 zlxL(oBjs5s&q{e#%Cl0QmGZ2VXQezVYu zl$S_(iIkT}d5M&lNO_5rmq>XDmj^+JYotb$zg(UUxI7(jdH8K}d7sPE0hgx(E>8zi zp7^1~5By99A18ij@dH0KEdRfhCw^%0LyI3;{J<{-^XJ76Eq-Y6LyI3;{Ltcu7C*H3 zfgF-tj`*R)4=sM+H{a!bIY043iyvD2(Bg*{KeYIv#SblhXz@dfA6op-;)fPLwD_UL z4=sLZ@dKGq_`JjqEq-Y6LyI3;{Ltcu7C*H3p~Vj^erWMSiyvD2(Bg*{KeYIv#Sblh zXz@dfA6op-;)fPLwD_UL4=sLZ@k5IrTKv%BhZaAy_@TuQEq-Y6LyI3;{Ltcu7C*H3 zp~Vj^erWMSiyvD2Ko3LpZNv}!c9Xnjo{jin#1A8Wn1FdU;)fAGjQC;152T9X^284# zei-q?h#yA!4%J-Ga*(KaBWc#1A8W81ci1A4dEz;s-L!ayjCM z5kK%-d-DIw^@<-x{4nB&5kHLhVZ;w3ei-q?h#yA$Fye<1KaBWc#1A8W81ci1A4dE@ z)-XOl@xzE8M*J}1hY>%F_+i8kBYqh1!-yY7{4nB&5kHLhVZ;w3ei-q?h#yA$Fye<1 zKaBWc#1A8W81ci1A4dEz;)fAGjQC;14%F_+i8kBYqh1!-yY7 z{4nB&6+f)_VFTs`sd}mYt@vTZ4=a9H@xzKAR{XHyhZR4p_+iBlob5_z^aF&HP#EKdks+ z#SbffSn&ftZpg=pA6ERZ;s<`)P2OkUtoUKY4=a9H@xzKAR{XHyhZR4p_+iBlD}Gq< z!-^kP{IKGO6+f)_VZ{$CepvCtiXT?|u;PamKdks+#SbffSns( zKajPQ?xzz!@KbN{n(wa@Kb-jC#1CW(;?Id6PW*7Ni62hs(Kb-jC#1AKaIPt?t|KY?BCw@5b!-*eG{BYuj6F;2z z;lvLoemLnrocQ6y4<~*&@xzH9_(^`QPw~TvA5Q#m;)fGIocQ6y4<~*&@xzH9PW*7< zhZ8@X_~FD4Cw@5b!-*eG{BYuj6F;2z;lvLoemL>Ni62hs(Kb-jC#1AKaIPt@Y zA5Q#m;)fGIocQ6y4<~*&@xzH9PW*7%6hA`oBNRVE@go#JLh&OMKSJ>%6hA`o zBNRVE@go#JLh&OMKSJ>%6hA`oBNRVE@go#JLh&OMKSJ>%6hA`oBNRVE@go#JLh&OM zKSJ>%6hA`oBNRVE@go#JLh&OMKSJ>%6hA`oBNRVE@go#JLh&OMKSJ>%6hA`oBNRVE z@go#JLh&OMKSJ>%6hA`oBNRVE@go#JLh&OMKSJ>%6hA`oBNRVE@go#JLh&OMKSJ>% z6hA`oBNRVE@go#JLh&OMKSJ>%6hA`oBNRVE@go#JLh&OMKSJ>%6hA`oBNRVE@go#J zLh&OMKO*rX5< zKO*rX5i0=Ke%L?#w|_>?(0olNr`~Vp zwfKMjzW><={@=Cv->#rb_qA`3!KC7h2*tD?`GSlHWkJ87KaM?ec_Cxe;OOBhrHG!(VkE!xd-jt*i5KzYNYfXV|TquQqvC;urYo7yNB;Tu*=u0d-Fq63P=f z2s4L_d@E(>LHggqd=oO3Ir{wD7yIOpF)iba%*S;171ENal{4O6Ro@Q1L57TsGU}Z9 zVK$_xQxj+OF7o4UR%8IaIAd12H*dwGRko96z&cxWJnk|!{xQ^Z`vRuah7t%h&dg5q{UG^ zXEfR!QV|)4jN?6JMg~#3p1ZD|`>v3Yjx+ioy`*W8Qbi4Z z|6N}`uk+zfWKgN;dIx0Ys_Uvn258Dyv_0jtBMlxhSkwI|4f3V6g;P~P8CDA9b9Bq| z%Lql^cRHj3&XBE&kB(-?dSQ4Ms%_o||$( zg4GTgVhZxtWXO=4)}KmGdVe|dcT7uUh~o@E^IUIznZL-mOBrLXS}(b~@%e`81L-%5 z^+3kh#?$xZY4+U99H^NyG#kC9d3GRUYs(qrf_FSKWH50ZWi&CRMampI9k6^wL!3)0avXTSbO#^rBsa{bFlvvEd4-KF~7aevd5&iC*I67u2m zC)dxjO;wToGM-(WVd(n;vmoPTa8vueT)&L&sLypL{$6vX$B2w(NM-*!pL87C?wbO% zU&MERUuPMN1{t~82j{mOS&7tIQT-snYY?o+SmZ4EesAM9BgHB*rV$s)nkp^A^{Z$8l?7+g=)5&!*T#9`ytUca`nLQ-$>5 z+kuQ?NaOrF|L?+f|urydy}Q^)NSGIEU;8H-ZR5ZQg% z`tHGqjOA3n`e{eoB7=3>} zMMiU^9VeeqSHW|^M^F97ouj+@Dr6Yt4BNxD4&R9kXnLmW(Q}^G$a$ugl`|%0nQqLR z!#`>d#w9OVErLn5Hy+QhSR5vn`R~esA*?w5g?^GWU zf9HmTk{a#jchUJ9KhX z^S$>2GOiAEzo6r3o_fNsq7xrOxxM{~49Q4*`m3LLdUVj&$Y94A%X70T5 z7WKvLzt`*BXUK@S&vbvzb#WKkU}TJ=^Lvo}cJ;_8xgF$3{oIY+uLI)^`g~>k(X2Z% zWV6p2nI)Ia7x0PBUw^L+kX91?HPu%$@5MWJ78#|;9ym4HbUq&O#8O5?=ugVP>H62r=HojdL-0bpjXuA!#(XN{Ujaih z`)V5|t2)Ujynp3e7s&8eQF&u_*F%Q!P+1UPYp%25wG%Q@vwvM4wEc#RgeTSKUgp`f zq5smHLDZWw9gt;8wVYAU&E3AfTdxAn@cIrta@eB(-Z{fzo_mvC&8ZeHf48U=wp7QxUkU^a@^sYr$TBM{@n)xlB_eDl`^e0R3yMNW3m3J^81KCO6 zzgz`|3)~vHGerWgbqEuM*7_E)Ju6y#Bb}bVPDVkdd7H3rsMK zzYL5wXEe+UTaRPeBBL6OH=c4FZHbJO&qqGG^S1YMAjADa?S)0Y+aC8o0qWoPpYCWo z`yc~aPWA2U3=K^4DSK0Wqwhkl`P-<8dB4orjrTFBmNTSbd^bORg^cc;VK6&y?S=vw zyDPe$+ot_cuE=m+)A{H5(&!uC{}j}I1~oEduJG$x`27w2Q-zG@*~;U&rL4{d;{n^y z^|kqjJAsUn$OHa6|9W+4K4HGprquq8gC z4vf=wGzuymiRa~Xy}8;8K2v?7f7+3O9vM0ZY7a{EXAaq&(SOnXSc0al?n7g|$MX}U zi2U|-SHnfun}WT(zRWlN> zW@-!Q`p)yQ6|zfWzC_p4`VPL=$l!O-{g}VXZ??zylglfc4Yc?Ocie z(bDy0NayWWWDIni(e)e;jL$HCF%{jPwEX&S!~CJ*49~^ns%&+)>Nq1{fqK3sWDL$n zDi8BdQw|s}Yz>Wvs>&f{=+~-!r1QmC=(@T)P-{l*S)j}8?!f2$5?@Vrjzx#|E#vve zFkE@5(VwpeeO|xor}r~c!AyMh$1pxmiSZ6+WX_$-?N>jle#ocgelFyk9+1J4`Xi%} zuJoKHHEZUjwOO5&T1_c^{$4Q~Xzi;;Zhw~m{Z)aC#LGwHB>I<09Xu zA59H1VAq_1z5AAGv}1=~siyi^*5e%R1@W4c_{-X*ZRf8B&&2Dn<)(IfkMR{{h;$IT zc-9j0Rr2#*p0E04Bo^KgEJ6-n%m=fFcv+4rdxtz%BWGNEk;E6IzKcU z^|LHR|unxc|(Cvd^ne4F$DdWw4$Xk|e8s_>#@@m} zsu}D82C|LU4v-L{BzhfSn{+9Rz{o!!B~cQo4~n9w55WH=MT(RuU8YH&AK)f%fc$|i z0=UW1z3*f;b_@h?`v3#XXx`_MMDp@}oOA9&+F$lL)tn4N#&PaL zHtB~G%e|FF2hc_sL+epIa+Xbv`sJqau3_}&h!gMkn&Z12;!zh~8iZIMKHLI>8vn>yEj*#UW{ZwXE0jd@@cfrS%AX zfkU|KR^Sxc_xov-Rih+M?B@Lc(I(4LHJA_1PrBg*rkZi$D%Ep3gF=%H2u}KhpE&+z;*mp4#*ECGC($oOm4~jc2da-Pt|> zAL7riJl)$N-!)TJVQ5aIUeSEYt=>H9(Mgg0nL5M$JFL%1 z{!SitwGt=Jnv(2iMtPU~kbq~<{Nn)bZBf`yxgdMm^0qe3jd*cWyaY^j6>gN`boBmk zzEQpTYG~P?sR+Ee#q-%dkxFbP;RNkuXg%hst{)(%h`%&nOXY&fb`=Zfr`L4@G67x| zIG=4BuOuKm(Qthg+qIlF4*(fXZL209!Y)T^`} zgC3iq@>WDX;r(3OwqCKH&XMv1fFbL?tt0Av+MoMfn+ua7%uMSY7o1@&&qE9ojmLSl zMpNo)>@f4Zs>jAwMIC2~Hdrj+g+-b~v2mYa^^*l|#+Vj!C zE9idv){fymkRNQ6FVt&cTn2su?cr;my{<#M2aRibf5ck@caeo=eC)d7sEeUN{3ibn z*ydO};EA=T>-*Nzy(GkU-tTQGrvZZ>fPcU1cXu&X?z-y`x6{ z>%Z_~S!;wIvSwk$-f$^X>wufwt9d5qt!-lx3TgcHSSzNTWHpNtdK+n(MB z)x>2zP5{pX+hbXI0M5XlCYt~Ly4LwU(fj(stDfoXCWrVPIev%K6eaSlhU0tfjcw!u zyy=whcna-t*7@RbP4}Os-BcO=ykmUFxDzh5sgaM6f9jDdV>=8YZRB6eeaw0>BTh`G zYgfv?sk;jKH{H*G9U5EUn+xMjsP6kNTI7o-*>mHfd|5(2?b!fd<`dSpvnz@QC&Wuh&u_rSouLB0$nkNGCJ3E{Z{#7q-#?_5Ne(;dJ)}R*w zAs~NrWRC}G@3F#odiHluhlKuFk>B$E1saDRZI!?mc>ZoTZ{r<<=opXhpK9#-8u%0Q zhefyOwM$AITrYzfs=5;OisO7r9aD1QM*YD2YbqDOm9Z0JLG}W?5hX%Gy}Q$V$y4_( zKBu@7UEgzan7jAj@96Vpn&+|yUX;0>pZ7Y>9q{@u|F@%>UERwca=z6&9Dr_6FWr&G z@9%c*)V_)<(fV!WQ5|u3{Q=pxya9+kM-nIdFB`*jhaLQY=KVY^vpzBY$o%Ynr}i`% zC&-^%8fSb)6eX=!(p_QK=@wJR z_6`1|TCQ6t#^0W+ntfVpp$>ZA&OhffS0(U1@?Ril9(iRWEc^2vy@sG%P){)arHa@O zW-y3{>~C>WeF)VdDo^_}0{%K@vjV?me<@)N2Tr_ixqfP`$prvd_(SsdPbv$q+6nb6 zeZM;!P{Qu52Wfuy78SEXzNji%zo8fhYtKf26MX06c$4J;^<~ZZN9(XLPv9@z!rwoN zr=N!zd=%xYwI0)ax(WV?|86d2NBGY=P(IW&%{7`Zi__5G3jiM5RW3p^zk0zLVMP=8 zM%qtXs$oy4$L^cvqr$fVe_p~c-rui5ON;e3k=7%u!|rTRis6gDv}PVr071$?<0js<%CWUx)}unaqx`AcA)eS#Z%vlg zJEHnt59mRzi|QMIH!?O)DK^#EZdqTcGvEBpu&RJRTiKAtE0G|T) zP+`4kJkNN}b(&|yFB<=S`F!;^^7ll~Ls_b?4Z@perTM$I#l*2lV&?j}>~hsqsCU|j z>_2QOn`cEn#P@5e1Y{TdhhzLoT@EGjv!lMD@%eT>)~13!fca6~w{3Gk&(U$bEc0~d z5_*TtQ9M%_>WRjH4;$h;|Hj&0S=0x0qIl~);MpzRqGUW4vDnuU`5$o4_w!3yro{k{ zKXzKbkU%sH)2sKO{dpd-FIQ6u)zJJX@L^?-{5b{6uTrZJqJSq=Z2xCC=c-wxXdKxa zs1Th~Ys9nB`)+n|zD9kxalAymGRdPlg%32pa*x`thXme1_ODy->*B~_yl6bjf`YA> zkWcge85`3hfMEY+if_7ZrS0xgASS)z>*b?%X)bZ{{fo{Y8T~YtiUZ^j~ z-trU75Q-jrD?QH^>dYPX!^ZO^J0!koivl&+d;e#f!!ZJ{sT|Euquzub`}qzupUbtv zJ4_4mDZ2k!_*!lf`ks>3TN!tswOIsyv*5j-t=bmwWE54V{p0!-7WeXxBdu560_feL zXQ()TZ=0=f75K`A`PiTlJp2xPYNPcVKyGy#_~^YL{Gz?Xjry_`lJUAF)qu33gFcC# zSM|s7m}L@WN%jP)U|;tDJgB4nTK8(w`)EWLC5?aZotfYdwwcCP-)Cqy3H;@u=Q#xE zYXBZRDZ1a2OV_R^^hP)Ry=u~yd(;z>`BSt8tGqqX>(pdlejQ}d$U=Zrqvwt0YLD&| zkRiO+`N3ow9l`H%`~^T8O7O=c>(!b)731~t9}UIJWxe5lAK+spt>2nq%w8e?XFP6P zws39018?R_Olp1aU;K&l;l|5-zM*&7R;dInGNx@-$DEX6IVk>6LTVL{Q1 z=h6F2>d3kppoe3B5Y(V^UK;Sl>b?KvhiA`r62(RNmU`Wr)C2GyT3?`9AaD>LX3h23 zTHl2{74R|IAO3hM)1W?p(|zw3)44l;?#O@Weia6jf(Kud>HB5Z-qiqq^Hopn)$ud{ zq=3gz{H>I2`on?mp6I$B7WlNW@G#gY-v>Dt#*zg;8jmFufP>iPsG2K^O{&*>sv z(2|I=p!uHQtgrUvgAZEoa_<131n?b->Z^X~A+S0Te|Wy6g_y}V$QO9L`#$TmM(E9$ zU!AVIb>R91;_5q}!&Ho;M15EU@=uWc#Y=*(GMUx~Fx?n>#D|0VW~H^73h+a*qtB-b z#SLm>;A>=0<8(c;27VaXzZ`lirvv-r(d5rY=o=K0TGVGWA8T1Qrpq(xQ?k!60f2A7 z$F*EPCj;L+M8-tp{xyF4585e4HP@xl94;7jhA z##630Bqr|F=h6Hf$gi`+{wXxsE5Ju6N`Ma=OP>eSa~Tc(bYgr$h9t{&0$;b2{g+Fb z&#p#%WIY?iaDA@8cYWp02YS5u=vg}(C4 zoj??O=i~PGl?zCJcdkFC zdKt8aKiPU({|Ed>(e1`ZH1wzJ-EESF*Rtrpcx^L?se z3i^V7QS^Sf4pm6dD`k%7_^As8{$UXIqW!qXs4@h*qDr*>IY5uPKTeeVK25*+$L(6c ziM;PO)`i|L@FPV@_5f^F_9ygQz$xFqcc$2j0s56#(EHyIpe=rezBkhN>phfb%*c<| z^8Ng_souukLf=UF(c?>r_zpgt^=$PxoN9yKXfJ5JZHw@3>lOMK+K*P|yI znwn?pfKS?y{Ilyu1$hhfo$L>zeGx4@?_@miTJ}M|{$Vh*Umh6Lej$Gtm_L!dHVTxp zfH2~H-!;$6Gb7)fSdVswuGLBP0xIqI@9u)*AD|xsiuYbiU6x${UoT5~pQ?j!V;Zu! zI3Bn2xelQpfrpbnbJ>C-0v}o2Q->6L_*!4fw8u>zQzm){gbdH_-ae-4132`C85R^qwOWV%YyjPy5}i57Y$? z{9RA>c7_78f3>z3^z(O(dl ze``}Z*9P-fE%ZK{UbmvxBlLQ7{|Q_%N|sYR{4250CR||!Ut)W@e>F8_a`hlO#$TZS z_eIRmo3E7rhSF!{Z z9DggND{B$YE$hv}UB>anmm5v*tM@7ZYC5og$bND$%KX|_chY>GRoGoW8$6%q(_JM5 zY`u6GAFfir%HF>C3%&mcHR-Vqz-LeLCs*r0Ng|$~%(u2qmrxK(p}1ZL|NlVJ*ou|) zNyD7m5j8dR8}vMcuc1%KPh24Ty^!1XE&St|C_VtX@Bx&#I0}mQh@JqDGvfKh^|mxm zT%QB_U(R2vS++o|MeAw2Z2|fYfI8wY8ur&ig!@vce>Ckc z2W`ATZ6P#|Pr6OV2Y6t^cv^7`?QClWK9KF*RC=Au75YC~&vYOG+u$Fap}*fdgu43$ z`wTR`P^IgbQEx)j{EjcXr|UqP2+#PY4KozF;0MrE^ZtDfyG%3q!;0$zH8?rB68Svq z&u58X`2a6VJb;)^U+fI@DE&qIx7x(TV57c=WKI%gdMEc9H=msI1mbpD#bPm_O1ZJf~~^@!AveIKY603kt7!|@C1 z;Te#$6WvDhsX7n-u0Z{}lRvvIH9Z-6_2VRa`rTHr_x=3>eQAJR3Ml-0txydqaDL)o z{|Y)i7SkS)-;urRVM*o!zht<6sLM&7<*lK&r|~~)A;}*n);AiRwe7)=ZQP&L@59|} z*q?Hw{jW?>Da2ymAIlxZyRBWJp0a_VRLeDlPP%hU~pLZ5o10$VbWEQUhXj zyTGq8-f&;8?E%R{pFnu?xGl39QiuKtTA!(x_u~=Yl;iQ0Y0VJC36KIb-%Yhi4|{X0 zf5UuSxdMKu66ZJZ@N0qmBKB0@AUlm29X_x}^1t^5co!{NB8_Ap{ZSZD)ZqKS{N`OdL3;jE1-t0$?N6fnC-C^nAiuAeABS{eUjP6L2t{c9(aWdq3i-}J;~9eOLIMAx zJ-v@XL4%f-MmV<5Fn13k%7pkE$9gK1Px3h?_gK$#w2Sr<>j4$TJN{)26QE4s=?&X&uUj*o;Pbhk#^l(ym2U*R();6of1*$Auov)i_D_J(jTv_EO9#cnG(Y$m^Ba2h zK=Y~VuIaNem@nR+FZ%VA4*GB!PYgxW0rBz6zt-5dAUM$<$o%`f6}xrNQxqNVkGq`C z75FV=%kTTj>44G;dMo#(2O3oFJ@Wg3<1LyK&&8~zFoC{5-v!uj-$0UEzK`rOel#T1^c4$B08SX=p&wTKUJ*p#&7?poXK7< z=!O=1cBoHiK96uf*$+L*#r+Z}uAy|seszZOj}5pn6n6pfl-J_~VBAALQL~;nh27@} ze#mfrxn5{aJJ7GufAz1fPIm+FuJ1CZqTXt>WdhUjkN?Ka}XUkdMw2#jm~W zO@mm5{FnSk8KPYy@;Pg0KJsiLs0kxLgT3!Fqdv=kaG`gj`$G%10Nz0UIgH{Te*T!vx!`wcMP$Bzy_XF$tVPFscna09y!?;l`rd7^ z3={e*I`&6Bx=mXE*y7>-Ifpv8fS?um#qrJu^hL{1TGSJ)Ujmd>xecdWjW@;nYR>h9 z-_a9;rg+&wr!z?C{h$k=^_uJg4CRErney!e)rD%oXSWa81Hz8&O7J;5=U>1}Zzs|3 zHnRSzg*eO_^wZ>m)@wTNrA9?1Abff6U&i{G(lSFoPWC9rXl_X4V866~3w=Fq2H%Uk z{QbO{({UH@zh&QjdfVGiZ~LdW{nOk2>1}6h!>23e?wtsrtKfUc#JA8WEKfUdr z-u6##`=_`4)7wti!Kb(V)7$>(ZU6MPe|pE$|Ma$hdfPv}?VsNEPjCC1AAfq= zKfUdr-u6##`=_`4)7$>WgHLb!r?>sn+y3co|Ma$hdfVT4@ab*;^tOL`+dsYSpWgOQ zZ~Ge$KE3Uq-u6##`=_`4)7$>(ZGYpz`RQ%{^tOL`+wt3mpWgP@AE-}n`=_`4)7$>( zZU6MPQ$Nb5xBb)G{{P+E{_QXR{NH{TG=8tTOaH1}(}I8P&Ct#IyWjifyFd7&Z-4&n z*#6Ns{GY$Sr#LRX{5#hruD|~e|NIyK@)y7P)zAL$yFd7a`n{ih^NaV3-+lA_fBR?O z|J8(le)Y58{QRHbr1+ozq~NpPzb+8KfAwFcAHVg(Grqq1w?Fy*um1KY_{491j>F=& z;yv{VhnOtyY4YcJclZgyV1GPK{vZ0l`;`CnKfnEZk17A}$KWIX=;wU@pZ?~j81*-p zjQ{*MKmGBE|7SXW`1bGlP%N zD^LA>;rCzbTfb8yah4>0ZR&o0oSJ{=1MhSG`mcZg?>*=5ObtHrkABYg|KqnbHGlHw zf58?f{#}=TnY*};>+(zdc({&icaKa;j><)0PO gn&MyosnXVTTI0x#KmHfr{MT>4`Q|VF&A*rb8*!6w7ytkO diff --git a/sdk/storage/azure-storage-blob/swagger/README.md b/sdk/storage/azure-storage-blob/swagger/README.md deleted file mode 100644 index fe6f996233e8..000000000000 --- a/sdk/storage/azure-storage-blob/swagger/README.md +++ /dev/null @@ -1,682 +0,0 @@ -# Azure Blob Storage for Java - -> see https://aka.ms/autorest - -### Setup - -> see https://github.com/Azure/autorest.java - -### Generation -> see https://github.com/Azure/autorest.java/releases for the latest version of autorest -```ps -cd -autorest -``` - -### Code generation settings -``` yaml -use: '@autorest/java@4.1.42' -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/refs/heads/feature/storage/stg96base2/specification/storage/data-plane/Microsoft.BlobStorage/stable/2025-01-05/blob.json -java: true -output-folder: ../ -namespace: com.azure.storage.blob -generate-client-as-impl: true -license-header: MICROSOFT_MIT_SMALL -enable-sync-stack: true -optional-constant-as-enum: true -default-http-exception-type: com.azure.storage.blob.implementation.models.BlobStorageExceptionInternal -models-subpackage: implementation.models -custom-types: BlobAccessPolicy,AccessTier,AccountKind,ArchiveStatus,BlobHttpHeaders,BlobContainerItem,BlobContainerItemProperties,BlobContainerEncryptionScope,BlobServiceProperties,BlobType,Block,BlockList,BlockListType,BlockLookupList,ClearRange,CopyStatusType,BlobCorsRule,CpkInfo,CustomerProvidedKeyInfo,DeleteSnapshotsOptionType,EncryptionAlgorithmType,FilterBlobsItem,GeoReplication,GeoReplicationStatusType,KeyInfo,LeaseDurationType,LeaseStateType,LeaseStatusType,ListBlobContainersIncludeType,ListBlobsIncludeItem,BlobAnalyticsLogging,BlobMetrics,PageList,PageRange,PathRenameMode,PublicAccessType,RehydratePriority,BlobRetentionPolicy,SequenceNumberActionType,BlobSignedIdentifier,SkuName,StaticWebsite,BlobErrorCode,BlobServiceStatistics,SyncCopyStatusType,UserDelegationKey,BlobQueryHeaders,GeoReplicationStatus,BlobImmutabilityPolicyMode,BlobCopySourceTagsMode -custom-types-subpackage: models -customization-class: src/main/java/BlobStorageCustomization.java -use-input-stream-for-binary: true -disable-client-builder: true -``` - -### /{containerName}/{blob} -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}"] - transform: > - $.get.description = "The Download operation reads or downloads a blob from the system, including its metadata and properties. You can also call Download to read a snapshot or version."; - $.delete.description = "If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently removed from the storage account. If the storage account's soft delete feature is enabled, then, when a blob is deleted, it is marked for deletion and becomes inaccessible immediately. However, the blob service retains the blob or snapshot for the number of days specified by the DeleteRetentionPolicy section of [Storage service properties] (Set-Blob-Service-Properties.md). After the specified number of days has passed, the blob's data is permanently removed from the storage account. Note that you continue to be charged for the soft-deleted blob's storage until it is permanently removed. Use the List Blobs API and specify the \"include=deleted\" query parameter to discover which blobs and snapshots have been soft deleted. You can then use the Undelete Blob API to restore a soft-deleted blob. All other operations on a soft-deleted blob or snapshot causes the service to return an HTTP status code of 404 (ResourceNotFound). If the storage account's automatic snapshot feature is enabled, then, when a blob is deleted, an automatic snapshot is created. The blob becomes inaccessible immediately. All other operations on the blob causes the service to return an HTTP status code of 404 (ResourceNotFound). You can access automatic snapshot using snapshot timestamp or version id. You can restore the blob by calling Put or Copy Blob API with automatic snapshot as source. Deleting automatic snapshot requires shared key or special SAS/RBAC permissions."; - $.get.responses["200"].headers["Content-MD5"]["x-ms-client-name"] = "contentMd5"; - $.get.responses["206"].headers["Content-MD5"]["x-ms-client-name"] = "contentMd5"; -``` - - -### /{containerName}/{blob}?comp=appendblock -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=appendblock"] - transform: > - $.put.consumes = ["application/octet-stream"]; -``` - -### /{containerName}/{blob}?comp=copy -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=copy"] - transform: > - $.put.responses["202"].headers["x-ms-version-id"] = { - "x-ms-client-name": "VersionId", - "type": "string", - "description": "UTC date/time value generated by the service that identifies the version of the blob. This header is returned for requests made against version 2018-11-09 and above." - }; - -``` - -### /{containerName}/{blob}?comp=copy&sync -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=copy&sync"] - transform: > - $.put.responses["202"].headers["x-ms-version-id"] = { - "x-ms-client-name": "VersionId", - "type": "string", - "description": "UTC date/time value generated by the service that identifies the version of the blob. This header is returned for requests made against version 2018-11-09 and above." - }; -``` - -### /{containerName}/{blob}?comp=pagelist -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=pagelist"] - transform: > - $.get.description = "The Get Page Ranges operation returns the list of valid page ranges for a page blob, version or snapshot of a page blob"; -``` - -### /{containerName}/{blob}?comp=pagelist&diff -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=pagelist&diff"] - transform: > - $.get.description = "[Update] The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that were changed between target blob and previous snapshot or version."; -``` - -### BlobItemInternal -``` yaml -directive: -- from: swagger-document - where: $.definitions.BlobItemInternal - transform: > - if (!$.required.includes("VersionId")) { - $.required.push("VersionId"); - $.properties.Metadata.type = "object"; - $.properties.Metadata.additionalProperties = { "type": "string" }; - delete $.properties.Metadata.$ref; - $.properties.VersionId = { "type": "string" }; - } - $.properties.IsPrefix = { "type": "boolean" }; -``` - -### BlobItemPropertiesInternal and ContainerItemProperties -``` yaml -directive: -- from: swagger-document - where: $.definitions - transform: > - if (!$.BlobContainerItemProperties) { - $.BlobContainerItemProperties = $.ContainerProperties; - delete $.ContainerProperties; - // - const etag = $.BlobContainerItemProperties.properties.Etag; - if (etag && !etag["x-ms-client-name"]) { - etag["x-ms-client-name"] = "eTag"; - $.BlobContainerItemProperties.properties.Etag = etag; - } - $.BlobContainerItemProperties.properties.DenyEncryptionScopeOverride["x-ms-client-name"] = "EncryptionScopeOverridePrevented"; - } - if (!$.BlobContainerItem) { - $.BlobContainerItem = $.ContainerItem; - const path = $.BlobContainerItem.properties.Properties.$ref.replace(/[#].*$/, "#/definitions/BlobContainerItemProperties"); - $.BlobContainerItem.properties.Properties.$ref = path; - delete $.ContainerItem; - } - if (!$.BlobItemPropertiesInternal) { - $.BlobItemPropertiesInternal = $.BlobPropertiesInternal; - delete $.BlobPropertiesInternal; - $.BlobItemPropertiesInternal.properties.CustomerProvidedKeySha256 = { "type": "string" } - $.BlobItemPropertiesInternal.properties["Content-MD5"]["x-ms-client-name"] = "contentMd5"; - const etag = $.BlobItemPropertiesInternal.properties.Etag; - if (etag && !etag["x-ms-client-name"]) { - etag["x-ms-client-name"] = "eTag"; - $.BlobItemPropertiesInternal.properties.Etag = etag; - } - } - if ($.BlobItemInternal) { - const path = $.BlobItemInternal.properties.Properties.$ref.replace(/[#].*$/, "#/definitions/BlobItemPropertiesInternal"); - $.BlobItemInternal.properties.Properties.$ref = path; - } -``` - -### BlobMetadata -Deleting out Encryption until https://github.com/Azure/azure-sdk-for-java/issues/5000 is determined. -``` yaml -directive: -- from: swagger-document - where: $.definitions.BlobMetadata - transform: > - delete $.properties -``` - -### ListBlobsFlatSegmentResponse -``` yaml -directive: -- from: swagger-document - where: $.definitions.ListBlobsFlatSegmentResponse - transform: > - if (!$.required.includes("Prefix")) { - $.required.push("Prefix"); - $.required.push("Marker"); - $.required.push("MaxResults"); - $.required.push("Delimiter"); - $.required.push("NextMarker"); - } -``` - -### ListBlobsHierarchySegmentResponse -``` yaml -directive: -- from: swagger-document - where: $.definitions.ListBlobsHierarchySegmentResponse - transform: > - if (!$.required.includes("Prefix")) { - $.required.push("Prefix"); - $.required.push("Marker"); - $.required.push("MaxResults"); - $.required.push("Delimiter"); - $.required.push("NextMarker"); - } -``` - -### KeyInfo -``` yaml -directive: -- from: swagger-document - where: $.parameters.KeyInfo - transform: > - if ($["x-ms-parameter-location"]) { - delete $["x-ms-parameter-location"]; - } -``` - -### Extra parameters -``` yaml -directive: -- from: swagger-document - where: $.parameters - transform: > - if (!$.CacheControl) { - $.CacheControl = { - "name": "Cache-Control", - "x-ms-client-name": "cacheControl", - "in": "header", - "required": false, - "type": "string", - "x-ms-parameter-location": "method", - "description": "Cache control for given resource" - }; - } -``` - -### Add EncryptionKeySha256 to PageBlobUploadPagesFromURLHeaders -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=page&update&fromUrl"].put.responses["201"].headers - transform: > - if (!$["x-ms-encryption-key-sha256"]) { - $["x-ms-encryption-key-sha256"] = { - "x-ms-client-name": "EncryptionKeySha256", - "type": "string", - "description": "The SHA-256 hash of the encryption key used to encrypt the pages. This header is only returned when the pages were encrypted with a customer-provided key." - }; - } -``` - -### Add IsServerEncrypted to AppendBlobAppendBlockFromUrlHeaders -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=appendblock&fromUrl"].put.responses["201"].headers - transform: > - if (!$["x-ms-request-server-encrypted"]) { - $["x-ms-request-server-encrypted"] = { - "x-ms-client-name": "IsServerEncrypted", - "type": "boolean", - "description": "The value of this header is set to true if the contents of the request are successfully encrypted using the specified algorithm, and false otherwise." - }; - } -``` - -### Add EncryptionKeySha256 and IsServerEncrypted to PageBlobClearPagesHeaders -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=page&clear"].put.responses["201"].headers - transform: > - if (!$["x-ms-request-server-encrypted"]) { - $["x-ms-request-server-encrypted"] = { - "x-ms-client-name": "IsServerEncrypted", - "type": "boolean", - "description": "The value of this header is set to true if the contents of the request are successfully encrypted using the specified algorithm, and false otherwise." - }; - } - if (!$["x-ms-encryption-key-sha256"]) { - $["x-ms-encryption-key-sha256"] = { - "x-ms-client-name": "EncryptionKeySha256", - "type": "string", - "description": "The SHA-256 hash of the encryption key used to encrypt the pages. This header is only returned when the pages were encrypted with a customer-provided key." - }; - } -``` - -### Batch returns a 202 -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/?comp=batch"].post.responses - transform: > - const response = $["200"]; - if (response) { - delete $["200"]; - $["202"] = response; - } -``` - -### Rename ListContainersIncludeType to ListBlobContainersIncludeType -``` yaml -directive: -- from: swagger-document - where: $.parameters.ListContainersInclude - transform: > - $["x-ms-client-name"] = "ListBlobContainersIncludeType"; - $["items"]["x-ms-enum"].name = "ListBlobContainersIncludeType"; -``` - -### /?comp=list -``` yaml -directive: -- from: swagger-document - where: $.definitions - transform: > - if (!$.BlobContainersSegment) { - $.BlobContainersSegment = $.ListContainersSegmentResponse; - delete $.ListContainersSegmentResponse; - $.BlobContainersSegment["x-az-public"] = false; - $.BlobContainersSegment.required.push("NextMarker"); - $.BlobContainersSegment.properties.BlobContainerItems = $.BlobContainersSegment.properties.ContainerItems; - delete $.BlobContainersSegment.properties.ContainerItems; - const path = $.BlobContainersSegment.properties.BlobContainerItems.items.$ref.replace(/[#].*$/, "#/definitions/BlobContainerItem"); - $.BlobContainersSegment.properties.BlobContainerItems.items.$ref = path; - } -- from: swagger-document - where: $["x-ms-paths"]["/?comp=list"] - transform: > - const def = $.get.responses["200"].schema; - if (def && def["$ref"] && !def["$ref"].endsWith("BlobContainersSegment")) { - const path = def["$ref"].replace(/[#].*$/, "#/definitions/BlobContainersSegment"); - $.get.responses["200"].schema = { "$ref": path }; - } - $.get.operationId = "Service_ListBlobContainersSegment"; -``` - -### GeoReplication -``` yaml -directive: -- from: swagger-document - where: $.definitions.GeoReplication.properties.Status - transform: > - $["x-ms-enum"].name = "GeoReplicationStatus"; -``` - -### BlobErrorCode -``` yaml -directive: -- from: swagger-document - where: $.definitions.ErrorCode - transform: > - $["x-ms-enum"].name = "BlobErrorCode"; -``` - -### Typo Fixed in ErrorCode Removed Enum Value -``` yaml -directive: -- from: swagger-document - where: $.definitions.ErrorCode - transform: > - $.enum.push("SnaphotOperationRateExceeded"); - $.enum.push("IncrementalCopyOfEralierVersionSnapshotNotAllowed"); -``` - -### BlobServiceProperties, BlobAnalyticsLogging, BlobMetrics, BlobCorsRule, and BlobRetentionPolicy -``` yaml -directive: -- rename-model: - from: Logging - to: BlobAnalyticsLogging -- rename-model: - from: Metrics - to: BlobMetrics -- rename-model: - from: CorsRule - to: BlobCorsRule -- rename-model: - from: RetentionPolicy - to: BlobRetentionPolicy -- rename-model: - from: StorageServiceProperties - to: BlobServiceProperties - -- from: swagger-document - where: $.definitions - transform: > - $.BlobMetrics.properties.IncludeAPIs["x-ms-client-name"] = "IncludeApis"; - delete $.BlobRetentionPolicy.properties.AllowPermanentDelete; - $.BlobServiceProperties.xml = {"name": "StorageServiceProperties"}; - $.BlobCorsRule.xml = {"name": "CorsRule"}; - -- from: swagger-document - where: $.parameters - transform: > - $.StorageServiceProperties.name = "BlobServiceProperties"; -``` - -### BlobServiceStatistics and BlobPrefixInternal -``` yaml -directive: -- rename-model: - from: StorageServiceStats - to: BlobServiceStatistics -- rename-model: - from: BlobPrefix - to: BlobPrefixInternal - -- from: swagger-document - where: $.definitions - transform: > - $.BlobServiceStatistics.xml = { "name": "StorageServiceStats" }; - $.BlobPrefixInternal.xml = { "name": "BlobPrefix" }; -``` - -### BlobAccessPolicy and BlobSignedIdentifier -``` yaml -directive: -- rename-model: - from: SignedIdentifier - to: BlobSignedIdentifier -- rename-model: - from: AccessPolicy - to: BlobAccessPolicy -- from: swagger-document - where: $.definitions - transform: > - $.BlobAccessPolicy.properties.Start["x-ms-client-name"] = "StartsOn"; - $.BlobAccessPolicy.properties.Expiry["x-ms-client-name"] = "ExpiresOn"; - $.BlobAccessPolicy.properties.Permission["x-ms-client-name"] = "Permissions"; -``` - -### Rename BlobHttpHeaders to BlobHttpHeader -``` yaml -directive: -- from: swagger-document - where: $.parameters - transform: > - $.BlobCacheControl["x-ms-parameter-grouping"].name = "blob-http-headers"; - $.BlobCacheControl["x-ms-client-name"] = "cacheControl"; - $.BlobContentDisposition["x-ms-parameter-grouping"].name = "blob-http-headers"; - $.BlobContentDisposition["x-ms-client-name"] = "contentDisposition"; - $.BlobContentEncoding["x-ms-parameter-grouping"].name = "blob-http-headers"; - $.BlobContentEncoding["x-ms-client-name"] = "contentEncoding"; - $.BlobContentLanguage["x-ms-parameter-grouping"].name = "blob-http-headers"; - $.BlobContentLanguage["x-ms-client-name"] = "contentLanguage"; - $.BlobContentMD5["x-ms-parameter-grouping"].name = "blob-http-headers"; - $.BlobContentMD5["x-ms-client-name"] = "contentMd5"; - $.BlobContentMD5.description = "Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks were validated when each was uploaded. The value does not need to be base64 encoded as the SDK will perform the encoding."; - $.BlobContentType["x-ms-parameter-grouping"].name = "blob-http-headers"; - $.BlobContentType["x-ms-client-name"] = "contentType"; -``` - -### Rename UserDelegationKey SignedOid and SignedTid -``` yaml -directive: -- from: swagger-document - where: $.definitions.UserDelegationKey - transform: > - $.properties.SignedOid["x-ms-client-name"] = "signedObjectId"; - $.properties.SignedTid["x-ms-client-name"] = "signedTenantId"; -``` - -### Remove AccessConditions parameter groupings -``` yaml -directive: -- from: swagger-document - where: $.parameters - transform: > - delete $.SourceIfMatch["x-ms-parameter-grouping"]; - delete $.SourceIfModifiedSince["x-ms-parameter-grouping"]; - delete $.SourceIfNoneMatch["x-ms-parameter-grouping"]; - delete $.SourceIfUnmodifiedSince["x-ms-parameter-grouping"]; - delete $.SourceIfTags["x-ms-parameter-grouping"]; -- from: swagger-document - where: $.parameters - transform: > - delete $.IfMatch["x-ms-parameter-grouping"]; - delete $.IfModifiedSince["x-ms-parameter-grouping"]; - delete $.IfNoneMatch["x-ms-parameter-grouping"]; - delete $.IfUnmodifiedSince["x-ms-parameter-grouping"]; - delete $.IfTags["x-ms-parameter-grouping"]; -- from: swagger-document - where: $.parameters - transform: > - delete $.BlobConditionAppendPos["x-ms-parameter-grouping"]; - delete $.BlobConditionMaxSize["x-ms-parameter-grouping"]; -- from: swagger-document - where: $.parameters - transform: > - delete $.IfSequenceNumberEqualTo["x-ms-parameter-grouping"]; - delete $.IfSequenceNumberLessThan["x-ms-parameter-grouping"]; - delete $.IfSequenceNumberLessThanOrEqualTo["x-ms-parameter-grouping"]; -- from: swagger-document - where: $.parameters - transform: > - delete $.LeaseIdOptional["x-ms-parameter-grouping"]; -``` - -### Rename container-cpk-scope-info to blob-container-encryption-scope -``` yaml -directive: -- from: swagger-document - where: $.parameters - transform: > - $.DenyEncryptionScopeOverride["x-ms-client-name"] = "EncryptionScopeOverridePrevented"; - $.DefaultEncryptionScope["x-ms-parameter-grouping"]["name"] = "blob-container-encryption-scope"; - $.DenyEncryptionScopeOverride["x-ms-parameter-grouping"]["name"] = "blob-container-encryption-scope"; -``` - -### Rename cpk-scope-info to encryption-scope -``` yaml -directive: -- from: swagger-document - where: $.parameters - transform: > - $.EncryptionScope["x-ms-parameter-grouping"]["name"] = "encryption-scope"; -``` - -### Block size int to long transition -``` yaml -directive: -- from: swagger-document - where: $.definitions.Block - transform: > - $.properties.Size["x-ms-client-name"] = "sizeLong"; - $.properties.Size["format"] = "int64"; - $.properties.SizeInt = { "type" : "integer" }; - $.required.push("SizeInt"); -``` - -### /{containerName}/{blob}?comp=query -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=query"] - transform: > - $.post.responses["200"].headers["Content-MD5"]["x-ms-client-name"] = "contentMd5"; - $.post.responses["206"].headers["Content-MD5"]["x-ms-client-name"] = "contentMd5"; - $.post.responses["200"].headers["x-ms-blob-content-md5"]["x-ms-client-name"] = "blobContentMd5"; - $.post.responses["206"].headers["x-ms-blob-content-md5"]["x-ms-client-name"] = "blobContentMd5"; - $.post.responses["200"].headers["x-ms-server-encrypted"]["x-ms-client-name"] = "serverEncrypted"; - $.post.responses["206"].headers["x-ms-server-encrypted"]["x-ms-client-name"] = "serverEncrypted"; -``` - -### Hide TagValue in FilterBlobItem -``` yaml -directive: -- from: swagger-document - where: $.definitions - transform: > - delete $.FilterBlobItem.properties.TagValue; -``` - -### Service_ListContainersSegment x-ms-pageable itemName -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/?comp=list"].get - transform: > - $["x-ms-pageable"].itemName = "BlobContainerItems"; -``` - - -### Delete Container_ListBlobFlatSegment x-ms-pageable as autorest can't recognize the itemName for this -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}?restype=container&comp=list&flat"].get - transform: > - delete $["x-ms-pageable"]; -``` - -### Delete Container_ListBlobHierarchySegment x-ms-pageable as autorest can't recognize the itemName for this -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}?restype=container&comp=list&hierarchy"].get - transform: > - delete $["x-ms-pageable"]; -``` - -### BlobDeleteType expandable string enum -``` yaml -directive: -- from: swagger-document - where: $.parameters.BlobDeleteType - transform: > - $["x-ms-enum"].modelAsString = true; -``` - -### Delete PageBlob_GetPageRanges x-ms-pageable as autorest can't recognize the itemName for this -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=pagelist"].get - transform: > - delete $["x-ms-pageable"]; -``` - -### Delete PageList_GetPageRangesDiff x-ms-pageable as autorest can't recognize the itemName for this -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?comp=pagelist&diff"].get - transform: > - delete $["x-ms-pageable"]; -``` - -### BlobCopySourceTags expandable string enum and rename -``` yaml -directive: -- from: swagger-document - where: $.parameters.CopySourceTags - transform: > - $["x-ms-enum"].modelAsString = true; - $["x-ms-enum"].name = "BlobCopySourceTagsMode"; -``` - -### Fix putBlobFromUrl Apostrophe -``` yaml -directive: -- from: swagger-document - where: $["x-ms-paths"]["/{containerName}/{blob}?BlockBlob&fromUrl"].put - transform: > - $.description = "The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial updates to a block blob's contents using a source URL, use the Put Block from URL API in conjunction with Put Block List."; -``` - -### Rename ListBlobsIncludeItem Enums to be underscore cased -```yaml -directive: - - from: swagger-document - where: $.parameters.ListBlobsInclude - transform: > - $.items["x-ms-enum"].values = [ - { - "value": "copy", - "name": "copy", - "description": "" - }, - { - "value": "deleted", - "name": "deleted", - "description": "" - }, - { - "value": "metadata", - "name": "metadata", - "description": "" - }, - { - "value": "snapshots", - "name": "snapshots", - "description": "" - }, - { - "value": "uncommittedblobs", - "name": "uncommittedblobs", - "description": "" - }, - { - "value": "versions", - "name": "versions", - "description": "" - }, - { - "value": "tags", - "name": "tags", - "description": "" - }, - { - "value": "immutabilitypolicy", - "name": "immutability_policy", - "description": "" - }, - { - "value": "legalhold", - "name": "legal_hold", - "description": "" - }, - { - "value": "deletedwithversions", - "name": "deleted_with_versions", - "description": "" - } - ]; -``` - - diff --git a/sdk/storage/azure-storage-blob/swagger/Update-Codegeneration.ps1 b/sdk/storage/azure-storage-blob/swagger/Update-Codegeneration.ps1 deleted file mode 100644 index e9146f384a42..000000000000 --- a/sdk/storage/azure-storage-blob/swagger/Update-Codegeneration.ps1 +++ /dev/null @@ -1 +0,0 @@ -& (Join-Path $PSScriptRoot ".." ".." ".." ".." eng scripts Invoke-Codegeneration.ps1) $PSScriptRoot diff --git a/sdk/storage/azure-storage-blob/swagger/package.json b/sdk/storage/azure-storage-blob/swagger/package.json deleted file mode 100644 index 0967ef424bce..000000000000 --- a/sdk/storage/azure-storage-blob/swagger/package.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/sdk/storage/azure-storage-blob/swagger/pom.xml b/sdk/storage/azure-storage-blob/swagger/pom.xml deleted file mode 100644 index 492aa3545f2a..000000000000 --- a/sdk/storage/azure-storage-blob/swagger/pom.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - com.azure - azure-code-customization-parent - 1.0.0-beta.1 - ../../../parents/azure-code-customization-parent - - - com.azure - azure-storage-blob-customization - 1.0.0-beta.1 - 4.0.0 - diff --git a/sdk/storage/azure-storage-blob/swagger/src/main/java/BlobStorageCustomization.java b/sdk/storage/azure-storage-blob/swagger/src/main/java/BlobStorageCustomization.java deleted file mode 100644 index 215ae140930b..000000000000 --- a/sdk/storage/azure-storage-blob/swagger/src/main/java/BlobStorageCustomization.java +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import com.azure.autorest.customization.ClassCustomization; -import com.azure.autorest.customization.Customization; -import com.azure.autorest.customization.JavadocCustomization; -import com.azure.autorest.customization.LibraryCustomization; -import com.azure.autorest.customization.PackageCustomization; -import com.github.javaparser.ParseProblemException; -import com.github.javaparser.StaticJavaParser; -import com.github.javaparser.ast.Modifier; -import com.github.javaparser.ast.NodeList; -import com.github.javaparser.ast.body.MethodDeclaration; -import com.github.javaparser.ast.body.Parameter; -import com.github.javaparser.ast.stmt.BlockStmt; -import com.github.javaparser.ast.stmt.CatchClause; -import com.github.javaparser.ast.stmt.Statement; -import com.github.javaparser.ast.stmt.TryStmt; -import com.github.javaparser.ast.type.ClassOrInterfaceType; -import com.github.javaparser.ast.type.Type; -import com.github.javaparser.javadoc.Javadoc; -import com.github.javaparser.javadoc.description.JavadocDescription; -import org.slf4j.Logger; - -import java.util.Arrays; -import java.util.List; - -/** - * Customization class for Blob Storage. - */ -public class BlobStorageCustomization extends Customization { - @Override - public void customize(LibraryCustomization customization, Logger logger) { - - // Implementation models customizations - PackageCustomization implementationModels = customization.getPackage("com.azure.storage.blob.implementation.models"); - - // Models customizations - PackageCustomization models = customization.getPackage("com.azure.storage.blob.models"); - - models.getClass("PageList").customizeAst(ast -> { - ast.addImport("com.azure.storage.blob.implementation.models.PageListHelper"); - - ast.getClassByName("PageList").ifPresent(clazz -> { - - clazz.getMethodsByName("getNextMarker").forEach(method -> method.setModifiers(Modifier.Keyword.PRIVATE)); - clazz.getMethodsByName("setNextMarker").forEach(method -> method.setModifiers(Modifier.Keyword.PRIVATE)); - - // Add Accessor to PageList - clazz.setMembers(clazz.getMembers() - .addFirst(StaticJavaParser.parseBodyDeclaration(String.join("\n", "static {", - " PageListHelper.setAccessor(new PageListHelper.PageListAccessor() {", - " @Override", - " public String getNextMarker(PageList pageList) {", - " return pageList.getNextMarker();", - " }", - "", - " @Override", - " public PageList setNextMarker(PageList pageList, String marker) {", - " return pageList.setNextMarker(marker);", - " }", - " });", - "}")))); - }); - }); - - ClassCustomization blobContainerEncryptionScope = models.getClass("BlobContainerEncryptionScope"); - blobContainerEncryptionScope.getMethod("isEncryptionScopeOverridePrevented") - .setReturnType("boolean", "return Boolean.TRUE.equals(%s);", true); - - ClassCustomization blobContainerItemProperties = models.getClass("BlobContainerItemProperties"); - blobContainerItemProperties.getMethod("isEncryptionScopeOverridePrevented") - .setReturnType("boolean", "return Boolean.TRUE.equals(%s);", true); - blobContainerItemProperties.getMethod("setIsImmutableStorageWithVersioningEnabled") - .rename("setImmutableStorageWithVersioningEnabled"); - blobContainerItemProperties.getMethod("setEncryptionScopeOverridePrevented") - .replaceParameters("boolean encryptionScopeOverridePrevented"); - - // Block - Generator - ClassCustomization block = models.getClass("Block"); - - block.getMethod("getSizeInt") - .rename("getSize") - .addAnnotation("@Deprecated") - .setReturnType("int", "return (int) this.sizeLong; // return %s;", true) - .getJavadoc() - .setDeprecated("Use {@link #getSizeLong()}"); - - block.getMethod("setSizeInt") - .rename("setSize") - .addAnnotation("@Deprecated") - .setReturnType("Block", "return %s.setSizeLong((long) sizeInt);", true) - .getJavadoc() - .setDeprecated("Use {@link #setSizeLong(long)}"); - - // BlobErrorCode - // Fix typo - String blobErrorCodeFile = "src/main/java/com/azure/storage/blob/models/BlobErrorCode.java"; - String blobErrorCodeFileContent = customization.getRawEditor().getFileContent(blobErrorCodeFile); - blobErrorCodeFileContent = blobErrorCodeFileContent.replaceAll("SnaphotOperationRateExceeded", "SnapshotOperationRateExceeded"); - customization.getRawEditor().replaceFile(blobErrorCodeFile, blobErrorCodeFileContent); - // deprecate - ClassCustomization blobErrorCode = models.getClass("BlobErrorCode"); - blobErrorCode.getConstant("SNAPHOT_OPERATION_RATE_EXCEEDED") - .addAnnotation("@Deprecated") - .getJavadoc() - .setDeprecated("Please use {@link BlobErrorCode#SNAPSHOT_OPERATION_RATE_EXCEEDED}"); - - blobErrorCode.getConstant("INCREMENTAL_COPY_OF_ERALIER_VERSION_SNAPSHOT_NOT_ALLOWED") - .addAnnotation("@Deprecated") - .getJavadoc() - .setDeprecated("Please use {@link BlobErrorCode#INCREMENTAL_COPY_OF_EARLIER_VERSION_SNAPSHOT_NOT_ALLOWED}"); - - //QueryFormat - customizeQueryFormat(implementationModels.getClass("QueryFormat")); - - //BlobSignedIdentifierWrapper - customizeBlobSignedIdentifierWrapper(implementationModels.getClass("BlobSignedIdentifierWrapper")); - - updateImplToMapInternalException(customization.getPackage("com.azure.storage.blob.implementation")); - - implementationModels.getClass("QueryRequest").customizeAst(ast -> ast.getClassByName("QueryRequest").ifPresent(clazz -> { - clazz.getFieldByName("queryType").ifPresent(field -> field.removeModifier(Modifier.Keyword.FINAL)); - clazz.addMethod("setQueryType", Modifier.Keyword.PUBLIC) - .setType("QueryRequest") - .addParameter("String", "queryType") - .setBody(StaticJavaParser.parseBlock("{ this.queryType = queryType; return this; }")) - .setJavadocComment(new Javadoc(JavadocDescription.parseText("Set the queryType property: Required. The type of the provided query expression.")) - .addBlockTag("param", "queryType", "the queryType value to set.") - .addBlockTag("return", "the QueryRequest object itself.")); - })); - } - - private static void customizeQueryFormat(ClassCustomization classCustomization) { - String fileContent = classCustomization.getEditor().getFileContent(classCustomization.getFileName()); - fileContent = fileContent.replace("xmlWriter.nullElement(\"ParquetTextConfiguration\", this.parquetTextConfiguration);", - "xmlWriter.writeStartElement(\"ParquetTextConfiguration\").writeEndElement();"); - fileContent = fileContent.replace("deserializedQueryFormat.parquetTextConfiguration = reader.null;", - "deserializedQueryFormat.parquetTextConfiguration = new Object();\nxmlReader.skipElement();"); - classCustomization.getEditor().replaceFile(classCustomization.getFileName(), fileContent); - } - - private static void customizeBlobSignedIdentifierWrapper(ClassCustomization classCustomization) { - JavadocCustomization javadocfromXml = classCustomization.getMethod("fromXml(XmlReader xmlReader)").getJavadoc(); - javadocfromXml.setDescription("Reads an instance of BlobSignedIdentifierWrapper from the XmlReader."); - javadocfromXml.setParam("xmlReader", "The XmlReader being read."); - javadocfromXml.setReturn("An instance of BlobSignedIdentifierWrapper if the XmlReader was pointing to an " + - "instance of it, or null if it was pointing to XML null."); - javadocfromXml.addThrows("XMLStreamException", "If an error occurs while reading the BlobSignedIdentifierWrapper."); - - JavadocCustomization javadocfromXmlWithRoot = classCustomization.getMethod("fromXml(XmlReader xmlReader, String rootElementName)").getJavadoc(); - javadocfromXmlWithRoot.setDescription("Reads an instance of BlobSignedIdentifierWrapper from the XmlReader."); - javadocfromXmlWithRoot.setParam("xmlReader", "The XmlReader being read."); - javadocfromXmlWithRoot.setParam("rootElementName", "Optional root element name to override the default defined " + - "by the model. Used to support cases where the model can deserialize from different root element names."); - javadocfromXmlWithRoot.setReturn("An instance of BlobSignedIdentifierWrapper if the XmlReader was pointing to an " + - "instance of it, or null if it was pointing to XML null."); - javadocfromXmlWithRoot.addThrows("XMLStreamException", "If an error occurs while reading the BlobSignedIdentifierWrapper."); - } - - /** - * Customizes the implementation classes that will perform calls to the service. The following logic is used: - *

- * - Check for the return of the method not equaling to PagedFlux, PagedIterable, PollerFlux, or SyncPoller. Those - * types wrap other APIs and those APIs being update is the correct change. - * - For asynchronous methods, add a call to - * {@code .onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException)} to handle - * mapping BlobStorageExceptionInternal to BlobStorageException. - * - For synchronous methods, wrap the return statement in a try-catch block that catches - * BlobStorageExceptionInternal and rethrows {@code ModelHelper.mapToBlobStorageException(e)}. Or, for void methods - * wrap the last statement. - * - * @param implPackage The implementation package. - */ - private static void updateImplToMapInternalException(PackageCustomization implPackage) { - List implsToUpdate = Arrays.asList("AppendBlobsImpl", "BlobsImpl", "BlockBlobsImpl", "ContainersImpl", - "PageBlobsImpl", "ServicesImpl"); - for (String implToUpdate : implsToUpdate) { - implPackage.getClass(implToUpdate).customizeAst(ast -> { - ast.addImport("com.azure.storage.blob.implementation.util.ModelHelper"); - ast.addImport("com.azure.storage.blob.models.BlobStorageException"); - ast.addImport("com.azure.storage.blob.implementation.models.BlobStorageExceptionInternal"); - ast.getClassByName(implToUpdate).ifPresent(clazz -> { - clazz.getFields(); - - clazz.getMethods().forEach(methodDeclaration -> { - Type returnType = methodDeclaration.getType(); - // The way code generation works we only need to update the methods that have a class return type. - // As non-class return types, such as "void", call into the Response methods. - if (!returnType.isClassOrInterfaceType()) { - return; - } - - ClassOrInterfaceType returnTypeClass = returnType.asClassOrInterfaceType(); - String returnTypeName = returnTypeClass.getNameAsString(); - if (returnTypeName.equals("PagedFlux") || returnTypeName.equals("PagedIterable") - || returnTypeName.equals("PollerFlux") || returnTypeName.equals("SyncPoller")) { - return; - } - - if (returnTypeName.equals("Mono") || returnTypeName.equals("Flux")) { - addErrorMappingToAsyncMethod(methodDeclaration); - } else { - addErrorMappingToSyncMethod(methodDeclaration); - } - }); - }); - }); - } - } - - private static void addErrorMappingToAsyncMethod(MethodDeclaration method) { - BlockStmt body = method.getBody().get(); - - // Bit of hack to insert the 'onErrorMap' in the right location. - // Unfortunately, 'onErrorMap' returns which for some calls breaks typing, such as Void -> Object or - // PagedResponse -> PagedResponseBase. So, 'onErrorMap' needs to be inserted after the first method call. - // To do this, we track the first found '(' and the associated closing ')' to insert 'onErrorMap' after the ')'. - // So, 'service.methodCall(parameters).map()' becomes 'service.methodCall(parameters).onErrorMap().map()'. - String originalReturnStatement = body.getStatement(body.getStatements().size() - 1).asReturnStmt() - .getExpression().get().toString(); - int insertionPoint = findAsyncOnErrorMapInsertionPoint(originalReturnStatement); - String newReturnStatement = "return " + originalReturnStatement.substring(0, insertionPoint) - + ".onErrorMap(BlobStorageExceptionInternal.class, ModelHelper::mapToBlobStorageException)" - + originalReturnStatement.substring(insertionPoint) + ";"; - try { - Statement newReturn = StaticJavaParser.parseStatement(newReturnStatement); - body.getStatements().set(body.getStatements().size() - 1, newReturn); - } catch (ParseProblemException ex) { - throw new RuntimeException("Failed to parse: " + newReturnStatement, ex); - } - } - - private static int findAsyncOnErrorMapInsertionPoint(String returnStatement) { - int openParenthesis = 0; - int closeParenthesis = 0; - for (int i = 0; i < returnStatement.length(); i++) { - char c = returnStatement.charAt(i); - if (c == '(') { - openParenthesis++; - } else if (c == ')') { - closeParenthesis++; - if (openParenthesis == closeParenthesis) { - return i + 1; - } - } - } - return -1; - } - - private static void addErrorMappingToSyncMethod(MethodDeclaration method) { - // Turn the entire method into a BlockStmt that will be used as the try block. - BlockStmt tryBlock = method.getBody().get(); - BlockStmt catchBlock = new BlockStmt(new NodeList<>(StaticJavaParser.parseStatement( - "throw ModelHelper.mapToBlobStorageException(internalException);"))); - Parameter catchParameter = new Parameter().setType("BlobStorageExceptionInternal") - .setName("internalException"); - CatchClause catchClause = new CatchClause(catchParameter, catchBlock); - TryStmt tryCatchMap = new TryStmt(tryBlock, new NodeList<>(catchClause), null); - - // Replace the last statement with the try-catch block. - method.setBody(new BlockStmt(new NodeList<>(tryCatchMap))); - } -} diff --git a/sdk/storage/azure-storage-blob/tsp-location.yaml b/sdk/storage/azure-storage-blob/tsp-location.yaml new file mode 100644 index 000000000000..057c055b6303 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/storage/Microsoft.BlobStorage +commit: bf3c43c9f99e28bd72ce3b5c0122e7ceecd44b92 +repo: Azure/azure-rest-api-specs +additionalDirectories: